diff --git a/docs/esp-image.md b/docs/esp-image.md index 8456d48d3d..dbe8bc5c11 100644 --- a/docs/esp-image.md +++ b/docs/esp-image.md @@ -239,11 +239,8 @@ and a partition table sits where that origin puts `0x8000` (file offset `table_file_offset`, a limitation says to reopen the file with `format: "esp-flash-image"` and that `flash_offset`, and `inspect_artifact` lists the same `open_binary` call as a next probe. `flash_dump` is null for -every other image. An Evidence bundle exported by an earlier release, without -`evidence_format`, is refused; recreate the observation. A standalone Evidence -record from before REA reported the field omits it; REA still reads and -compares such a record, and the omission says nothing about where the file was -read from. +every other image. An Evidence bundle or record from an earlier Evidence +format revision is refused; recreate the observation. ## Limits diff --git a/docs/guides/runtime/process-capture.md b/docs/guides/runtime/process-capture.md index a91d7881ed..8dde4ededf 100644 --- a/docs/guides/runtime/process-capture.md +++ b/docs/guides/runtime/process-capture.md @@ -373,11 +373,8 @@ The terminal finalizer then freezes PTY input, retains normalized and rendered facts, and releases the renderer. Cleanup retry reuses those completed facts. All new captures commit `terminal_observation_version: "deferred-rendered-journal-v1"`, including when -PID and port normalization are disabled. An Evidence bundle exported by an -earlier release, without `evidence_format`, is refused; recreate the -observation. A standalone record with an earlier observation version remains -readable; recapture both sides with the same observation version before -comparison. +PID and port normalization are disabled. An Evidence bundle or record from an +earlier Evidence format revision is refused; recreate the observation. When path normalization is enabled, aliases apply to selected path identities at clear text delimiters. A selected executable path does not alias a longer diff --git a/docs/il2cpp-metadata.md b/docs/il2cpp-metadata.md index c1b8424546..091e01b376 100644 --- a/docs/il2cpp-metadata.md +++ b/docs/il2cpp-metadata.md @@ -113,9 +113,8 @@ After finding method indices, parameters can be requested directly: } ``` -An Evidence bundle exported by an earlier release, without `evidence_format`, -is refused; recreate the observation. A standalone Evidence record that -predates these member collections remains queryable. A missing collection has an unknown (`null`) summary count, and requesting it +An Evidence bundle or record from an earlier Evidence format revision is +refused; recreate the observation. A missing collection has an unknown (`null`) summary count, and requesting it reports that it was not collected; it is never presented as an empty inventory. The same holds for Evidence that predates binary linking: its summary omits `binary`, and `method_addresses`, `method_address_states`, `return_types`, `field_types` and `parameter_types` counts are `null`. A link retained before diff --git a/docs/reference/mcp-contracts.md b/docs/reference/mcp-contracts.md index 31cb2a19b3..4e70a69373 100644 --- a/docs/reference/mcp-contracts.md +++ b/docs/reference/mcp-contracts.md @@ -352,7 +352,8 @@ Omit `fields` for complete records; a selected field list always retains remain distinguishable. Search tools apply their existing filters before retention. Follow `coverage.next_offset`; exhaustion describes the retained list, not complete discovery of all code or strings. An unbound source keeps -`artifact: null` and the derived Evidence keeps `subject: null`. +`artifact: null`, and the derived Evidence names an unknown subject +(`subject.identity.kind: "unknown"`). The CLI uses the same projector. For an original complete Evidence JSON file, write `{"source":{"kind":"evidence-file","path":"/absolute/source.json"},"view":{"kind":"native-inventory","limit":32}}` @@ -1015,11 +1016,24 @@ whether it was never recorded, cleared, or retained by another connection. Supply complete inline Evidence, repeat its producer, or import an exported Evidence bundle before referencing that imported record. Export a bundle or use `reset_investigation(save_path)` before ending the process if the investigation -needs it later. Exported bundles carry `evidence_format`, the Evidence format revision -(currently `1`). Import, comparison and every other bundle reader refuse a -bundle without it, or with another revision, as an integrity mismatch whose -recovery is to recreate the observations with the current release; -re-exporting an earlier bundle does not update its format or identities. Retention has no automatic persistence or silent eviction. +needs it later. Exported bundles and every Evidence record carry +`evidence_format`, the Evidence format revision (currently `2`). Import, +comparison and every other Evidence reader refuse a bundle or record without +it, or with another revision, as an integrity mismatch whose recovery is to +recreate the observations with the current release; re-exporting an earlier +bundle does not update its format or identities. Revision 2 names the subject +by its target identity, `subject.identity` (`kind: "file"`, `sha256`, `format`, +`architecture` and `selection`: the raw or DOL entry point or the ESP flash +offsets that select what was analysed, otherwise `null`), and the Evidence ID +commits to that identity; `subject.name` and `subject.local_path` are display +facts outside the ID. The subject has no separate `digest`, `format` or +`architecture` members; read them from `subject.identity`. Every record has a +subject: one whose target REA did not identify names +`{ "kind": "unknown", "reason": … }`, where the reason is +`derived-from-linked-evidence` (comparisons and workflows, whose sources are +committed through `evidence_links`), `not-observed` or `unsupported-subject`, +and its `name` and `local_path` are `null`. Retention has no +automatic persistence or silent eviction. `binary_session.investigation` reports record/revision/head counts, estimated retained representation bytes and the fixed allowance derived from initial V8 heap headroom. A capacity refusal preserves the existing investigation; checkpoint diff --git a/docs/reference/reconstruction-obligation-ledgers.md b/docs/reference/reconstruction-obligation-ledgers.md index 5e3310dafb..c952016096 100644 --- a/docs/reference/reconstruction-obligation-ledgers.md +++ b/docs/reference/reconstruction-obligation-ledgers.md @@ -36,7 +36,7 @@ never claims closure: rea build-reconstruction-obligation-ledger \ '{ "evidence_bundle": { - "evidence_format": 1, + "evidence_format": 2, "artifacts": [], "providers": [], "environments": [], diff --git a/docs/specs/native/windows-shortcut/plan.md b/docs/specs/native/windows-shortcut/plan.md index 0e1858b6a2..ad065f5a3a 100644 --- a/docs/specs/native/windows-shortcut/plan.md +++ b/docs/specs/native/windows-shortcut/plan.md @@ -8,7 +8,7 @@ coverage; `src/domain/native/windowsShortcut.ts` owns the result schema. `WindowsShortcutProvider` (`rea-windows-shortcut`, built in) owns path validation and the stable regular-file read through `readStableArtifact` and `ArtifactResourceScope`. `WindowsShortcutService` owns Evidence provenance with -`subject.format: "file"`. The CLI command and MCP tool consume that Evidence +`subject.identity.format: "file"`. The CLI command and MCP tool consume that Evidence and add no interpretation. ANSI strings use a byte-preserving Latin1 projection because the original diff --git a/scripts/lib/browser-module-e2e.mjs b/scripts/lib/browser-module-e2e.mjs index 47cfcbb214..53481224b8 100644 --- a/scripts/lib/browser-module-e2e.mjs +++ b/scripts/lib/browser-module-e2e.mjs @@ -114,7 +114,7 @@ export async function verifyBrowserModules( const mcpResult = assertTrace(mcpEvidence, oracle, site, scriptIndex); assert.deepEqual(mcpResult, cliResult, "CLI and MCP module traces differ"); assert.equal( - cliEvidence.subject.digest.sha256, + cliEvidence.subject.identity.sha256, createHash("sha256").update(site.main).digest("hex"), ); const mapBytes = await readFile(mapPath); diff --git a/scripts/lib/javascript-application-paths.d.mts b/scripts/lib/javascript-application-paths.d.mts index 4181c5b81e..e0194581ff 100644 --- a/scripts/lib/javascript-application-paths.d.mts +++ b/scripts/lib/javascript-application-paths.d.mts @@ -1,7 +1,7 @@ export function assertJavaScriptApplicationInputPaths( evidence: { readonly parameters: Readonly>; - readonly subject: { readonly local_path: string } | null; + readonly subject: { readonly local_path: string | null }; readonly normalized_result: { readonly input_path: string }; }, inputPath: string, diff --git a/scripts/lib/real-ghidra-large-results.mjs b/scripts/lib/real-ghidra-large-results.mjs index f27a5c03c8..1b2c6550ee 100644 --- a/scripts/lib/real-ghidra-large-results.mjs +++ b/scripts/lib/real-ghidra-large-results.mjs @@ -142,7 +142,7 @@ export async function verifyGhidraLargeResults({ ); assert.ok(record, `Missing exported retained record ${id}`); assert.equal(record.provider.id, "ghidra"); - assert.equal(record.subject.digest.sha256, sha256); + assert.equal(record.subject.identity.sha256, sha256); return record; }; const originalError = bundle.records.find( @@ -151,7 +151,7 @@ export async function verifyGhidraLargeResults({ assert.ok(originalError); assert.equal(originalError.operation, "mcp_tool_error"); assert.equal(originalError.provider.id, "rea-mcp"); - assert.equal(originalError.subject, null); + assert.equal(originalError.subject.identity.kind, "unknown"); assert.equal(originalError.parameters.tool_name, "procedure_address"); assert.equal(originalError.normalized_result.error.code, "invalid_request"); assert.equal(originalError.raw_result.isError, true); diff --git a/scripts/lib/real-ghidra-relocation-symbols.mjs b/scripts/lib/real-ghidra-relocation-symbols.mjs index 2ce4522bcf..2dac131d2c 100644 --- a/scripts/lib/real-ghidra-relocation-symbols.mjs +++ b/scripts/lib/real-ghidra-relocation-symbols.mjs @@ -60,7 +60,7 @@ export async function verifyGhidraRelocationSymbols({ clang, lld, env }) { "--json", ]); const evidence = parseEvidence(JSON.parse(stdout)); - assert.equal(evidence.subject?.digest.sha256, before); + assert.equal(evidence.subject?.identity.sha256, before); assert.equal(evidence.provider.id, "ghidra"); const report = evidence.normalized_result; assert.equal(report.status, "unsupported"); diff --git a/scripts/verify-apktool.mjs b/scripts/verify-apktool.mjs index 99b8f302fd..79d8720777 100644 --- a/scripts/verify-apktool.mjs +++ b/scripts/verify-apktool.mjs @@ -38,9 +38,9 @@ const run = async (operation, input) => { const target = evidence.normalized_result.target; check( "resource Evidence preserves the decoded APK subject identity", - evidence.subject?.digest.sha256 === target.sha256 && + evidence.subject?.identity.sha256 === target.sha256 && evidence.subject?.local_path === target.path && - evidence.subject?.format === "apk", + evidence.subject?.identity.format === "apk", ); } return result.value.normalized_result; diff --git a/scripts/verify-evm-interface.mjs b/scripts/verify-evm-interface.mjs index 1ce2df2127..b4c07951d0 100644 --- a/scripts/verify-evm-interface.mjs +++ b/scripts/verify-evm-interface.mjs @@ -133,7 +133,7 @@ try { report.artifact.sha256, createHash("sha256").update(carrier).digest("hex"), ); - assert.equal(evidence.subject.digest.sha256, report.artifact.sha256); + assert.equal(evidence.subject.identity.sha256, report.artifact.sha256); assert.equal(report.artifact.bytes, carrier.length); assert.equal( report.bytecode.sha256, diff --git a/scripts/verify-flutter.mjs b/scripts/verify-flutter.mjs index 2d6656ed94..474c558b96 100644 --- a/scripts/verify-flutter.mjs +++ b/scripts/verify-flutter.mjs @@ -242,7 +242,10 @@ async function run(operation, input) { assert.deepEqual(cli.normalized_result, mcp.normalized_result); assert.deepEqual(cli.subject, mcp.subject); assert.equal(cli.subject.local_path, input.path); - assert.equal(cli.subject.digest.sha256, cli.normalized_result.target.sha256); + assert.equal( + cli.subject.identity.sha256, + cli.normalized_result.target.sha256, + ); assert.deepEqual(cli.limitations, mcp.limitations); process.stdout.write( `[ok] ${operation}${input.abi === undefined ? "" : ` ${input.abi}`}: CLI/MCP Evidence parity\n`, diff --git a/scripts/verify-go-binary.mjs b/scripts/verify-go-binary.mjs index eed0300d0d..6b60423c0e 100644 --- a/scripts/verify-go-binary.mjs +++ b/scripts/verify-go-binary.mjs @@ -390,7 +390,7 @@ async function inspect(mode, path, includeStringLiterals = false) { const evidence = parseEvidence(envelope); assert.equal(evidence.subject.local_path, path); const report = goBinarySchema.parse(evidence.normalized_result); - assert.equal(evidence.subject.digest.sha256, report.artifact.sha256); + assert.equal(evidence.subject.identity.sha256, report.artifact.sha256); return { evidence, report }; } @@ -450,7 +450,7 @@ async function verify( assert.equal(report.format, target[2]); assert.equal(report.architecture, target[1]); assert.equal( - evidence.subject.architecture, + evidence.subject.identity.architecture, { amd64: "x86_64", 386: "x86", arm64: "arm64", mips: "mips" }[ target[1] ] ?? null, diff --git a/scripts/verify-http3-network-captures.mjs b/scripts/verify-http3-network-captures.mjs index 54c5e0e215..36496507a8 100644 --- a/scripts/verify-http3-network-captures.mjs +++ b/scripts/verify-http3-network-captures.mjs @@ -162,7 +162,7 @@ async function inspect(name) { assert.equal(evidence.normalized_result.runtime_attribution, "unknown"); assert.deepEqual(evidence.provider, evidence.normalized_result.decoder); assert.equal( - evidence.subject.digest.sha256, + evidence.subject.identity.sha256, digest(await readFile(input.capture_path)), ); } diff --git a/scripts/verify-package-evidence.mjs b/scripts/verify-package-evidence.mjs index f513632e79..194c3e8932 100644 --- a/scripts/verify-package-evidence.mjs +++ b/scripts/verify-package-evidence.mjs @@ -2,6 +2,7 @@ import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { createEvidence } from "../dist/domain/evidence.js"; +import { unknownTarget } from "../dist/domain/targetIdentity.js"; /** Round-trip historical reference import and evidence bundles. */ export async function verifyPackageEvidence({ @@ -30,7 +31,7 @@ export async function verifyPackageEvidence({ ); const sourceBundle = createEvidenceBundle([ createEvidence( - undefined, + unknownTarget("not-observed"), { id: "package", name: "Package verifier", version: "1" }, { operation: "health", parameters: {}, result: true }, ), diff --git a/scripts/verify-pcap.mjs b/scripts/verify-pcap.mjs index 8b91adfe96..b41e54f2ca 100644 --- a/scripts/verify-pcap.mjs +++ b/scripts/verify-pcap.mjs @@ -131,7 +131,7 @@ async function run(name, input) { if (input.path !== undefined) { assert.equal(cli.subject.local_path, input.path); assert.equal( - cli.subject.digest.sha256, + cli.subject.identity.sha256, cli.normalized_result.target.sha256, ); } diff --git a/scripts/verify-real-ghidra-6502.mjs b/scripts/verify-real-ghidra-6502.mjs index df27a0ebad..0ac4ccbd18 100644 --- a/scripts/verify-real-ghidra-6502.mjs +++ b/scripts/verify-real-ghidra-6502.mjs @@ -219,7 +219,7 @@ await withVerifierFixture(workspaceFixture, async () => { const cli = parseEvidence(JSON.parse(stdout)); assert.deepEqual(cli.normalized_result, image.normalized_result); assert.equal(cli.analysis_profile.digest, image.analysis_profile.digest); - assert.equal(cli.subject.digest.sha256, sha256); + assert.equal(cli.subject.identity.sha256, sha256); const fileCli = await exec( process.execPath, [ @@ -245,7 +245,7 @@ await withVerifierFixture(workspaceFixture, async () => { filePseudo.normalized_result, ); assert.deepEqual(fileCliEvidence.locations, filePseudo.locations); - assert.equal(fileCliEvidence.subject.digest.sha256, sha256); + assert.equal(fileCliEvidence.subject.identity.sha256, sha256); assert.deepEqual(await readFile(path), bytes); assert.deepEqual(await readdir(runtime), []); const lowMemory = []; @@ -511,8 +511,8 @@ async function call(name, args = {}) { function evidence(value, sha256) { const result = parseEvidence(value); - assert.equal(result.subject.digest.sha256, sha256); - assert.equal(result.subject.architecture, "6502"); - assert.equal(result.subject.format, "raw-binary"); + assert.equal(result.subject.identity.sha256, sha256); + assert.equal(result.subject.identity.architecture, "6502"); + assert.equal(result.subject.identity.format, "raw-binary"); return result; } diff --git a/scripts/verify-real-ghidra-address-context.mjs b/scripts/verify-real-ghidra-address-context.mjs index 93b2bcfd06..b26c64b824 100644 --- a/scripts/verify-real-ghidra-address-context.mjs +++ b/scripts/verify-real-ghidra-address-context.mjs @@ -82,7 +82,7 @@ try { connected = true; await call("open_binary", { path, provider_id: "ghidra" }); const overview = parseEvidence(await call("binary_overview")); - assert.equal(overview.subject.digest.sha256, sha256); + assert.equal(overview.subject.identity.sha256, sha256); const base = overview.normalized_result.image_base; assert.match(base, /^0x[0-9a-f]+$/u); assert.notEqual(base, "0x0"); diff --git a/scripts/verify-real-ghidra-com.mjs b/scripts/verify-real-ghidra-com.mjs index a38bf8dce6..73a0160676 100644 --- a/scripts/verify-real-ghidra-com.mjs +++ b/scripts/verify-real-ghidra-com.mjs @@ -522,7 +522,7 @@ async function call(name, args = {}) { if (["open_binary", "close_binary"].includes(name)) return requireMcpLifecycleResult(value, name); const evidence = parseEvidence(requireMcpOutput(value, name)); - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); return evidence.normalized_result; } async function cli(command, address, options = []) { @@ -543,8 +543,8 @@ async function cli(command, address, options = []) { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(stdout)); - assert.equal(evidence.subject.digest.sha256, sha256); - assert.equal(evidence.subject.format, "dos-com"); + assert.equal(evidence.subject.identity.sha256, sha256); + assert.equal(evidence.subject.identity.format, "dos-com"); assert.equal(evidence.analysis_profile.parameters.loader, "BinaryLoader"); assert.equal( evidence.analysis_profile.parameters.language_id, diff --git a/scripts/verify-real-ghidra-dol.mjs b/scripts/verify-real-ghidra-dol.mjs index 47be906b72..09b6fd87ed 100644 --- a/scripts/verify-real-ghidra-dol.mjs +++ b/scripts/verify-real-ghidra-dol.mjs @@ -248,14 +248,14 @@ async function runPass({ fixture, languageOverride, label, layout }) { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(cli.stdout)); - assert.equal(evidence.subject?.architecture, "powerpc"); - assert.equal(evidence.subject?.digest.sha256, fixture.sha256); + assert.equal(evidence.subject?.identity.architecture, "powerpc"); + assert.equal(evidence.subject?.identity.sha256, fixture.sha256); const cliDossier = functionDossierSchema.parse(evidence.normalized_result); assert.equal(BigInt(cliDossier.procedure.address), layout.entry); assert.ok(cliDossier.pseudocode.includes("__start")); report.cli = { entry: cliDossier.procedure.address, - subject_format: evidence.subject?.format ?? null, + subject_format: evidence.subject?.identity.format ?? null, }; } return report; diff --git a/scripts/verify-real-ghidra-dos.mjs b/scripts/verify-real-ghidra-dos.mjs index d86e19ba25..4c36d40fa2 100644 --- a/scripts/verify-real-ghidra-dos.mjs +++ b/scripts/verify-real-ghidra-dos.mjs @@ -604,7 +604,7 @@ async function evidenceCall(name, arguments_) { { timeout: 240000 }, ); const evidence = parseEvidence(requireMcpOutput(result, name)); - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); assert.equal(evidence.provider.id, "ghidra"); assertProfile(evidence.analysis_profile); return evidence; @@ -625,7 +625,7 @@ async function cliEvidence(command, procedure, options = []) { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(stdout)); - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); assert.equal(evidence.provider.id, "ghidra"); assertProfile(evidence.analysis_profile); assert.equal(digest(await readFile(targetPath)), sha256); diff --git a/scripts/verify-real-ghidra-m68k.mjs b/scripts/verify-real-ghidra-m68k.mjs index d3e91e6bf1..db76f04026 100644 --- a/scripts/verify-real-ghidra-m68k.mjs +++ b/scripts/verify-real-ghidra-m68k.mjs @@ -303,8 +303,8 @@ async function call(name, args = {}) { function evidence(value) { const result = parseEvidence(value); - assert.equal(result.subject.digest.sha256, sha256); - assert.equal(result.subject.architecture, "m68k"); - assert.equal(result.subject.format, "raw-binary"); + assert.equal(result.subject.identity.sha256, sha256); + assert.equal(result.subject.identity.architecture, "m68k"); + assert.equal(result.subject.identity.format, "raw-binary"); return result; } diff --git a/scripts/verify-real-ghidra-mips-relocatable.mjs b/scripts/verify-real-ghidra-mips-relocatable.mjs index 946e934fc5..44c53d07e3 100755 --- a/scripts/verify-real-ghidra-mips-relocatable.mjs +++ b/scripts/verify-real-ghidra-mips-relocatable.mjs @@ -278,8 +278,8 @@ async function verifyFixture(byteOrder, kernelModule) { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(cli.stdout)); - assert.equal(evidence.subject?.architecture, "mips"); - assert.equal(evidence.subject?.digest.sha256, fixture.sha256); + assert.equal(evidence.subject?.identity.architecture, "mips"); + assert.equal(evidence.subject?.identity.sha256, fixture.sha256); assert.equal( functionDossierSchema.parse(evidence.normalized_result).procedure.address, dossier.procedure.address, diff --git a/scripts/verify-real-ghidra-mips.mjs b/scripts/verify-real-ghidra-mips.mjs index 467d19588b..113b85ffac 100644 --- a/scripts/verify-real-ghidra-mips.mjs +++ b/scripts/verify-real-ghidra-mips.mjs @@ -697,7 +697,10 @@ try { ); } for (const evidence of snapshot.evidence_bundle.records) - assert.equal(parseEvidence(evidence).subject?.architecture, "mips"); + assert.equal( + parseEvidence(evidence).subject?.identity.architecture, + "mips", + ); await call("open_binary", { path: fixture.path, provider_id: "ghidra", @@ -766,8 +769,8 @@ try { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(cli.stdout)); - assert.equal(evidence.subject?.architecture, "mips"); - assert.equal(evidence.subject?.digest.sha256, fixture.sha256); + assert.equal(evidence.subject?.identity.architecture, "mips"); + assert.equal(evidence.subject?.identity.sha256, fixture.sha256); const cliDossier = functionDossierSchema.parse( evidence.normalized_result, ); diff --git a/scripts/verify-real-ghidra-nativeaot.mjs b/scripts/verify-real-ghidra-nativeaot.mjs index a8daf25039..9319047422 100644 --- a/scripts/verify-real-ghidra-nativeaot.mjs +++ b/scripts/verify-real-ghidra-nativeaot.mjs @@ -373,7 +373,7 @@ await withVerifierFixture(workspaceFixture, async () => { { env, timeout: 360000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(stdout)); - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); assert.deepEqual( evidence.normalized_result.metadata_recovery, metadata, @@ -424,6 +424,6 @@ async function call(name, args = {}) { ); if (name === "close_binary") return requireMcpLifecycleResult(response, name); const evidence = parseEvidence(requireMcpOutput(response, name)); - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); return evidence.normalized_result; } diff --git a/scripts/verify-real-ghidra-ppc.mjs b/scripts/verify-real-ghidra-ppc.mjs index 6329618bad..f613ea5b10 100644 --- a/scripts/verify-real-ghidra-ppc.mjs +++ b/scripts/verify-real-ghidra-ppc.mjs @@ -241,7 +241,10 @@ try { ); assert.ok(snapshot.evidence_bundle.records.length > 0); for (const evidence of snapshot.evidence_bundle.records) - assert.equal(parseEvidence(evidence).subject?.architecture, "powerpc"); + assert.equal( + parseEvidence(evidence).subject?.identity.architecture, + "powerpc", + ); await call("open_binary", { path: fixture.path, provider_id: "ghidra", @@ -265,8 +268,8 @@ try { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const evidence = parseEvidence(JSON.parse(cli.stdout)); - assert.equal(evidence.subject?.architecture, "powerpc"); - assert.equal(evidence.subject?.digest.sha256, fixture.sha256); + assert.equal(evidence.subject?.identity.architecture, "powerpc"); + assert.equal(evidence.subject?.identity.sha256, fixture.sha256); const cliDossier = functionDossierSchema.parse( evidence.normalized_result, ); diff --git a/scripts/verify-real-ghidra-raw.mjs b/scripts/verify-real-ghidra-raw.mjs index 1955471a15..f98194f846 100644 --- a/scripts/verify-real-ghidra-raw.mjs +++ b/scripts/verify-real-ghidra-raw.mjs @@ -274,7 +274,7 @@ await withVerifierFixture(workspaceFixture, async () => { { env, timeout: 240000, maxBuffer: 16 * 1024 * 1024 }, ); const cli = parseEvidence(JSON.parse(stdout)); - assert.equal(cli.subject.digest.sha256, sha256); + assert.equal(cli.subject.identity.sha256, sha256); assert.equal(cli.normalized_result.status, "verified"); assert.equal(cli.normalized_result.base_address, "0x8000000"); assert.equal(cli.analysis_profile.digest, profiles[0]); @@ -646,8 +646,8 @@ async function call( return requireMcpLifecycleResult(result, name); const output = requireMcpOutput(result, name); const evidence = parseEvidence(output); - assert.equal(evidence.subject.digest.sha256, targetSha256); - assert.equal(evidence.subject.format, targetFormat); + assert.equal(evidence.subject.identity.sha256, targetSha256); + assert.equal(evidence.subject.identity.format, targetFormat); return evidence; } @@ -762,7 +762,7 @@ async function verifyCrossBlockProject(target, targetSha256) { return requireMcpLifecycleResult(reply, name); const output = requireMcpOutput(reply, name); const evidence = parseEvidence(output); - assert.equal(evidence.subject.digest.sha256, targetSha256); + assert.equal(evidence.subject.identity.sha256, targetSha256); return evidence.normalized_result; }; await projectCall("open_binary", { path: target, provider_id: "ghidra" }); diff --git a/scripts/verify-real-ghidra-riscv.mjs b/scripts/verify-real-ghidra-riscv.mjs index 05e2475c10..9d57533509 100644 --- a/scripts/verify-real-ghidra-riscv.mjs +++ b/scripts/verify-real-ghidra-riscv.mjs @@ -177,8 +177,8 @@ try { assert.deepEqual(parameters.riscv_elf, want.riscvElf); }; const assertEvidence = (evidence) => { - assert.equal(evidence.subject.architecture, "riscv"); - assert.equal(evidence.subject.digest.sha256, fixture.sha256); + assert.equal(evidence.subject.identity.architecture, "riscv"); + assert.equal(evidence.subject.identity.sha256, fixture.sha256); // Composed workflows such as inspect_native_api commit the Ghidra // profile as their upstream profile. The residual-unknown registry // records what they could not establish, such as the types of a diff --git a/scripts/verify-real-ghidra-switch.mjs b/scripts/verify-real-ghidra-switch.mjs index 6f3427fffc..10b680ca1b 100644 --- a/scripts/verify-real-ghidra-switch.mjs +++ b/scripts/verify-real-ghidra-switch.mjs @@ -304,7 +304,7 @@ async function verifyTarget(path, sha256, fixtures, variant) { ]); } function assertWorkflowIdentity(evidence, sha256) { - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); assert.equal(evidence.operation, "inspect_native_api"); assert.equal(evidence.provider.id, "rea-workflow"); assert.equal(evidence.analysis_profile.provider.id, "rea-workflow"); diff --git a/scripts/verify-real-kuna.mjs b/scripts/verify-real-kuna.mjs index 2ea9bcddf3..b3ddf8ce1f 100644 --- a/scripts/verify-real-kuna.mjs +++ b/scripts/verify-real-kuna.mjs @@ -514,7 +514,7 @@ const verifyKuna = async ( const pseudocode = await cold.call("procedure_pseudo_code", { procedure: address, }); - assert.equal(pseudocode.structured.subject.digest.sha256, sha256); + assert.equal(pseudocode.structured.subject.identity.sha256, sha256); assert.equal(pseudocode.structured.provider.id, "kuna"); const source = pseudocode.structured.raw_result?.source?.kind; // A fast export can finish before the first request reaches the diff --git a/scripts/verify-wasm-artifact.mjs b/scripts/verify-wasm-artifact.mjs index 861583866a..227076a3d8 100644 --- a/scripts/verify-wasm-artifact.mjs +++ b/scripts/verify-wasm-artifact.mjs @@ -437,7 +437,7 @@ try { ({ evidence_id }) => evidence_id === partial.evidence_id, ); assert.ok(failed, "Retained failed WASM Evidence missing from bundle"); - assert.equal(failed.subject.digest.sha256, sha256(invalidBytes)); + assert.equal(failed.subject.identity.sha256, sha256(invalidBytes)); assert.equal( failed.normalized_result.tool_profile.timeout_ms, invalidInput.command_timeout_ms ?? 30_000, diff --git a/scripts/verify-wasm-interface-comparison.mjs b/scripts/verify-wasm-interface-comparison.mjs index 7dd07299d2..c3f35916a8 100644 --- a/scripts/verify-wasm-interface-comparison.mjs +++ b/scripts/verify-wasm-interface-comparison.mjs @@ -117,7 +117,10 @@ await withVerifierFixture(rootFixture, async () => { ); const left = await inspect(path); const equivalent = await inspect(equivalentPath); - assert.notEqual(left.subject.digest.sha256, equivalent.subject.digest.sha256); + assert.notEqual( + left.subject.identity.sha256, + equivalent.subject.identity.sha256, + ); const same = await compare(left, equivalent); assert.deepEqual(same.summary, { added: 0, @@ -195,8 +198,8 @@ await withVerifierFixture(rootFixture, async () => { JSON.stringify(left.normalized_result.interface), ), comparison_result_bytes: Buffer.byteLength(JSON.stringify(same)), - original_sha256: left.subject.digest.sha256, - equivalent_sha256: equivalent.subject.digest.sha256, + original_sha256: left.subject.identity.sha256, + equivalent_sha256: equivalent.subject.identity.sha256, cases: [ "equivalent padded LEB128", "function signature change", diff --git a/scripts/verify-web-network-captures.mjs b/scripts/verify-web-network-captures.mjs index 3000634422..6c279d9411 100644 --- a/scripts/verify-web-network-captures.mjs +++ b/scripts/verify-web-network-captures.mjs @@ -1053,8 +1053,9 @@ function assertSensitiveLimitations(evidence, literals) { "Declared literal retained in Evidence parameter", ); const result = evidence.normalized_result; - if (result.artifact.sha256 === null) assert.equal(evidence.subject, null); - else assert.equal(evidence.subject.digest.sha256, result.artifact.sha256); + if (result.artifact.sha256 === null) + assert.equal(evidence.subject.identity.kind, "unknown"); + else assert.equal(evidence.subject.identity.sha256, result.artifact.sha256); assert.deepEqual( evidence.provider, result.decoder, diff --git a/scripts/verify/advertised-schemas/tools/address_name.json b/scripts/verify/advertised-schemas/tools/address_name.json index 98300f8969..6f5316cdb7 100644 --- a/scripts/verify/advertised-schemas/tools/address_name.json +++ b/scripts/verify/advertised-schemas/tools/address_name.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "9e24f29540c4da8a" + "output compact": "0b02ebb3ff9b71d9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/address_to_file_offset.json b/scripts/verify/advertised-schemas/tools/address_to_file_offset.json index 51c4ed3c12..0a71edfc17 100644 --- a/scripts/verify/advertised-schemas/tools/address_to_file_offset.json +++ b/scripts/verify/advertised-schemas/tools/address_to_file_offset.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "940657f284593726", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/analyze_function.json b/scripts/verify/advertised-schemas/tools/analyze_function.json index 163872bc4a..eb201b4d66 100644 --- a/scripts/verify/advertised-schemas/tools/analyze_function.json +++ b/scripts/verify/advertised-schemas/tools/analyze_function.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "02ac81c718b49410", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/analyze_javascript_application.json b/scripts/verify/advertised-schemas/tools/analyze_javascript_application.json index 6363cfd04c..a71d9699fc 100644 --- a/scripts/verify/advertised-schemas/tools/analyze_javascript_application.json +++ b/scripts/verify/advertised-schemas/tools/analyze_javascript_application.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "990f691d36bfeeec", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/analyze_swift_types.json b/scripts/verify/advertised-schemas/tools/analyze_swift_types.json index 70d834226a..10e7385088 100644 --- a/scripts/verify/advertised-schemas/tools/analyze_swift_types.json +++ b/scripts/verify/advertised-schemas/tools/analyze_swift_types.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "954672370cc76451", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/analyze_web_bundle.json b/scripts/verify/advertised-schemas/tools/analyze_web_bundle.json index 4e67e941cd..6b761b15fb 100644 --- a/scripts/verify/advertised-schemas/tools/analyze_web_bundle.json +++ b/scripts/verify/advertised-schemas/tools/analyze_web_bundle.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3d7959f5cdca863d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/annotate_native_function.json b/scripts/verify/advertised-schemas/tools/annotate_native_function.json index 28f079a5d0..b5c7f9335b 100644 --- a/scripts/verify/advertised-schemas/tools/annotate_native_function.json +++ b/scripts/verify/advertised-schemas/tools/annotate_native_function.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "70c17ea61092a8c3", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/audit_release_exposure.json b/scripts/verify/advertised-schemas/tools/audit_release_exposure.json index daa5661338..7d6bd3af9b 100644 --- a/scripts/verify/advertised-schemas/tools/audit_release_exposure.json +++ b/scripts/verify/advertised-schemas/tools/audit_release_exposure.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "d4ebd6a35bc062aa", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/batch_decompile.json b/scripts/verify/advertised-schemas/tools/batch_decompile.json index 1c4816922e..9588134552 100644 --- a/scripts/verify/advertised-schemas/tools/batch_decompile.json +++ b/scripts/verify/advertised-schemas/tools/batch_decompile.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "cd55cbd9191fb397", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/binary_overview.json b/scripts/verify/advertised-schemas/tools/binary_overview.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/binary_overview.json +++ b/scripts/verify/advertised-schemas/tools/binary_overview.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/build_call_path.json b/scripts/verify/advertised-schemas/tools/build_call_path.json index 3344fcae91..f8e57d12f1 100644 --- a/scripts/verify/advertised-schemas/tools/build_call_path.json +++ b/scripts/verify/advertised-schemas/tools/build_call_path.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5b291bcc2323c4d0", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/build_reconstruction_obligation_ledger.json b/scripts/verify/advertised-schemas/tools/build_reconstruction_obligation_ledger.json index 7f378aca25..0bfbfa0aaf 100644 --- a/scripts/verify/advertised-schemas/tools/build_reconstruction_obligation_ledger.json +++ b/scripts/verify/advertised-schemas/tools/build_reconstruction_obligation_ledger.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "a7cd5ce32e774439", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/capture_adb_screen.json b/scripts/verify/advertised-schemas/tools/capture_adb_screen.json index c1f4bc84d1..bacb477adb 100644 --- a/scripts/verify/advertised-schemas/tools/capture_adb_screen.json +++ b/scripts/verify/advertised-schemas/tools/capture_adb_screen.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5270421b8c21c650", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/capture_browser_scenario.json b/scripts/verify/advertised-schemas/tools/capture_browser_scenario.json index e657b058ba..06a3a65006 100644 --- a/scripts/verify/advertised-schemas/tools/capture_browser_scenario.json +++ b/scripts/verify/advertised-schemas/tools/capture_browser_scenario.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b6594631753958b4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/capture_electron_scenario.json b/scripts/verify/advertised-schemas/tools/capture_electron_scenario.json index 50a62d9c2a..c0874ac63e 100644 --- a/scripts/verify/advertised-schemas/tools/capture_electron_scenario.json +++ b/scripts/verify/advertised-schemas/tools/capture_electron_scenario.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "1966487f98e87f51", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/capture_native_ui_scenario.json b/scripts/verify/advertised-schemas/tools/capture_native_ui_scenario.json index 96e7f76bf0..1467a6b269 100644 --- a/scripts/verify/advertised-schemas/tools/capture_native_ui_scenario.json +++ b/scripts/verify/advertised-schemas/tools/capture_native_ui_scenario.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "699d21a37250979b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/capture_process_scenario.json b/scripts/verify/advertised-schemas/tools/capture_process_scenario.json index 4ea381b4e7..7cb3931db5 100644 --- a/scripts/verify/advertised-schemas/tools/capture_process_scenario.json +++ b/scripts/verify/advertised-schemas/tools/capture_process_scenario.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b16f62e36c31a0cc", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/capture_web_screenshot.json b/scripts/verify/advertised-schemas/tools/capture_web_screenshot.json index 35ab95a441..1d857cc907 100644 --- a/scripts/verify/advertised-schemas/tools/capture_web_screenshot.json +++ b/scripts/verify/advertised-schemas/tools/capture_web_screenshot.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7ba00cbe6d75c7d9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/collect_adb_bugreport.json b/scripts/verify/advertised-schemas/tools/collect_adb_bugreport.json index c1f4bc84d1..bacb477adb 100644 --- a/scripts/verify/advertised-schemas/tools/collect_adb_bugreport.json +++ b/scripts/verify/advertised-schemas/tools/collect_adb_bugreport.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5270421b8c21c650", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/comment.json b/scripts/verify/advertised-schemas/tools/comment.json index 98300f8969..6f5316cdb7 100644 --- a/scripts/verify/advertised-schemas/tools/comment.json +++ b/scripts/verify/advertised-schemas/tools/comment.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "9e24f29540c4da8a" + "output compact": "0b02ebb3ff9b71d9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_application_versions.json b/scripts/verify/advertised-schemas/tools/compare_application_versions.json index 85dbf9cf66..aaeeb845f9 100644 --- a/scripts/verify/advertised-schemas/tools/compare_application_versions.json +++ b/scripts/verify/advertised-schemas/tools/compare_application_versions.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6e86c4697a074d94", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_artifacts.json b/scripts/verify/advertised-schemas/tools/compare_artifacts.json index 19a321c512..cd9c5774f4 100644 --- a/scripts/verify/advertised-schemas/tools/compare_artifacts.json +++ b/scripts/verify/advertised-schemas/tools/compare_artifacts.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "633f07e1c25fb0e9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_bundles.json b/scripts/verify/advertised-schemas/tools/compare_bundles.json index 1766e74e02..265648f534 100644 --- a/scripts/verify/advertised-schemas/tools/compare_bundles.json +++ b/scripts/verify/advertised-schemas/tools/compare_bundles.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "65c9f2cad6fee49f", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$", "^ev_[0-9a-f]{64}$"] diff --git a/scripts/verify/advertised-schemas/tools/compare_functions.json b/scripts/verify/advertised-schemas/tools/compare_functions.json index 19a321c512..cd9c5774f4 100644 --- a/scripts/verify/advertised-schemas/tools/compare_functions.json +++ b/scripts/verify/advertised-schemas/tools/compare_functions.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "633f07e1c25fb0e9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_javascript_export_shapes.json b/scripts/verify/advertised-schemas/tools/compare_javascript_export_shapes.json index eddab4f5f7..00662d31bc 100644 --- a/scripts/verify/advertised-schemas/tools/compare_javascript_export_shapes.json +++ b/scripts/verify/advertised-schemas/tools/compare_javascript_export_shapes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "169fa0bb1123cfed", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_managed_members.json b/scripts/verify/advertised-schemas/tools/compare_managed_members.json index 19a321c512..cd9c5774f4 100644 --- a/scripts/verify/advertised-schemas/tools/compare_managed_members.json +++ b/scripts/verify/advertised-schemas/tools/compare_managed_members.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "633f07e1c25fb0e9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_process_captures.json b/scripts/verify/advertised-schemas/tools/compare_process_captures.json index 672eec4ad4..fbb9abad7a 100644 --- a/scripts/verify/advertised-schemas/tools/compare_process_captures.json +++ b/scripts/verify/advertised-schemas/tools/compare_process_captures.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "09de9679075c918d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_source_to_bundle.json b/scripts/verify/advertised-schemas/tools/compare_source_to_bundle.json index 76587b90ec..612f614e92 100644 --- a/scripts/verify/advertised-schemas/tools/compare_source_to_bundle.json +++ b/scripts/verify/advertised-schemas/tools/compare_source_to_bundle.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "53e35e56039bbec8", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_static_and_observed_endpoints.json b/scripts/verify/advertised-schemas/tools/compare_static_and_observed_endpoints.json index 63d09b8104..ec5919a602 100644 --- a/scripts/verify/advertised-schemas/tools/compare_static_and_observed_endpoints.json +++ b/scripts/verify/advertised-schemas/tools/compare_static_and_observed_endpoints.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "87bd558a19485f40", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_wasm_interfaces.json b/scripts/verify/advertised-schemas/tools/compare_wasm_interfaces.json index 34817461e2..87a3945bb3 100644 --- a/scripts/verify/advertised-schemas/tools/compare_wasm_interfaces.json +++ b/scripts/verify/advertised-schemas/tools/compare_wasm_interfaces.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "762370ff0063b96c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_web_captures.json b/scripts/verify/advertised-schemas/tools/compare_web_captures.json index 8180c09e7e..6acafc6a8a 100644 --- a/scripts/verify/advertised-schemas/tools/compare_web_captures.json +++ b/scripts/verify/advertised-schemas/tools/compare_web_captures.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "9a27667fef6bb852", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/compare_web_screenshots.json b/scripts/verify/advertised-schemas/tools/compare_web_screenshots.json index cb74f19814..e636d34a08 100644 --- a/scripts/verify/advertised-schemas/tools/compare_web_screenshots.json +++ b/scripts/verify/advertised-schemas/tools/compare_web_screenshots.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "eff327dda5c10d9a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[0-9a-f]{64}$"] diff --git a/scripts/verify/advertised-schemas/tools/correlate_static_and_runtime.json b/scripts/verify/advertised-schemas/tools/correlate_static_and_runtime.json index 813f7ed798..2cf4ed5c11 100644 --- a/scripts/verify/advertised-schemas/tools/correlate_static_and_runtime.json +++ b/scripts/verify/advertised-schemas/tools/correlate_static_and_runtime.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "24360903f54081d4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/current_address.json b/scripts/verify/advertised-schemas/tools/current_address.json index 21f4d6f043..e9ebbc9666 100644 --- a/scripts/verify/advertised-schemas/tools/current_address.json +++ b/scripts/verify/advertised-schemas/tools/current_address.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4df1857d0f25b9b1", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/current_document.json b/scripts/verify/advertised-schemas/tools/current_document.json index a0d7db9087..15b08d2d5d 100644 --- a/scripts/verify/advertised-schemas/tools/current_document.json +++ b/scripts/verify/advertised-schemas/tools/current_document.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/current_procedure.json b/scripts/verify/advertised-schemas/tools/current_procedure.json index 21f4d6f043..e9ebbc9666 100644 --- a/scripts/verify/advertised-schemas/tools/current_procedure.json +++ b/scripts/verify/advertised-schemas/tools/current_procedure.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4df1857d0f25b9b1", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/cutter_command.json b/scripts/verify/advertised-schemas/tools/cutter_command.json index 4f65333e9b..f4cf04b8a9 100644 --- a/scripts/verify/advertised-schemas/tools/cutter_command.json +++ b/scripts/verify/advertised-schemas/tools/cutter_command.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b91fd6378ec89ada", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/decode_android_resources.json b/scripts/verify/advertised-schemas/tools/decode_android_resources.json index f5f2b474fe..ef23e3b94a 100644 --- a/scripts/verify/advertised-schemas/tools/decode_android_resources.json +++ b/scripts/verify/advertised-schemas/tools/decode_android_resources.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "a1b45d95750ca8ef", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/decode_interface_builder.json b/scripts/verify/advertised-schemas/tools/decode_interface_builder.json index 6c81ef83db..929375e2c5 100644 --- a/scripts/verify/advertised-schemas/tools/decode_interface_builder.json +++ b/scripts/verify/advertised-schemas/tools/decode_interface_builder.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0395893cc47e3a89", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/decode_signal_recording.json b/scripts/verify/advertised-schemas/tools/decode_signal_recording.json index bd6e79dcba..9c5059a62d 100644 --- a/scripts/verify/advertised-schemas/tools/decode_signal_recording.json +++ b/scripts/verify/advertised-schemas/tools/decode_signal_recording.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "57f1e31eab5d6150", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/decompile_all.json b/scripts/verify/advertised-schemas/tools/decompile_all.json index 92e239955d..73117118a5 100644 --- a/scripts/verify/advertised-schemas/tools/decompile_all.json +++ b/scripts/verify/advertised-schemas/tools/decompile_all.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f9475f6ca1476ae0", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/decompile_jeb_item.json b/scripts/verify/advertised-schemas/tools/decompile_jeb_item.json index 6ba6b27f30..21ef29702a 100644 --- a/scripts/verify/advertised-schemas/tools/decompile_jeb_item.json +++ b/scripts/verify/advertised-schemas/tools/decompile_jeb_item.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "365c0a3f3e7ee733", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/demangle_swift.json b/scripts/verify/advertised-schemas/tools/demangle_swift.json index 99fdf633f8..faaa86e82c 100644 --- a/scripts/verify/advertised-schemas/tools/demangle_swift.json +++ b/scripts/verify/advertised-schemas/tools/demangle_swift.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ce0ed2a63eb8849e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x0a]*$"] diff --git a/scripts/verify/advertised-schemas/tools/discover_webmcp_tools.json b/scripts/verify/advertised-schemas/tools/discover_webmcp_tools.json index 9bff10adfc..37753edc71 100644 --- a/scripts/verify/advertised-schemas/tools/discover_webmcp_tools.json +++ b/scripts/verify/advertised-schemas/tools/discover_webmcp_tools.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4425590849a07d7f", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/execute_rizin_command.json b/scripts/verify/advertised-schemas/tools/execute_rizin_command.json index 43aca2b281..8414397ae7 100644 --- a/scripts/verify/advertised-schemas/tools/execute_rizin_command.json +++ b/scripts/verify/advertised-schemas/tools/execute_rizin_command.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "abd06cd2d1a16823", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/export_web_scripts.json b/scripts/verify/advertised-schemas/tools/export_web_scripts.json index 3e3f6c6095..43f87c76f5 100644 --- a/scripts/verify/advertised-schemas/tools/export_web_scripts.json +++ b/scripts/verify/advertised-schemas/tools/export_web_scripts.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b18c35aaccafe15a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/extract_artifact.json b/scripts/verify/advertised-schemas/tools/extract_artifact.json index e28bcd7b31..6edd342ec7 100644 --- a/scripts/verify/advertised-schemas/tools/extract_artifact.json +++ b/scripts/verify/advertised-schemas/tools/extract_artifact.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5ecb2020ae1f8f42", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$", "^occ_[0-9a-f]{64}$"] diff --git a/scripts/verify/advertised-schemas/tools/extract_firmware.json b/scripts/verify/advertised-schemas/tools/extract_firmware.json index b7f3fb72a0..e5bd5e41f4 100644 --- a/scripts/verify/advertised-schemas/tools/extract_firmware.json +++ b/scripts/verify/advertised-schemas/tools/extract_firmware.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6ca4f62a458ff3d7", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/find_changed_behavior.json b/scripts/verify/advertised-schemas/tools/find_changed_behavior.json index 6bcb871232..7b1aa388aa 100644 --- a/scripts/verify/advertised-schemas/tools/find_changed_behavior.json +++ b/scripts/verify/advertised-schemas/tools/find_changed_behavior.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "a8a946736b36ddb8", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/find_xrefs_to_name.json b/scripts/verify/advertised-schemas/tools/find_xrefs_to_name.json index f0773468e7..4e03be3cbd 100644 --- a/scripts/verify/advertised-schemas/tools/find_xrefs_to_name.json +++ b/scripts/verify/advertised-schemas/tools/find_xrefs_to_name.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ba6030423e62d130", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/frida_session_status.json b/scripts/verify/advertised-schemas/tools/frida_session_status.json index 46643dca6c..486f4dbb6a 100644 --- a/scripts/verify/advertised-schemas/tools/frida_session_status.json +++ b/scripts/verify/advertised-schemas/tools/frida_session_status.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "31cc6bc09d1bb29d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/gdb_console.json b/scripts/verify/advertised-schemas/tools/gdb_console.json index e8dceecf01..8cc8ba0586 100644 --- a/scripts/verify/advertised-schemas/tools/gdb_console.json +++ b/scripts/verify/advertised-schemas/tools/gdb_console.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3a493db9e13845e2", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/get_call_graph.json b/scripts/verify/advertised-schemas/tools/get_call_graph.json index b3775594a9..86f789ff6c 100644 --- a/scripts/verify/advertised-schemas/tools/get_call_graph.json +++ b/scripts/verify/advertised-schemas/tools/get_call_graph.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5d40cd3080063c1d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/get_objc_classes.json b/scripts/verify/advertised-schemas/tools/get_objc_classes.json index 58756a5d13..98ca03cec1 100644 --- a/scripts/verify/advertised-schemas/tools/get_objc_classes.json +++ b/scripts/verify/advertised-schemas/tools/get_objc_classes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "e2e179a75a6a8189", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/get_objc_protocols.json b/scripts/verify/advertised-schemas/tools/get_objc_protocols.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/get_objc_protocols.json +++ b/scripts/verify/advertised-schemas/tools/get_objc_protocols.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/goto_address.json b/scripts/verify/advertised-schemas/tools/goto_address.json index fc80424833..bfc3de38a5 100644 --- a/scripts/verify/advertised-schemas/tools/goto_address.json +++ b/scripts/verify/advertised-schemas/tools/goto_address.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "940657f284593726", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/identify_flutter_build.json b/scripts/verify/advertised-schemas/tools/identify_flutter_build.json index 6fcf0c2226..e748e5238e 100644 --- a/scripts/verify/advertised-schemas/tools/identify_flutter_build.json +++ b/scripts/verify/advertised-schemas/tools/identify_flutter_build.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "18d266261424a97c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/import_managed_reconstruction.json b/scripts/verify/advertised-schemas/tools/import_managed_reconstruction.json index 600d927591..c1089adbac 100644 --- a/scripts/verify/advertised-schemas/tools/import_managed_reconstruction.json +++ b/scripts/verify/advertised-schemas/tools/import_managed_reconstruction.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32ffbbfc8df34d78", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inline_comment.json b/scripts/verify/advertised-schemas/tools/inline_comment.json index 98300f8969..6f5316cdb7 100644 --- a/scripts/verify/advertised-schemas/tools/inline_comment.json +++ b/scripts/verify/advertised-schemas/tools/inline_comment.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "9e24f29540c4da8a" + "output compact": "0b02ebb3ff9b71d9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_adb_client.json b/scripts/verify/advertised-schemas/tools/inspect_adb_client.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_adb_client.json +++ b/scripts/verify/advertised-schemas/tools/inspect_adb_client.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_adb_device.json b/scripts/verify/advertised-schemas/tools/inspect_adb_device.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_adb_device.json +++ b/scripts/verify/advertised-schemas/tools/inspect_adb_device.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_adb_display.json b/scripts/verify/advertised-schemas/tools/inspect_adb_display.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_adb_display.json +++ b/scripts/verify/advertised-schemas/tools/inspect_adb_display.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_adb_package.json b/scripts/verify/advertised-schemas/tools/inspect_adb_package.json index 1eda154f6f..9f457c049a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_adb_package.json +++ b/scripts/verify/advertised-schemas/tools/inspect_adb_package.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2d6b5bb69d217de1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/inspect_adb_window.json b/scripts/verify/advertised-schemas/tools/inspect_adb_window.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_adb_window.json +++ b/scripts/verify/advertised-schemas/tools/inspect_adb_window.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_analysis_view.json b/scripts/verify/advertised-schemas/tools/inspect_analysis_view.json index f404f34da9..355f72efdd 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_analysis_view.json +++ b/scripts/verify/advertised-schemas/tools/inspect_analysis_view.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "99dbe34c28cd04dd", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_android_class.json b/scripts/verify/advertised-schemas/tools/inspect_android_class.json index 1c68f1710f..9a6c8d2c1a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_android_class.json +++ b/scripts/verify/advertised-schemas/tools/inspect_android_class.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fb8be61f22dca985", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_android_jni_bindings.json b/scripts/verify/advertised-schemas/tools/inspect_android_jni_bindings.json index 4178989271..e88802f19a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_android_jni_bindings.json +++ b/scripts/verify/advertised-schemas/tools/inspect_android_jni_bindings.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "e5d2cfec1580148e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/inspect_android_method.json b/scripts/verify/advertised-schemas/tools/inspect_android_method.json index d195b5ca98..976f9a8392 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_android_method.json +++ b/scripts/verify/advertised-schemas/tools/inspect_android_method.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f4d383779c829cc1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_android_package.json b/scripts/verify/advertised-schemas/tools/inspect_android_package.json index 8a90da75b1..677fe963fe 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_android_package.json +++ b/scripts/verify/advertised-schemas/tools/inspect_android_package.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6f391991d856198a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_api_contract.json b/scripts/verify/advertised-schemas/tools/inspect_api_contract.json index b52285fb3e..ca58b0ff33 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_api_contract.json +++ b/scripts/verify/advertised-schemas/tools/inspect_api_contract.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "79519ee02b61df07", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_apk_signature.json b/scripts/verify/advertised-schemas/tools/inspect_apk_signature.json index 4346d4bb1c..ccede02270 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_apk_signature.json +++ b/scripts/verify/advertised-schemas/tools/inspect_apk_signature.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "dec153ba3fc1960c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_apktool_client.json b/scripts/verify/advertised-schemas/tools/inspect_apktool_client.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_apktool_client.json +++ b/scripts/verify/advertised-schemas/tools/inspect_apktool_client.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_apple_ips.json b/scripts/verify/advertised-schemas/tools/inspect_apple_ips.json index 3bc2a264b5..2654bae774 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_apple_ips.json +++ b/scripts/verify/advertised-schemas/tools/inspect_apple_ips.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c55c03a1cfb12bf4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_artifact.json b/scripts/verify/advertised-schemas/tools/inspect_artifact.json index 5815d89c82..9d4c9e2200 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_artifact.json +++ b/scripts/verify/advertised-schemas/tools/inspect_artifact.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "aabcc05db1232b21", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_asset_catalog.json b/scripts/verify/advertised-schemas/tools/inspect_asset_catalog.json index f1e3fd461f..0d68fb719a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_asset_catalog.json +++ b/scripts/verify/advertised-schemas/tools/inspect_asset_catalog.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "72d0fff774075e7c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_binary_hardening.json b/scripts/verify/advertised-schemas/tools/inspect_binary_hardening.json index ed3f47888b..ed8d2a99b9 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_binary_hardening.json +++ b/scripts/verify/advertised-schemas/tools/inspect_binary_hardening.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c2417cfbfd1a4976", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_binary_layout.json b/scripts/verify/advertised-schemas/tools/inspect_binary_layout.json index e69e874663..bb5951157a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_binary_layout.json +++ b/scripts/verify/advertised-schemas/tools/inspect_binary_layout.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "59748ce45f667d12", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_byte_entropy.json b/scripts/verify/advertised-schemas/tools/inspect_byte_entropy.json index b0f75a1910..be219321bd 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_byte_entropy.json +++ b/scripts/verify/advertised-schemas/tools/inspect_byte_entropy.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fdd4a3a111b4308b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_dart_aot.json b/scripts/verify/advertised-schemas/tools/inspect_dart_aot.json index dbb38e3289..a6162ae5ee 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_dart_aot.json +++ b/scripts/verify/advertised-schemas/tools/inspect_dart_aot.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "a048bd94aa23c39e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$", "^[^\\x2f]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_desktop_application.json b/scripts/verify/advertised-schemas/tools/inspect_desktop_application.json index ec09a06c98..2da7716a15 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_desktop_application.json +++ b/scripts/verify/advertised-schemas/tools/inspect_desktop_application.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f7cf5551a6ffd825", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_devicetree.json b/scripts/verify/advertised-schemas/tools/inspect_devicetree.json index e72ce565d7..89a912fe06 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_devicetree.json +++ b/scripts/verify/advertised-schemas/tools/inspect_devicetree.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "02a13a32cf55d458", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_electron_fuses.json b/scripts/verify/advertised-schemas/tools/inspect_electron_fuses.json index 6fcf0c2226..e748e5238e 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_electron_fuses.json +++ b/scripts/verify/advertised-schemas/tools/inspect_electron_fuses.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "18d266261424a97c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_electron_page.json b/scripts/verify/advertised-schemas/tools/inspect_electron_page.json index 6af8863417..277fd758b7 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_electron_page.json +++ b/scripts/verify/advertised-schemas/tools/inspect_electron_page.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4bfd2a08afbc54fc", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_elf_notes.json b/scripts/verify/advertised-schemas/tools/inspect_elf_notes.json index 7b3c28a22f..30600328a7 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_elf_notes.json +++ b/scripts/verify/advertised-schemas/tools/inspect_elf_notes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "8b30e04cd3ac0805", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_elf_unwind_ranges.json b/scripts/verify/advertised-schemas/tools/inspect_elf_unwind_ranges.json index 6906f44efc..490470a156 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_elf_unwind_ranges.json +++ b/scripts/verify/advertised-schemas/tools/inspect_elf_unwind_ranges.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "9a9a8438a4b6e9f0", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_erlang_beam.json b/scripts/verify/advertised-schemas/tools/inspect_erlang_beam.json index 86e3c6395f..e02891adc7 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_erlang_beam.json +++ b/scripts/verify/advertised-schemas/tools/inspect_erlang_beam.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c14ca0aea789c645", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_evm_interface.json b/scripts/verify/advertised-schemas/tools/inspect_evm_interface.json index 67ab7d46f4..8257c82aad 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_evm_interface.json +++ b/scripts/verify/advertised-schemas/tools/inspect_evm_interface.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f8a87e80e0ca66fe", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_firmware_regions.json b/scripts/verify/advertised-schemas/tools/inspect_firmware_regions.json index b7e2b1d71d..478c464093 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_firmware_regions.json +++ b/scripts/verify/advertised-schemas/tools/inspect_firmware_regions.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ac72671d7bdc9ed4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_go_binary.json b/scripts/verify/advertised-schemas/tools/inspect_go_binary.json index f8ed375218..5992e482c1 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_go_binary.json +++ b/scripts/verify/advertised-schemas/tools/inspect_go_binary.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f5cc9dc3caf9edf4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json b/scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json index 0c73feb375..b8480252f7 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json +++ b/scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "01c7ceeb7a6ac4d4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[0-9a-f]{64}$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_il2cpp_metadata.json b/scripts/verify/advertised-schemas/tools/inspect_il2cpp_metadata.json index 074c0f2749..32aafbe572 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_il2cpp_metadata.json +++ b/scripts/verify/advertised-schemas/tools/inspect_il2cpp_metadata.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7181073b85e89641", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_jeb_client.json b/scripts/verify/advertised-schemas/tools/inspect_jeb_client.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_jeb_client.json +++ b/scripts/verify/advertised-schemas/tools/inspect_jeb_client.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_kernel_build_config.json b/scripts/verify/advertised-schemas/tools/inspect_kernel_build_config.json index 4878d679df..2cd28cf2a6 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_kernel_build_config.json +++ b/scripts/verify/advertised-schemas/tools/inspect_kernel_build_config.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "67f91f8c76d696c7", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^CONFIG_[0-9A-Z_a-z]+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_kernel_module.json b/scripts/verify/advertised-schemas/tools/inspect_kernel_module.json index fe448cfcba..1f918efbb1 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_kernel_module.json +++ b/scripts/verify/advertised-schemas/tools/inspect_kernel_module.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "9f3ed49a3c380bd6", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_keyed_archive.json b/scripts/verify/advertised-schemas/tools/inspect_keyed_archive.json index f15d9e3e1c..2790612ac3 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_keyed_archive.json +++ b/scripts/verify/advertised-schemas/tools/inspect_keyed_archive.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fe4818885a05bfb0", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_macho.json b/scripts/verify/advertised-schemas/tools/inspect_macho.json index 65a89b6a10..0d5406a773 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_macho.json +++ b/scripts/verify/advertised-schemas/tools/inspect_macho.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "d50348f9415e6058", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_managed_artifact.json b/scripts/verify/advertised-schemas/tools/inspect_managed_artifact.json index d9667fad09..dda1e1cb8c 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_managed_artifact.json +++ b/scripts/verify/advertised-schemas/tools/inspect_managed_artifact.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b64e74c7116cc99b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_managed_members.json b/scripts/verify/advertised-schemas/tools/inspect_managed_members.json index 9dac97d0fd..47fef33d3c 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_managed_members.json +++ b/scripts/verify/advertised-schemas/tools/inspect_managed_members.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2c6c9865b3119ae2", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_managed_native_boundaries.json b/scripts/verify/advertised-schemas/tools/inspect_managed_native_boundaries.json index 3f7a729535..551f52a82a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_managed_native_boundaries.json +++ b/scripts/verify/advertised-schemas/tools/inspect_managed_native_boundaries.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ab5465849952e847", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_model_artifact.json b/scripts/verify/advertised-schemas/tools/inspect_model_artifact.json index 51b83099a2..961f5dad5a 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_model_artifact.json +++ b/scripts/verify/advertised-schemas/tools/inspect_model_artifact.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0a9a2b524be0ce15", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_api.json b/scripts/verify/advertised-schemas/tools/inspect_native_api.json index 33886b4d83..ca17aa562d 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_api.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_api.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "e1341c240f08c350", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_data_type.json b/scripts/verify/advertised-schemas/tools/inspect_native_data_type.json index f77b50d20b..61f3ca80ed 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_data_type.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_data_type.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "957e0a1d7fa1bd33", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_dispatch_metadata.json b/scripts/verify/advertised-schemas/tools/inspect_native_dispatch_metadata.json index 247f8e33e7..41a45a1e40 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_dispatch_metadata.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_dispatch_metadata.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "743838105118ca29", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_exports.json b/scripts/verify/advertised-schemas/tools/inspect_native_exports.json index d86171b238..d18a6401fa 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_exports.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_exports.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "70adce0beddda5eb", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_initializers.json b/scripts/verify/advertised-schemas/tools/inspect_native_initializers.json index 6635748df5..509228e167 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_initializers.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_initializers.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "546bf32e9f7eb381", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_instruction.json b/scripts/verify/advertised-schemas/tools/inspect_native_instruction.json index 51c4ed3c12..0a71edfc17 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_instruction.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_instruction.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "940657f284593726", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_native_load_image.json b/scripts/verify/advertised-schemas/tools/inspect_native_load_image.json index 5a87e7432d..5a4f10095b 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_native_load_image.json +++ b/scripts/verify/advertised-schemas/tools/inspect_native_load_image.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f23a678531aa373a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_ntfs_journal.json b/scripts/verify/advertised-schemas/tools/inspect_ntfs_journal.json index a6271f73d0..35f6e56e37 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_ntfs_journal.json +++ b/scripts/verify/advertised-schemas/tools/inspect_ntfs_journal.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2e70facfe9d6f4f4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_packet_capture.json b/scripts/verify/advertised-schemas/tools/inspect_packet_capture.json index 1904780cbc..bd684f029d 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_packet_capture.json +++ b/scripts/verify/advertised-schemas/tools/inspect_packet_capture.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6b084c215c2391a6", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_packet_fields.json b/scripts/verify/advertised-schemas/tools/inspect_packet_fields.json index 93b7cd71f2..06122f3a29 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_packet_fields.json +++ b/scripts/verify/advertised-schemas/tools/inspect_packet_fields.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7c1e0a2a80f4c87c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_pcap_capture.json b/scripts/verify/advertised-schemas/tools/inspect_pcap_capture.json index 4cf73c86e2..da712a7bf4 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pcap_capture.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pcap_capture.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5655059de2dcc830", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_pcap_client.json b/scripts/verify/advertised-schemas/tools/inspect_pcap_client.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pcap_client.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pcap_client.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_pe_certificates.json b/scripts/verify/advertised-schemas/tools/inspect_pe_certificates.json index b0f66cd46a..7d43845b4b 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pe_certificates.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pe_certificates.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "eaa9f9a271f19ee9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_pe_imports.json b/scripts/verify/advertised-schemas/tools/inspect_pe_imports.json index af30481859..684b316cbd 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pe_imports.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pe_imports.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ad8b37fcf0adb19e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_pe_load_config.json b/scripts/verify/advertised-schemas/tools/inspect_pe_load_config.json index ed671405ec..6252318a01 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pe_load_config.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pe_load_config.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ea4a836a963d167b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_pe_resources.json b/scripts/verify/advertised-schemas/tools/inspect_pe_resources.json index f80dc840dd..fa290a4703 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_pe_resources.json +++ b/scripts/verify/advertised-schemas/tools/inspect_pe_resources.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2caac0f860526546", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_playwright_trace.json b/scripts/verify/advertised-schemas/tools/inspect_playwright_trace.json index effdf0b6e9..ed7ad1758e 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_playwright_trace.json +++ b/scripts/verify/advertised-schemas/tools/inspect_playwright_trace.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "8211b6c65f46d420", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/inspect_plist.json b/scripts/verify/advertised-schemas/tools/inspect_plist.json index 1a9c5b3a23..1199926d1d 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_plist.json +++ b/scripts/verify/advertised-schemas/tools/inspect_plist.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c22855860d96f2a7", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_python_pyc.json b/scripts/verify/advertised-schemas/tools/inspect_python_pyc.json index c209ddc2fd..d5d59188e4 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_python_pyc.json +++ b/scripts/verify/advertised-schemas/tools/inspect_python_pyc.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5969a9c826c2c055", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_recorded_crash.json b/scripts/verify/advertised-schemas/tools/inspect_recorded_crash.json index a37df0d5bc..1e4d741684 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_recorded_crash.json +++ b/scripts/verify/advertised-schemas/tools/inspect_recorded_crash.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3460ff3dfbfb1b2a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_rust_binary.json b/scripts/verify/advertised-schemas/tools/inspect_rust_binary.json index 4dd01716a3..b959e3327d 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_rust_binary.json +++ b/scripts/verify/advertised-schemas/tools/inspect_rust_binary.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "55e64710a49b9fa2", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_signal_decoders.json b/scripts/verify/advertised-schemas/tools/inspect_signal_decoders.json index cb16a6f937..d6e7c32517 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_signal_decoders.json +++ b/scripts/verify/advertised-schemas/tools/inspect_signal_decoders.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3748645472ab43e5", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[+\\-0-9A-Z_a-z]+$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_signature.json b/scripts/verify/advertised-schemas/tools/inspect_signature.json index 944cf205a0..094f5619ba 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_signature.json +++ b/scripts/verify/advertised-schemas/tools/inspect_signature.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fcb6d54fec138c1e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_sqlite_database.json b/scripts/verify/advertised-schemas/tools/inspect_sqlite_database.json index a9ae1cbe70..0b868bcdb2 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_sqlite_database.json +++ b/scripts/verify/advertised-schemas/tools/inspect_sqlite_database.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "e85331872a5525e6", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_v8_code_cache.json b/scripts/verify/advertised-schemas/tools/inspect_v8_code_cache.json index 60f062bca8..79ea4f1aa1 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_v8_code_cache.json +++ b/scripts/verify/advertised-schemas/tools/inspect_v8_code_cache.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "17341f97702a0422", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_wasm_artifact.json b/scripts/verify/advertised-schemas/tools/inspect_wasm_artifact.json index 16881a9d4f..b87bac88af 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_wasm_artifact.json +++ b/scripts/verify/advertised-schemas/tools/inspect_wasm_artifact.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7a138da90fc5e650", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_web_event_listeners.json b/scripts/verify/advertised-schemas/tools/inspect_web_event_listeners.json index 77e304ae54..7819685b88 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_web_event_listeners.json +++ b/scripts/verify/advertised-schemas/tools/inspect_web_event_listeners.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2ef444a0a29f50e4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_web_network_capture.json b/scripts/verify/advertised-schemas/tools/inspect_web_network_capture.json index 08337d3db2..a625a5ac5d 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_web_network_capture.json +++ b/scripts/verify/advertised-schemas/tools/inspect_web_network_capture.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "9a171b304737ce3d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_web_page.json b/scripts/verify/advertised-schemas/tools/inspect_web_page.json index c32b6bfc98..7f7d5da3e1 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_web_page.json +++ b/scripts/verify/advertised-schemas/tools/inspect_web_page.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ae6db425047c0a8f", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/inspect_windows_shortcut.json b/scripts/verify/advertised-schemas/tools/inspect_windows_shortcut.json index b10191017d..e5283d29b4 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_windows_shortcut.json +++ b/scripts/verify/advertised-schemas/tools/inspect_windows_shortcut.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f7055432bf97761a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/inspect_with_objdump.json b/scripts/verify/advertised-schemas/tools/inspect_with_objdump.json index 1031cab6ad..e4e56e5e77 100644 --- a/scripts/verify/advertised-schemas/tools/inspect_with_objdump.json +++ b/scripts/verify/advertised-schemas/tools/inspect_with_objdump.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3f51a78954949124", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/install_adb_package.json b/scripts/verify/advertised-schemas/tools/install_adb_package.json index 3e19db9bcb..1598f45546 100644 --- a/scripts/verify/advertised-schemas/tools/install_adb_package.json +++ b/scripts/verify/advertised-schemas/tools/install_adb_package.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "46f07cf88578ac7a", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/instrument_with_frida.json b/scripts/verify/advertised-schemas/tools/instrument_with_frida.json index b8e7cd1dca..f169fd625e 100644 --- a/scripts/verify/advertised-schemas/tools/instrument_with_frida.json +++ b/scripts/verify/advertised-schemas/tools/instrument_with_frida.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6d62658ca139ecb4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/list_adb_devices.json b/scripts/verify/advertised-schemas/tools/list_adb_devices.json index 9c5fded762..7bc8c224cb 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_devices.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_devices.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_adb_directory.json b/scripts/verify/advertised-schemas/tools/list_adb_directory.json index ec684c8b21..81cf952e1f 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_directory.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_directory.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5560c011cdc77714", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^/[^\\x00]*$", "^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/list_adb_features.json b/scripts/verify/advertised-schemas/tools/list_adb_features.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_features.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_features.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/list_adb_packages.json b/scripts/verify/advertised-schemas/tools/list_adb_packages.json index 436a348a39..5197f6d10d 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_packages.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_packages.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5cd991375a9f0a8f", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/list_adb_processes.json b/scripts/verify/advertised-schemas/tools/list_adb_processes.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_processes.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_processes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/list_adb_services.json b/scripts/verify/advertised-schemas/tools/list_adb_services.json index db7c5f3fd9..bbccac9cd5 100644 --- a/scripts/verify/advertised-schemas/tools/list_adb_services.json +++ b/scripts/verify/advertised-schemas/tools/list_adb_services.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "0eefd4f4245ea66b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/list_architectures.json b/scripts/verify/advertised-schemas/tools/list_architectures.json index 944cf205a0..094f5619ba 100644 --- a/scripts/verify/advertised-schemas/tools/list_architectures.json +++ b/scripts/verify/advertised-schemas/tools/list_architectures.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fcb6d54fec138c1e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_bookmarks.json b/scripts/verify/advertised-schemas/tools/list_bookmarks.json index 165220d0ea..a87e770955 100644 --- a/scripts/verify/advertised-schemas/tools/list_bookmarks.json +++ b/scripts/verify/advertised-schemas/tools/list_bookmarks.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4df1857d0f25b9b1", - "output compact": "ef2ab2008a66fdd8" + "output compact": "a9eb4a3f4b89cd50" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_browser_targets.json b/scripts/verify/advertised-schemas/tools/list_browser_targets.json index 31548617bc..9689bf982d 100644 --- a/scripts/verify/advertised-schemas/tools/list_browser_targets.json +++ b/scripts/verify/advertised-schemas/tools/list_browser_targets.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "cfdc32cb7dc51cda", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_documents.json b/scripts/verify/advertised-schemas/tools/list_documents.json index e70e63ddb8..ca386cc84b 100644 --- a/scripts/verify/advertised-schemas/tools/list_documents.json +++ b/scripts/verify/advertised-schemas/tools/list_documents.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "32062bdb9024160d", - "output compact": "49662c31e39ea6a1" + "output compact": "f3d59f8b286b1a3d" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_electron_targets.json b/scripts/verify/advertised-schemas/tools/list_electron_targets.json index e71bce56af..510889bcfa 100644 --- a/scripts/verify/advertised-schemas/tools/list_electron_targets.json +++ b/scripts/verify/advertised-schemas/tools/list_electron_targets.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c32eb20cbe48cefa", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_javascript_runtime_targets.json b/scripts/verify/advertised-schemas/tools/list_javascript_runtime_targets.json index 9bf3baae89..52b6a38d2f 100644 --- a/scripts/verify/advertised-schemas/tools/list_javascript_runtime_targets.json +++ b/scripts/verify/advertised-schemas/tools/list_javascript_runtime_targets.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2b836a5a8a6c41d0", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_jeb_units.json b/scripts/verify/advertised-schemas/tools/list_jeb_units.json index 0ec6ade5ae..2871bc5dca 100644 --- a/scripts/verify/advertised-schemas/tools/list_jeb_units.json +++ b/scripts/verify/advertised-schemas/tools/list_jeb_units.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4b137397fb16524d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_names.json b/scripts/verify/advertised-schemas/tools/list_names.json index e7b5d7b984..3031ff36da 100644 --- a/scripts/verify/advertised-schemas/tools/list_names.json +++ b/scripts/verify/advertised-schemas/tools/list_names.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "d49ef0db75d3206f", - "output compact": "2622a47474da6c03" + "output compact": "dedfba10a6cd6ea4" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_procedures.json b/scripts/verify/advertised-schemas/tools/list_procedures.json index f428307dfc..24f6447738 100644 --- a/scripts/verify/advertised-schemas/tools/list_procedures.json +++ b/scripts/verify/advertised-schemas/tools/list_procedures.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "96e4c1b335588f47", - "output compact": "2622a47474da6c03" + "output compact": "dedfba10a6cd6ea4" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_segments.json b/scripts/verify/advertised-schemas/tools/list_segments.json index 165220d0ea..a87e770955 100644 --- a/scripts/verify/advertised-schemas/tools/list_segments.json +++ b/scripts/verify/advertised-schemas/tools/list_segments.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "4df1857d0f25b9b1", - "output compact": "ef2ab2008a66fdd8" + "output compact": "a9eb4a3f4b89cd50" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/list_strings.json b/scripts/verify/advertised-schemas/tools/list_strings.json index e7b5d7b984..3031ff36da 100644 --- a/scripts/verify/advertised-schemas/tools/list_strings.json +++ b/scripts/verify/advertised-schemas/tools/list_strings.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "d49ef0db75d3206f", - "output compact": "2622a47474da6c03" + "output compact": "dedfba10a6cd6ea4" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/load_frida_script.json b/scripts/verify/advertised-schemas/tools/load_frida_script.json index f2347c3e0d..308d8eed96 100644 --- a/scripts/verify/advertised-schemas/tools/load_frida_script.json +++ b/scripts/verify/advertised-schemas/tools/load_frida_script.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ed20157c00980757", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/match_native_functions.json b/scripts/verify/advertised-schemas/tools/match_native_functions.json index 16703fb3ae..196a4053e9 100644 --- a/scripts/verify/advertised-schemas/tools/match_native_functions.json +++ b/scripts/verify/advertised-schemas/tools/match_native_functions.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "149e91c2ce2cc2f3", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/next_address.json b/scripts/verify/advertised-schemas/tools/next_address.json index 464cf96103..9c638653a7 100644 --- a/scripts/verify/advertised-schemas/tools/next_address.json +++ b/scripts/verify/advertised-schemas/tools/next_address.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/observe_javascript_runtime.json b/scripts/verify/advertised-schemas/tools/observe_javascript_runtime.json index ee84306b2c..6e0cd86ca7 100644 --- a/scripts/verify/advertised-schemas/tools/observe_javascript_runtime.json +++ b/scripts/verify/advertised-schemas/tools/observe_javascript_runtime.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "e04053c4c8250c81", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/observe_native_calls.json b/scripts/verify/advertised-schemas/tools/observe_native_calls.json index e5b25d44f4..93a212091b 100644 --- a/scripts/verify/advertised-schemas/tools/observe_native_calls.json +++ b/scripts/verify/advertised-schemas/tools/observe_native_calls.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3ef1f34cab7e4387", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/observe_native_ui.json b/scripts/verify/advertised-schemas/tools/observe_native_ui.json index 483aeb33ca..c8a9b9baab 100644 --- a/scripts/verify/advertised-schemas/tools/observe_native_ui.json +++ b/scripts/verify/advertised-schemas/tools/observe_native_ui.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "79890b6c44be3b32", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/observe_web_execution.json b/scripts/verify/advertised-schemas/tools/observe_web_execution.json index c911c560f6..08bc3cec3d 100644 --- a/scripts/verify/advertised-schemas/tools/observe_web_execution.json +++ b/scripts/verify/advertised-schemas/tools/observe_web_execution.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "d59167e845f9c262", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/observe_web_session.json b/scripts/verify/advertised-schemas/tools/observe_web_session.json index ce6142abf6..bfb69b90cc 100644 --- a/scripts/verify/advertised-schemas/tools/observe_web_session.json +++ b/scripts/verify/advertised-schemas/tools/observe_web_session.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "b68bdfd126b58c24", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/open_jeb_project.json b/scripts/verify/advertised-schemas/tools/open_jeb_project.json index 6fcf0c2226..e748e5238e 100644 --- a/scripts/verify/advertised-schemas/tools/open_jeb_project.json +++ b/scripts/verify/advertised-schemas/tools/open_jeb_project.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "18d266261424a97c", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/prev_address.json b/scripts/verify/advertised-schemas/tools/prev_address.json index 464cf96103..9c638653a7 100644 --- a/scripts/verify/advertised-schemas/tools/prev_address.json +++ b/scripts/verify/advertised-schemas/tools/prev_address.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_address.json b/scripts/verify/advertised-schemas/tools/procedure_address.json index 74d17abaad..ee61113c72 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_address.json +++ b/scripts/verify/advertised-schemas/tools/procedure_address.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "69b78eac500c94b7", - "output compact": "4f6bd8217751f707" + "output compact": "fbd287539efb521d" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_assembly.json b/scripts/verify/advertised-schemas/tools/procedure_assembly.json index 30fc6c9621..d27c5a37d2 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_assembly.json +++ b/scripts/verify/advertised-schemas/tools/procedure_assembly.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c93184eb12436c88", - "output compact": "ffd2432283f65468" + "output compact": "5292dc5fc2e7b1c1" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_callees.json b/scripts/verify/advertised-schemas/tools/procedure_callees.json index e36a8f4a79..50e33f23ae 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_callees.json +++ b/scripts/verify/advertised-schemas/tools/procedure_callees.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "69b78eac500c94b7", - "output compact": "3558a96c0cb0a314" + "output compact": "6ea8063881cbb7c7" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_callers.json b/scripts/verify/advertised-schemas/tools/procedure_callers.json index e36a8f4a79..50e33f23ae 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_callers.json +++ b/scripts/verify/advertised-schemas/tools/procedure_callers.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "69b78eac500c94b7", - "output compact": "3558a96c0cb0a314" + "output compact": "6ea8063881cbb7c7" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_info.json b/scripts/verify/advertised-schemas/tools/procedure_info.json index 290073b859..b8fff185c3 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_info.json +++ b/scripts/verify/advertised-schemas/tools/procedure_info.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c93184eb12436c88", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_pseudo_code.json b/scripts/verify/advertised-schemas/tools/procedure_pseudo_code.json index c3fd2f10ee..0ffca344e2 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_pseudo_code.json +++ b/scripts/verify/advertised-schemas/tools/procedure_pseudo_code.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5b0207420ce15a84", - "output compact": "a6a19eed5331b2af" + "output compact": "4750323a9e43caee" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/procedure_references.json b/scripts/verify/advertised-schemas/tools/procedure_references.json index cbee9fa944..1f0421e8e6 100644 --- a/scripts/verify/advertised-schemas/tools/procedure_references.json +++ b/scripts/verify/advertised-schemas/tools/procedure_references.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "3f5be054a5907bc6", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/project_android_application_graph.json b/scripts/verify/advertised-schemas/tools/project_android_application_graph.json index 2e938bfd11..38e93ea75a 100644 --- a/scripts/verify/advertised-schemas/tools/project_android_application_graph.json +++ b/scripts/verify/advertised-schemas/tools/project_android_application_graph.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "af88743b51732378", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/project_apple_application_graph.json b/scripts/verify/advertised-schemas/tools/project_apple_application_graph.json index 2e938bfd11..38e93ea75a 100644 --- a/scripts/verify/advertised-schemas/tools/project_apple_application_graph.json +++ b/scripts/verify/advertised-schemas/tools/project_apple_application_graph.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "af88743b51732378", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/project_harmony_application_graph.json b/scripts/verify/advertised-schemas/tools/project_harmony_application_graph.json index 2e938bfd11..38e93ea75a 100644 --- a/scripts/verify/advertised-schemas/tools/project_harmony_application_graph.json +++ b/scripts/verify/advertised-schemas/tools/project_harmony_application_graph.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "af88743b51732378", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/project_managed_application_graph.json b/scripts/verify/advertised-schemas/tools/project_managed_application_graph.json index a41406bc17..a136d9a532 100644 --- a/scripts/verify/advertised-schemas/tools/project_managed_application_graph.json +++ b/scripts/verify/advertised-schemas/tools/project_managed_application_graph.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "926cbfd4477960cc", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/pull_adb_file.json b/scripts/verify/advertised-schemas/tools/pull_adb_file.json index 0b50d1467a..b3db69cc71 100644 --- a/scripts/verify/advertised-schemas/tools/pull_adb_file.json +++ b/scripts/verify/advertised-schemas/tools/pull_adb_file.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "da6ee35a3849c53b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^/[^\\x00]*$", "^[^\\x00\\x09-\\x0d \"']+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/pull_adb_package.json b/scripts/verify/advertised-schemas/tools/pull_adb_package.json index 440dbbbf42..454e973001 100644 --- a/scripts/verify/advertised-schemas/tools/pull_adb_package.json +++ b/scripts/verify/advertised-schemas/tools/pull_adb_package.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7f3087dd0cb3722b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/push_adb_file.json b/scripts/verify/advertised-schemas/tools/push_adb_file.json index 26e2df5d8f..d9ae3a030d 100644 --- a/scripts/verify/advertised-schemas/tools/push_adb_file.json +++ b/scripts/verify/advertised-schemas/tools/push_adb_file.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "09c89b1cb90f857b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^/[^\\x00]*$", "^[^\\x00\\x09-\\x0d \"']+$", "^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/read_adb_logcat.json b/scripts/verify/advertised-schemas/tools/read_adb_logcat.json index ac81e3ef21..4bf9dfc5ab 100644 --- a/scripts/verify/advertised-schemas/tools/read_adb_logcat.json +++ b/scripts/verify/advertised-schemas/tools/read_adb_logcat.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "827ccf60f59990d4", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/read_adb_setting.json b/scripts/verify/advertised-schemas/tools/read_adb_setting.json index 1787703109..ec386bf869 100644 --- a/scripts/verify/advertised-schemas/tools/read_adb_setting.json +++ b/scripts/verify/advertised-schemas/tools/read_adb_setting.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ffd694dc45e55a70", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[\\-.0-9A-Z_a-z]+$", "^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/read_bytes.json b/scripts/verify/advertised-schemas/tools/read_bytes.json index ef79a2fbf3..5f964b7de6 100644 --- a/scripts/verify/advertised-schemas/tools/read_bytes.json +++ b/scripts/verify/advertised-schemas/tools/read_bytes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "914f9d8e19bfa4e5", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/read_function_instructions.json b/scripts/verify/advertised-schemas/tools/read_function_instructions.json index 290073b859..b8fff185c3 100644 --- a/scripts/verify/advertised-schemas/tools/read_function_instructions.json +++ b/scripts/verify/advertised-schemas/tools/read_function_instructions.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c93184eb12436c88", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/reconcile_javascript_runtime.json b/scripts/verify/advertised-schemas/tools/reconcile_javascript_runtime.json index a1f8e99d98..b38b969aa6 100644 --- a/scripts/verify/advertised-schemas/tools/reconcile_javascript_runtime.json +++ b/scripts/verify/advertised-schemas/tools/reconcile_javascript_runtime.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "12dcdff55b84d363", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/recover_javascript_sources.json b/scripts/verify/advertised-schemas/tools/recover_javascript_sources.json index 893fb8c942..3a36815194 100644 --- a/scripts/verify/advertised-schemas/tools/recover_javascript_sources.json +++ b/scripts/verify/advertised-schemas/tools/recover_javascript_sources.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "8ac2f60d560cb8e9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/resolve_adb_packages.json b/scripts/verify/advertised-schemas/tools/resolve_adb_packages.json index 4a7d6b031a..7aa4e51bb2 100644 --- a/scripts/verify/advertised-schemas/tools/resolve_adb_packages.json +++ b/scripts/verify/advertised-schemas/tools/resolve_adb_packages.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "16856277f255380d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00\\x09-\\x0d \"']+$"] diff --git a/scripts/verify/advertised-schemas/tools/resolve_containing_procedure.json b/scripts/verify/advertised-schemas/tools/resolve_containing_procedure.json index 14095182eb..fc3f6c263b 100644 --- a/scripts/verify/advertised-schemas/tools/resolve_containing_procedure.json +++ b/scripts/verify/advertised-schemas/tools/resolve_containing_procedure.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "1178f3ac840bf5c1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/resolve_native_call_targets.json b/scripts/verify/advertised-schemas/tools/resolve_native_call_targets.json index 51c4ed3c12..0a71edfc17 100644 --- a/scripts/verify/advertised-schemas/tools/resolve_native_call_targets.json +++ b/scripts/verify/advertised-schemas/tools/resolve_native_call_targets.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "940657f284593726", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/rizin_debug_command.json b/scripts/verify/advertised-schemas/tools/rizin_debug_command.json index 78a9363505..f80d635486 100644 --- a/scripts/verify/advertised-schemas/tools/rizin_debug_command.json +++ b/scripts/verify/advertised-schemas/tools/rizin_debug_command.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c70e42c90db7a9f1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/search_android_classes.json b/scripts/verify/advertised-schemas/tools/search_android_classes.json index aa7f2a30c9..608865355d 100644 --- a/scripts/verify/advertised-schemas/tools/search_android_classes.json +++ b/scripts/verify/advertised-schemas/tools/search_android_classes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "db67ac2566308239", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/search_bytes.json b/scripts/verify/advertised-schemas/tools/search_bytes.json index 28ce6bcb23..0a7c2c4d35 100644 --- a/scripts/verify/advertised-schemas/tools/search_bytes.json +++ b/scripts/verify/advertised-schemas/tools/search_bytes.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "7f0fd8e904b80147", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/search_procedures.json b/scripts/verify/advertised-schemas/tools/search_procedures.json index 7239f9fddc..1c7395535b 100644 --- a/scripts/verify/advertised-schemas/tools/search_procedures.json +++ b/scripts/verify/advertised-schemas/tools/search_procedures.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "05ff4a8d2a0fa1cf", - "output compact": "2622a47474da6c03" + "output compact": "dedfba10a6cd6ea4" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/search_strings.json b/scripts/verify/advertised-schemas/tools/search_strings.json index 7239f9fddc..1c7395535b 100644 --- a/scripts/verify/advertised-schemas/tools/search_strings.json +++ b/scripts/verify/advertised-schemas/tools/search_strings.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "05ff4a8d2a0fa1cf", - "output compact": "2622a47474da6c03" + "output compact": "dedfba10a6cd6ea4" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/set_address_name.json b/scripts/verify/advertised-schemas/tools/set_address_name.json index 36ae584540..dd98a98118 100644 --- a/scripts/verify/advertised-schemas/tools/set_address_name.json +++ b/scripts/verify/advertised-schemas/tools/set_address_name.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "8428dd5f2b08637f", - "output compact": "3c3f5b2578e1a632" + "output compact": "73962653b28f53c9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/set_addresses_names.json b/scripts/verify/advertised-schemas/tools/set_addresses_names.json index 9a449ef2ee..ee3a778a7d 100644 --- a/scripts/verify/advertised-schemas/tools/set_addresses_names.json +++ b/scripts/verify/advertised-schemas/tools/set_addresses_names.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "9dabf376fc823a5d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/set_bookmark.json b/scripts/verify/advertised-schemas/tools/set_bookmark.json index a262cbbc02..867289ac75 100644 --- a/scripts/verify/advertised-schemas/tools/set_bookmark.json +++ b/scripts/verify/advertised-schemas/tools/set_bookmark.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "a24b2532fbf81d90", - "output compact": "3c3f5b2578e1a632" + "output compact": "73962653b28f53c9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/set_comment.json b/scripts/verify/advertised-schemas/tools/set_comment.json index e99e24e12f..dfb8cab187 100644 --- a/scripts/verify/advertised-schemas/tools/set_comment.json +++ b/scripts/verify/advertised-schemas/tools/set_comment.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f10575c521d53534", - "output compact": "3c3f5b2578e1a632" + "output compact": "73962653b28f53c9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/set_inline_comment.json b/scripts/verify/advertised-schemas/tools/set_inline_comment.json index e99e24e12f..dfb8cab187 100644 --- a/scripts/verify/advertised-schemas/tools/set_inline_comment.json +++ b/scripts/verify/advertised-schemas/tools/set_inline_comment.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "f10575c521d53534", - "output compact": "3c3f5b2578e1a632" + "output compact": "73962653b28f53c9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/start_adb_activity.json b/scripts/verify/advertised-schemas/tools/start_adb_activity.json index 7180261ff8..4375bf74e4 100644 --- a/scripts/verify/advertised-schemas/tools/start_adb_activity.json +++ b/scripts/verify/advertised-schemas/tools/start_adb_activity.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "1457e8daaa15b8ce", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/start_adb_app.json b/scripts/verify/advertised-schemas/tools/start_adb_app.json index 1eda154f6f..9f457c049a 100644 --- a/scripts/verify/advertised-schemas/tools/start_adb_app.json +++ b/scripts/verify/advertised-schemas/tools/start_adb_app.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2d6b5bb69d217de1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/stop_adb_app.json b/scripts/verify/advertised-schemas/tools/stop_adb_app.json index 1eda154f6f..9f457c049a 100644 --- a/scripts/verify/advertised-schemas/tools/stop_adb_app.json +++ b/scripts/verify/advertised-schemas/tools/stop_adb_app.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2d6b5bb69d217de1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/trace_android_references.json b/scripts/verify/advertised-schemas/tools/trace_android_references.json index ba4eeb3612..8af65438bb 100644 --- a/scripts/verify/advertised-schemas/tools/trace_android_references.json +++ b/scripts/verify/advertised-schemas/tools/trace_android_references.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "bed8f76edd347cb6", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/trace_application_feature.json b/scripts/verify/advertised-schemas/tools/trace_application_feature.json index ab11720bb4..ff25be00bd 100644 --- a/scripts/verify/advertised-schemas/tools/trace_application_feature.json +++ b/scripts/verify/advertised-schemas/tools/trace_application_feature.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6da6ada4587d6b1e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_call_path.json b/scripts/verify/advertised-schemas/tools/trace_call_path.json index a74c95853c..5ccc7ce333 100644 --- a/scripts/verify/advertised-schemas/tools/trace_call_path.json +++ b/scripts/verify/advertised-schemas/tools/trace_call_path.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "eb86d04cd6c8d08e", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_dylib_resolution.json b/scripts/verify/advertised-schemas/tools/trace_dylib_resolution.json index ee3f1786c8..12dd0e86fe 100644 --- a/scripts/verify/advertised-schemas/tools/trace_dylib_resolution.json +++ b/scripts/verify/advertised-schemas/tools/trace_dylib_resolution.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fba037864c570ea9", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/trace_feature.json b/scripts/verify/advertised-schemas/tools/trace_feature.json index c0b7378ee4..a9e237be36 100644 --- a/scripts/verify/advertised-schemas/tools/trace_feature.json +++ b/scripts/verify/advertised-schemas/tools/trace_feature.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6e6c01e5a00f75ec", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_javascript_semantics.json b/scripts/verify/advertised-schemas/tools/trace_javascript_semantics.json index 2ef761bfe6..e32247e0e6 100644 --- a/scripts/verify/advertised-schemas/tools/trace_javascript_semantics.json +++ b/scripts/verify/advertised-schemas/tools/trace_javascript_semantics.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "86bc47efe9065d21", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_native_ui_action.json b/scripts/verify/advertised-schemas/tools/trace_native_ui_action.json index dc2ac10fc2..cecc0308da 100644 --- a/scripts/verify/advertised-schemas/tools/trace_native_ui_action.json +++ b/scripts/verify/advertised-schemas/tools/trace_native_ui_action.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "5f7e5def746a8c3d", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_native_values.json b/scripts/verify/advertised-schemas/tools/trace_native_values.json index c0b86f6b85..6e6335857a 100644 --- a/scripts/verify/advertised-schemas/tools/trace_native_values.json +++ b/scripts/verify/advertised-schemas/tools/trace_native_values.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2d2afa5eefb4be64", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/trace_web_module_imports.json b/scripts/verify/advertised-schemas/tools/trace_web_module_imports.json index ac73c57fcc..f81b52ec9c 100644 --- a/scripts/verify/advertised-schemas/tools/trace_web_module_imports.json +++ b/scripts/verify/advertised-schemas/tools/trace_web_module_imports.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "fac6a749ccacd74f", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/trace_web_source_location.json b/scripts/verify/advertised-schemas/tools/trace_web_source_location.json index 38162e570d..5296e02960 100644 --- a/scripts/verify/advertised-schemas/tools/trace_web_source_location.json +++ b/scripts/verify/advertised-schemas/tools/trace_web_source_location.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "ae3268db6e89a16b", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": ["^[^\\x00]*$"] diff --git a/scripts/verify/advertised-schemas/tools/uninstall_adb_package.json b/scripts/verify/advertised-schemas/tools/uninstall_adb_package.json index 1eda154f6f..9f457c049a 100644 --- a/scripts/verify/advertised-schemas/tools/uninstall_adb_package.json +++ b/scripts/verify/advertised-schemas/tools/uninstall_adb_package.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "2d6b5bb69d217de1", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": { "input": [ diff --git a/scripts/verify/advertised-schemas/tools/unset_bookmark.json b/scripts/verify/advertised-schemas/tools/unset_bookmark.json index 789e6a89c7..5dac451cdd 100644 --- a/scripts/verify/advertised-schemas/tools/unset_bookmark.json +++ b/scripts/verify/advertised-schemas/tools/unset_bookmark.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "940657f284593726", - "output compact": "3c3f5b2578e1a632" + "output compact": "73962653b28f53c9" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/verify_managed_native_boundaries.json b/scripts/verify/advertised-schemas/tools/verify_managed_native_boundaries.json index 2728c31a66..52d14abd28 100644 --- a/scripts/verify/advertised-schemas/tools/verify_managed_native_boundaries.json +++ b/scripts/verify/advertised-schemas/tools/verify_managed_native_boundaries.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "6b357d640e0a98f5", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/verify_reconstruction.json b/scripts/verify/advertised-schemas/tools/verify_reconstruction.json index c6e8dc81b2..b03cfecf04 100644 --- a/scripts/verify/advertised-schemas/tools/verify_reconstruction.json +++ b/scripts/verify/advertised-schemas/tools/verify_reconstruction.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "8b4cfb9f381ccb12", - "output compact": "9087cdd7aaaf031b" + "output compact": "4bda7c3651bfc579" }, "patterns": {} } diff --git a/scripts/verify/advertised-schemas/tools/xrefs.json b/scripts/verify/advertised-schemas/tools/xrefs.json index 84b04a0ebc..1a37d44287 100644 --- a/scripts/verify/advertised-schemas/tools/xrefs.json +++ b/scripts/verify/advertised-schemas/tools/xrefs.json @@ -1,7 +1,7 @@ { "schemas": { "input compact": "c3e7279c968e665b", - "output compact": "49662c31e39ea6a1" + "output compact": "f3d59f8b286b1a3d" }, "patterns": {} } diff --git a/scripts/verify/android/analysis.mjs b/scripts/verify/android/analysis.mjs index 69051d44fb..e075dfa062 100644 --- a/scripts/verify/android/analysis.mjs +++ b/scripts/verify/android/analysis.mjs @@ -126,7 +126,7 @@ for (const task of tasks) { }, ); const evidence = parseEvidence(JSON.parse(response.stdout)); - assert.equal(evidence.subject?.digest.sha256, fixture.sha256); + assert.equal(evidence.subject?.identity.sha256, fixture.sha256); assert.equal(evidence.operation, task.name); cliResults.set(task.name, evidence); console.log(`PASS CLI ${task.name}`); @@ -161,8 +161,8 @@ try { assert.deepEqual(evidence.parameters, cliResults.get(task.name).parameters); assert.deepEqual(evidence.provider, cliResults.get(task.name).provider); assert.deepEqual( - evidence.subject.digest, - cliResults.get(task.name).subject.digest, + evidence.subject.identity, + cliResults.get(task.name).subject.identity, ); assert.deepEqual( evidence.limitations, diff --git a/scripts/verify/android/class-search.mjs b/scripts/verify/android/class-search.mjs index 29ad5bcde3..85908cdbc8 100644 --- a/scripts/verify/android/class-search.mjs +++ b/scripts/verify/android/class-search.mjs @@ -14,7 +14,7 @@ export const verifyAndroidClassSearch = async ({ client, path, sha256 }) => { requireMcpOutput(response, "search_android_classes"), ); const result = evidence.normalized_result; - assert.equal(evidence.subject.digest.sha256, sha256); + assert.equal(evidence.subject.identity.sha256, sha256); assert.equal(evidence.parameters.query, query); assert.equal(result.query, query); return result; diff --git a/scripts/verify/android/direct-invokes.mjs b/scripts/verify/android/direct-invokes.mjs index 7cb9972db2..5fbc00331f 100644 --- a/scripts/verify/android/direct-invokes.mjs +++ b/scripts/verify/android/direct-invokes.mjs @@ -16,7 +16,7 @@ export const verifyAndroidDirectInvokes = async ({ const digest = await hashAndroidFile(apk); const check = (value) => { const evidence = parseEvidence(value); - assert.equal(evidence.subject.digest.sha256, digest); + assert.equal(evidence.subject.identity.sha256, digest); assert.equal(evidence.operation, "trace_android_references"); const result = evidence.normalized_result; assert.equal(result.class_name, "fixture.Target"); diff --git a/scripts/verify/android/external-invokes.mjs b/scripts/verify/android/external-invokes.mjs index e15712b4b8..c8888db4aa 100644 --- a/scripts/verify/android/external-invokes.mjs +++ b/scripts/verify/android/external-invokes.mjs @@ -28,7 +28,7 @@ const input = (path, index) => ({ const check = (value, digest, index, dexEntry) => { const evidence = parseEvidence(value); assert.equal(evidence.operation, operation); - assert.equal(evidence.subject.digest.sha256, digest); + assert.equal(evidence.subject.identity.sha256, digest); const result = evidence.normalized_result; assert.equal(result.target_definition, "external"); assert.equal(result.reference_scope, "direct_dex_invokes"); @@ -206,7 +206,7 @@ const verifyLimit = async ( const checkSiteBudget = (value, digest) => { const evidence = parseEvidence(value); - assert.equal(evidence.subject.digest.sha256, digest); + assert.equal(evidence.subject.identity.sha256, digest); const result = evidence.normalized_result; assert.equal(result.total, 11); const partial = result.references.filter( diff --git a/scripts/verify/android/method-bodies.mjs b/scripts/verify/android/method-bodies.mjs index beb0d0f697..dedb68553c 100644 --- a/scripts/verify/android/method-bodies.mjs +++ b/scripts/verify/android/method-bodies.mjs @@ -101,7 +101,7 @@ export const verifyAndroidMethodBodies = async ({ const digest = await hashAndroidFile(apk); const check = (value, scenario) => { const evidence = parseEvidence(value); - assert.equal(evidence.subject.digest.sha256, digest); + assert.equal(evidence.subject.identity.sha256, digest); const result = evidence.normalized_result; assert.equal(result.class_name, scenario.class_name); assert.equal(result.method.name, scenario.method_name); diff --git a/scripts/verify/apple/macos-bundle.mjs b/scripts/verify/apple/macos-bundle.mjs index 3aa5c5bb47..edf6fbc60b 100644 --- a/scripts/verify/apple/macos-bundle.mjs +++ b/scripts/verify/apple/macos-bundle.mjs @@ -122,7 +122,7 @@ await withVerifierCleanup(async () => { input, ); const projection = evidence.normalized_result; - assert.equal(evidence.subject?.format, format); + assert.equal(evidence.subject?.identity.format, format); assert.equal(projection.root_format, format); assert.deepEqual(projection.platforms, ["macos"]); assert.deepEqual(projection.application_roots, [applicationRoot]); diff --git a/scripts/verify/apple/native-provenance.mjs b/scripts/verify/apple/native-provenance.mjs index d4e6a02715..f3e745a5f8 100644 --- a/scripts/verify/apple/native-provenance.mjs +++ b/scripts/verify/apple/native-provenance.mjs @@ -35,7 +35,7 @@ export async function verifyNativeProvenance(app, executable) { const resourcePlistCli = toolContract("inspect_plist").outputSchema.parse( await artifactCliEvidence("inspect-plist", app), ); - assert.equal(resourcePlistCli.subject, null); + assert.equal(resourcePlistCli.subject.identity.kind, "unknown"); assert.equal(resourcePlistCli.raw_result, null); await withBundleResourcesMcp(app, async (client) => { const response = await artifactMcpCall(client, { @@ -46,7 +46,7 @@ export async function verifyNativeProvenance(app, executable) { const mcp = toolContract("inspect_plist").outputSchema.parse( response.structuredContent, ); - assert.equal(mcp.subject, null); + assert.equal(mcp.subject.identity.kind, "unknown"); assert.equal(mcp.raw_result, null); assert.deepEqual(mcp.normalized_result, resourcePlistCli.normalized_result); assert.deepEqual( @@ -65,7 +65,7 @@ export async function verifyNativeProvenance(app, executable) { const binaryPlistCli = toolContract("inspect_plist").outputSchema.parse( await artifactCliEvidence("inspect-plist", executable), ); - assert.equal(binaryPlistCli.subject?.digest.sha256, sha256); + assert.equal(binaryPlistCli.subject?.identity.sha256, sha256); assert.equal(binaryPlistCli.raw_result, null); assert.equal(binaryPlistCli.normalized_result.resource_root, undefined); await withArtifactMcp(app, async (client) => { @@ -77,7 +77,7 @@ export async function verifyNativeProvenance(app, executable) { const binaryPlistMcp = toolContract("inspect_plist").outputSchema.parse( plistResponse.structuredContent, ); - assert.equal(binaryPlistMcp.subject?.digest.sha256, sha256); + assert.equal(binaryPlistMcp.subject?.identity.sha256, sha256); assert.equal(binaryPlistMcp.raw_result, null); assert.equal(binaryPlistMcp.normalized_result.resource_root, undefined); assert.deepEqual( diff --git a/scripts/verify/firmware/analysis.mjs b/scripts/verify/firmware/analysis.mjs index 50f76b217f..47f5cf8b4f 100644 --- a/scripts/verify/firmware/analysis.mjs +++ b/scripts/verify/firmware/analysis.mjs @@ -130,7 +130,7 @@ async function callTool(name, args) { // --------------------------------------------------------------------------- function verifyRegions(evidence) { - assert.equal(evidence.subject.digest.sha256, oracle.sha256); + assert.equal(evidence.subject.identity.sha256, oracle.sha256); const parsed = firmwareResultSchemas.inspect_firmware_regions.parse( evidence.normalized_result, @@ -360,7 +360,7 @@ async function stageGhidra(mcpFiles) { }); const dossier = parseEvidence(dossierRaw); assert.equal( - dossier.subject.digest.sha256, + dossier.subject.identity.sha256, oracle.files["usr/bin/probe"].sha256, ); diff --git a/scripts/verify/harmony/analysis.mjs b/scripts/verify/harmony/analysis.mjs index eebbe780e2..ddb017c96f 100644 --- a/scripts/verify/harmony/analysis.mjs +++ b/scripts/verify/harmony/analysis.mjs @@ -53,8 +53,8 @@ await withVerifierFixture(workspaceFixture, async () => { ); const inspection = parseEvidence(JSON.parse(inspectResponse.stdout)); assert.equal(inspection.operation, "inspect_artifact"); - assert.equal(inspection.subject?.format, "hap"); - assert.equal(inspection.subject?.digest.sha256, fixture.sha256); + assert.equal(inspection.subject?.identity.format, "hap"); + assert.equal(inspection.subject?.identity.sha256, fixture.sha256); console.log("PASS CLI inspect_artifact"); const projectionInput = JSON.stringify({ diff --git a/scripts/verify/javascript/digests.mjs b/scripts/verify/javascript/digests.mjs index 03c61bd818..912fb39e8f 100644 --- a/scripts/verify/javascript/digests.mjs +++ b/scripts/verify/javascript/digests.mjs @@ -9,6 +9,7 @@ import { createEvidence, parseEvidence, } from "../../../dist/domain/evidence.js"; +import { unknownTarget } from "../../../dist/domain/targetIdentity.js"; // This opt-in check crosses the actual engine string limit; keep it outside // routine source tests. Build first, then run this script with the local Node. @@ -26,7 +27,7 @@ expected.update("]}"); assert.equal(digestCanonicalValue(value), expected.digest("hex")); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "large-json-fixture", name: "Large JSON fixture", version: "1" }, { operation: "inspect_fixture", parameters: {}, result: value }, ); diff --git a/scripts/verify/javascript/native-handoffs.mjs b/scripts/verify/javascript/native-handoffs.mjs index 9a713e4cce..74d102acb2 100644 --- a/scripts/verify/javascript/native-handoffs.mjs +++ b/scripts/verify/javascript/native-handoffs.mjs @@ -222,7 +222,7 @@ await withVerifierCleanup(async () => { const timedOut = preparation.wire_response.isError === true; assert.equal(timedOut, values["expect-timeout"]); if (!timedOut) - assert.equal(preparation.response.subject.digest.sha256, archiveSha256); + assert.equal(preparation.response.subject.identity.sha256, archiveSha256); const sourceId = timedOut ? preparation.response.error.details.partial_observation.evidence_id : preparation.response.normalized_result.parent_evidence_id; diff --git a/scripts/verify/javascript/output.mjs b/scripts/verify/javascript/output.mjs index 92913f22dd..5c1eed600b 100644 --- a/scripts/verify/javascript/output.mjs +++ b/scripts/verify/javascript/output.mjs @@ -16,6 +16,7 @@ import { estimateTokenCount } from "tokenx"; import { parseCliOutputArguments } from "../../../dist/cliOutput.js"; import { createCliResultOutput } from "../../../dist/cli/cliResultOutput.js"; import { createEvidence } from "../../../dist/domain/evidence.js"; +import { unknownTarget } from "../../../dist/domain/targetIdentity.js"; import { VerifierFixture, withVerifierFixture, @@ -59,7 +60,7 @@ fixture.releaseAfter(async () => { }); await withVerifierFixture(fixture, async () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "large-output-fixture", name: "Large output fixture", version: "1" }, { operation: "inspect_fixture", diff --git a/scripts/verify/managed/completion-report.mjs b/scripts/verify/managed/completion-report.mjs index 9cd900f589..1f038b547e 100644 --- a/scripts/verify/managed/completion-report.mjs +++ b/scripts/verify/managed/completion-report.mjs @@ -1,4 +1,5 @@ import { createEvidence } from "../../../dist/domain/evidence.js"; +import { unknownTarget } from "../../../dist/domain/targetIdentity.js"; const COMPLETION_PROVIDER = { id: "rea-managed-conformance", @@ -16,18 +17,24 @@ const completionClaim = ({ const artifactSha256s = [ ...new Set(targets.map(({ sha256: digest }) => digest)), ].sort(); - const evidence = createEvidence(targets[0], COMPLETION_PROVIDER, { - predicateType: "rea.verification", - operation: "verify_managed_conformance", - parameters: { - scenario_id: scenarioId, - scenario_version: 1, - artifact_sha256s: artifactSha256s, + const evidence = createEvidence( + // A claim without an observed artifact (an unsupported optional + // scenario) names no file. + targets[0] ?? unknownTarget("not-observed"), + COMPLETION_PROVIDER, + { + predicateType: "rea.verification", + operation: "verify_managed_conformance", + parameters: { + scenario_id: scenarioId, + scenario_version: 1, + artifact_sha256s: artifactSha256s, + }, + result: { status }, + rawResult: null, + limitations, }, - result: { status }, - rawResult: null, - limitations, - }); + ); return { claim_id: claimId, scenario: { id: scenarioId, version: 1 }, diff --git a/scripts/verify/managed/conformance.mjs b/scripts/verify/managed/conformance.mjs index 8874ad8a01..e127d34039 100644 --- a/scripts/verify/managed/conformance.mjs +++ b/scripts/verify/managed/conformance.mjs @@ -11,6 +11,7 @@ import { projectManagedApplicationGraphEvidence } from "../../../dist/applicatio import { traceApplicationFeatureEvidence } from "../../../dist/application/javascript/JavaScriptApplicationWorkflowService.js"; import { MANAGED_STATIC_PROVIDER } from "../../../dist/domain/investigationProviders.js"; import { createEvidence } from "../../../dist/domain/evidence.js"; +import { unknownTarget } from "../../../dist/domain/targetIdentity.js"; import { functionDossier } from "../../fixtures/managed/function-dossier.mjs"; import { alternateMvid, @@ -262,7 +263,7 @@ await withVerifierFixture(workspaceFixture, async () => { const reconstructionMethod = obfuscatedMembers.methods[0]; assert.ok(reconstructionMethod); const obfuscatedMembersEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_members", diff --git a/src/adb/AdbProvider.ts b/src/adb/AdbProvider.ts index df0adf2931..936895ad62 100644 --- a/src/adb/AdbProvider.ts +++ b/src/adb/AdbProvider.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { ADB_PROVIDER_IDENTITY } from "./AdbProviderIdentity.js"; import { HOST_PLATFORM } from "../platform/HostPlatform.js"; import { @@ -2517,7 +2518,7 @@ export class AdbProvider { if (verificationFailed) deviceDigest.error.retainPartialObservation( createEvidence( - completed.subject ?? undefined, + completed.subject ?? unknownTarget("not-observed"), completed.provider, { operation, @@ -2561,7 +2562,7 @@ export class AdbProvider { `The device-reported digest does not match the staged local file: ${localPath}`, { partialObservation: createEvidence( - completed.subject ?? undefined, + completed.subject ?? unknownTarget("not-observed"), completed.provider, { operation, diff --git a/src/apktool/ApktoolProvider.test.ts b/src/apktool/ApktoolProvider.test.ts index 7530f53736..6d80e5c9ab 100644 --- a/src/apktool/ApktoolProvider.test.ts +++ b/src/apktool/ApktoolProvider.test.ts @@ -191,7 +191,7 @@ it("recovers later string pages and an exhausted XML admission on the same APK", }); if (!outcome.ok) throw outcome.error; expect(outcome.value.subject).toMatchObject({ - digest: { sha256: apk.sha256 }, + identity: { sha256: apk.sha256 }, }); return apktoolResultSchemas.decode_android_resources.parse( outcome.value.normalized_result, @@ -247,7 +247,7 @@ it("returns table-only facts for a single selected primary table", async () => { if (!outcome.ok) throw outcome.error; expect(outcome.value).toMatchObject({ parameters: { path: apk.path, string_tables_only: true }, - subject: { digest: { sha256: apk.sha256 } }, + subject: { identity: { sha256: apk.sha256 } }, normalized_result: { strings: [], string_tables: [ @@ -298,7 +298,7 @@ sdkInfo: if (!outcome.ok) throw outcome.error; expect(outcome.value).toMatchObject({ parameters: { path: apk.path }, - subject: { digest: { sha256: apk.sha256 } }, + subject: { identity: { sha256: apk.sha256 } }, normalized_result: { client: { apktool_version: "3.0.3" }, target: { path: apk.path, sha256: apk.sha256, bytes: apk.bytes }, @@ -355,7 +355,7 @@ it.each([ const observation = { operation: "decode_android_resources", parameters: { path: apk.path, locales: ["de"] }, - subject: { local_path: apk.path, digest: { sha256: apk.sha256 } }, + subject: { local_path: apk.path, identity: { sha256: apk.sha256 } }, normalized_result: { metadata: { package_name: "com.rea.apktool.probe" }, manifest: `${REAL_MANIFEST}\n`, @@ -445,7 +445,7 @@ it.each( const observation = result.error.partialObservation; expect(observation).toMatchObject({ operation: "decode_android_resources", - subject: { local_path: apk.path, digest: { sha256: apk.sha256 } }, + subject: { local_path: apk.path, identity: { sha256: apk.sha256 } }, normalized_result: { coverage: "partial", metadata: { @@ -815,12 +815,8 @@ it("uses an owned APK snapshot and framework cache and resolves regional locales if (!observation.ok) throw observation.error; expect(observation.value.subject).toMatchObject({ local_path: apk.path, - format: "apk", - digest: { sha256: apk.sha256 }, + identity: { format: "apk", sha256: apk.sha256 }, }); - expect(observation.value.limitations).not.toContainEqual( - expect.stringMatching(/artifact identity.*unavailable/iu), - ); expect(await readFile(apk.path, "utf8")).toBe("changed original"); const result = apktoolResultSchemas.decode_android_resources.parse( observation.value.normalized_result, @@ -1228,7 +1224,7 @@ it("retains completed Evidence and live cleanup until a denied workspace removal expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ operation: "decode_android_resources", - subject: { local_path: apk.path, digest: { sha256: apk.sha256 } }, + subject: { local_path: apk.path, identity: { sha256: apk.sha256 } }, normalized_result: { metadata: { package_name: "com.rea.apktool.probe" }, strings: [ @@ -1387,7 +1383,10 @@ it.each(["decode", "projection"] as const)( } : { operation: "decode_android_resources", - subject: { local_path: apk.path, digest: { sha256: apk.sha256 } }, + subject: { + local_path: apk.path, + identity: { sha256: apk.sha256 }, + }, normalized_result: { coverage: "partial", metadata: { package_name: "com.rea.apktool.probe" }, diff --git a/src/application/AnalysisEvidenceSources.ts b/src/application/AnalysisEvidenceSources.ts index cb6174e133..54490db86b 100644 --- a/src/application/AnalysisEvidenceSources.ts +++ b/src/application/AnalysisEvidenceSources.ts @@ -1,6 +1,7 @@ import { readArtifactInspectionSources } from "../domain/artifactInspection.js"; import type { AnalysisError } from "../domain/analysisErrorBase.js"; -import { tryParseEvidence, type Evidence } from "../domain/evidence.js"; +import type { Evidence } from "../domain/evidence.js"; +import { recognizeEvidence } from "../domain/evidenceValidation.js"; import { jsonValueByteLength } from "../domain/jsonValueByteLength.js"; import { err, ok, type Result } from "../domain/result.js"; @@ -131,10 +132,12 @@ export const undeliveredSourceClosure = ( options: { readonly inlineRecords: boolean }, ): UndeliveredSourceClosure | UnavailableSourceClosure | undefined => { try { - const observation = tryParseEvidence(partialObservation); - return observation === undefined + const observation = recognizeEvidence(partialObservation); + // A record that fails authentication cannot select which sources it + // cites; the failure carrying it is reported unchanged. + return !observation.ok || observation.value === undefined ? undefined - : collectSourceClosure(observation, captured, options); + : collectSourceClosure(observation.value, captured, options); } catch (cause: unknown) { return { publication: "not_published", diff --git a/src/application/AppBundleResourceRoot.test.ts b/src/application/AppBundleResourceRoot.test.ts index fbc13b3792..4ab8c134ff 100644 --- a/src/application/AppBundleResourceRoot.test.ts +++ b/src/application/AppBundleResourceRoot.test.ts @@ -144,6 +144,50 @@ it.skipIf(process.platform === "win32" || process.getuid?.() === 0)( }, ); +it("binds the target's selection to a provider subject naming its bytes", () => { + const flash: BinaryTarget = { + path: "/fixture/flash.bin", + sha256: "e".repeat(64), + kind: "archive", + format: "esp-flash-image", + espFlash: { + selected: true, + flashOffset: 0x1000, + partitionTableOffset: 0x8000, + }, + }; + const selection = { + kind: "esp-flash", + flash_offset: 0x1000, + partition_table_offset: 0x8000, + }; + const subject = { + path: flash.path, + sha256: flash.sha256, + format: "esp-flash-image" as const, + }; + const bind = (provided: { + readonly path: string; + readonly sha256: string; + readonly format: "esp-flash-image" | "file"; + }) => + bindExecutionTarget( + { + ok: true, + value: createAnalysisExecution({ ok: true }, provider, { + subject: provided, + }), + }, + "inventory_artifact", + flash, + ); + const bound = bind(subject); + expect(bound.ok && bound.value.subject).toEqual({ ...subject, selection }); + // A different root (a member of the image) is not the target itself. + const member = bind({ ...subject, format: "file" }); + expect(member.ok && member.value.subject).not.toHaveProperty("selection"); +}); + it("distinguishes default target binding from an explicitly unbound observation", () => { const defaultSubject = createAnalysisExecution({ ok: true }, provider); const unbound = createAnalysisExecution({ ok: true }, provider, { @@ -169,6 +213,6 @@ it("distinguishes default target binding from an explicitly unbound observation" expect(preserved.ok && preserved.value.subject).toBeNull(); expect( createAnalysisExecutionEvidence("inspect_plist", {}, unbound, "observed") - .subject, - ).toBeNull(); + .subject.identity.kind, + ).toBe("unknown"); }); diff --git a/src/application/BrowserEvidence.ts b/src/application/BrowserEvidence.ts index 195ce9009f..1dc89045f6 100644 --- a/src/application/BrowserEvidence.ts +++ b/src/application/BrowserEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { isDeepStrictEqual } from "node:util"; import type { ProviderIdentity } from "../ports/AnalysisProvider.js"; import { @@ -95,7 +96,7 @@ export const createBrowserEvidence = ( const comparison = operation === "compare_web_captures" || operation === "compare_web_screenshots"; - return createEvidence(undefined, provider, { + return createEvidence(unknownTarget("not-observed"), provider, { predicateType: browserPredicate(operation), operation, parameters: { diff --git a/src/application/BrowserScenarioEvidence.ts b/src/application/BrowserScenarioEvidence.ts index adb4384c0e..b6e389de4d 100644 --- a/src/application/BrowserScenarioEvidence.ts +++ b/src/application/BrowserScenarioEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { isDeepStrictEqual } from "node:util"; import { digestCanonicalValue } from "../domain/canonicalDigest.js"; import type { ProviderIdentity } from "../ports/AnalysisProvider.js"; @@ -32,7 +33,7 @@ export const createBrowserScenarioEvidence = ( provider: ProviderIdentity, ): Evidence => { const capture = report.facts; - return createEvidence(undefined, provider, { + return createEvidence(unknownTarget("not-observed"), provider, { predicateType: "rea.browser-scenario-capture", operation: "capture_browser_scenario", parameters: browserScenarioParameters(scenario), diff --git a/src/application/DirectAnalysis.ts b/src/application/DirectAnalysis.ts index c57244f8cb..24e92c2968 100644 --- a/src/application/DirectAnalysis.ts +++ b/src/application/DirectAnalysis.ts @@ -21,11 +21,9 @@ import { import type { ResolvedSessionOpen } from "./binary/BinarySessionOpen.js"; import { silentLogger } from "../logger.js"; import type { Logger } from "pino"; -import { - tryParseEvidence, - withEvidenceCallerInputPath, -} from "../domain/evidence.js"; +import { withEvidenceCallerInputPath } from "../domain/evidence.js"; import { createImmutableEvidenceBundle } from "../domain/evidenceBundle.js"; +import { recognizeEvidence } from "../domain/evidenceValidation.js"; import { retainAnalysisResultSources, type AnalysisResultWithSources, @@ -533,9 +531,10 @@ const runAnalysis = async ( }); if (!executed.ok) { if (options.includeEvidenceSources) { - const partial = tryParseEvidence(executed.error.partialObservation); - if (partial !== undefined) { - const captured = captureSources(partial); + const partial = recognizeEvidence(executed.error.partialObservation); + if (!partial.ok) executed.error.retainSecondaryFailure(partial.error); + else if (partial.value !== undefined) { + const captured = captureSources(partial.value); if (!captured.ok) executed.error.retainSecondaryFailure(captured.error); } diff --git a/src/application/DirectAnalysisCleanup.ts b/src/application/DirectAnalysisCleanup.ts index 7f887a6593..b8ac2646b4 100644 --- a/src/application/DirectAnalysisCleanup.ts +++ b/src/application/DirectAnalysisCleanup.ts @@ -19,10 +19,8 @@ import { analysisErrorWithCleanupFailure, analysisErrorWithCloseRejection, } from "../domain/analysisErrorCleanup.js"; -import { - tryParseEvidence, - withEvidenceCallerInputPath, -} from "../domain/evidence.js"; +import { withEvidenceCallerInputPath } from "../domain/evidence.js"; +import { recognizeEvidence } from "../domain/evidenceValidation.js"; /** * Project a one-shot failure for its invocation, which has released its @@ -45,11 +43,13 @@ export const projectDirectAnalysisFailure = ( partial !== null && !Array.isArray(partial) && partial.kind === "unretained-evidence"; - const observation = tryParseEvidence(wrapped ? partial.evidence : partial); + // Only authenticated Evidence gains the request path; a record that fails + // authentication is projected as the owner reported it, never as absent. + const observation = recognizeEvidence(wrapped ? partial.evidence : partial); const rebound = - observation === undefined + !observation.ok || observation.value === undefined ? undefined - : withEvidenceCallerInputPath(observation, callerInputPath); + : withEvidenceCallerInputPath(observation.value, callerInputPath); const completed = sourcePublicationRecoveryOf(error)?.completed; const completedWithPath = completed?.kind === "unretained-evidence" || diff --git a/src/application/EvidenceRequestResolution.test.ts b/src/application/EvidenceRequestResolution.test.ts index b6e04b8789..9a4525b033 100644 --- a/src/application/EvidenceRequestResolution.test.ts +++ b/src/application/EvidenceRequestResolution.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { describe, expect, expectTypeOf, it } from "vitest"; import { z } from "zod"; @@ -21,7 +22,7 @@ import { } from "./EvidenceInputResolver.js"; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "test-evidence-input", name: "Evidence input regression", diff --git a/src/application/FunctionAnalysisEvidence.test.ts b/src/application/FunctionAnalysisEvidence.test.ts index 6c3cfe12a6..36636529ce 100644 --- a/src/application/FunctionAnalysisEvidence.test.ts +++ b/src/application/FunctionAnalysisEvidence.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { createAnalysisExecution } from "../ports/AnalysisProvider.js"; import { executeFunctionAnalysisEvidence } from "./FunctionAnalysisEvidence.js"; @@ -64,7 +65,7 @@ it.each(["selected-target", "no-subject", "provider-subject"] as const)( sha256: "b".repeat(64), }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", @@ -119,7 +120,8 @@ it.each(["selected-target", "no-subject", "provider-subject"] as const)( kind: "address", address: "0x401000", }); - if (binding === "no-subject") expect(evidence.subject).toBeNull(); + if (binding === "no-subject") + expect(evidence.subject.identity.kind).toBe("unknown"); else expect(evidence.subject?.local_path).toBe( binding === "selected-target" ? target.path : subject.path, @@ -169,7 +171,7 @@ it.each(["provider-failure", "invalid-dossier"] as const)( ); it("retains malformed dossier facts and source links through public error projection", async () => { - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "retained source", @@ -197,7 +199,7 @@ it("retains malformed dossier facts and source links through public error projec const retained = parseEvidence(projected.details?.partial_observation); expect(retained.normalized_result).toEqual(malformed); expect(retained.raw_result).toEqual({ text: "original provider output" }); - expect(retained.subject).toBeNull(); + expect(retained.subject.identity.kind).toBe("unknown"); expect(retained.evidence_links).toEqual([source.evidence_id]); expect(retained.locations).toEqual([ { kind: "address", address: "0x401000" }, diff --git a/src/application/InventoryProjectionEvidence.ts b/src/application/InventoryProjectionEvidence.ts index c54079719b..fdd612a667 100644 --- a/src/application/InventoryProjectionEvidence.ts +++ b/src/application/InventoryProjectionEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { resolveEvidenceRequest, type EvidenceLookup, @@ -7,9 +8,9 @@ import type { AnalysisInputError } from "../domain/analysisErrorCore.js"; import type { AnalysisError } from "../domain/analysisErrorBase.js"; import { createEvidence, - evidenceSubjectTarget, type Evidence, type EvidenceProvider, + evidenceSubjectInput, } from "../domain/evidence.js"; import type { JsonValue } from "../domain/jsonValue.js"; import type { ParsedInventorySet } from "../domain/artifactInventoryEvidence.js"; @@ -69,7 +70,9 @@ export const projectInventoryEvidence = < const first = source.value.evidence[0]; return ok({ evidence: createEvidence( - evidenceSubjectTarget(first?.subject ?? null), + first === undefined + ? unknownTarget("derived-from-linked-evidence") + : evidenceSubjectInput(first.subject), options.provider, { predicateType: options.predicateType, diff --git a/src/application/ReconstructionObligationCandidates.test.ts b/src/application/ReconstructionObligationCandidates.test.ts index 19e48cdd63..a76f668cea 100644 --- a/src/application/ReconstructionObligationCandidates.test.ts +++ b/src/application/ReconstructionObligationCandidates.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { javascriptApplicationAnalysisResultSchema } from "../domain/javascript/javascriptApplicationAnalysis.js"; import { JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE } from "../contracts/javascript/javascriptRuntimeReconciliationExample.js"; import { @@ -49,7 +50,7 @@ const applicationWithUnknowns = ( }: { kind?: "unknown" | "package"; label?: string } = {}, ) => { const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture-source", name: "Fixture source", version: "1" }, { operation: "inspect_fixture_source", @@ -112,40 +113,44 @@ const applicationWithUnknowns = ( coverage: completeCoverage, limitations: base.limitations, }); - const application = createEvidence(undefined, MANAGED_WORKFLOW_PROVIDER, { - predicateType: "rea.managed-application-graph", - operation: "project_managed_application_graph", - parameters: {}, - result: { - projection_id: `magp_${"a".repeat(64)}`, - root_artifact_sha256: APPLICATION_GRAPH_DIGESTS.asar, - source_evidence: { - managed_artifact_evidence_id: source.evidence_id, - managed_members_evidence_id: null, - managed_native_boundaries_evidence_id: null, + const application = createEvidence( + unknownTarget("not-observed"), + MANAGED_WORKFLOW_PROVIDER, + { + predicateType: "rea.managed-application-graph", + operation: "project_managed_application_graph", + parameters: {}, + result: { + projection_id: `magp_${"a".repeat(64)}`, + root_artifact_sha256: APPLICATION_GRAPH_DIGESTS.asar, + source_evidence: { + managed_artifact_evidence_id: source.evidence_id, + managed_members_evidence_id: null, + managed_native_boundaries_evidence_id: null, + }, + summary: { + graph_nodes: graph.nodes.length, + graph_edges: graph.edges.length, + assemblies: 0, + modules: 0, + types: 0, + methods: 0, + fields: 0, + pinvoke_imports: 0, + native_implementations: 0, + calls: 0, + field_accesses: 0, + }, + graph, + coverage: { status: "complete-within-inputs" }, + evidence_links: [source.evidence_id], + limitations: [], }, - summary: { - graph_nodes: graph.nodes.length, - graph_edges: graph.edges.length, - assemblies: 0, - modules: 0, - types: 0, - methods: 0, - fields: 0, - pinvoke_imports: 0, - native_implementations: 0, - calls: 0, - field_accesses: 0, - }, - graph, - coverage: { status: "complete-within-inputs" }, - evidence_links: [source.evidence_id], - limitations: [], + confidence: "inferred", + authority: "analyst-inference", + evidenceLinks: [source.evidence_id], }, - confidence: "inferred", - authority: "analyst-inference", - evidenceLinks: [source.evidence_id], - }); + ); return { graph, unknownNodes, @@ -239,24 +244,28 @@ describe("reconstruction obligation candidates", () => { exit, ...rest } = FINALIZED_PROCESS_CAPTURE_EXAMPLE; - const evidence = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: { - ...rest, - manifest, - exit: { - ...exit, - finalization: { - ...exit.finalization, - signals: [ - { ...exit.finalization.signals[0], reason: "not allowed here" }, - ], + const evidence = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: { + ...rest, + manifest, + exit: { + ...exit, + finalization: { + ...exit.finalization, + signals: [ + { ...exit.finalization.signals[0], reason: "not allowed here" }, + ], + }, }, }, }, - }); + ); const invalid = safeParseProcessCapture(evidence.normalized_result); expect(invalid.success).toBe(false); if (invalid.success) throw new Error("Expected invalid capture fixture"); diff --git a/src/application/ReconstructionObligationLedger.authority.test.ts b/src/application/ReconstructionObligationLedger.authority.test.ts index 7d7e6fa833..e4b4e37ff3 100644 --- a/src/application/ReconstructionObligationLedger.authority.test.ts +++ b/src/application/ReconstructionObligationLedger.authority.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { reconstructionProofApplicabilityCases } from "../../tests/fixtures/reconstructionProofApplicability.js"; @@ -11,7 +12,7 @@ import { reviewedObligation, readyReviewedLedgerRequest, } from "./ReconstructionObligationLedger.fixture.js"; -import { createEvidence } from "../domain/evidence.js"; +import { createEvidence, evidenceSubjectInput } from "../domain/evidence.js"; import type { ReviewedReconstructionObligation } from "../domain/reconstructionObligationLedgerSchemas.js"; describe("selected reconstruction fixture outcomes", () => { @@ -65,7 +66,7 @@ const registerOriginalProcessAuthorityCases = (): void => { ({ defect, state, qualifies }) => { const capture = processEvidence(); const original = createEvidence( - undefined, + evidenceSubjectInput(capture.subject), defect === "provider" ? { id: "foreign", name: "Foreign observer", version: "1" } : capture.provider, @@ -301,7 +302,7 @@ describe("reconstruction obligation ledger fail-closed behavior", () => { it("fails closed on ambiguous ownership and contradiction", () => { const original = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "external", name: "External protocol observer", version: "1" }, { predicateType: "rea.protocol-observation", diff --git a/src/application/ReconstructionObligationLedger.fixture.ts b/src/application/ReconstructionObligationLedger.fixture.ts index 5d2e422592..1f1f3284a7 100644 --- a/src/application/ReconstructionObligationLedger.fixture.ts +++ b/src/application/ReconstructionObligationLedger.fixture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { reconstructionObligationProofSchema, type ReconstructionObligationProof, @@ -26,7 +27,7 @@ import { /** Build controlled fixture Evidence used by reconstruction-ledger scenarios. */ export const proofEvidence = (id: string) => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: `fixture-${id}`, name: "Fixture verifier", version: "1" }, { predicateType: "rea.fixture-verification", @@ -42,7 +43,7 @@ export const proofEvidence = (id: string) => export const processEvidence = ( overrides: Partial = {}, ) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: {}, @@ -61,7 +62,7 @@ export const boundProofEvidence = ( authority: "shipped-artifact" | "controlled-replay" = "controlled-replay", ) => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: `proof-${id}`, name: "Reconstruction proof", version: "1" }, { predicateType: "rea.reconstruction-proof", @@ -212,7 +213,7 @@ const authorityEvidence = ( authority: "shipped-artifact" | "controlled-replay", ) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", diff --git a/src/application/ReconstructionObligationLedgerService.ts b/src/application/ReconstructionObligationLedgerService.ts index b9d01b6172..9891d694b0 100644 --- a/src/application/ReconstructionObligationLedgerService.ts +++ b/src/application/ReconstructionObligationLedgerService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import type { AnalysisError } from "../domain/analysisErrorBase.js"; import { createEvidence, type Evidence } from "../domain/evidence.js"; import type { ReconstructionObligationLedger } from "../domain/reconstructionObligationLedgerSchemas.js"; @@ -38,18 +39,22 @@ export const buildResolvedReconstructionObligationLedgerEvidence = ( const createLedgerEvidence = ( ledger: ReconstructionObligationLedger, ): Evidence => - createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.reconstruction-obligation-ledger", - operation: OPERATION, - parameters: { - ledger_id: ledger.ledger_id, - closure_digest: ledger.closure_digest, + createEvidence( + unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.reconstruction-obligation-ledger", + operation: OPERATION, + parameters: { + ledger_id: ledger.ledger_id, + closure_digest: ledger.closure_digest, + }, + result: ledger, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: ledger.limitations, + evidenceLinks: ledger.evidence_links, }, - result: ledger, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: ledger.limitations, - evidenceLinks: ledger.evidence_links, - }); + ); diff --git a/src/application/WebNetworkCaptureService.test.ts b/src/application/WebNetworkCaptureService.test.ts index 5d669e092a..76ba31e198 100644 --- a/src/application/WebNetworkCaptureService.test.ts +++ b/src/application/WebNetworkCaptureService.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../tests/fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { WebNetworkCaptureService } from "./WebNetworkCaptureService.js"; import { historicalHar } from "../../tests/fixtures/historicalHar.js"; @@ -40,7 +41,9 @@ it.each(["REDACTED", "[", "]", "/capture.har"])( location.kind !== "artifact-path" || !location.path.includes(literal), ), ).toBe(true); - expect(result.value.subject?.digest.sha256).toBe(report.artifact.sha256); + expect(fileIdentity(result.value.subject).sha256).toBe( + report.artifact.sha256, + ); }, ); @@ -79,7 +82,7 @@ it("keeps observed artifact identity when the entire sensitive path is excluded" if (!result.ok) throw result.error; expect(result.value.subject).toMatchObject({ local_path: "", - digest: { sha256: "a".repeat(64) }, + identity: { sha256: "a".repeat(64) }, }); expect(result.value.locations).toEqual([]); }); @@ -121,7 +124,7 @@ it.each(["a".repeat(64), "aaaa"])( sensitive_values: [literal], }); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect(result.value.normalized_result).toMatchObject({ artifact: { path: "/capture.har", sha256: null, bytes: 10 }, }); @@ -142,7 +145,7 @@ it("projects the unknown-subject explanation before generating its Evidence ID", sensitive_values: ["a"], }); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect(result.value.limitations).toContainEqual( expect.stringMatching(/digest.*unknown.*Evidence/u), ); @@ -351,7 +354,9 @@ it.each([ ].flat(); for (const literal of literals) expect(texts.every((text) => !text.includes(literal))).toBe(true); - expect(result.value.subject?.digest.sha256).toBe(report.artifact.sha256); + expect(fileIdentity(result.value.subject).sha256).toBe( + report.artifact.sha256, + ); expect(projected.decoder).toEqual(report.decoder); expect(projected.records[0]?.reported).toEqual(first.reported); }, diff --git a/src/application/WebNetworkCaptureService.ts b/src/application/WebNetworkCaptureService.ts index 3ee5176944..9b20775694 100644 --- a/src/application/WebNetworkCaptureService.ts +++ b/src/application/WebNetworkCaptureService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { redactExplicitFailure } from "../domain/explicitSensitiveFailure.js"; import { excludeCaptureCoordinates } from "../domain/webNetworkCaptureCoordinates.js"; import { redactExplicitText } from "../domain/explicitSensitiveValues.js"; @@ -244,7 +245,7 @@ export class WebNetworkCaptureService { }); const evidence = createEvidence( safeSha256 === null - ? undefined + ? unknownTarget("not-observed") : { path: safePath, sha256: safeSha256, @@ -278,8 +279,10 @@ export class WebNetworkCaptureService { }), confidence: "observed", authority: "historical-reference", - limitations, - ...(safeSha256 === null ? { subjectUnavailableReason } : {}), + limitations: + safeSha256 === null + ? [subjectUnavailableReason, ...limitations] + : limitations, locations: safePath === "" ? [] : [{ kind: "artifact-path", path: safePath }], }, diff --git a/src/application/WebRuntimeService.ts b/src/application/WebRuntimeService.ts index a944bf72e2..42f47ff642 100644 --- a/src/application/WebRuntimeService.ts +++ b/src/application/WebRuntimeService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { z } from "zod"; import type { ExecutionOptions } from "../ports/AnalysisProvider.js"; import type { WebRuntimePort } from "../ports/WebRuntimePort.js"; @@ -155,7 +156,7 @@ export class WebRuntimeService { ), ); return completeProviderEvidence( - createEvidence(undefined, this.provider.identity(), { + createEvidence(unknownTarget("not-observed"), this.provider.identity(), { predicateType: `rea.${operation.replaceAll("_", "-")}`, operation, parameters: input, diff --git a/src/application/WebSourceLocationService.test.ts b/src/application/WebSourceLocationService.test.ts index fecefc0ecd..868373c788 100644 --- a/src/application/WebSourceLocationService.test.ts +++ b/src/application/WebSourceLocationService.test.ts @@ -283,7 +283,7 @@ it("honors cancellation both before acquisition and across decoder completion", authority: "historical-reference", subject: { local_path: fixture.sourceFile.path, - digest: { sha256: fixture.sourceFile.sha256 }, + identity: { sha256: fixture.sourceFile.sha256 }, }, parameters: args, raw_result: { source_map_text: fixture.sourceMap.text }, diff --git a/src/application/WorkflowEvidence.test.ts b/src/application/WorkflowEvidence.test.ts index 63e590e109..749e3328c3 100644 --- a/src/application/WorkflowEvidence.test.ts +++ b/src/application/WorkflowEvidence.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { z } from "zod"; @@ -73,7 +74,7 @@ it.each([0, 1, 100])( "admits enough recovery representation for %i completed batch items", (count) => { const provider = { id: "fixture", name: "Fixture", version: "1" }; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "source", @@ -149,7 +150,7 @@ it.each([0, 1, 100])( it("links shared provider source Evidence once without copying its payload into the workflow", async () => { const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "health", @@ -238,7 +239,7 @@ it.each([false, true])( const provider = { id: "fixture", name: "Fixture", version: "1" }; it("retains requested live observations and links their original producer sources", async () => { - const upstream = createEvidence(undefined, provider, { + const upstream = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "source", @@ -276,7 +277,7 @@ it("retains requested live observations and links their original producer source }); it("keeps an existing session-issued source identity on replay", async () => { - const original = createEvidence(undefined, provider, { + const original = createEvidence(unknownTarget("not-observed"), provider, { operation: "analyze_function", parameters: { procedure: "0x1" }, result: "original", diff --git a/src/application/WorkflowEvidence.ts b/src/application/WorkflowEvidence.ts index a146fba59e..f29875974f 100644 --- a/src/application/WorkflowEvidence.ts +++ b/src/application/WorkflowEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { AnalysisWorkScope } from "../ports/AnalysisWorkScope.js"; import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js"; import { jsonStringByteLength } from "../domain/jsonStringByteLength.js"; @@ -23,8 +24,8 @@ import { import type { BinaryTarget } from "../domain/binaryTargetTypes.js"; import { createEvidence, - MISSING_EVIDENCE_SUBJECT_LIMITATION, evidenceEnvelopeForAdmission, + evidenceSubjectTarget, type Evidence, type EvidenceLocation, } from "../domain/evidence.js"; @@ -240,10 +241,14 @@ const workflowLimitations = ( ? [WORKFLOW_DERIVATION_LIMITATION, TRACE_FEATURE_REFERENCE_LIMITATION] : [WORKFLOW_DERIVATION_LIMITATION]; +/** A workflow without an open target derives only from the Evidence it links. */ +const workflowSubject = (target: BinaryTarget | undefined) => + target ?? unknownTarget("derived-from-linked-evidence"); + export const createWorkflowEvidence = ( input: WorkflowEvidenceInput, ): Evidence => - createEvidence(input.target, REA_WORKFLOW_PROVIDER, { + createEvidence(workflowSubject(input.target), REA_WORKFLOW_PROVIDER, { operation: input.operation, parameters: input.parameters, result: input.result, @@ -297,7 +302,7 @@ const admitWorkflowRecovery = ( // the workflow profile embeds the upstream profile. Admit these copies // before constructing or hashing the recovery Evidence. const shell = evidenceEnvelopeForAdmission( - evidenceInput.target, + workflowSubject(evidenceInput.target), REA_WORKFLOW_PROVIDER, { operation: evidenceInput.operation, @@ -325,9 +330,6 @@ const admitWorkflowRecovery = ( observation.result, evidenceInput.upstreamProfile ?? null, shell, - ...(evidenceInput.target === undefined - ? [MISSING_EVIDENCE_SUBJECT_LIMITATION] - : []), ]); return admitRecovery(admissionInput, evidenceInput.operation, additional); }; @@ -482,17 +484,7 @@ export const workflowSnapshotRecord = ( analysisProfile: analysisProfileSchema.parse(evidence.analysis_profile), limitations: evidence.limitations, locations: evidence.locations, - subject: - evidence.subject === null - ? null - : { - path: evidence.subject.local_path, - sha256: evidence.subject.digest.sha256, - format: evidence.subject.format, - ...(evidence.subject.architecture === null - ? {} - : { architecture: evidence.subject.architecture }), - }, + subject: evidenceSubjectTarget(evidence.subject) ?? null, }, }; }; diff --git a/src/application/analysisView/AnalysisViewService.test.ts b/src/application/analysisView/AnalysisViewService.test.ts index 526304d07b..773b517928 100644 --- a/src/application/analysisView/AnalysisViewService.test.ts +++ b/src/application/analysisView/AnalysisViewService.test.ts @@ -1,3 +1,5 @@ +import { fileSubjectTarget } from "../../../tests/fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -229,14 +231,10 @@ it("keeps retained admission and payload ownership for a large capture when only expect(ledger.record(parent).ok).toBe(true); const retained = ledger.forAnalysis(parent.evidence_id)!; const payload = retained.normalized_result; - const subject = retained.subject!; + const subject = retained.subject; const selected = rebindEvidenceToTargetPath(retained, { + ...fileSubjectTarget(subject), path: "/selected/capture.har", - sha256: subject.digest.sha256, - format: subject.format, - ...(subject.architecture === null - ? {} - : { architecture: subject.architecture }), }); const retention = { recordEvidence: (evidence: Evidence) => ledger.record(evidence), @@ -583,7 +581,7 @@ it("rejects stale retained IDs and unsupported parent operations", async () => { }, }); const unsupported = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_recorded_crash", @@ -613,12 +611,16 @@ it("rejects stale retained IDs and unsupported parent operations", async () => { it("preserves an absent parent subject instead of guessing its format", async () => { const analysis = analysisViewJavaScriptAnalysisWithSource(); const original = analysisViewJavaScriptEvidence(analysis); - const parent = createEvidence(undefined, original.provider, { - operation: original.operation, - parameters: {}, - result: original.normalized_result, - limitations: original.limitations, - }); + const parent = createEvidence( + unknownTarget("not-observed"), + original.provider, + { + operation: original.operation, + parameters: {}, + result: original.normalized_result, + limitations: original.limitations, + }, + ); const result = await inspectAnalysisView( { source: { kind: "retained-evidence", evidence_id: parent.evidence_id }, @@ -627,7 +629,7 @@ it("preserves an absent parent subject instead of guessing its format", async () () => parent, ); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect(result.value.locations).toEqual([ { kind: "artifact-path", path: analysis.input_path }, ]); @@ -738,7 +740,7 @@ it("seals inferred and literal HAR pages, including a null artifact digest", asy }); if (!result.ok) throw result.error; expect(result.value.confidence).toBe(confidence); - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect(parseEvidence(result.value)).toEqual(result.value); } expect( @@ -841,7 +843,7 @@ it("seals an inferred environment manifest and a derived manifest without templa }); if (!derived.ok) throw derived.error; expect(derived.value.confidence).toBe("derived"); - expect(derived.value.subject).toBeNull(); + expect(derived.value.subject.identity.kind).toBe("unknown"); expect(derived.value.normalized_result).toMatchObject({ templated_groups: 0, tools: [{ name: "get_org" }, { name: "get_search" }, { name: "get_user" }], @@ -1653,7 +1655,7 @@ it.each(["file", "bundle"] as const)( "preserves a produced %s projection failure when cancellation arrives", async (kind) => { const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_recorded_crash", diff --git a/src/application/analysisView/AnalysisViewService.ts b/src/application/analysisView/AnalysisViewService.ts index e4a43a0f22..73a3f6dd2a 100644 --- a/src/application/analysisView/AnalysisViewService.ts +++ b/src/application/analysisView/AnalysisViewService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { projectAnalysisErrorWithoutCapturedOutput } from "../../domain/analysisErrorProjection.js"; import { analysisErrorWithCleanupDependencies } from "../../domain/analysisErrorCleanup.js"; import { parseAnalysisInput } from "../AnalysisInput.js"; @@ -18,9 +19,15 @@ import { } from "../../domain/analysisErrorCore.js"; import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js"; import { validateAnalysisViewSubject } from "../../domain/analysisView/analysisViewParent.js"; -import { safeParseEvidence } from "../../domain/evidenceValidation.js"; +import { + safeParseEvidence, + unsupportedEvidenceFormatError, +} from "../../domain/evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../../domain/evidenceFormat.js"; import { createEvidence, + evidenceFileTarget, + evidenceSubjectDisplay, evidenceSubjectTarget, rebindEvidenceToTargetPath, type Evidence, @@ -238,13 +245,7 @@ const projectResolvedAnalysisView = ( subject: presentation.subject, limitations: parent.limitations, parameters: parent.parameters, - artifact: - presentation.subject === null - ? null - : { - path: presentation.subject.local_path, - sha256: presentation.subject.digest.sha256, - }, + artifact: viewArtifact(presentation), }); if (!projected.ok) return projected; const identity = validateAnalysisViewSubject( @@ -352,6 +353,8 @@ const authenticateEvidence = ( const parsed = safeParseEvidence(value); if (parsed.ok) return parsed; const cause = parsed.error; + if (isUnsupportedEvidenceFormat(cause)) + return err(unsupportedEvidenceFormatError(cause)); return err( analysisInputErrorFromIssues( INSPECT_ANALYSIS_VIEW_OPERATION, @@ -384,7 +387,7 @@ const createAnalysisViewEvidence = ( (result.kind === "summary" && isNativeObservationOperation(result.parent_operation)); return createEvidence( - target, + target ?? unknownTarget("derived-from-linked-evidence"), ANALYSIS_VIEW_PROVIDER, { predicateType: "rea.analysis-view", @@ -443,3 +446,14 @@ const createAnalysisViewEvidence = ( { immutable: true }, ); }; + +/** The artifact a view names: the presented file target and its display path. */ +const viewArtifact = ( + evidence: Evidence, +): { readonly path: string; readonly sha256: string } | null => { + const target = evidenceFileTarget(evidence); + const display = evidenceSubjectDisplay(evidence); + return target === undefined || display === undefined + ? null + : { path: display.local_path, sha256: target.sha256 }; +}; diff --git a/src/application/analysisView/BrowserScenarioViews.test.ts b/src/application/analysisView/BrowserScenarioViews.test.ts index 3d3a714425..7ee25ea2df 100644 --- a/src/application/analysisView/BrowserScenarioViews.test.ts +++ b/src/application/analysisView/BrowserScenarioViews.test.ts @@ -141,10 +141,9 @@ describe("browser scenario analysis views", () => { const summary = await view(capture, { kind: "summary" }); expect(summary).toMatchObject({ limitations: [ - expect.stringMatching(/artifact identity.*unavailable/iu), expect.stringMatching(/platform.*architecture.*not observed/iu), ], - summary: { limitation_count: 2 }, + summary: { limitation_count: 1 }, }); }); diff --git a/src/application/analysisView/NativeObservationViews.test.ts b/src/application/analysisView/NativeObservationViews.test.ts index c34ade9b59..55dc6a42c4 100644 --- a/src/application/analysisView/NativeObservationViews.test.ts +++ b/src/application/analysisView/NativeObservationViews.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCore.js"; import { projectAnalysisError } from "../../domain/analysisErrorProjection.js"; import { nativeGraphViewItemsSchema } from "../../domain/analysisView/nativeObservationSchemas.js"; @@ -225,7 +226,7 @@ it("pages complete context fields and changes its digest when source profile or }); it("keeps absent profile and inapplicable result caveats distinct from observed empty data", async () => { - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_address", parameters: {}, result: "0x0000", @@ -612,7 +613,7 @@ it.each([ ])( "keeps $status relationship coverage on every context facet", async (coverage) => { - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_callees", parameters: {}, result: [], diff --git a/src/application/analysisView/evidenceFileSource.test.ts b/src/application/analysisView/evidenceFileSource.test.ts index fbf889194c..3c673a610c 100644 --- a/src/application/analysisView/evidenceFileSource.test.ts +++ b/src/application/analysisView/evidenceFileSource.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -309,7 +310,7 @@ it("keeps bundle-selection errors useful when operation labels exceed the reply const operation = '\u0000"'.repeat(50_000); const records = [1, 2].map((ordinal) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation, diff --git a/src/application/analysisView/evidenceFileSource.ts b/src/application/analysisView/evidenceFileSource.ts index 73062a481c..0a9b4ec7eb 100644 --- a/src/application/analysisView/evidenceFileSource.ts +++ b/src/application/analysisView/evidenceFileSource.ts @@ -11,7 +11,11 @@ import { import { INSPECT_ANALYSIS_VIEW_OPERATION } from "../../domain/analysisView/analysisViewErrors.js"; import { err, ok, type Result } from "../../domain/result.js"; import type { Evidence } from "../../domain/evidence.js"; -import { safeParseImmutableEvidence } from "../../domain/evidenceValidation.js"; +import { + safeParseImmutableEvidence, + unsupportedEvidenceFormatError, +} from "../../domain/evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../../domain/evidenceFormat.js"; import { EvidenceFileError } from "../../domain/evidenceErrors.js"; import { projectInputIssuesBounded } from "../../domain/inputIssueProjection.js"; import { readJsonFile } from "../JsonFiles.js"; @@ -195,13 +199,15 @@ export const readEvidenceFileSource = async ( const parsed = safeParseImmutableEvidence(value); if (!parsed.ok) return err( - new EvidenceFileError("read", "wrong-kind", { - path, - cause: parsed.error, - contentIssues: boundedContentIssues(parsed.error.issues, value), - userMessage: - "The selected file does not contain valid Evidence. Repair or recreate the file and try again.", - }), + isUnsupportedEvidenceFormat(parsed.error) + ? unsupportedEvidenceFormatError(parsed.error) + : new EvidenceFileError("read", "wrong-kind", { + path, + cause: parsed.error, + contentIssues: boundedContentIssues(parsed.error.issues, value), + userMessage: + "The selected file does not contain valid Evidence. Repair or recreate the file and try again.", + }), ); if (evidenceId !== undefined && parsed.value.evidence_id !== evidenceId) return err( diff --git a/src/application/android/AndroidAnalysisService.test.ts b/src/application/android/AndroidAnalysisService.test.ts index 0763a975c2..174e9a48cb 100644 --- a/src/application/android/AndroidAnalysisService.test.ts +++ b/src/application/android/AndroidAnalysisService.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it, vi } from "vitest"; import { AndroidAnalysisService } from "./AndroidAnalysisService.js"; import type { AndroidAnalysisPort } from "../../ports/android/AndroidAnalysisPort.js"; @@ -67,7 +68,7 @@ it.each(["omitted", "null", "explicit"] as const)( status: "unknown", reason: "Calls were not inspected", } as const; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "read_dex", parameters: {}, result: { inventory: true }, @@ -122,7 +123,7 @@ it.each(["omitted", "null", "explicit"] as const)( expect(evidence).toMatchObject({ subject: subjectKind === "null" - ? null + ? { identity: { kind: "unknown", reason: "not-observed" } } : { local_path: subjectKind === "omitted" ? path : explicit.path }, }); } diff --git a/src/application/android/AndroidSearchEvidenceSummary.ts b/src/application/android/AndroidSearchEvidenceSummary.ts index 95c54c9cf8..7a1e97b3e3 100644 --- a/src/application/android/AndroidSearchEvidenceSummary.ts +++ b/src/application/android/AndroidSearchEvidenceSummary.ts @@ -1,8 +1,8 @@ import type { EvidenceWriter } from "../investigation/InvestigationRecordPort.js"; import { createEvidence, - evidenceSubjectTarget, type Evidence, + evidenceSubjectInput, } from "../../domain/evidence.js"; import type { AnalysisError } from "../../domain/analysisErrorBase.js"; import type { JsonValue } from "../../domain/jsonValue.js"; @@ -23,7 +23,7 @@ export const summarizeRetainedAndroidSearch = ( const recorded = recordEvidence(evidence); if (!recorded.ok) return recorded; return ok( - createEvidence(evidenceSubjectTarget(evidence.subject), evidence.provider, { + createEvidence(evidenceSubjectInput(evidence.subject), evidence.provider, { operation: evidence.operation, parameters: evidence.parameters, result: evidence.normalized_result, diff --git a/src/application/artifacts/ArtifactComparisonEvidence.test.ts b/src/application/artifacts/ArtifactComparisonEvidence.test.ts index 62fb67152a..5b2f91ce62 100644 --- a/src/application/artifacts/ArtifactComparisonEvidence.test.ts +++ b/src/application/artifacts/ArtifactComparisonEvidence.test.ts @@ -1,3 +1,7 @@ +import { + fileSubjectTarget, + displayedEvidenceSubject, +} from "../../../tests/fixtures/evidenceSubject.js"; import { RECREATE_EVIDENCE_GUIDANCE } from "../../domain/evidenceFormat.js"; import { expect, it } from "vitest"; @@ -8,8 +12,10 @@ import { artifactInventorySummaryViewResultSchema } from "../../domain/analysisV import { createEvidence, parseEvidence, + evidenceSubjectTarget, rebindEvidenceToTargetPath, type Evidence, + type EvidenceSubjectTarget, } from "../../domain/evidence.js"; import { EvidenceIntegrityError, @@ -40,38 +46,25 @@ const recreateSummary = ( normalizedResult: Evidence["normalized_result"], parameters: Evidence["parameters"] = summary.parameters, ): Evidence => { - if (summary.subject === null) - throw new Error("artifact summary fixture must identify its subject"); - return createEvidence( - { - path: summary.subject.local_path, - sha256: summary.subject.digest.sha256, - format: summary.subject.format, - ...(summary.subject.architecture === null - ? {} - : { architecture: summary.subject.architecture }), - }, - summary.provider, - { - predicateType: summary.predicate_type, - operation: summary.operation, - parameters, - result: normalizedResult, - ...(summary.analysis_profile === null - ? {} - : { analysisProfile: summary.analysis_profile }), - rawResult: summary.raw_result, - confidence: summary.confidence, - authority: summary.authority, - environment: summary.environment, - limitations: summary.limitations, - ...(summary.relationship_coverage === null - ? {} - : { relationshipCoverage: summary.relationship_coverage }), - locations: summary.locations, - evidenceLinks: summary.evidence_links, - }, - ); + return createEvidence(fileSubjectTarget(summary.subject), summary.provider, { + predicateType: summary.predicate_type, + operation: summary.operation, + parameters, + result: normalizedResult, + ...(summary.analysis_profile === null + ? {} + : { analysisProfile: summary.analysis_profile }), + rawResult: summary.raw_result, + confidence: summary.confidence, + authority: summary.authority, + environment: summary.environment, + limitations: summary.limitations, + ...(summary.relationship_coverage === null + ? {} + : { relationshipCoverage: summary.relationship_coverage }), + locations: summary.locations, + evidenceLinks: summary.evidence_links, + }); }; it("reports a missing retained parent instead of treating summary facts as inventory", async () => { @@ -156,15 +149,14 @@ it("rejects summary facts that do not reproject from the complete parent", async it("accepts display-only subject changes excluded from Evidence identity", async () => { const { parent, summary } = await artifactSummary(); - if (summary.subject === null) + if (summary.subject.identity.kind !== "file") throw new Error("artifact summary fixture must identify its subject"); const displayOnly = parseEvidence({ ...summary, - subject: { - ...summary.subject, + subject: displayedEvidenceSubject(summary.subject, { name: "renamed.app", local_path: "/display-only/renamed.app", - }, + }), }); const resolved = resolveArtifactComparisonEvidence( displayOnly, @@ -181,13 +173,19 @@ const hashesUnknown = type SummaryEra = "pre-ce1f4b1bb" | "pre-b395190e4" | "current"; /** Recommit an inventory whose two independent unknowns exercise both migrations. */ -const unknownInventory = () => { +const unknownInventory = (target: Partial = {}) => { const original = ARTIFACT_COMPARISON_EXAMPLE.left; const inventory = artifactInventoryResultSchema.parse( original.normalized_result, ); inventory.coverage.status = "unknown"; inventory.occurrences[0]!.hash_status = "unavailable"; + if (target.format === "esp-flash-image") { + inventory.manifest.root_format = target.format; + for (const occurrence of inventory.occurrences) + if (occurrence.logical_path === ".") + occurrence.artifact_format = target.format; + } const graphSha256 = artifactGraphDigest({ nodes: inventory.nodes, occurrences: inventory.occurrences, @@ -204,6 +202,7 @@ const unknownInventory = () => { path: "historical-inventory", sha256: inventory.manifest.root_sha256, format: "file", + ...target, }, original.provider, { @@ -236,9 +235,8 @@ const summaryAtEra = async (era: SummaryEra, aliasPath?: string) => { aliasPath === undefined ? parent : rebindEvidenceToTargetPath(parent, { + ...fileSubjectTarget(parent.subject), path: aliasPath, - sha256: parent.subject!.digest.sha256, - format: parent.subject!.format, }); const projected = await inspectAnalysisView({ source: { kind: "inline", evidence: selectedParent }, @@ -316,9 +314,8 @@ it.each(["current"])( async (era) => { const { parent, summary } = await summaryAtEra(era); const rebound = rebindEvidenceToTargetPath(parent, { + ...fileSubjectTarget(parent.subject), path: "/selected/alias.bin", - sha256: parent.subject!.digest.sha256, - format: parent.subject!.format, }); expect(rebound.evidence_id).toBe(parent.evidence_id); expect(resolveArtifactComparisonEvidence(summary, () => rebound)).toEqual({ @@ -463,3 +460,30 @@ it.each(["current"])( expect(parseEvidence(summary).evidence_id).toBe(before.summaryId); }, ); + +it("authenticates an alias summary of a selected flash image against its retained inventory", async () => { + const parent = unknownInventory({ + format: "esp-flash-image", + selection: { + kind: "esp-flash", + flash_offset: 0x1_0000, + partition_table_offset: 0x8000, + }, + }); + const { name: _name, ...target } = evidenceSubjectTarget(parent.subject)!; + const alias = rebindEvidenceToTargetPath(parent, { + ...target, + path: "/selected/alias.bin", + }); + expect(alias.subject?.local_path).toBe("/selected/alias.bin"); + const summary = await inspectAnalysisView({ + source: { kind: "inline", evidence: alias }, + view: { kind: "summary" }, + }); + if (!summary.ok) throw summary.error; + // The owner rebinds its retained parent to the alias with the selection, so + // the reprojected summary names the same path and Evidence ID. + expect( + resolveArtifactComparisonEvidence(summary.value, () => parent), + ).toEqual({ ok: true, value: parent }); +}); diff --git a/src/application/artifacts/ArtifactComparisonEvidence.ts b/src/application/artifacts/ArtifactComparisonEvidence.ts index bfcc50d4e3..8abf7002ec 100644 --- a/src/application/artifacts/ArtifactComparisonEvidence.ts +++ b/src/application/artifacts/ArtifactComparisonEvidence.ts @@ -21,12 +21,18 @@ import { } from "../../domain/evidenceErrors.js"; import { createEvidence, + evidenceSubjectTarget, + evidenceTargetIdentity, rebindEvidenceToTargetPath, type Evidence, } from "../../domain/evidence.js"; import { readEvidence } from "../../domain/evidenceValidation.js"; import { RECREATE_EVIDENCE_GUIDANCE } from "../../domain/evidenceFormat.js"; import { err, ok, type Result } from "../../domain/result.js"; +import { + sameTargetIdentity, + unknownTarget, +} from "../../domain/targetIdentity.js"; const OPERATION = "compare_artifacts"; @@ -92,19 +98,23 @@ export const compareArtifactEvidence = ({ const rightEvidenceIds = [right.evidence_id]; return ok({ comparison, - evidence: createEvidence(undefined, ARTIFACT_COMPARISON_PROVIDER, { - predicateType: "rea.artifact-comparison", - operation: OPERATION, - parameters: { - left_evidence_ids: leftEvidenceIds, - right_evidence_ids: rightEvidenceIds, + evidence: createEvidence( + unknownTarget("derived-from-linked-evidence"), + ARTIFACT_COMPARISON_PROVIDER, + { + predicateType: "rea.artifact-comparison", + operation: OPERATION, + parameters: { + left_evidence_ids: leftEvidenceIds, + right_evidence_ids: rightEvidenceIds, + }, + result: comparison, + confidence: "derived", + authority: "analyst-inference", + limitations: comparison.limitations, + evidenceLinks: [...leftEvidenceIds, ...rightEvidenceIds], }, - result: comparison, - confidence: "derived", - authority: "analyst-inference", - limitations: comparison.limitations, - evidenceLinks: [...leftEvidenceIds, ...rightEvidenceIds], - }), + ), }); }; @@ -151,24 +161,23 @@ export const resolveArtifactComparisonEvidence = ( const authenticated = readEvidence(selected.value); if (!authenticated.ok) return authenticated; const owner = authenticated.value; - const subject = evidence.subject; + const identity = evidenceTargetIdentity(evidence); + const ownerIdentity = evidenceTargetIdentity(owner); + const target = evidenceSubjectTarget(evidence.subject); if ( - subject === null || - owner.subject === null || - subject.digest.sha256 !== owner.subject.digest.sha256 || - subject.format !== owner.subject.format || - subject.architecture !== owner.subject.architecture + identity === null || + ownerIdentity === null || + target === undefined || + !sameTargetIdentity(identity, ownerIdentity) ) return mismatch(); // The ledger preserves its original display path; summary delivery may use a // later caller-selected alias for this same authenticated owner identity. + // The alias names the whole target, selection included. + const { name: _name, ...aliasTarget } = target; const presentation = rebindEvidenceToTargetPath(owner, { + ...aliasTarget, path: summary.data.artifact.path, - sha256: subject.digest.sha256, - format: subject.format, - ...(subject.architecture === null - ? {} - : { architecture: subject.architecture }), }); const reprojected = inspectAnalysisViewValidated( { diff --git a/src/application/binary/AnalysisSnapshotCache.test.ts b/src/application/binary/AnalysisSnapshotCache.test.ts index db6c542c81..af9fb6aa75 100644 --- a/src/application/binary/AnalysisSnapshotCache.test.ts +++ b/src/application/binary/AnalysisSnapshotCache.test.ts @@ -1,3 +1,5 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; +import { displayedEvidenceSubject } from "../../../tests/fixtures/evidenceSubject.js"; import { describe, expect, it } from "vitest"; import { createAnalysisProfile } from "../../domain/analysisProfile.js"; @@ -231,10 +233,9 @@ it.each(["provider", "workflow"] as const)( if (!before.ok) throw before.error; const nameOnly = { ...evidence, - subject: - evidence.subject === null - ? null - : { ...evidence.subject, name: "display-only-name" }, + subject: displayedEvidenceSubject(evidence.subject, { + name: "display-only-name", + }), }; const nameImport = ledger.import(createEvidenceBundle([nameOnly])); if (!nameImport.ok) throw nameImport.error; @@ -251,14 +252,14 @@ it.each(["provider", "workflow"] as const)( }); expect(ledger.record(alternative).ok).toBe(true); const relocate = (record: typeof evidence) => { - if (record.subject === null) throw new Error("Expected fixture subject"); + if (record.subject.identity.kind !== "file") + throw new Error("Expected fixture subject"); return { ...record, - subject: { - ...record.subject, + subject: displayedEvidenceSubject(record.subject, { local_path: "/relocated/fixture", name: "renamed", - }, + }), }; }; const foreign = ledger.import( @@ -329,7 +330,7 @@ it.each(["provider", "workflow"] as const)( else cache.recordWorkflow(input); expect( ledger.record( - createEvidence(subject ?? undefined, provider, { + createEvidence(subject ?? unknownTarget("not-observed"), provider, { operation, parameters, result, @@ -1506,17 +1507,17 @@ it("replays source-bearing entries only when their complete retained closure exi .lookup(target, profile, "procedure_info", parameters) ?.sourceEvidence?.map((record) => record.evidence_id), ).toEqual([source.evidence_id, parent.evidence_id]); - if (source.subject === null) throw new Error("Expected source subject"); + if (source.subject.identity.kind !== "file") + throw new Error("Expected source subject"); const ledger = new EvidenceLedger(); for (const record of [parent, source, leaf]) expect(ledger.record(record).ok).toBe(true); const movedSource = { ...source, - subject: { - ...source.subject, + subject: displayedEvidenceSubject(source.subject, { local_path: "/relocated/source", name: "source", - }, + }), }; const replacement = ledger.import(createEvidenceBundle([movedSource])); if (!replacement.ok) throw replacement.error; diff --git a/src/application/binary/AnalysisSnapshotCache.ts b/src/application/binary/AnalysisSnapshotCache.ts index f52fa29726..ea60385cbb 100644 --- a/src/application/binary/AnalysisSnapshotCache.ts +++ b/src/application/binary/AnalysisSnapshotCache.ts @@ -12,6 +12,7 @@ import type { AnalysisError } from "../../domain/analysisErrorBase.js"; import { rebindEvidenceSubjectTargetPath, type Evidence, + evidenceSubjectDisplay, } from "../../domain/evidence.js"; import { err, ok, type Result } from "../../domain/result.js"; import { @@ -48,7 +49,10 @@ import { snapshotReplayBinding, type SnapshotReplayBinding, } from "./AnalysisSnapshotReplayBinding.js"; -import { sameTargetIdentity } from "../../domain/targetIdentity.js"; +import { + binaryTargetSelection, + sameTargetIdentity, +} from "../../domain/targetIdentity.js"; import { createInvestigationEvidenceClosureChecker } from "../investigation/InvestigationEvidence.js"; const RELATIONSHIP_OPERATIONS: ReadonlySet = new Set([ @@ -341,9 +345,10 @@ export class AnalysisSnapshotCache { } const header = { target: this.#target, binding: this.#binding }; for (const { previous, current } of replacements) { + const display = evidenceSubjectDisplay(current); if ( - current.subject === null || - previous.subject?.local_path === current.subject.local_path + display === undefined || + evidenceSubjectDisplay(previous)?.local_path === display.local_path ) continue; const queryId = analysisQueryId( @@ -364,7 +369,7 @@ export class AnalysisSnapshotCache { ...entry.execution, subject: { ...entry.execution.subject, - path: current.subject.local_path, + path: display.local_path, }, }, }); @@ -380,7 +385,7 @@ export class AnalysisSnapshotCache { ...workflow.execution, subject: { ...workflow.execution.subject, - path: current.subject.local_path, + path: display.local_path, }, }, }); @@ -552,6 +557,13 @@ export class AnalysisSnapshotCache { binding = restored; } const cachedSubject = cached.execution.subject; + // The query ID commits to the snapshot target, including its selection, + // so a cached subject naming the target's bytes made the same selection. + // Snapshot subjects do not persist it yet (ADR target-identity slice 2d). + const selection = + cachedSubject?.sha256 === target.sha256 + ? binaryTargetSelection(target) + : null; const subject = cachedSubject == null ? null @@ -563,6 +575,7 @@ export class AnalysisSnapshotCache { ...(cachedSubject.architecture === null ? {} : { architecture: cachedSubject.architecture }), + ...(selection === null ? {} : { selection }), }, target, ); diff --git a/src/application/binary/BinarySessionBundleResources.test.ts b/src/application/binary/BinarySessionBundleResources.test.ts index 1727fda008..3bdd55b3c8 100644 --- a/src/application/binary/BinarySessionBundleResources.test.ts +++ b/src/application/binary/BinarySessionBundleResources.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { mkdir, mkdtemp, rm, stat, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; @@ -837,7 +838,7 @@ it("cancels a binary switch during resource retirement and retains null-subject const observed = await session.execute("inspect_plist", {}); if (!observed.ok) throw observed.error; const recorded = session.recordEvidence( - createEvidence(undefined, identity, { + createEvidence(unknownTarget("not-observed"), identity, { operation: "inspect_plist", parameters: {}, result: observed.value.result, @@ -871,7 +872,9 @@ it("cancels a binary switch during resource retirement and retains null-subject expect(result.error.cleanupIncomplete).toBe(true); expect(await session.status()).toMatchObject({ open: false }); expect(session.exportEvidenceBundle().records).toHaveLength(1); - expect(session.evidenceById(evidenceId)).toMatchObject({ subject: null }); + expect(session.evidenceById(evidenceId)).toMatchObject({ + subject: { identity: { kind: "unknown" } }, + }); expect(await session.status()).toMatchObject({ cleanup_pending: true }); expect(await session.close()).toMatchObject({ ok: true }); expect(resourceCloseAttempts).toBe(2); diff --git a/src/application/binary/BinarySessionExecution.ts b/src/application/binary/BinarySessionExecution.ts index d6086c982b..daca6e841b 100644 --- a/src/application/binary/BinarySessionExecution.ts +++ b/src/application/binary/BinarySessionExecution.ts @@ -9,6 +9,7 @@ import { ProviderAdapterError } from "../../domain/providerAdapterError.js"; import type { AnalysisError } from "../../domain/analysisErrorBase.js"; import type { JsonValue } from "../../domain/jsonValue.js"; import type { EvidenceSubjectTarget } from "../../domain/evidence.js"; +import { binaryTargetSelection } from "../../domain/targetIdentity.js"; import { err, ok, type Result } from "../../domain/result.js"; import type { AnalysisClient, @@ -203,16 +204,15 @@ export const bindExecutionTarget = ( target: BinaryTarget, ): Result => { if (!result.ok) return result; + const selection = binaryTargetSelection(target); const subject: EvidenceSubjectTarget = { path: target.path, sha256: target.sha256, - format: - target.format === "analysis-database" - ? "analysis-database" - : target.format, + format: target.format, ...(target.architecture === undefined ? {} : { architecture: target.architecture }), + ...(selection === null ? {} : { selection }), }; if ( result.value.subject !== undefined && @@ -226,8 +226,16 @@ export const bindExecutionTarget = ( `${operation}:subject`, ), ); - return result.value.subject === undefined - ? ok({ ...result.value, subject }) + const provided = result.value.subject; + if (provided === undefined) return ok({ ...result.value, subject }); + // A provider subject naming the target's own bytes and format is the + // target, so it makes the target's selection. + return provided !== null && + provided.selection === undefined && + selection !== null && + provided.sha256 === target.sha256 && + provided.format === target.format + ? ok({ ...result.value, subject: { ...provided, selection } }) : result; }; diff --git a/src/application/binary/BinarySessionInvestigation.test.ts b/src/application/binary/BinarySessionInvestigation.test.ts index 6f36281b6e..fd9dd83642 100644 --- a/src/application/binary/BinarySessionInvestigation.test.ts +++ b/src/application/binary/BinarySessionInvestigation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; import { expect, it, vi } from "vitest"; @@ -28,7 +29,7 @@ import { awaitAcknowledgement } from "../../../tests/fixtures/lifecycleAcknowled const observation = (label: string) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Lifecycle fixture", version: "1" }, { operation: label, parameters: {}, result: { fixture: label } }, ); diff --git a/src/application/binary/BinarySessionLiveness.test.ts b/src/application/binary/BinarySessionLiveness.test.ts index d323d39257..4c8a03de93 100644 --- a/src/application/binary/BinarySessionLiveness.test.ts +++ b/src/application/binary/BinarySessionLiveness.test.ts @@ -141,7 +141,9 @@ it("keeps unbound observations out of persisted target snapshots", async () => { expect(session.exportEvidenceBundle().records).toEqual( expect.arrayContaining([ expect.objectContaining({ - subject: null, + subject: expect.objectContaining({ + identity: { kind: "unknown", reason: "not-observed" }, + }), normalized_result: "unbound observation", }), ]), diff --git a/src/application/binary/SessionEvidenceReuse.ts b/src/application/binary/SessionEvidenceReuse.ts index fdb39a5d97..e5d5415698 100644 --- a/src/application/binary/SessionEvidenceReuse.ts +++ b/src/application/binary/SessionEvidenceReuse.ts @@ -1,3 +1,4 @@ +import { evidenceSubjectDisplay } from "../../domain/evidence.js"; import { basename } from "node:path"; import type { AnalysisExecution } from "../../ports/AnalysisProvider.js"; import type { Evidence } from "../../domain/evidence.js"; @@ -21,12 +22,13 @@ export const bindSessionEvidenceExecution = ( // Semantic IDs intentionally omit display paths and names. A duplicate in // the ledger can therefore refer to the same bytes at a different path. const selected = execution.subject; + const display = evidenceSubjectDisplay(evidence); if ( selected == null - ? evidence.subject !== null - : evidence.subject === null || - evidence.subject.local_path !== selected.path || - evidence.subject.name !== (basename(selected.path) || "artifact") + ? display !== undefined + : display === undefined || + display.local_path !== selected.path || + display.name !== (basename(selected.path) || "artifact") ) return execution; const subject = diff --git a/src/application/binary/TargetFormatVocabularies.test.ts b/src/application/binary/TargetFormatVocabularies.test.ts index 476111853e..689fa32f5b 100644 --- a/src/application/binary/TargetFormatVocabularies.test.ts +++ b/src/application/binary/TargetFormatVocabularies.test.ts @@ -155,8 +155,10 @@ describe("target format vocabularies", () => { result: { observed: true }, }); expect(parseEvidence(roundTrip(evidence)).subject).toMatchObject({ - format: target.format, - architecture: target.architecture ?? null, + identity: { + format: target.format, + architecture: target.architecture ?? null, + }, }); const bundle = createImmutableEvidenceBundle([evidence]); expect(parseEvidenceBundle(roundTrip(bundle)).artifacts).toEqual([ diff --git a/src/application/binaryDiagnostics/AppleIpsService.test.ts b/src/application/binaryDiagnostics/AppleIpsService.test.ts index 620ec493f6..d0c168965f 100644 --- a/src/application/binaryDiagnostics/AppleIpsService.test.ts +++ b/src/application/binaryDiagnostics/AppleIpsService.test.ts @@ -149,7 +149,7 @@ it("records the selected report as a file subject", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "file" }, + subject: { identity: { format: "file" } }, normalized_result: report, }); }); diff --git a/src/application/binaryDiagnostics/BinaryHardeningService.test.ts b/src/application/binaryDiagnostics/BinaryHardeningService.test.ts index b2736ab2b9..5414683734 100644 --- a/src/application/binaryDiagnostics/BinaryHardeningService.test.ts +++ b/src/application/binaryDiagnostics/BinaryHardeningService.test.ts @@ -72,7 +72,7 @@ it("returns derived Evidence for a multi-field ELF row", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "derived", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: value, }); expect(result.value.limitations).toEqual([...BINARY_HARDENING_LIMITATIONS]); @@ -101,8 +101,7 @@ it("labels one Mach-O slice as a universal image and omits derived confidence", if (!result.ok) throw result.error; expect(result.value.confidence).toBe("observed"); expect(result.value.subject).toMatchObject({ - format: "mach-o-universal", - architecture: "arm64", + identity: { format: "mach-o-universal", architecture: "arm64" }, }); expect(result.value.locations).toEqual([ { kind: "artifact-path", path: value.artifact.path }, @@ -138,8 +137,7 @@ it("omits architecture when more than one slice is present", async () => { const result = await service(value).inspect({ path: value.artifact.path }); if (!result.ok) throw result.error; expect(result.value.subject).toMatchObject({ - format: "mach-o-universal", - architecture: null, + identity: { format: "mach-o-universal", architecture: null }, }); }); diff --git a/src/application/binaryDiagnostics/BinaryLayoutService.test.ts b/src/application/binaryDiagnostics/BinaryLayoutService.test.ts index abc48fad93..ea88afa0e8 100644 --- a/src/application/binaryDiagnostics/BinaryLayoutService.test.ts +++ b/src/application/binaryDiagnostics/BinaryLayoutService.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { BinaryLayoutService } from "./BinaryLayoutService.js"; import { @@ -75,7 +76,9 @@ it.each([ }); const result = await service.inspect({ path: layout.artifact.path }); if (!result.ok) throw result.error; - expect(parseEvidence(result.value).subject?.architecture).toBe(expected); + expect(fileIdentity(parseEvidence(result.value).subject).architecture).toBe( + expected, + ); }, ); diff --git a/src/application/binaryDiagnostics/ByteEntropyService.test.ts b/src/application/binaryDiagnostics/ByteEntropyService.test.ts index e9187ef579..fe91bd5a2a 100644 --- a/src/application/binaryDiagnostics/ByteEntropyService.test.ts +++ b/src/application/binaryDiagnostics/ByteEntropyService.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { open, stat, rename, symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -31,7 +32,9 @@ it("keeps whole-file identity and entropy while selecting unaligned blocks and a bytes: 1024, sha256: createHash("sha256").update(bytes).digest("hex"), }); - expect(result.value.subject?.digest.sha256).toBe(report.artifact.sha256); + expect(fileIdentity(result.value.subject).sha256).toBe( + report.artifact.sha256, + ); expect(result.value.confidence).toBe("observed"); }); diff --git a/src/application/binaryDiagnostics/ElfNotesService.test.ts b/src/application/binaryDiagnostics/ElfNotesService.test.ts index a682610ab6..93b568066d 100644 --- a/src/application/binaryDiagnostics/ElfNotesService.test.ts +++ b/src/application/binaryDiagnostics/ElfNotesService.test.ts @@ -55,7 +55,7 @@ it("records the selected ELF and an absent note table", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, }); }); diff --git a/src/application/binaryDiagnostics/ElfUnwindRangesService.test.ts b/src/application/binaryDiagnostics/ElfUnwindRangesService.test.ts index e14180b5e0..d106d29505 100644 --- a/src/application/binaryDiagnostics/ElfUnwindRangesService.test.ts +++ b/src/application/binaryDiagnostics/ElfUnwindRangesService.test.ts @@ -89,7 +89,7 @@ it("records an absent unwind table for the selected ELF", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, }); expect(result.value.locations).toEqual([ diff --git a/src/application/binaryDiagnostics/KernelModuleService.test.ts b/src/application/binaryDiagnostics/KernelModuleService.test.ts index 612ba4d2fc..353f453fdb 100644 --- a/src/application/binaryDiagnostics/KernelModuleService.test.ts +++ b/src/application/binaryDiagnostics/KernelModuleService.test.ts @@ -110,7 +110,7 @@ it("records an applicable module and its x86_64 architecture", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, }); }); @@ -186,7 +186,7 @@ it("retains a completed observation if the caller cancels while the provider com expect(parseEvidence(late.error.partialObservation)).toMatchObject({ operation: "inspect_kernel_module", confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, }); }); diff --git a/src/application/binaryDiagnostics/NativeInitializersService.test.ts b/src/application/binaryDiagnostics/NativeInitializersService.test.ts index b89ef02ad5..4daeacb851 100644 --- a/src/application/binaryDiagnostics/NativeInitializersService.test.ts +++ b/src/application/binaryDiagnostics/NativeInitializersService.test.ts @@ -101,7 +101,7 @@ it("records the selected image and each slot range as Evidence", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, locations: [ { kind: "artifact-path", path: report.artifact.path }, @@ -134,7 +134,9 @@ it.each(["arm64", "x86_64", undefined] as const)( return; } expect(result.value).toMatchObject({ - subject: { format: "mach-o-universal", architecture: "arm64" }, + subject: { + identity: { format: "mach-o-universal", architecture: "arm64" }, + }, normalized_result: parsed, parameters: { architecture: "arm64" }, }); diff --git a/src/application/binaryDiagnostics/PeLoadConfigService.test.ts b/src/application/binaryDiagnostics/PeLoadConfigService.test.ts index dd2de934ab..509cfda4c7 100644 --- a/src/application/binaryDiagnostics/PeLoadConfigService.test.ts +++ b/src/application/binaryDiagnostics/PeLoadConfigService.test.ts @@ -58,7 +58,7 @@ it("retains absent directories and artifact provenance", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "pe", architecture: "x86_64" }, + subject: { identity: { format: "pe", architecture: "x86_64" } }, normalized_result: report, }); }); diff --git a/src/application/binaryDiagnostics/PeResourcesService.test.ts b/src/application/binaryDiagnostics/PeResourcesService.test.ts index 355110a195..919e92dd75 100644 --- a/src/application/binaryDiagnostics/PeResourcesService.test.ts +++ b/src/application/binaryDiagnostics/PeResourcesService.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { expect, it } from "vitest"; import { PeResourcesService } from "./PeResourcesService.js"; @@ -95,7 +96,9 @@ it.each([ }); const result = await service.inspect({ path: report.artifact.path }); if (!result.ok) throw result.error; - expect(result.value.subject?.architecture ?? null).toBe(architecture); + expect(fileIdentity(result.value.subject).architecture ?? null).toBe( + architecture, + ); }, ); @@ -122,7 +125,7 @@ it("retains a completed observation on late cancellation and keeps output errors expect(late.error.cause).toBe(reason); expect(parseEvidence(late.error.partialObservation)).toMatchObject({ operation: "inspect_pe_resources", - subject: { architecture: "x86" }, + subject: { identity: { architecture: "x86" } }, normalized_result: report, }); } diff --git a/src/application/binaryDiagnostics/RecordedCrashService.test.ts b/src/application/binaryDiagnostics/RecordedCrashService.test.ts index bb9783b742..06cc792a3a 100644 --- a/src/application/binaryDiagnostics/RecordedCrashService.test.ts +++ b/src/application/binaryDiagnostics/RecordedCrashService.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { RecordedCrashService } from "./RecordedCrashService.js"; import { @@ -49,7 +50,9 @@ it.each([ include_debugger_context: false, }); if (!result.ok) throw result.error; - expect(parseEvidence(result.value).subject?.architecture).toBe(expected); + expect(fileIdentity(parseEvidence(result.value).subject).architecture).toBe( + expected, + ); }, ); diff --git a/src/application/binaryDiagnostics/WindowsShortcutService.test.ts b/src/application/binaryDiagnostics/WindowsShortcutService.test.ts index ba9b98b000..f49aecee79 100644 --- a/src/application/binaryDiagnostics/WindowsShortcutService.test.ts +++ b/src/application/binaryDiagnostics/WindowsShortcutService.test.ts @@ -58,7 +58,7 @@ it("records the selected shortcut as a file subject", async () => { if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "file" }, + subject: { identity: { format: "file" } }, normalized_result: report, }); }); diff --git a/src/application/desktop/DesktopApplicationCapture.ts b/src/application/desktop/DesktopApplicationCapture.ts index 3e45f3ef71..1f918eaf52 100644 --- a/src/application/desktop/DesktopApplicationCapture.ts +++ b/src/application/desktop/DesktopApplicationCapture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { processInspectionCleanupFailures } from "../../process/ProcessInspectionCleanup.js"; import { samplingInspectionFailures } from "../../process/capture/ProcessSamplingObservation.js"; import type { DesktopLibraryPolicyInput } from "../../domain/desktop/libraryPolicy.js"; @@ -173,7 +174,7 @@ const captureEvidence = ( request: DesktopCaptureRequest, capture: DesktopApplicationCapture, ): Evidence => - createEvidence(undefined, DESKTOP_PROVIDER, { + createEvidence(unknownTarget("not-observed"), DESKTOP_PROVIDER, { predicateType: "rea.desktop-application-capture", operation: DESKTOP_OPERATION, parameters: { diff --git a/src/application/desktop/DesktopApplicationExport.ts b/src/application/desktop/DesktopApplicationExport.ts index 6f97d14dda..4852ac233f 100644 --- a/src/application/desktop/DesktopApplicationExport.ts +++ b/src/application/desktop/DesktopApplicationExport.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { DesktopViewPolicyInput } from "../../domain/desktop/desktopViewPolicy.js"; import { AnalysisError } from "../../domain/analysisErrorBase.js"; import type { DownloadInstall } from "../../domain/desktop/appDownloadInstall.js"; @@ -577,46 +578,50 @@ export const exportDesktopApplication = async ( copyCompletion, copyFailure, } = await runExport(request, readers, signal); - const evidence = createEvidence(undefined, DESKTOP_PROVIDER, { - predicateType: "rea.desktop-application-export", - operation: OPERATION, - parameters: { - capture_evidence_id: captureEvidenceId, - named: request.name !== undefined, - tasks: request.tasks.length, - task_ends: [...(request.taskEnds ?? [])], - package_url: request.packageUrl !== undefined, - download_install: request.downloadInstall !== undefined, - extra_packages: [...(request.extraPackages ?? [])], - seed_checkpoint: request.seedCheckpoint ?? null, - end_checkpoint: request.endCheckpoint ?? null, - synthetic_seed: request.syntheticSeed === true, - withhold_from: request.withhold?.from ?? null, - withhold_to: request.withhold?.to ?? null, - withhold_paths: [...(request.withhold?.paths ?? [])], - seed_withheld: request.seedWithheld === true, - ...(request.viewPolicy === undefined - ? {} - : { view_policy: { ...request.viewPolicy } }), - }, - result: { - ...result, - checkpoints: { ...result.checkpoints }, - paths: [...result.paths], - seed_files: [...result.seed_files], - unseeded_files: [...result.unseeded_files], - scrubbed_files: [...result.scrubbed_files], - recompressed_files: [...result.recompressed_files], - unscrubbed_files: [...result.unscrubbed_files], - files: [...result.files], + const evidence = createEvidence( + unknownTarget("not-observed"), + DESKTOP_PROVIDER, + { + predicateType: "rea.desktop-application-export", + operation: OPERATION, + parameters: { + capture_evidence_id: captureEvidenceId, + named: request.name !== undefined, + tasks: request.tasks.length, + task_ends: [...(request.taskEnds ?? [])], + package_url: request.packageUrl !== undefined, + download_install: request.downloadInstall !== undefined, + extra_packages: [...(request.extraPackages ?? [])], + seed_checkpoint: request.seedCheckpoint ?? null, + end_checkpoint: request.endCheckpoint ?? null, + synthetic_seed: request.syntheticSeed === true, + withhold_from: request.withhold?.from ?? null, + withhold_to: request.withhold?.to ?? null, + withhold_paths: [...(request.withhold?.paths ?? [])], + seed_withheld: request.seedWithheld === true, + ...(request.viewPolicy === undefined + ? {} + : { view_policy: { ...request.viewPolicy } }), + }, + result: { + ...result, + checkpoints: { ...result.checkpoints }, + paths: [...result.paths], + seed_files: [...result.seed_files], + unseeded_files: [...result.unseeded_files], + scrubbed_files: [...result.scrubbed_files], + recompressed_files: [...result.recompressed_files], + unscrubbed_files: [...result.unscrubbed_files], + files: [...result.files], + limitations: [...result.limitations], + withheld_files: result.withheld_files.map((file) => ({ ...file })), + consented_files: [...result.consented_files], + }, + confidence: "derived", + authority: "analyst-inference", limitations: [...result.limitations], - withheld_files: result.withheld_files.map((file) => ({ ...file })), - consented_files: [...result.consented_files], }, - confidence: "derived", - authority: "analyst-inference", - limitations: [...result.limitations], - }); + ); return ( publishedExportFailure( request, diff --git a/src/application/desktop/DesktopApplicationState.test.ts b/src/application/desktop/DesktopApplicationState.test.ts index 8e40ecdad8..c29205b2d9 100644 --- a/src/application/desktop/DesktopApplicationState.test.ts +++ b/src/application/desktop/DesktopApplicationState.test.ts @@ -14,6 +14,7 @@ import { primaryAnalysisError, } from "../../domain/analysisErrorBase.js"; import { EvidenceFileError } from "../../domain/evidenceErrors.js"; +import { RECREATE_EVIDENCE_GUIDANCE } from "../../domain/evidenceFormat.js"; import { ArtifactResourceScope } from "../../resources/ArtifactResourceScope.js"; import { OwnedFileHandle } from "../../filesystem/OwnedFileHandle.js"; import { PrivateRuntimeRoot } from "../../process/PrivateRuntimeRoot.js"; @@ -204,6 +205,22 @@ it("records the complete effective view policy and refuses state without it", as ); }); +it("refuses a capture from an earlier format revision with the recreate guidance", async () => { + const folder = await writeCaptureFolder(capture()); + const path = join(folder, "capture.json"); + const { evidence_format: _current, ...earlier } = JSON.parse( + await readFile(path, "utf8"), + ) as Record; + await writeFile(path, JSON.stringify(earlier)); + + const refused = await inspectDesktopApplicationState(folder, readers); + + expect(refused).toBeInstanceOf(Error); + expect(refused instanceof Error ? refused.message : "").toContain( + RECREATE_EVIDENCE_GUIDANCE, + ); +}); + describe("inspectDesktopApplicationState", () => { it("assigns roles and reads each version into typed views and changes", async () => { const folder = await writeCaptureFolder(capture()); diff --git a/src/application/desktop/DesktopApplicationState.ts b/src/application/desktop/DesktopApplicationState.ts index 606376bd3a..0f30fdf896 100644 --- a/src/application/desktop/DesktopApplicationState.ts +++ b/src/application/desktop/DesktopApplicationState.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { desktopViewPolicy, desktopViewPolicyInputSchema, @@ -43,7 +44,11 @@ import { stateRole, } from "../../domain/desktop/stateRoles.js"; import { createEvidence, type Evidence } from "../../domain/evidence.js"; -import { safeParseEvidence } from "../../domain/evidenceValidation.js"; +import { + safeParseEvidence, + unsupportedEvidenceFormatError, +} from "../../domain/evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../../domain/evidenceFormat.js"; import type { JsonValue } from "../../domain/jsonValue.js"; import { err, ok, type Result } from "../../domain/result.js"; import { describeValidationFailure } from "../../domain/validationFailure.js"; @@ -117,6 +122,10 @@ export const readDesktopCapture = async ( ); } const evidence = safeParseEvidence(loaded.value); + // A capture from another format revision is refused with the recreate + // guidance, not reported as some other kind of file. + if (!evidence.ok && isUnsupportedEvidenceFormat(evidence.error)) + throw unsupportedEvidenceFormatError(evidence.error); if ( !evidence.ok || evidence.value.operation !== DESKTOP_OPERATION || @@ -551,7 +560,7 @@ const inspectState = async ( limitations, }; if (signal?.aborted === true) throw cancelledBy(OPERATION, signal); - return createEvidence(undefined, DESKTOP_PROVIDER, { + return createEvidence(unknownTarget("not-observed"), DESKTOP_PROVIDER, { predicateType: "rea.desktop-application-state", operation: OPERATION, parameters: { diff --git a/src/application/desktop/DesktopBuildOutputRead.test.ts b/src/application/desktop/DesktopBuildOutputRead.test.ts index 8819f9ad72..d51d6a9172 100644 --- a/src/application/desktop/DesktopBuildOutputRead.test.ts +++ b/src/application/desktop/DesktopBuildOutputRead.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { AnalysisResourceConstraintError } from "../../domain/analysisErrorCore.js"; @@ -119,7 +120,7 @@ describe("endedCapture", () => { }; const body = Buffer.from( JSON.stringify( - createEvidence(undefined, DESKTOP_PROVIDER, { + createEvidence(unknownTarget("not-observed"), DESKTOP_PROVIDER, { predicateType: "rea.desktop-application-capture", operation: DESKTOP_OPERATION, parameters: {}, diff --git a/src/application/desktop/DesktopBuildWitnessRecord.ts b/src/application/desktop/DesktopBuildWitnessRecord.ts index 09dc2b30b7..35362cd0af 100644 --- a/src/application/desktop/DesktopBuildWitnessRecord.ts +++ b/src/application/desktop/DesktopBuildWitnessRecord.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { join } from "node:path"; import { Readable } from "node:stream"; @@ -318,22 +319,26 @@ export const writeWitnessRecord = async ( const result = redact( recorded as unknown as JsonValue, ) as unknown as typeof recorded; - const evidence = createEvidence(undefined, DESKTOP_PROVIDER, { - predicateType: "rea.desktop-build-witness", - operation: CHECK, - parameters: { task: result.task.name, stages: witness.stages.length }, - result: result as unknown as JsonValue, - confidence: "observed", - authority: "controlled-replay", - limitations: [ - howChecked(witness.task), - ...("error" in recording - ? [`The recording is missing: ${recording.error}`] - : []), - ...logLimitations(actions, dropped), - ...unsettledLimitation(result.stages), - ], - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + DESKTOP_PROVIDER, + { + predicateType: "rea.desktop-build-witness", + operation: CHECK, + parameters: { task: result.task.name, stages: witness.stages.length }, + result: result as unknown as JsonValue, + confidence: "observed", + authority: "controlled-replay", + limitations: [ + howChecked(witness.task), + ...("error" in recording + ? [`The recording is missing: ${recording.error}`] + : []), + ...logLimitations(actions, dropped), + ...unsettledLimitation(result.stages), + ], + }, + ); const files = [ ...("segments" in recording ? recording.segments.flatMap((target, index) => { diff --git a/src/application/desktop/DesktopSqliteState.test.ts b/src/application/desktop/DesktopSqliteState.test.ts index 7188fc2a11..3a241c19e1 100644 --- a/src/application/desktop/DesktopSqliteState.test.ts +++ b/src/application/desktop/DesktopSqliteState.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import type { AnalysisError } from "../../domain/analysisErrorBase.js"; @@ -75,7 +76,7 @@ const service = (failure: (table: string) => AnalysisError | undefined) => ({ if (refused !== undefined) return err(refused); return ok( createEvidence( - undefined, + unknownTarget("not-observed"), { id: "sqlite", name: "SQLite", version: "1" }, { operation: OPERATION, @@ -114,7 +115,7 @@ describe("readSqliteStateView", () => { } return ok( createEvidence( - undefined, + unknownTarget("not-observed"), { id: "sqlite", name: "SQLite", version: "1" }, { operation: OPERATION, diff --git a/src/application/desktop/DesktopTaskDraft.ts b/src/application/desktop/DesktopTaskDraft.ts index c731cdf51a..7a533daf63 100644 --- a/src/application/desktop/DesktopTaskDraft.ts +++ b/src/application/desktop/DesktopTaskDraft.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { DesktopViewPolicyInput } from "../../domain/desktop/desktopViewPolicy.js"; import { AnalysisError } from "../../domain/analysisErrorBase.js"; import { exportedStateFiles } from "../../domain/desktop/appExport.js"; @@ -160,7 +161,7 @@ const draft = async ( .sort(), } as unknown as JsonValue; if (signal?.aborted === true) throw cancelledBy(OPERATION, signal); - return createEvidence(undefined, DESKTOP_PROVIDER, { + return createEvidence(unknownTarget("not-observed"), DESKTOP_PROVIDER, { predicateType: "rea.desktop-application-task-draft", operation: OPERATION, parameters: { diff --git a/src/application/desktop/desktopCapture.fixture.ts b/src/application/desktop/desktopCapture.fixture.ts index da4ab47e0d..5619bc05f6 100644 --- a/src/application/desktop/desktopCapture.fixture.ts +++ b/src/application/desktop/desktopCapture.fixture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { mkdir, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -267,14 +268,18 @@ export const writeCaptureFolder = async ( ...extraContent, ]) await writeFile(join(folder, "content", sha256(text)), text); - const evidence = createEvidence(undefined, DESKTOP_PROVIDER, { - predicateType: "rea.desktop-application-capture", - operation, - parameters: {}, - result, - confidence: "observed", - authority: "controlled-replay", - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + DESKTOP_PROVIDER, + { + predicateType: "rea.desktop-application-capture", + operation, + parameters: {}, + result, + confidence: "observed", + authority: "controlled-replay", + }, + ); await writeFile(join(folder, "capture.json"), JSON.stringify(evidence)); return folder; }; diff --git a/src/application/electron/ElectronFuseService.test.ts b/src/application/electron/ElectronFuseService.test.ts index 16c693f509..fadd9d458d 100644 --- a/src/application/electron/ElectronFuseService.test.ts +++ b/src/application/electron/ElectronFuseService.test.ts @@ -51,8 +51,10 @@ it("retains completed fuse Evidence when the provider completes after abort", as provider: identity, subject: { local_path: report.artifact.resolved_path, - digest: { sha256: report.artifact.sha256 }, - format: report.artifact.format, + identity: { + sha256: report.artifact.sha256, + format: report.artifact.format, + }, }, parameters: { path: report.artifact.selected_path }, confidence: "observed", diff --git a/src/application/environment/environmentSource.test.ts b/src/application/environment/environmentSource.test.ts index af8e925a11..1426b633c5 100644 --- a/src/application/environment/environmentSource.test.ts +++ b/src/application/environment/environmentSource.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { describe, expect, it } from "vitest"; @@ -109,7 +110,7 @@ const resealed = ( unknown >; edit(result); - return createEvidence(undefined, evidence.provider, { + return createEvidence(unknownTarget("not-observed"), evidence.provider, { operation, parameters: structuredClone(evidence.parameters), result: result as never, @@ -279,12 +280,16 @@ describe("loadEnvironmentSource payload attribution", () => { "inspect_web_network_capture", "capture_browser_scenario", ]) { - const capture = createEvidence(undefined, fixture.capture.provider, { - operation, - parameters: {}, - result: {}, - confidence: "observed", - }); + const capture = createEvidence( + unknownTarget("not-observed"), + fixture.capture.provider, + { + operation, + parameters: {}, + result: {}, + confidence: "observed", + }, + ); for (const command of ["environment-serve", "environment-export"]) { const loaded = loadEnvironmentSource( citing(fixture.manifest, capture), diff --git a/src/application/environment/environmentSource.ts b/src/application/environment/environmentSource.ts index 3299a12347..14d6c219e0 100644 --- a/src/application/environment/environmentSource.ts +++ b/src/application/environment/environmentSource.ts @@ -26,7 +26,11 @@ import { type AnalysisInputIssue, } from "../../domain/analysisErrorCore.js"; import type { Evidence } from "../../domain/evidence.js"; -import { safeParseImmutableEvidence } from "../../domain/evidenceValidation.js"; +import { + safeParseImmutableEvidence, + unsupportedEvidenceFormatError, +} from "../../domain/evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../../domain/evidenceFormat.js"; import { parseExactJson } from "../../domain/exactJsonNumber.js"; import { projectInputIssues } from "../../domain/inputIssueProjection.js"; import { immutableJsonSnapshotMember } from "../../domain/immutableJson.js"; @@ -145,15 +149,16 @@ export const parseEvidenceFile = ( for (const key of ["parameters", "raw_result", "normalized_result"]) immutableJsonSnapshotMember(value, key); const parsed = safeParseImmutableEvidence(value); - return parsed.ok - ? parsed - : err( - schemaInputError( - operation, - { prefix: [role], cause: parsed.error, value }, - `The ${role} file is not authenticated REA Evidence JSON.`, - ), - ); + if (parsed.ok) return parsed; + if (isUnsupportedEvidenceFormat(parsed.error)) + return err(unsupportedEvidenceFormatError(parsed.error)); + return err( + schemaInputError( + operation, + { prefix: [role], cause: parsed.error, value }, + `The ${role} file is not authenticated REA Evidence JSON.`, + ), + ); }; /** A schema refusal of `value`, found at `prefix`; issue paths extend the prefix and the schema failure is retained. */ diff --git a/src/application/frida/FridaInstrumentationService.ts b/src/application/frida/FridaInstrumentationService.ts index 0bafd438a3..349a79cabd 100644 --- a/src/application/frida/FridaInstrumentationService.ts +++ b/src/application/frida/FridaInstrumentationService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { constants } from "node:fs"; import { access, stat } from "node:fs/promises"; import { setTimeout as delay } from "node:timers/promises"; @@ -454,7 +455,7 @@ const fridaEvidence = ( script?: FridaScriptObservation, ): Evidence => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "frida", name: "Frida", version: null }, { predicateType: "rea.frida.instrumentation-observation", diff --git a/src/application/go/GoBinaryService.test.ts b/src/application/go/GoBinaryService.test.ts index a13a8e03c4..4824e1a5ec 100644 --- a/src/application/go/GoBinaryService.test.ts +++ b/src/application/go/GoBinaryService.test.ts @@ -76,9 +76,8 @@ it("preserves unsupported subject architectures and does not duplicate metadata" const result = await service.inspect({ path: report.artifact.path }); if (!result.ok) throw result.error; expect(result.value.subject).toMatchObject({ - architecture: null, local_path: report.artifact.path, - digest: { sha256: report.artifact.sha256 }, + identity: { architecture: null, sha256: report.artifact.sha256 }, }); expect(result.value.normalized_result).toEqual(report); expect(result.value.raw_result).toBeNull(); diff --git a/src/application/il2cpp/Il2cppMetadataService.test.ts b/src/application/il2cpp/Il2cppMetadataService.test.ts index 9aeef5c3a0..fd7bf9c794 100644 --- a/src/application/il2cpp/Il2cppMetadataService.test.ts +++ b/src/application/il2cpp/Il2cppMetadataService.test.ts @@ -100,9 +100,8 @@ it("returns explicit complete artifact-bound Evidence without retention", async expect(result.value.parameters).toEqual({ path: report.artifact.path }); expect(result.value.normalized_result).toEqual(report); expect(result.value.subject).toMatchObject({ - format: "file", local_path: report.artifact.path, - digest: { sha256: report.artifact.sha256 }, + identity: { format: "file", sha256: report.artifact.sha256 }, }); }); diff --git a/src/application/investigation/EvidenceLedger.residualUnknown.test.ts b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts index e8224debbe..c792f38c0c 100644 --- a/src/application/investigation/EvidenceLedger.residualUnknown.test.ts +++ b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createHash } from "node:crypto"; import canonicalize from "canonicalize"; @@ -28,7 +29,7 @@ const evidence = ( label: string, confidence: "observed" | "derived" | "inferred" = "derived", ) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: label, parameters: {}, result: { label }, diff --git a/src/application/investigation/EvidenceLedger.test.ts b/src/application/investigation/EvidenceLedger.test.ts index 3a7a90aeae..9386d92f3a 100644 --- a/src/application/investigation/EvidenceLedger.test.ts +++ b/src/application/investigation/EvidenceLedger.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import type { BinaryTarget } from "../../domain/binaryTargetTypes.js"; @@ -375,12 +376,12 @@ describe("evidence bundle imports", () => { it("atomically rejects Evidence plus an invalid unknown", () => { const ledger = new EvidenceLedger(); - const output = createEvidence(undefined, PROVIDER, { + const output = createEvidence(unknownTarget("not-observed"), PROVIDER, { operation: "derived", parameters: {}, result: { status: "unknown" }, }); - const mutation = createEvidence(undefined, PROVIDER, { + const mutation = createEvidence(unknownTarget("not-observed"), PROVIDER, { predicateType: "rea.residual-unknown-mutation", operation: "record_unknown", parameters: {}, diff --git a/src/application/investigation/EvidenceLedger.ts b/src/application/investigation/EvidenceLedger.ts index ae589ac16e..4c9674b441 100644 --- a/src/application/investigation/EvidenceLedger.ts +++ b/src/application/investigation/EvidenceLedger.ts @@ -21,6 +21,7 @@ import { UnknownRegistryError } from "../../domain/unknownRegistryError.js"; import { isImmutableEvidence, evidenceDisplayMetadataAgree, + evidenceFileTarget, type Evidence, } from "../../domain/evidence.js"; import { freezeJsonSnapshot } from "../../domain/immutableJson.js"; @@ -317,7 +318,7 @@ export class EvidenceLedger { unknown = createResidualUnknown( input, parsedMutation.evidence_id, - parsedMutation.subject?.digest.sha256 ?? null, + evidenceFileTarget(parsedMutation)?.sha256 ?? null, ); } catch (cause: unknown) { if (!(cause instanceof z.ZodError)) throw cause; @@ -362,7 +363,7 @@ export class EvidenceLedger { unknown = createResidualUnknown( input, mutation.evidence_id, - mutation.subject?.digest.sha256 ?? null, + evidenceFileTarget(mutation)?.sha256 ?? null, ); } catch (cause: unknown) { if (!(cause instanceof z.ZodError)) throw cause; diff --git a/src/application/investigation/FunctionComparisonEvidence.ts b/src/application/investigation/FunctionComparisonEvidence.ts index d432bf2f5b..bef6f151ec 100644 --- a/src/application/investigation/FunctionComparisonEvidence.ts +++ b/src/application/investigation/FunctionComparisonEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { functionComparisonInputSchema } from "../../domain/functionComparisonSchemas.js"; import { FUNCTION_COMPARISON_PROFILE, @@ -50,20 +51,24 @@ export const compareFunctionEvidence = ( const rightEvidence = right.value.evidence; const leftIds = [leftEvidence.evidence_id]; const rightIds = [rightEvidence.evidence_id]; - const evidence = createEvidence(undefined, FUNCTION_COMPARISON_PROVIDER, { - predicateType: "rea.function-comparison", - operation: "compare_functions", - analysisProfile: FUNCTION_COMPARISON_PROFILE, - parameters: { - left_evidence_id: leftEvidence.evidence_id, - right_evidence_id: rightEvidence.evidence_id, + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + FUNCTION_COMPARISON_PROVIDER, + { + predicateType: "rea.function-comparison", + operation: "compare_functions", + analysisProfile: FUNCTION_COMPARISON_PROFILE, + parameters: { + left_evidence_id: leftEvidence.evidence_id, + right_evidence_id: rightEvidence.evidence_id, + }, + result: comparison, + confidence: "derived", + authority: "analyst-inference", + limitations: comparison.limitations, + evidenceLinks: [...leftIds, ...rightIds], }, - result: comparison, - confidence: "derived", - authority: "analyst-inference", - limitations: comparison.limitations, - evidenceLinks: [...leftIds, ...rightIds], - }); + ); return ok({ evidence, sources: [leftEvidence, rightEvidence], diff --git a/src/application/investigation/InvestigationRecords.test.ts b/src/application/investigation/InvestigationRecords.test.ts index 9c9d88be42..7419fec670 100644 --- a/src/application/investigation/InvestigationRecords.test.ts +++ b/src/application/investigation/InvestigationRecords.test.ts @@ -1,3 +1,5 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { @@ -24,7 +26,7 @@ const unknownInput = (question: string) => recommended_probes: [], relationships: [], }); -const evidence = createEvidence(undefined, provider, { +const evidence = createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect-fixture", parameters: {}, result: true, @@ -85,7 +87,7 @@ describe("investigation record ownership", () => { unknownMutationEvidence(undefined, { operation: "record_unknown", input }) .evidence_id, ); - expect(mutation?.subject).toBeNull(); + expect(mutation?.subject.identity.kind).toBe("unknown"); expect(mutation?.parameters).toEqual(input); expect(records.listUnknowns()).toHaveLength(2); }); @@ -131,8 +133,10 @@ describe("investigation record ownership", () => { }); const bundle = records.exportEvidenceBundle(); expect( - bundle.records.find(({ operation }) => operation === "update_unknown") - ?.subject?.digest.sha256, + fileIdentity( + bundle.records.find(({ operation }) => operation === "update_unknown") + ?.subject, + ).sha256, ).toBe(target.sha256); expect( bundle.records.find(({ operation }) => operation === "update_unknown") @@ -250,7 +254,7 @@ it("rejects changed creation intent after the original unknown was updated", () }); if (!updated.ok) throw updated.error; const retained = records.exportEvidenceBundle(); - const addition = createEvidence(undefined, provider, { + const addition = createEvidence(unknownTarget("not-observed"), provider, { operation: "another-derived-result", parameters: {}, result: true, diff --git a/src/application/investigation/InvestigationRetention.test.ts b/src/application/investigation/InvestigationRetention.test.ts index 7b212abfd4..710729c041 100644 --- a/src/application/investigation/InvestigationRetention.test.ts +++ b/src/application/investigation/InvestigationRetention.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it, vi } from "vitest"; import { createEvidence, type Evidence } from "../../domain/evidence.js"; @@ -82,7 +83,7 @@ it("returns only authenticated Evidence when a completed record exceeds retentio if (invalid.ok) throw new Error("Expected integrity refusal"); expect(invalid.error._tag).toBe("EvidenceIntegrityError"); expect(invalid.error.partialObservation).toBeUndefined(); - const mutable = createEvidence(undefined, provider, { + const mutable = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: { value: 1 }, diff --git a/src/application/investigation/InvestigationWorkflows.ts b/src/application/investigation/InvestigationWorkflows.ts index 74be84dd50..5cdccae86a 100644 --- a/src/application/investigation/InvestigationWorkflows.ts +++ b/src/application/investigation/InvestigationWorkflows.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { callPathRequestSchema, staticRuntimeCorrelationRequestSchema, @@ -90,22 +91,26 @@ export const buildCallPathEvidence = ( sources, ); if (!closure.ok) return closure; - const evidence = createEvidence(undefined, CALL_PATH_PROVIDER, { - predicateType: "rea.call-path", - operation: "build_call_path", - analysisProfile: createAnalysisProfile(CALL_PATH_PROVIDER, { - workflow_revision: 2, - }), - parameters: { - start: selected.value.input.start.address, - goal: selected.value.input.goal.address, + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + CALL_PATH_PROVIDER, + { + predicateType: "rea.call-path", + operation: "build_call_path", + analysisProfile: createAnalysisProfile(CALL_PATH_PROVIDER, { + workflow_revision: 2, + }), + parameters: { + start: selected.value.input.start.address, + goal: selected.value.input.goal.address, + }, + result, + confidence: "derived", + authority: "analyst-inference", + limitations: result.limitations, + evidenceLinks: closure.value, }, - result, - confidence: "derived", - authority: "analyst-inference", - limitations: result.limitations, - evidenceLinks: closure.value, - }); + ); return finish(evidence, sources, result.status === "unknown", { question: "Can the requested call path be established from complete analysis?", @@ -155,16 +160,20 @@ export const findChangedBehaviorEvidence = ( sources, ); if (!closure.ok) return closure; - const evidence = createEvidence(undefined, CHANGED_BEHAVIOR_PROVIDER, { - predicateType: "rea.changed-behavior", - operation: "find_changed_behavior", - parameters: { comparison_evidence_ids: [...comparisonEvidenceIds] }, - result, - confidence: "derived", - authority: "analyst-inference", - limitations: result.limitations, - evidenceLinks: closure.value, - }); + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + CHANGED_BEHAVIOR_PROVIDER, + { + predicateType: "rea.changed-behavior", + operation: "find_changed_behavior", + parameters: { comparison_evidence_ids: [...comparisonEvidenceIds] }, + result, + confidence: "derived", + authority: "analyst-inference", + limitations: result.limitations, + evidenceLinks: closure.value, + }, + ); return finish( evidence, sources, @@ -221,16 +230,20 @@ export const correlateStaticAndRuntimeEvidence = ( sources, ); if (!closure.ok) return closure; - const evidence = createEvidence(undefined, STATIC_RUNTIME_PROVIDER, { - predicateType: "rea.static-runtime-correlation", - operation: "correlate_static_and_runtime", - parameters: { mapping_count: selected.value.input.mappings.length }, - result, - confidence: "inferred", - authority: "analyst-inference", - limitations: result.limitations, - evidenceLinks: closure.value, - }); + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + STATIC_RUNTIME_PROVIDER, + { + predicateType: "rea.static-runtime-correlation", + operation: "correlate_static_and_runtime", + parameters: { mapping_count: selected.value.input.mappings.length }, + result, + confidence: "inferred", + authority: "analyst-inference", + limitations: result.limitations, + evidenceLinks: closure.value, + }, + ); return finish( evidence, sources, diff --git a/src/application/investigation/UnknownEvidence.ts b/src/application/investigation/UnknownEvidence.ts index 219663b8a2..4ffe2df684 100644 --- a/src/application/investigation/UnknownEvidence.ts +++ b/src/application/investigation/UnknownEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { BinaryTarget } from "../../domain/binaryTargetTypes.js"; import { createEvidence, type Evidence } from "../../domain/evidence.js"; import type { @@ -25,26 +26,30 @@ export const unknownMutationEvidence = ( target: BinaryTarget | undefined, mutation: UnknownMutation, ): Evidence => - createEvidence(target, UNKNOWN_REGISTRY_PROVIDER, { - predicateType: "rea.residual-unknown-mutation", - operation: mutation.operation, - parameters: { ...mutation.input }, - result: - mutation.operation === "record_unknown" - ? { - action: "record", - question: mutation.input.question, - required_authority: mutation.input.required_authority, - required_confidence: mutation.input.required_confidence, - } - : { action: "update", status: mutation.input.status }, - confidence: "derived", - authority: "analyst-inference", - evidenceLinks: unknownEvidenceLinks(mutation.input), - limitations: [ - "Registry mutation evidence records analyst intent, not proof of the answer.", - ], - }); + createEvidence( + target ?? unknownTarget("not-observed"), + UNKNOWN_REGISTRY_PROVIDER, + { + predicateType: "rea.residual-unknown-mutation", + operation: mutation.operation, + parameters: { ...mutation.input }, + result: + mutation.operation === "record_unknown" + ? { + action: "record", + question: mutation.input.question, + required_authority: mutation.input.required_authority, + required_confidence: mutation.input.required_confidence, + } + : { action: "update", status: mutation.input.status }, + confidence: "derived", + authority: "analyst-inference", + evidenceLinks: unknownEvidenceLinks(mutation.input), + limitations: [ + "Registry mutation evidence records analyst intent, not proof of the answer.", + ], + }, + ); /** Deduplicate evidence links carried by an unknown mutation. */ const unknownEvidenceLinks = ( diff --git a/src/application/investigation/admitCompletedAnalysis.ts b/src/application/investigation/admitCompletedAnalysis.ts index d446fdce66..7a21e43918 100644 --- a/src/application/investigation/admitCompletedAnalysis.ts +++ b/src/application/investigation/admitCompletedAnalysis.ts @@ -1,4 +1,3 @@ -import { MISSING_EVIDENCE_SUBJECT_LIMITATION } from "../../domain/evidence.js"; import { analysisExecutionEnvelopeForAdmission, type AnalysisObservation, @@ -25,14 +24,6 @@ export const admitCompletedAnalysis = ( ); let valueBytes = 0; let serializedUtf16Bytes = 0; - if (observation.subject == null) { - const entry = estimateJsonArrayScalarEntry( - MISSING_EVIDENCE_SUBJECT_LIMITATION, - observation.limitations.length > 0, - ); - valueBytes += entry.valueBytes; - serializedUtf16Bytes += entry.serializedUtf16Bytes; - } for (const [index, source] of (observation.sourceEvidence ?? []).entries()) { const entry = estimateJsonArrayScalarEntry(source.evidence_id, index > 0); valueBytes += entry.valueBytes; diff --git a/src/application/investigation/recordEvidenceSources.test.ts b/src/application/investigation/recordEvidenceSources.test.ts index e0f77afed5..f508e50fc6 100644 --- a/src/application/investigation/recordEvidenceSources.test.ts +++ b/src/application/investigation/recordEvidenceSources.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { createEvidence } from "../../domain/evidence.js"; import { AnalysisCancelledError } from "../../domain/analysisErrorCore.js"; @@ -9,7 +10,7 @@ import { } from "./recordEvidenceSources.js"; const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "health", parameters: {}, result: "historical" }, ); diff --git a/src/application/javascript/ElectronActiveEvidence.ts b/src/application/javascript/ElectronActiveEvidence.ts index ace6ebaef7..4ae5c17e57 100644 --- a/src/application/javascript/ElectronActiveEvidence.ts +++ b/src/application/javascript/ElectronActiveEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { digestCanonicalValue } from "../../domain/canonicalDigest.js"; import type { ProviderIdentity } from "../../ports/AnalysisProvider.js"; import type { Evidence, EvidenceObservation } from "../../domain/evidence.js"; @@ -16,7 +17,7 @@ export const createElectronActiveEvidence = ( provider: ProviderIdentity, resolvedInput: CanonicalElectronActiveObservationInput, ): Evidence => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { predicateType: "rea.electron-active-scenario", operation: "capture_electron_scenario", parameters: parameters(input, resolvedInput), diff --git a/src/application/javascript/ElectronEvidence.ts b/src/application/javascript/ElectronEvidence.ts index 5d03845fa4..bb8fc0cf43 100644 --- a/src/application/javascript/ElectronEvidence.ts +++ b/src/application/javascript/ElectronEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { isDeepStrictEqual } from "node:util"; import type { JsonValue } from "../../domain/jsonValue.js"; import type { ProviderIdentity } from "../../ports/AnalysisProvider.js"; @@ -29,7 +30,7 @@ export const createElectronEvidence = ( provider: ProviderIdentity, ): Evidence => { const result = report.facts; - return createEvidence(undefined, provider, { + return createEvidence(unknownTarget("not-observed"), provider, { predicateType: operation === "list_electron_targets" ? "rea.electron-target-list" diff --git a/src/application/javascript/JavaScriptApplicationEvidenceGraph.ts b/src/application/javascript/JavaScriptApplicationEvidenceGraph.ts index 8d23cd4e24..e71799a1af 100644 --- a/src/application/javascript/JavaScriptApplicationEvidenceGraph.ts +++ b/src/application/javascript/JavaScriptApplicationEvidenceGraph.ts @@ -5,6 +5,8 @@ import { } from "../../domain/investigationProviders.js"; import { isImmutableEvidence, + evidenceFileTarget, + evidenceSubjectDisplay, evidenceSubjectTarget, type Evidence, type EvidenceSubjectTarget, @@ -56,14 +58,13 @@ export const applicationGraphSubjectTarget = ( ({ evidence }) => evidence.extractor.operation === "inventory-root", ), ); - return evidenceSubjectTarget( - staticRootObserved || - (source.kind === "managed-application" && - subject?.format === "pe" && - subject.digest.sha256 === source.rootArtifactSha256) - ? subject - : null, - ); + const file = evidenceFileTarget({ subject }); + return staticRootObserved || + (source.kind === "managed-application" && + file?.format === "pe" && + file.sha256 === source.rootArtifactSha256) + ? evidenceSubjectTarget(subject) + : undefined; }; /** Caller-owned Evidence failed validation at the application graph boundary. */ @@ -296,11 +297,12 @@ const assertApplicationSubject = ( result: JavaScriptApplicationAnalysisResult, path: readonly (string | number)[], ): void => { + const target = evidenceFileTarget(evidence); if ( - evidence.subject === null || - evidence.subject.digest.sha256 !== result.root_artifact_sha256 || - evidence.subject.format !== result.format || - evidence.subject.local_path !== result.input_path + target === undefined || + target.sha256 !== result.root_artifact_sha256 || + target.format !== result.format || + evidenceSubjectDisplay(evidence)?.local_path !== result.input_path ) throw invalidEvidence( path, @@ -361,7 +363,9 @@ export const parseNativeApplicationEvidence = ( > => captureInputValidation(() => { const parsed = inputs.map((input) => parseEvidenceInput(input)); - const withoutSubject = parsed.findIndex(({ subject }) => subject === null); + const withoutSubject = parsed.findIndex( + (evidence) => evidenceFileTarget(evidence) === undefined, + ); if (withoutSubject !== -1) throw invalidEvidence( [...path, withoutSubject], diff --git a/src/application/javascript/JavaScriptApplicationWorkflowEvidence.ts b/src/application/javascript/JavaScriptApplicationWorkflowEvidence.ts index 3f0d1f51d4..c3ecf1743c 100644 --- a/src/application/javascript/JavaScriptApplicationWorkflowEvidence.ts +++ b/src/application/javascript/JavaScriptApplicationWorkflowEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createEvidence, type Evidence, @@ -17,18 +18,22 @@ export const createApplicationFeatureTraceEvidence = ( parameters: EvidenceObservation["parameters"], result: ApplicationFeatureTraceResult, ): Evidence => - createEvidence(subject, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.application-feature-trace", - operation: "trace_application_feature", - parameters, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + subject ?? unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.application-feature-trace", + operation: "trace_application_feature", + parameters, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); /** Create derived Evidence for one bounded JavaScript semantic trace. */ export const createJavaScriptSemanticTraceEvidence = ( @@ -36,69 +41,85 @@ export const createJavaScriptSemanticTraceEvidence = ( parameters: EvidenceObservation["parameters"], result: JavaScriptSemanticTraceResult, ): Evidence => - createEvidence(subject, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.javascript-semantic-trace", - operation: "trace_javascript_semantics", - parameters, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + subject ?? unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.javascript-semantic-trace", + operation: "trace_javascript_semantics", + parameters, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); /** Create derived Evidence for one tiered application version comparison. */ export const createApplicationVersionComparisonEvidence = ( parameters: EvidenceObservation["parameters"], result: ApplicationVersionComparisonResult, ): Evidence => - createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.application-version-comparison", - operation: "compare_application_versions", - parameters, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.application-version-comparison", + operation: "compare_application_versions", + parameters, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); /** Create derived Evidence for one historical-source to bundle comparison. */ export const createSourceToBundleComparisonEvidence = ( parameters: EvidenceObservation["parameters"], result: SourceToBundleComparisonResult, ): Evidence => - createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.source-to-bundle-comparison", - operation: "compare_source_to_bundle", - parameters, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.source-to-bundle-comparison", + operation: "compare_source_to_bundle", + parameters, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); /** Create derived Evidence for one bounded static export-shape comparison. */ export const createJavaScriptExportShapeComparisonEvidence = ( parameters: EvidenceObservation["parameters"], result: JavaScriptExportShapeComparisonResult, ): Evidence => - createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { - predicateType: "rea.javascript-export-shape-comparison", - operation: "compare_javascript_export_shapes", - parameters, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, + { + predicateType: "rea.javascript-export-shape-comparison", + operation: "compare_javascript_export_shapes", + parameters, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); diff --git a/src/application/javascript/JavaScriptEvidenceInputs.test.ts b/src/application/javascript/JavaScriptEvidenceInputs.test.ts index 2235fc310e..2ee964e0b8 100644 --- a/src/application/javascript/JavaScriptEvidenceInputs.test.ts +++ b/src/application/javascript/JavaScriptEvidenceInputs.test.ts @@ -1,3 +1,9 @@ +import { + fileIdentity, + fileSubjectDisplay, + fileSubjectTarget, + displayedEvidenceSubject, +} from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it, vi } from "vitest"; import { @@ -52,14 +58,8 @@ it("keeps a static trace subject unknown when legacy graph root evidence is omit ...semanticInput, application_graph_id: graph.graph_id, }); - if (original.subject === null) - throw new Error("Expected application subject"); const legacy = createEvidence( - { - path: original.subject.local_path, - sha256: original.subject.digest.sha256, - format: original.subject.format, - }, + fileSubjectTarget(original.subject), original.provider, { operation: original.operation, @@ -75,7 +75,7 @@ it("keeps a static trace subject unknown when legacy graph root evidence is omit application: legacy, }); if (!trace.ok) throw trace.error; - expect(trace.value.evidence.subject).toBeNull(); + expect(trace.value.evidence.subject.identity.kind).toBe("unknown"); }); const native = createEvidence( @@ -86,13 +86,11 @@ const native = createEvidence( it("preserves the verified application subject in both trace workflows", async () => { const original = JAVASCRIPT_FEATURE_TRACE_EXAMPLE.application; - if (original.subject === null) - throw new Error("Expected application subject"); const application = createEvidence( { - path: original.subject.local_path, - sha256: original.subject.digest.sha256, - format: original.subject.format, + path: fileSubjectDisplay(original.subject).local_path, + sha256: fileIdentity(original.subject).sha256, + format: fileIdentity(original.subject).format, architecture: "x86_64", name: "caller-selected-name", }, @@ -120,9 +118,6 @@ it("preserves the verified application subject in both trace workflows", async ( for (const result of [feature, semantic]) { if (!result.ok) throw result.error; expect(result.value.evidence.subject).toEqual(application.subject); - expect(result.value.evidence.limitations).not.toContain( - "Artifact identity is unavailable for this observation.", - ); } if (!feature.ok) throw feature.error; const view = await inspectAnalysisView({ @@ -133,7 +128,9 @@ it("preserves the verified application subject in both trace workflows", async ( expect(view.value.subject).toEqual(application.subject); const selected = parseEvidence({ ...feature.value.evidence, - subject: { ...feature.value.evidence.subject, name: "selected display" }, + subject: displayedEvidenceSubject(feature.value.evidence.subject, { + name: "selected display", + }), }); const retained = projectRetainedAnalysis( selected, @@ -147,9 +144,9 @@ it("preserves the verified application subject in both trace workflows", async ( expect(retained.value.subject?.name).toBe("selected display"); expect( rebindEvidenceToTargetPath(feature.value.evidence, { - path: application.subject!.local_path, + path: fileSubjectDisplay(application.subject).local_path, sha256: "f".repeat(64), - format: application.subject!.format, + format: fileIdentity(application.subject).format, architecture: "x86_64", name: "wrong artifact", }), @@ -176,10 +173,7 @@ it("does not attribute a multi-source reconciliation graph to its envelope subje application: reconciliation, }); if (!result.ok) throw result.error; - expect(result.value.evidence.subject).toBeNull(); - expect(result.value.evidence.limitations).toContain( - "Artifact identity is unavailable for this observation.", - ); + expect(result.value.evidence.subject.identity.kind).toBe("unknown"); }); it("resolves feature native arrays without changing source identity or unknowns", () => { diff --git a/src/application/javascript/JavaScriptRecoveryService.test.ts b/src/application/javascript/JavaScriptRecoveryService.test.ts index ce52326465..c56068f69f 100644 --- a/src/application/javascript/JavaScriptRecoveryService.test.ts +++ b/src/application/javascript/JavaScriptRecoveryService.test.ts @@ -192,8 +192,7 @@ it("returns cancellation with the validated Evidence when the caller aborts afte parameters: input, subject: { local_path: artifact.path, - digest: { sha256: artifact.sha256 }, - format: "javascript", + identity: { sha256: artifact.sha256, format: "javascript" }, }, confidence: "derived", authority: "shipped-artifact", diff --git a/src/application/javascript/JavaScriptRuntimeObservationEvidence.ts b/src/application/javascript/JavaScriptRuntimeObservationEvidence.ts index 41769053ab..10634bf0f6 100644 --- a/src/application/javascript/JavaScriptRuntimeObservationEvidence.ts +++ b/src/application/javascript/JavaScriptRuntimeObservationEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { ProviderIdentity } from "../../ports/AnalysisProvider.js"; import { createEvidence, @@ -22,7 +23,7 @@ export const createJavaScriptRuntimeObservationEvidence = ( result: JavaScriptRuntimeTargetList | JavaScriptRuntimeObservation, provider: ProviderIdentity, ): Evidence => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { predicateType: operation === "list_javascript_runtime_targets" ? "rea.javascript-runtime-target-list" diff --git a/src/application/javascript/JavaScriptRuntimeReconciliationEvidence.ts b/src/application/javascript/JavaScriptRuntimeReconciliationEvidence.ts index 9c59724ebc..8ac53a3ecc 100644 --- a/src/application/javascript/JavaScriptRuntimeReconciliationEvidence.ts +++ b/src/application/javascript/JavaScriptRuntimeReconciliationEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createEvidence, type Evidence, @@ -14,18 +15,22 @@ export const createJavaScriptRuntimeReconciliationEvidence = ( input: ReconcileJavaScriptRuntimeInput, result: JavaScriptRuntimeReconciliationResult, ): Evidence => - createEvidence(undefined, JAVASCRIPT_RUNTIME_RECONCILIATION_PROVIDER, { - predicateType: "rea.javascript-runtime-reconciliation", - operation: "reconcile_javascript_runtime", - parameters: parameters(input), - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + createEvidence( + unknownTarget("derived-from-linked-evidence"), + JAVASCRIPT_RUNTIME_RECONCILIATION_PROVIDER, + { + predicateType: "rea.javascript-runtime-reconciliation", + operation: "reconcile_javascript_runtime", + parameters: parameters(input), + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, + }, + ); const parameters = ( input: ReconcileJavaScriptRuntimeInput, diff --git a/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts b/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts index 99e0777081..0ef9b06b81 100644 --- a/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts +++ b/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts @@ -1,8 +1,10 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { createEvidence, parseEvidence, type Evidence, + evidenceSubjectInput, } from "../../domain/evidence.js"; import { JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE } from "../../contracts/javascript/javascriptRuntimeReconciliationExample.js"; import { javascriptRuntimeReconciliationResultSchema } from "../../domain/javascript/javascriptRuntimeReconciliationSchemas.js"; @@ -31,14 +33,21 @@ const reconcile = (observations: readonly Evidence[]) => { it("keeps equal runtime payloads at distinct selected endpoints separate through service graph Evidence", () => { const first = electronRuntimeEvidence("/synthetic", SOURCE); - const second = createEvidence(undefined, first.provider, { - predicateType: first.predicate_type, - operation: first.operation, - parameters: { ...first.parameters, cdp_endpoint: "http://127.0.0.1:9444" }, - confidence: first.confidence, - authority: first.authority, - result: first.normalized_result, - }); + const second = createEvidence( + evidenceSubjectInput(first.subject), + first.provider, + { + predicateType: first.predicate_type, + operation: first.operation, + parameters: { + ...first.parameters, + cdp_endpoint: "http://127.0.0.1:9444", + }, + confidence: first.confidence, + authority: first.authority, + result: first.normalized_result, + }, + ); const observed = reconcile([first, second]); expect(observed.result.graph.coverage).toMatchObject({ status: "complete", @@ -81,22 +90,26 @@ it("preserves attach-limited frame and worker coverage through service graph Evi const inspection = electronPageInspectionSchema.parse( first.normalized_result, ); - const capture = createEvidence(undefined, first.provider, { - predicateType: first.predicate_type, - operation: first.operation, - parameters: first.parameters, - confidence: first.confidence, - authority: first.authority, - result: { - ...inspection, - completeness: { - ...inspection.completeness, - status: "attach_limited", - conditions: ["attach_limited"], - attach_limited_sections: ["frames", "workers"], + const capture = createEvidence( + evidenceSubjectInput(first.subject), + first.provider, + { + predicateType: first.predicate_type, + operation: first.operation, + parameters: first.parameters, + confidence: first.confidence, + authority: first.authority, + result: { + ...inspection, + completeness: { + ...inspection.completeness, + status: "attach_limited", + conditions: ["attach_limited"], + attach_limited_sections: ["frames", "workers"], + }, }, }, - }); + ); const { result } = reconcile([capture]); const runtime = result.graph.nodes.filter( ({ identity }) => identity.strategy === "runtime-instance", @@ -129,7 +142,7 @@ it("preserves attach-limited frame and worker coverage through service graph Evi it("preserves unresolved Inspector target location reason through service Evidence", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-v8-inspector", name: "REA passive Node/Electron V8 Inspector provider", diff --git a/src/application/javascript/StaticObservedEndpointComparisonService.test.ts b/src/application/javascript/StaticObservedEndpointComparisonService.test.ts index 3170351bdb..b9bace60d9 100644 --- a/src/application/javascript/StaticObservedEndpointComparisonService.test.ts +++ b/src/application/javascript/StaticObservedEndpointComparisonService.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { compareStaticAndObservedEndpointsEvidence } from "./StaticObservedEndpointComparisonService.js"; import { STATIC_OBSERVED_ENDPOINT_COMPARISON_EXAMPLE } from "../../contracts/javascript/staticObservedEndpointExample.js"; @@ -36,7 +37,7 @@ it("admits the combined representation before source authentication can clone it it("locates malformed retained capture facts at the named consumer input", async () => { const capture = createEvidence( - undefined, + unknownTarget("not-observed"), STATIC_OBSERVED_ENDPOINT_COMPARISON_EXAMPLE.capture.provider, { operation: "inspect_web_network_capture", diff --git a/src/application/javascript/StaticObservedEndpointComparisonService.ts b/src/application/javascript/StaticObservedEndpointComparisonService.ts index 4d2ae36bd5..a9753438d0 100644 --- a/src/application/javascript/StaticObservedEndpointComparisonService.ts +++ b/src/application/javascript/StaticObservedEndpointComparisonService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { WebNetworkCapture } from "../../domain/webNetworkCapture.js"; import { setImmediate } from "node:timers/promises"; import { compareStaticObservedEndpointsRequestSchema } from "../../contracts/javascript/applicationWorkflowInputContracts.js"; @@ -178,7 +179,7 @@ const createComparison = ( limitations, }; const evidence: Evidence = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, { predicateType: "rea.static-observed-endpoint-comparison", diff --git a/src/application/managed/ManagedApplicationGraphService.ts b/src/application/managed/ManagedApplicationGraphService.ts index 302208c735..7c48862e99 100644 --- a/src/application/managed/ManagedApplicationGraphService.ts +++ b/src/application/managed/ManagedApplicationGraphService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { resolveEvidenceRequest, type EvidenceLookup, @@ -63,33 +64,37 @@ const createManagedApplicationGraphEvidence = ( input: ParsedManagedGraphInput, result: ManagedApplicationGraphResult, ): Evidence => - createEvidence(subjectTarget(input), MANAGED_WORKFLOW_PROVIDER, { - predicateType: "rea.managed-application-graph", - operation: OPERATION, - parameters: { - managed_artifact_evidence_id: - input.artifact?.evidence.evidence_id ?? null, - managed_members_evidence_id: input.members?.evidence.evidence_id ?? null, - managed_native_boundaries_evidence_id: - input.boundaries?.evidence.evidence_id ?? null, + createEvidence( + subjectTarget(input) ?? unknownTarget("derived-from-linked-evidence"), + MANAGED_WORKFLOW_PROVIDER, + { + predicateType: "rea.managed-application-graph", + operation: OPERATION, + parameters: { + managed_artifact_evidence_id: + input.artifact?.evidence.evidence_id ?? null, + managed_members_evidence_id: + input.members?.evidence.evidence_id ?? null, + managed_native_boundaries_evidence_id: + input.boundaries?.evidence.evidence_id ?? null, + }, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, }, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + ); const subjectTarget = ( input: ParsedManagedGraphInput, ): EvidenceSubjectTarget | undefined => { - const subject = - input.artifact?.evidence.subject ?? - input.members?.evidence.subject ?? - input.boundaries?.evidence.subject; - if (subject === undefined || subject === null || subject.format !== "pe") - return undefined; - return evidenceSubjectTarget(subject); + // Every subject is present; an unknown one names no file, so the first + // file subject among the inputs is the graph's target. + const target = [input.artifact, input.members, input.boundaries] + .map((source) => evidenceSubjectTarget(source?.evidence.subject)) + .find((candidate) => candidate !== undefined); + return target?.format === "pe" ? target : undefined; }; diff --git a/src/application/managed/ManagedMemberComparisonService.ts b/src/application/managed/ManagedMemberComparisonService.ts index 18e50d89c5..d2b18ad76a 100644 --- a/src/application/managed/ManagedMemberComparisonService.ts +++ b/src/application/managed/ManagedMemberComparisonService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { resolveEvidenceRequest, type EvidenceLookup, @@ -93,32 +94,36 @@ const createManagedMemberComparisonEvidence = ( result: ManagedMemberComparisonResult, selection?: ManagedMemberComparisonSelection, ): Evidence => - createEvidence(undefined, MANAGED_WORKFLOW_PROVIDER, { - predicateType: "rea.managed-member-comparison", - operation: "compare_managed_members", - parameters: { - left_evidence_id: left.evidence_id, - right_evidence_id: right.evidence_id, - ...(selection === undefined - ? {} - : { - left_path: selection.leftPath, - right_path: selection.rightPath, - ...selection.inspection, - }), + createEvidence( + unknownTarget("derived-from-linked-evidence"), + MANAGED_WORKFLOW_PROVIDER, + { + predicateType: "rea.managed-member-comparison", + operation: "compare_managed_members", + parameters: { + left_evidence_id: left.evidence_id, + right_evidence_id: right.evidence_id, + ...(selection === undefined + ? {} + : { + left_path: selection.leftPath, + right_path: selection.rightPath, + ...selection.inspection, + }), + }, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + locations: + selection === undefined + ? [] + : [ + { kind: "artifact-path", path: selection.leftPath }, + { kind: "artifact-path", path: selection.rightPath }, + ], + evidenceLinks: result.evidence_links, }, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - locations: - selection === undefined - ? [] - : [ - { kind: "artifact-path", path: selection.leftPath }, - { kind: "artifact-path", path: selection.rightPath }, - ], - evidenceLinks: result.evidence_links, - }); + ); diff --git a/src/application/managed/ManagedNativeVerificationService.platform.test.ts b/src/application/managed/ManagedNativeVerificationService.platform.test.ts index f006e01e8a..efc34f4dfe 100644 --- a/src/application/managed/ManagedNativeVerificationService.platform.test.ts +++ b/src/application/managed/ManagedNativeVerificationService.platform.test.ts @@ -1,3 +1,5 @@ +import { fileIdentity } from "../../../tests/fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../contracts/managed/managedWorkflowExamples.js"; @@ -83,20 +85,24 @@ const verify = ( const managed = managedNativeBoundaryInspectionSchema.parse( original.normalized_result, ); - const managedEvidence = createEvidence(undefined, original.provider, { - operation: original.operation, - parameters: {}, - result: { - ...managed, - pinvoke_imports: managed.pinvoke_imports.map((item) => ({ - ...item, - import_scope_name: scope, - no_mangle: !decorated, - char_set: decorated ? "unicode" : "not-specified", - call_convention: "cdecl", - })), + const managedEvidence = createEvidence( + unknownTarget("not-observed"), + original.provider, + { + operation: original.operation, + parameters: {}, + result: { + ...managed, + pinvoke_imports: managed.pinvoke_imports.map((item) => ({ + ...item, + import_scope_name: scope, + no_mangle: !decorated, + char_set: decorated ? "unicode" : "not-specified", + call_convention: "cdecl", + })), + }, }, - }); + ); const nativeEvidence = native(format, path, decorated); const execution = executeManagedNativeBoundaries({ managed_boundaries: managedEvidence, @@ -107,7 +113,9 @@ const verify = ( managedEvidence, nativeEvidence, ]); - expect(execution.value.sourceEvidence[1]?.subject?.format).toBe(format); + expect(fileIdentity(execution.value.sourceEvidence[1]?.subject).format).toBe( + format, + ); const result = managedNativeVerificationResultSchema.parse( execution.value.evidence.normalized_result, ); diff --git a/src/application/managed/ManagedNativeVerificationService.ts b/src/application/managed/ManagedNativeVerificationService.ts index cfc28ac0ba..f13698e159 100644 --- a/src/application/managed/ManagedNativeVerificationService.ts +++ b/src/application/managed/ManagedNativeVerificationService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { resolveEvidenceRequest, type EvidenceLookup, @@ -67,20 +68,24 @@ const createManagedNativeVerificationEvidence = ( source: ManagedNativeVerificationSource, result: ManagedNativeVerificationResult, ): Evidence => - createEvidence(undefined, MANAGED_WORKFLOW_PROVIDER, { - predicateType: "rea.managed-native-verification", - operation: OPERATION, - parameters: { - managed_boundaries_evidence_id: source.managedEvidence.evidence_id, - native_evidence_ids: source.nativeObservations.map( - ({ evidence }) => evidence.evidence_id, - ), + createEvidence( + unknownTarget("derived-from-linked-evidence"), + MANAGED_WORKFLOW_PROVIDER, + { + predicateType: "rea.managed-native-verification", + operation: OPERATION, + parameters: { + managed_boundaries_evidence_id: source.managedEvidence.evidence_id, + native_evidence_ids: source.nativeObservations.map( + ({ evidence }) => evidence.evidence_id, + ), + }, + result, + rawResult: null, + confidence: "inferred", + authority: "analyst-inference", + environment: null, + limitations: result.limitations, + evidenceLinks: result.evidence_links, }, - result, - rawResult: null, - confidence: "inferred", - authority: "analyst-inference", - environment: null, - limitations: result.limitations, - evidenceLinks: result.evidence_links, - }); + ); diff --git a/src/application/managed/ManagedReconstructionService.test.ts b/src/application/managed/ManagedReconstructionService.test.ts index 81a3786238..011087bdb4 100644 --- a/src/application/managed/ManagedReconstructionService.test.ts +++ b/src/application/managed/ManagedReconstructionService.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE } from "../../contracts/managed/managedWorkflowExamples.js"; @@ -91,7 +92,7 @@ it("managed reconstruction rejects static Evidence with a token MVID but no modu if (members.module === null || members.module.mvid === null) throw new Error("Expected fixture module identity and MVID"); const inconsistentEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), input.static_members.provider, { operation: "inspect_managed_members", @@ -139,7 +140,7 @@ it("managed reconstruction rejects locks for partial CIL without normalized iden coverage: { state: "partial" as const, issues: [] }, }; const partialEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), input.static_members.provider, { operation: "inspect_managed_members", @@ -220,17 +221,21 @@ describe("managed reconstruction input diagnostics", () => { it("reports nested Evidence schema issues without a misleading request path", () => { const input = exampleInput(); - const malformed = createEvidence(undefined, input.static_members.provider, { - operation: "inspect_managed_members", - parameters: {}, - result: { - ...managedMemberInspectionSchema.parse( - input.static_members.normalized_result, - ), - artifact: { sha256: 7 }, + const malformed = createEvidence( + unknownTarget("not-observed"), + input.static_members.provider, + { + operation: "inspect_managed_members", + parameters: {}, + result: { + ...managedMemberInspectionSchema.parse( + input.static_members.normalized_result, + ), + artifact: { sha256: 7 }, + }, + rawResult: null, }, - rawResult: null, - }); + ); const result = importManagedReconstructionEvidence({ ...MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE, static_members: malformed, diff --git a/src/application/native/NativeFunctionMatchingService.test.ts b/src/application/native/NativeFunctionMatchingService.test.ts index 890c33fccc..11d87434ce 100644 --- a/src/application/native/NativeFunctionMatchingService.test.ts +++ b/src/application/native/NativeFunctionMatchingService.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { createHash } from "node:crypto"; import { matchNativeFunctions } from "./NativeFunctionMatchingService.js"; @@ -27,17 +28,25 @@ const compare = async (input: unknown) => { }; it("retains transitive provenance without treating dependencies as native observations and fails closed for a missing ancestor", async () => { - const ancestor = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_provenance", - parameters: {}, - result: { provenance: "Synthetic ancestor" }, - }); - const dependency = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_dependency", - parameters: {}, - result: { provenance: "Synthetic dependency" }, - evidenceLinks: [ancestor.evidence_id], - }); + const ancestor = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_provenance", + parameters: {}, + result: { provenance: "Synthetic ancestor" }, + }, + ); + const dependency = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_dependency", + parameters: {}, + result: { provenance: "Synthetic dependency" }, + evidenceLinks: [ancestor.evidence_id], + }, + ); const left = nativeMatchingInventory( "1", [{ address: "0x10", value: "main" }], diff --git a/src/application/native/NativeFunctionMatchingService.ts b/src/application/native/NativeFunctionMatchingService.ts index 72ac58667c..88a9329275 100644 --- a/src/application/native/NativeFunctionMatchingService.ts +++ b/src/application/native/NativeFunctionMatchingService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { NativeMatchingAdmission } from "./NativeMatchingAdmission.js"; import { loadNativeMatchingBundleSources } from "./NativeMatchingBundleSources.js"; import { RegularFileCleanupFailure } from "../../filesystem/OwnedRegularFile.js"; @@ -8,7 +9,11 @@ import { matchNativeFunctionsInputSchema, type MatchNativeFunctionsInput, } from "../../contracts/native/functionMatchingContracts.js"; -import { createEvidence, type Evidence } from "../../domain/evidence.js"; +import { + createEvidence, + evidenceFileTarget, + type Evidence, +} from "../../domain/evidence.js"; import { readFunctionInventory } from "../../domain/native/functionInventory.js"; import { nativeFunctionMatchingSchema, @@ -87,9 +92,11 @@ const matchWithAdmission = async ( rightObservations, checkpoint, ); + const leftTarget = evidenceFileTarget(left); + const rightTarget = evidenceFileTarget(right); const compatible = - left.subject?.architecture != null && - left.subject.architecture === right.subject?.architecture; + leftTarget?.architecture != null && + leftTarget.architecture === rightTarget?.architecture; const { matches, summary } = await matchFunctionInventories( leftFunctions, rightFunctions, @@ -145,12 +152,12 @@ const matchWithAdmission = async ( const report = nativeFunctionMatchingSchema.parse({ left: { evidence_id: left.evidence_id, - sha256: left.subject!.digest.sha256, + sha256: leftTarget!.sha256, functions: leftFunctions.length, }, right: { evidence_id: right.evidence_id, - sha256: right.subject!.digest.sha256, + sha256: rightTarget!.sha256, functions: rightFunctions.length, }, scope: "provider-observed-inputs", @@ -181,22 +188,26 @@ const matchWithAdmission = async ( limitations, }); await checkpoint(); - const evidence = createEvidence(undefined, FUNCTION_COMPARISON_PROVIDER, { - operation: OPERATION, - predicateType: NATIVE_FUNCTION_MATCHING_PREDICATE, - confidence: "derived", - authority: "analyst-inference", - parameters: { - left_evidence_id: left.evidence_id, - right_evidence_id: right.evidence_id, - left_observation_ids: leftObservations.map((x) => x.evidence_id), - right_observation_ids: rightObservations.map((x) => x.evidence_id), - algorithm: "exact-symbol-body-bytes-and-structural-candidates-v1", + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + FUNCTION_COMPARISON_PROVIDER, + { + operation: OPERATION, + predicateType: NATIVE_FUNCTION_MATCHING_PREDICATE, + confidence: "derived", + authority: "analyst-inference", + parameters: { + left_evidence_id: left.evidence_id, + right_evidence_id: right.evidence_id, + left_observation_ids: leftObservations.map((x) => x.evidence_id), + right_observation_ids: rightObservations.map((x) => x.evidence_id), + algorithm: "exact-symbol-body-bytes-and-structural-candidates-v1", + }, + result: report, + limitations, + evidenceLinks: directLinks, }, - result: report, - limitations, - evidenceLinks: directLinks, - }); + ); await checkpoint(); return { evidence, sources, detail: input.detail }; }; diff --git a/src/application/native/NativeMatchingSources.ts b/src/application/native/NativeMatchingSources.ts index e8950fd914..f227050cf6 100644 --- a/src/application/native/NativeMatchingSources.ts +++ b/src/application/native/NativeMatchingSources.ts @@ -5,6 +5,7 @@ import { ANALYSIS_EVIDENCE_PREDICATE, isImmutableEvidence, type Evidence, + evidenceFileTarget, } from "../../domain/evidence.js"; import { readEvidence } from "../../domain/evidenceValidation.js"; import { retainedEvidenceReferenceSchema } from "../../domain/evidenceReference.js"; @@ -88,7 +89,7 @@ export const resolveNativeMatchingSources = async ( if ( evidence.predicate_type !== ANALYSIS_EVIDENCE_PREDICATE || !operations.includes(evidence.operation) || - evidence.subject === null + evidenceFileTarget(evidence) === undefined ) { const message = `Expected artifact-bound rea.analysis ${operations.join(" or ")} Evidence, received ${evidence.predicate_type} ${evidence.operation}`; throw new AnalysisInputError( diff --git a/src/application/pcap/PcapAnalysisService.test.ts b/src/application/pcap/PcapAnalysisService.test.ts index ad93b69d3a..98af8507b9 100644 --- a/src/application/pcap/PcapAnalysisService.test.ts +++ b/src/application/pcap/PcapAnalysisService.test.ts @@ -149,7 +149,7 @@ it.each(["inspect_pcap_client", "inspect_pcap_capture"] as const)( expect(evidence.authority).toBe("historical-reference"); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256: target.sha256 }, + identity: { sha256: target.sha256 }, }); } pcapResultSchemas[operation].parse(evidence.normalized_result); diff --git a/src/application/process/ProcessCli.ts b/src/application/process/ProcessCli.ts index 2d37d09941..3aa386a833 100644 --- a/src/application/process/ProcessCli.ts +++ b/src/application/process/ProcessCli.ts @@ -43,6 +43,8 @@ import { import { EvidenceFileError } from "../../domain/evidenceErrors.js"; import type { Evidence } from "../../domain/evidence.js"; import { completeProviderEvidence } from "../ProviderOperationExecution.js"; +import { unsupportedEvidenceFormatError } from "../../domain/evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../../domain/evidenceFormat.js"; /** Preserve the owning reader's facts when retaining a different cause. */ const artifactFailureFacts = (failure: ArtifactReaderFailure) => ({ @@ -211,6 +213,8 @@ export const projectCaptureFileFailure = ( ): AnalysisError => { switch (failure.kind) { case "invalid-evidence": + if (isUnsupportedEvidenceFormat(failure.cause)) + return unsupportedEvidenceFormatError(failure.cause, side); return analysisInputErrorFromIssues( "compare_process_captures", failure.cause.issues, diff --git a/src/application/process/ProcessEvidence.ts b/src/application/process/ProcessEvidence.ts index d0b00656ac..dd26f19d10 100644 --- a/src/application/process/ProcessEvidence.ts +++ b/src/application/process/ProcessEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { z } from "zod"; import { posix, win32 } from "node:path"; @@ -14,7 +15,10 @@ import { safeParseProcessCapture, type ProcessCapture, } from "../../domain/process/processCaptureParsing.js"; -import { safeParseEvidence } from "../../domain/evidenceValidation.js"; +import { + safeParseEvidence, + type EvidenceReadFailure, +} from "../../domain/evidenceValidation.js"; import { processScenarioPlanProjection, processScenarioPlanSchema, @@ -35,7 +39,7 @@ const PROCESS_SCENARIO_PLAN_EVIDENCE = { /** Semantic rejection facts; CLI and MCP retain their own error projections. */ export type ProcessCaptureEvidenceFailure = - | { readonly kind: "invalid-evidence"; readonly cause: z.ZodError } + | { readonly kind: "invalid-evidence"; readonly cause: EvidenceReadFailure } | { readonly kind: "wrong-workflow"; readonly expected: typeof PROCESS_CAPTURE_EVIDENCE; @@ -109,7 +113,7 @@ export const createProcessCaptureEvidence = ( scenario: ProcessScenario, capture: ProcessCapture, ) => { - return createEvidence(undefined, PROCESS_PROVIDER, { + return createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: PROCESS_CAPTURE_EVIDENCE.predicate, operation: PROCESS_CAPTURE_EVIDENCE.operation, parameters: processEvidenceParameters(scenario, capture.manifest.platform), @@ -136,7 +140,7 @@ export const createProcessScenarioPlanEvidence = ( scenario: processScenarioPlanProjection(scenario), ambient_environment: "inherited-at-run", }); - return createEvidence(undefined, PROCESS_PROVIDER, { + return createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: PROCESS_SCENARIO_PLAN_EVIDENCE.predicate, operation: PROCESS_SCENARIO_PLAN_EVIDENCE.operation, parameters: processEvidenceParameters(scenario, platform), diff --git a/src/application/python/PythonPycService.test.ts b/src/application/python/PythonPycService.test.ts index 2e0f0a12d2..3f6fa12048 100644 --- a/src/application/python/PythonPycService.test.ts +++ b/src/application/python/PythonPycService.test.ts @@ -119,7 +119,7 @@ it("records the selected artifact and the header plus marshal ranges", async () if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "file" }, + subject: { identity: { format: "file" } }, normalized_result: report, }); expect(result.value.locations).toEqual([ diff --git a/src/application/releaseExposure/ReleaseExposureService.ts b/src/application/releaseExposure/ReleaseExposureService.ts index 20132941c9..d21fd85b21 100644 --- a/src/application/releaseExposure/ReleaseExposureService.ts +++ b/src/application/releaseExposure/ReleaseExposureService.ts @@ -25,11 +25,8 @@ import { electronFuseReportSchema, type ElectronFuseReport, } from "../../domain/electron/electronFuses.js"; -import { - createEvidence, - evidenceSchema, - type Evidence, -} from "../../domain/evidence.js"; +import { createEvidence, type Evidence } from "../../domain/evidence.js"; +import { recognizeEvidence } from "../../domain/evidenceValidation.js"; import { evidenceSubjectFormatSchema } from "../../domain/evidenceSubject.js"; import { goBinarySchema } from "../../domain/go/goBinary.js"; import { RELEASE_EXPOSURE_PROVIDER } from "../../domain/investigationProviders.js"; @@ -458,10 +455,9 @@ interface OwnerOutcome { * completeProviderEvidence carries as the error's partial observation. */ const completedOwnerEvidence = (error: AnalysisError): Evidence | undefined => { - const partial = error.partialObservation; - return evidenceSchema.safeParse(partial).success - ? (partial as Evidence) - : undefined; + // Only authenticated Evidence settles the owner; otherwise it did not run. + const partial = recognizeEvidence(error.partialObservation); + return partial.ok ? partial.value : undefined; }; /** Settle one fuse image from its owner's Evidence. */ diff --git a/src/application/reverse/ReverseEngineeringService.ts b/src/application/reverse/ReverseEngineeringService.ts index 954d811f5b..84383484b0 100644 --- a/src/application/reverse/ReverseEngineeringService.ts +++ b/src/application/reverse/ReverseEngineeringService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { HOST_PLATFORM } from "../../platform/HostPlatform.js"; import { nativeDeadlineRecovery } from "../../domain/native/nativeDeadlines.js"; import { Budget } from "../../domain/budget.js"; @@ -1213,7 +1214,7 @@ export class ReverseEngineeringService { ]; const evidence = createEvidence( absolutePath === undefined || digest === undefined - ? undefined + ? unknownTarget("not-observed") : { path: absolutePath, sha256: digest, format: "unknown" }, profile.identity, { diff --git a/src/application/rust/RustBinaryService.test.ts b/src/application/rust/RustBinaryService.test.ts index c2a2be41ea..ee200f82cd 100644 --- a/src/application/rust/RustBinaryService.test.ts +++ b/src/application/rust/RustBinaryService.test.ts @@ -79,7 +79,7 @@ it("records the selected artifact and the dependency section range", async () => if (!result.ok) throw result.error; expect(result.value).toMatchObject({ confidence: "observed", - subject: { format: "elf", architecture: "x86_64" }, + subject: { identity: { format: "elf", architecture: "x86_64" } }, normalized_result: report, locations: [ { kind: "artifact-path", path: report.artifact.path }, diff --git a/src/application/sqlite/SqliteDatabaseService.test.ts b/src/application/sqlite/SqliteDatabaseService.test.ts index c8edfd2a94..73c46b47e6 100644 --- a/src/application/sqlite/SqliteDatabaseService.test.ts +++ b/src/application/sqlite/SqliteDatabaseService.test.ts @@ -283,7 +283,7 @@ it.each([false, true])( confidence: "observed", subject: { local_path: "/selected.db", - digest: { sha256: "a".repeat(64) }, + identity: { sha256: "a".repeat(64) }, }, normalized_result: value, analysis_profile: profile, diff --git a/src/application/wasm/WasmInterfaceComparisonService.test.ts b/src/application/wasm/WasmInterfaceComparisonService.test.ts index 969db1bc5b..3db77934c1 100644 --- a/src/application/wasm/WasmInterfaceComparisonService.test.ts +++ b/src/application/wasm/WasmInterfaceComparisonService.test.ts @@ -152,7 +152,7 @@ it("authenticates semantic Evidence and rejects altered artifact digests", async }), ).toMatchObject({ ok: false, error: { _tag: "AnalysisInputError" } }); const rebound = JSON.parse(JSON.stringify(evidence(facts("f")))); - rebound.subject.digest.sha256 = "b".repeat(64); + rebound.subject.identity.sha256 = "b".repeat(64); expect( await compareWasmInterfaces({ left: rebound, diff --git a/src/application/wasm/WasmInterfaceComparisonService.ts b/src/application/wasm/WasmInterfaceComparisonService.ts index b4e186b7e4..8017bf4d73 100644 --- a/src/application/wasm/WasmInterfaceComparisonService.ts +++ b/src/application/wasm/WasmInterfaceComparisonService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { joinCoverageStatus, type CoverageStatus, @@ -14,6 +15,7 @@ import { import { createEvidence, evidenceEnvelopeForAdmission, + evidenceFileTarget, type Evidence, } from "../../domain/evidence.js"; import { @@ -63,12 +65,7 @@ const parseInspection = ( if ( !wasmArtifactMatchesSubject( result.artifact, - evidence.subject === null - ? null - : { - sha256: evidence.subject.digest.sha256, - format: evidence.subject.format, - }, + evidenceFileTarget(evidence), ) || evidence.parameters.path !== result.artifact.path ) @@ -278,7 +275,7 @@ export const compareWasmInterfaces = async ( }; const admission = requireAuthenticationHeadroom( evidenceEnvelopeForAdmission( - undefined, + unknownTarget("derived-from-linked-evidence"), ARTIFACT_COMPARISON_PROVIDER, observation, ), @@ -291,10 +288,14 @@ export const compareWasmInterfaces = async ( ); if (!admission.ok) return admission; const report = wasmInterfaceComparisonSchema.parse(observedReport); - const evidence = createEvidence(undefined, ARTIFACT_COMPARISON_PROVIDER, { - ...observation, - result: report, - }); + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + ARTIFACT_COMPARISON_PROVIDER, + { + ...observation, + result: report, + }, + ); await setImmediate(); const completed = completeProviderEvidence(evidence, options?.signal); const sources = [left.evidence, right.evidence]; diff --git a/src/artifacts/ArtifactProvider.ts b/src/artifacts/ArtifactProvider.ts index f75e5646a1..702ffa8898 100644 --- a/src/artifacts/ArtifactProvider.ts +++ b/src/artifacts/ArtifactProvider.ts @@ -55,6 +55,7 @@ import { err, ok, type Result } from "../domain/result.js"; import { artifactCapabilities } from "./ArtifactProviderMetadata.js"; import { ARTIFACT_GRAPH_PROVIDER } from "../domain/investigationProviders.js"; import { createEvidence } from "../domain/evidence.js"; +import { binaryTargetSelection } from "../domain/targetIdentity.js"; import { freezeJsonSnapshot } from "../domain/immutableJson.js"; import { artifactInspectionSources, @@ -390,10 +391,7 @@ class ArtifactClient implements AnalysisClient { createAnalysisExecution(result, ARTIFACT_GRAPH_PROVIDER, { rawResult: null, limitations: result.limitations, - subject: subjectFor( - artifactTargetSelectedPath(this.target), - result.manifest, - ), + subject: subjectFor(this.target, result.manifest), // Each extracted file's path is already in artifacts. locations: [], }), @@ -405,10 +403,7 @@ class ArtifactClient implements AnalysisClient { createAnalysisExecution(result, ARTIFACT_GRAPH_PROVIDER, { rawResult: null, limitations: result.limitations, - subject: subjectFor( - artifactTargetSelectedPath(this.target), - result.manifest, - ), + subject: subjectFor(this.target, result.manifest), // Each occurrence's logical path is already in the result. locations: [], }), @@ -518,10 +513,7 @@ class ArtifactClient implements AnalysisClient { const inventory = freezeJsonSnapshot( await this.inventory(inventoryParameters, options), ); - const subject = subjectFor( - artifactTargetSelectedPath(this.target), - inventory.manifest, - ); + const subject = subjectFor(this.target, inventory.manifest); const inventoryEvidence = createEvidence(subject, ARTIFACT_GRAPH_PROVIDER, { operation: "inventory_artifact", parameters: inventoryParameters, @@ -601,14 +593,27 @@ const isArtifactOperation = ( operation as (typeof ARTIFACT_ANALYSIS_OPERATIONS)[number], ); +/** + * The inventory root as an Evidence subject. When the root is the open + * target's own bytes, it carries the target's selection (ESP flash offsets), + * so observations of different selections name different subjects. + */ const subjectFor = ( - path: string, + target: BinaryTarget, manifest: { readonly root_sha256: string; readonly root_format: import("../domain/artifactGraph.js").ArtifactInventoryResult["manifest"]["root_format"]; }, -) => ({ - path, - sha256: manifest.root_sha256, - format: manifest.root_format, -}); +) => { + const selection = + manifest.root_sha256 === target.sha256 && + manifest.root_format === target.format + ? binaryTargetSelection(target) + : null; + return { + path: artifactTargetSelectedPath(target), + sha256: manifest.root_sha256, + format: manifest.root_format, + ...(selection === null ? {} : { selection }), + }; +}; diff --git a/src/cli/flutterCommands.ts b/src/cli/flutterCommands.ts index a45f846f52..e9e609fbd7 100644 --- a/src/cli/flutterCommands.ts +++ b/src/cli/flutterCommands.ts @@ -1,8 +1,6 @@ import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js"; -import { - evidenceSchema, - withEvidenceCallerInputPath, -} from "../domain/evidence.js"; +import { withEvidenceCallerInputPath } from "../domain/evidence.js"; +import { recognizeEvidence } from "../domain/evidenceValidation.js"; import { FlutterBuildAnalysisService } from "../application/flutter/FlutterBuildAnalysisService.js"; import type { FlutterBuildAnalysisPort } from "../application/flutter/FlutterBuildAnalysisPort.js"; import { createFlutterBuildAnalysisProvider } from "../composition/flutter.js"; @@ -46,9 +44,10 @@ export const registerFlutterCommands = ( undefined, { recoverCompletedObservation: (observation) => { - const parsed = evidenceSchema.safeParse(observation); - return parsed.success - ? withEvidenceCallerInputPath(parsed.data, input.path) + // Only authenticated Evidence is recovered; otherwise the error stands. + const parsed = recognizeEvidence(observation); + return parsed.ok && parsed.value !== undefined + ? withEvidenceCallerInputPath(parsed.value, input.path) : undefined; }, }, diff --git a/src/cli/reverseEngineeringCommands.ts b/src/cli/reverseEngineeringCommands.ts index 8659c05085..25565dfde6 100644 --- a/src/cli/reverseEngineeringCommands.ts +++ b/src/cli/reverseEngineeringCommands.ts @@ -10,7 +10,8 @@ import { AnalysisInputError, AnalysisOutputError, } from "../domain/analysisErrorCore.js"; -import { evidenceSchema, type Evidence } from "../domain/evidence.js"; +import type { Evidence } from "../domain/evidence.js"; +import { recognizeEvidence } from "../domain/evidenceValidation.js"; import type { JsonValue } from "../domain/jsonValue.js"; import type { Result } from "../domain/result.js"; import { ok } from "../domain/result.js"; @@ -74,14 +75,15 @@ const cleanupOnlyCompleteEvidence = ( error.partialObservation === undefined ) return undefined; - const parsed = evidenceSchema.safeParse(error.partialObservation); - if (!parsed.success) return undefined; - const normalized = parsed.data.normalized_result; + // Only authenticated Evidence is recovered; otherwise the error stands. + const parsed = recognizeEvidence(error.partialObservation); + if (!parsed.ok || parsed.value === undefined) return undefined; + const normalized = parsed.value.normalized_result; return typeof normalized === "object" && normalized !== null && !Array.isArray(normalized) && normalized.completion_status !== "unknown" - ? parsed.data + ? parsed.value : undefined; }; diff --git a/src/contracts/analysisViewApiSurfaceExample.ts b/src/contracts/analysisViewApiSurfaceExample.ts index 42ff40f822..5ebedcab1f 100644 --- a/src/contracts/analysisViewApiSurfaceExample.ts +++ b/src/contracts/analysisViewApiSurfaceExample.ts @@ -4,7 +4,7 @@ export const API_SURFACE_EXAMPLE = { source: { kind: "retained-evidence", evidence_id: - "ev_1cfc841a51d771fb713db42cab9979d799226b4b88efab7d9616ca4ef9316ad6", + "ev_267522986f962ec19b8712fd3dfdaa5644031f68fb547373fc39de3fef643acb", }, view: { kind: "api-surface", @@ -14,12 +14,12 @@ export const API_SURFACE_EXAMPLE = { }, output: { parent_evidence_id: - "ev_1cfc841a51d771fb713db42cab9979d799226b4b88efab7d9616ca4ef9316ad6", + "ev_267522986f962ec19b8712fd3dfdaa5644031f68fb547373fc39de3fef643acb", parent_operation: "inspect_web_network_capture", parent_digest: - "1cfc841a51d771fb713db42cab9979d799226b4b88efab7d9616ca4ef9316ad6", + "267522986f962ec19b8712fd3dfdaa5644031f68fb547373fc39de3fef643acb", view_digest: - "fea1ecf2d7c23f1a25f4f2e1ba6b538a8d6e9c6a8748dad3a756a44bad64e3c2", + "39fc0119d9290a8bf0d8863e1e0275674c2417c0e1c7b7dcb4df486423cec626", artifact: { path: "/fixtures/api-surface.har", sha256: diff --git a/src/contracts/analysisViewEnvironmentManifestExample.ts b/src/contracts/analysisViewEnvironmentManifestExample.ts index 63f9e0f6e6..92e64b56ef 100644 --- a/src/contracts/analysisViewEnvironmentManifestExample.ts +++ b/src/contracts/analysisViewEnvironmentManifestExample.ts @@ -4,7 +4,7 @@ export const ENVIRONMENT_MANIFEST_EXAMPLE = { source: { kind: "retained-evidence", evidence_id: - "ev_3f40227d7f1cad9a068f750f06191eac1a348f4eb04b57afba758b12800adffb", + "ev_8eb1873465f0b0acb83f57e6bda1f7dc921f16bf6832310a2102d7c1f6eaad3c", }, view: { kind: "environment-manifest", @@ -14,12 +14,12 @@ export const ENVIRONMENT_MANIFEST_EXAMPLE = { }, output: { parent_evidence_id: - "ev_3f40227d7f1cad9a068f750f06191eac1a348f4eb04b57afba758b12800adffb", + "ev_8eb1873465f0b0acb83f57e6bda1f7dc921f16bf6832310a2102d7c1f6eaad3c", parent_operation: "inspect_web_network_capture", parent_digest: - "3f40227d7f1cad9a068f750f06191eac1a348f4eb04b57afba758b12800adffb", + "8eb1873465f0b0acb83f57e6bda1f7dc921f16bf6832310a2102d7c1f6eaad3c", view_digest: - "1796278f74478e3f932ddb79f6871dee5c6ef8b58ceee1653c471e69b7e971b3", + "ab9708516d5cd0b6c377215e14231222f822552d77c3f446155d7eae6e4ea045", artifact: { path: "/fixtures/environment-manifest.har", sha256: diff --git a/src/contracts/applicationToolContracts.ts b/src/contracts/applicationToolContracts.ts index 1f58b1ee95..ebcf3a4407 100644 --- a/src/contracts/applicationToolContracts.ts +++ b/src/contracts/applicationToolContracts.ts @@ -3,6 +3,7 @@ import { API_CONTRACT_TOOL_CONTRACTS } from "./apiContractToolContracts.js"; import { NTFS_JOURNAL_TOOL_CONTRACTS } from "./ntfsJournalToolContracts.js"; import { applicationInventoryProjectionInputSchema } from "../domain/mobileApplicationGraphProjection.js"; import { z } from "zod"; +import { EVIDENCE_FORMAT_REVISION } from "../domain/evidenceFormat.js"; import { featureTraceSummaryViewResultSchema, featureTraceViewResultSchema, @@ -317,7 +318,7 @@ export const APPLICATION_TOOL_CONTRACTS = [ title: "Generate the complete obligation ledger", input: { evidence_bundle: { - evidence_format: 1, + evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: [], providers: [], environments: [], @@ -350,7 +351,7 @@ export const APPLICATION_TOOL_CONTRACTS = [ input: { coverage: { evidence_bundle: { - evidence_format: 1, + evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: [], providers: [], environments: [], diff --git a/src/contracts/investigationExamples.ts b/src/contracts/investigationExamples.ts index 071587f6f2..03416f8ed9 100644 --- a/src/contracts/investigationExamples.ts +++ b/src/contracts/investigationExamples.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { createEvidence } from "../domain/evidence.js"; import { FUNCTION_COMPARISON_PROFILE, @@ -24,7 +25,7 @@ if (!right.ok) throw right.error; const comparison = compareFunctions(left.value, right.value); export const FUNCTION_COMPARISON_EVIDENCE = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), FUNCTION_COMPARISON_PROVIDER, { predicateType: "rea.function-comparison", @@ -47,7 +48,7 @@ export const FUNCTION_COMPARISON_EVIDENCE = createEvidence( const capture = parseProcessCapture(EMPTY_PROCESS_CAPTURE_EXAMPLE); const captureEvidence = (scenario: string) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { scenario }, diff --git a/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts b/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts index 7834ee50a6..a030d93e05 100644 --- a/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts +++ b/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import type { JsonValue } from "../../domain/jsonValue.js"; import { createEvidence } from "../../domain/evidence.js"; import { @@ -23,7 +24,7 @@ if (!reconciliationInput.ok) ); const reconciliation = reconcileJavaScriptRuntime(reconciliationInput.value); const reconciliationEvidence = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-javascript-runtime-reconciliation", name: "REA JavaScript runtime reconciliation", diff --git a/src/contracts/javascript/javascriptRuntimeReconciliationExample.ts b/src/contracts/javascript/javascriptRuntimeReconciliationExample.ts index 74830c478d..ded0d4d40c 100644 --- a/src/contracts/javascript/javascriptRuntimeReconciliationExample.ts +++ b/src/contracts/javascript/javascriptRuntimeReconciliationExample.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createEvidence } from "../../domain/evidence.js"; import { createJavaScriptApplicationGraph, @@ -217,7 +218,7 @@ export const JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE = createEvidence( ); const runtimeEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-cdp-electron", name: "REA Electron file-page CDP observation provider", diff --git a/src/contracts/javascript/staticObservedEndpointExample.ts b/src/contracts/javascript/staticObservedEndpointExample.ts index 68107fb587..f356c4ce9d 100644 --- a/src/contracts/javascript/staticObservedEndpointExample.ts +++ b/src/contracts/javascript/staticObservedEndpointExample.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createEvidence } from "../../domain/evidence.js"; import { JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE } from "./javascriptRuntimeReconciliationExample.js"; @@ -5,7 +6,7 @@ import { JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE } from "./javascriptRuntimeReco export const STATIC_OBSERVED_ENDPOINT_COMPARISON_EXAMPLE = { application: JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE, capture: createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-example-har", name: "Example HAR", version: "1" }, { operation: "inspect_web_network_capture", diff --git a/src/contracts/managed/managedWorkflowExamples.ts b/src/contracts/managed/managedWorkflowExamples.ts index 91c515e321..1bead17e57 100644 --- a/src/contracts/managed/managedWorkflowExamples.ts +++ b/src/contracts/managed/managedWorkflowExamples.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../domain/targetIdentity.js"; import { createEvidence } from "../../domain/evidence.js"; import type { ManagedMemberInspection, @@ -64,13 +65,17 @@ const emptyManagedMembers = ( }); const evidence = (result: ManagedMemberInspection) => - createEvidence(undefined, MANAGED_STATIC_EXAMPLE_PROVIDER, { - operation: "inspect_managed_members", - parameters: {}, - result, - rawResult: null, - limitations: result.limitations, - }); + createEvidence( + unknownTarget("not-observed"), + MANAGED_STATIC_EXAMPLE_PROVIDER, + { + operation: "inspect_managed_members", + parameters: {}, + result, + rawResult: null, + limitations: result.limitations, + }, + ); const runtimeMembers = (): ManagedMemberInspection => { const result = emptyManagedMembers( @@ -222,13 +227,17 @@ const boundaryEvidence = () => { coverage: { state: "complete", issues: [] }, limitations: [], }; - return createEvidence(undefined, MANAGED_STATIC_EXAMPLE_PROVIDER, { - operation: "inspect_managed_native_boundaries", - parameters: {}, - result, - rawResult: null, - limitations: result.limitations, - }); + return createEvidence( + unknownTarget("not-observed"), + MANAGED_STATIC_EXAMPLE_PROVIDER, + { + operation: "inspect_managed_native_boundaries", + parameters: {}, + result, + rawResult: null, + limitations: result.limitations, + }, + ); }; const nativeExportEvidence = () => { diff --git a/src/cutter/CutterBridgeService.ts b/src/cutter/CutterBridgeService.ts index 91b718c459..7da70d06b5 100644 --- a/src/cutter/CutterBridgeService.ts +++ b/src/cutter/CutterBridgeService.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js"; import { AnalysisCleanupRelease } from "../domain/analysisCleanupRelease.js"; import { ProviderCleanupError } from "../domain/providerCleanupError.js"; @@ -164,7 +165,7 @@ export class CutterBridgeService { }); const normalizedOutput = jsonValueSchema.parse(output.output); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { ...CUTTER_PROVIDER_IDENTITY, version: output.cutterVersion, @@ -191,9 +192,8 @@ export class CutterBridgeService { identity_status: output.identityStatus, }, rawResult: normalizedOutput, - subjectUnavailableReason: - "Cutter exposes no verified stable identity for the active unsaved document or tab.", limitations: [ + "Cutter exposes no verified stable identity for the active unsaved document or tab.", "Document identity is partial: the bridge uses a plugin instance UUID and observed generation; a same-path tab switch or reload may not be distinguishable.", "Cutter command effects depend on the Rizin command and active plugins.", "The local IPC protocol is implemented by REA and is not an upstream Cutter API.", diff --git a/src/domain/analysisErrorCleanup.test.ts b/src/domain/analysisErrorCleanup.test.ts index ffbc20ad71..1fa63e2def 100644 --- a/src/domain/analysisErrorCleanup.test.ts +++ b/src/domain/analysisErrorCleanup.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { expect, it } from "vitest"; import { AnalysisCancelledError, @@ -188,7 +189,7 @@ it.each([ truncated: true, }, partialObservation: createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: null }, { operation: "inspect", @@ -324,12 +325,12 @@ it("preserves recovery and secondary failures owned by an intermediate cleanup", it("prefers the outer publication source over the nested primary observation", () => { const provider = { id: "fixture", name: "Fixture", version: null }; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "source", parameters: {}, result: "source", }); - const nested = createEvidence(undefined, provider, { + const nested = createEvidence(unknownTarget("not-observed"), provider, { operation: "nested", parameters: {}, result: "nested", @@ -412,7 +413,7 @@ it("retains an observation attached to the composite after the primary failed", cleanup, ).bindCleanupDependencies([primary, cleanup]); const observation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: null }, { operation: "inspect", diff --git a/src/domain/analysisObservation.ts b/src/domain/analysisObservation.ts index 7bf5aff0ed..acda257ff9 100644 --- a/src/domain/analysisObservation.ts +++ b/src/domain/analysisObservation.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { createEvidence, evidenceEnvelopeForAdmission, @@ -60,7 +61,7 @@ export const analysisExecutionEnvelopeForAdmission = ( confidence: "observed" | "derived", ) => evidenceEnvelopeForAdmission( - execution.subject ?? undefined, + execution.subject ?? unknownTarget("not-observed"), execution.provider, analysisExecutionEvidenceInput(operation, input, execution, confidence), ); @@ -74,7 +75,7 @@ export const createAnalysisExecutionEvidence = ( options?: EvidenceCreationOptions, ): Evidence => createEvidence( - execution.subject ?? undefined, + execution.subject ?? unknownTarget("not-observed"), execution.provider, { ...analysisExecutionEvidenceInput( diff --git a/src/domain/analysisSnapshot.test.ts b/src/domain/analysisSnapshot.test.ts index 77af142042..cc2618c869 100644 --- a/src/domain/analysisSnapshot.test.ts +++ b/src/domain/analysisSnapshot.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../tests/fixtures/evidenceSubject.js"; import { describe, expect, it } from "vitest"; import { @@ -320,7 +321,9 @@ describe("analysis snapshot contract", () => { architecture, }); expect(parsed.entries[0]?.execution.subject?.format).toBe(format); - expect(parsed.evidence_bundle.records[0]?.subject?.format).toBe(format); + expect( + fileIdentity(parsed.evidence_bundle.records[0]?.subject).format, + ).toBe(format); }, ); @@ -585,6 +588,78 @@ it("retains linked foreign Evidence without treating it as selected-target repla ).toThrow("unrelated to the selected target and its linked sources"); }); +it("binds raw Evidence only when its entry point matches the snapshot target", () => { + const raw = (entryPoint: string): BinaryTarget => ({ + path: "/fixture/image.bin", + sha256: ANALYSIS_SNAPSHOT_TARGET.sha256, + kind: "executable", + format: "raw-binary", + architecture: "arm", + availableArchitectures: ["arm"], + entryPoint, + entryPointSource: entryPoint, + }); + const selected = raw("0x8000000"); + const target = snapshotTarget(selected); + const binding = snapshotBinding(ANALYSIS_SNAPSHOT_PROFILE); + const parameters = { procedure: "main" }; + const observe = (observed: BinaryTarget) => + createEvidence(observed, ANALYSIS_SNAPSHOT_PROVIDER, { + operation: "analyze_function", + parameters, + result: { summary: "cached" }, + analysisProfile: ANALYSIS_SNAPSHOT_PROFILE, + }); + const snapshotWith = (evidence: ReturnType) => + analysisSnapshotSchema.parse({ + target, + binding, + entries: [ + { + query_id: analysisQueryId( + target, + binding, + "analyze_function", + parameters, + ), + operation: "analyze_function", + parameters, + execution: { + result: { summary: "cached" }, + raw_result: null, + provider: binding.provider, + limitations: [], + relationship_coverage: null, + locations: [], + subject: { + path: selected.path, + sha256: selected.sha256, + format: "raw-binary", + architecture: "arm", + }, + }, + }, + ], + workflow_entries: [], + evidence_bundle: createEvidenceBundle([evidence]), + }); + const query = { + target: selected, + bindingProfile: ANALYSIS_SNAPSHOT_PROFILE, + operation: "analyze_function", + parameters, + provider: ANALYSIS_SNAPSHOT_PROVIDER, + evidenceProfile: ANALYSIS_SNAPSHOT_PROFILE, + }; + const matching = observe(selected); + expect(snapshotEvidenceForQuery(snapshotWith(matching), query)).toEqual( + matching, + ); + expect( + snapshotEvidenceForQuery(snapshotWith(observe(raw("0x9000000"))), query), + ).toBeUndefined(); +}); + describe("analysis snapshot Evidence binding", () => { it("finds only Evidence committed to the exact binding and profile", () => { const { current, snapshot } = snapshotWithHistoricalEvidence(); diff --git a/src/domain/analysisSnapshot.ts b/src/domain/analysisSnapshot.ts index 7f882c7ad4..c31e66ccbc 100644 --- a/src/domain/analysisSnapshot.ts +++ b/src/domain/analysisSnapshot.ts @@ -11,6 +11,7 @@ import { } from "./unicodeCodePointOrder.js"; import { localPathStringSchema } from "./localPath.js"; import { + binaryTargetIdentity, sameTargetIdentity, type FileTargetIdentity, } from "./targetIdentity.js"; @@ -35,7 +36,9 @@ import { parseImmutableEvidenceBundle, } from "./evidenceBundle.js"; import { + evidenceFileTarget, evidenceLocationSchema, + evidenceSubjectTarget, rebindEvidenceToTargetPath, type Evidence, type EvidenceLocation, @@ -372,15 +375,7 @@ const snapshotContentDigest = ( const metadata = jsonObjectSchema.parse({ limitations: execution.limitations, locations: execution.locations, - subject: - execution.subject === null - ? null - : { - local_path: execution.subject.path, - sha256: execution.subject.sha256, - format: execution.subject.format, - architecture: execution.subject.architecture, - }, + subject: executionSubjectContent(execution.subject ?? undefined), relationship_coverage: execution.relationship_coverage, }); return contentDigest({ @@ -390,6 +385,26 @@ const snapshotContentDigest = ( }); }; +/** The execution subject facts a snapshot content digest commits to. */ +const executionSubjectContent = ( + subject: + | { + readonly path: string; + readonly sha256: string; + readonly format: string; + readonly architecture?: string | null; + } + | undefined, +) => + subject === undefined + ? null + : { + local_path: subject.path, + sha256: subject.sha256, + format: subject.format, + architecture: subject.architecture ?? null, + }; + const evidenceContentDigest = (evidence: Evidence): string => { return contentDigest({ ...jsonObjectSchema.parse(evidenceContentMetadata(evidence)), @@ -523,7 +538,7 @@ export const snapshotMatchesTarget = ( ): boolean => sameTargetIdentity( snapshotTargetIdentity(snapshot), - snapshotTargetIdentity(snapshotTarget(target)), + binaryTargetIdentity(target), ); /** Compare a snapshot binding with the selected concrete analysis profile. */ @@ -641,7 +656,7 @@ export const snapshotEvidenceForQuery = ( for (const record of snapshot.evidence_bundle.records) { if ( !( - record.subject?.digest.sha256 === target.sha256 && + evidenceFileTarget(record)?.sha256 === target.sha256 && record.operation === operation && committedProvidersEqual(record.provider, provider) && record.analysis_profile !== null && @@ -828,7 +843,7 @@ const restoreSnapshot = ( if ( evidence.predicate_type !== "rea.analysis" || evidence.authority !== "shipped-artifact" || - evidence.subject?.digest.sha256 !== header.target.sha256 || + evidenceFileTarget(evidence)?.sha256 !== header.target.sha256 || evidence.analysis_profile === null || (evidence.confidence !== "observed" && evidence.confidence !== "derived") ) @@ -952,6 +967,21 @@ const hasCanonicalQueryOrder = ( return true; }; +/** + * Whether Evidence is about the snapshot target's bytes. A subject in the + * target's own format is the target, so its whole identity, including the + * selection that the query IDs commit to, must agree with the header. + */ +const subjectNamesSnapshotTarget = ( + evidence: Evidence, + target: AnalysisSnapshotTarget, +): boolean => { + const file = evidenceFileTarget(evidence); + if (file === undefined || file.sha256 !== target.sha256) return false; + const expected = snapshotTargetIdentity(target); + return file.format !== expected.format || sameTargetIdentity(file, expected); +}; + const isCorrespondingEvidence = ( evidence: Evidence, snapshot: Pick, @@ -959,7 +989,7 @@ const isCorrespondingEvidence = ( evidence.predicate_type === "rea.analysis" && evidence.confidence === "observed" && evidence.authority === "shipped-artifact" && - evidence.subject?.digest.sha256 === snapshot.target.sha256 && + subjectNamesSnapshotTarget(evidence, snapshot.target) && evidence.analysis_profile !== null && analysisProfilesEqual( evidence.analysis_profile, @@ -1035,7 +1065,7 @@ const isWorkflowEvidence = ( evidence.predicate_type === "rea.analysis" && evidence.confidence === "derived" && evidence.authority === "shipped-artifact" && - evidence.subject?.digest.sha256 === snapshot.target.sha256 && + subjectNamesSnapshotTarget(evidence, snapshot.target) && evidence.analysis_profile !== null && analysisProfilesEqual( evidence.analysis_profile, @@ -1060,15 +1090,7 @@ const evidenceContentMetadata = (evidence: Evidence) => { limitations: evidence.limitations, relationship_coverage: evidence.relationship_coverage, locations: evidence.locations, - subject: - evidence.subject === null - ? null - : { - local_path: evidence.subject.local_path, - sha256: evidence.subject.digest.sha256, - format: evidence.subject.format, - architecture: evidence.subject.architecture, - }, + subject: executionSubjectContent(evidenceSubjectTarget(evidence.subject)), }; }; diff --git a/src/domain/analysisView/WebNetworkProjectionAccumulator.ts b/src/domain/analysisView/WebNetworkProjectionAccumulator.ts index 66e13ad1a9..51f1905437 100644 --- a/src/domain/analysisView/WebNetworkProjectionAccumulator.ts +++ b/src/domain/analysisView/WebNetworkProjectionAccumulator.ts @@ -21,6 +21,7 @@ import { textBytes, type Reserve, } from "./webNetworkRouteTemplates.js"; +import { evidenceFileTarget } from "../evidence.js"; /** Shared retained/temporary byte accounting for views that group retained HAR records. */ export abstract class WebNetworkProjectionAccumulator { @@ -218,11 +219,11 @@ export const admitHarCaptureParent = ( // Environment views preserve the recorded report path and authenticate its digest; // the api-surface view keeps the admission its existing callers rely on. const { artifact } = parsed.data; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( viewKind !== "api-surface" && artifact.sha256 !== null && - (subject == null || subject.digest.sha256 !== artifact.sha256) + (subject == null || subject.sha256 !== artifact.sha256) ) return err( analysisViewInputError([ diff --git a/src/domain/analysisView/analysisViewParent.ts b/src/domain/analysisView/analysisViewParent.ts index d47030caa8..5bb5fb51ad 100644 --- a/src/domain/analysisView/analysisViewParent.ts +++ b/src/domain/analysisView/analysisViewParent.ts @@ -1,7 +1,7 @@ import type { z } from "zod"; import type { AnalysisInputError } from "../analysisErrorCore.js"; import type { AnalysisError } from "../analysisErrorBase.js"; -import type { Evidence } from "../evidence.js"; +import { evidenceFileTarget, type Evidence } from "../evidence.js"; import { analysisInputErrorFromIssues } from "../inputIssueProjection.js"; import { err, ok, type Result } from "../result.js"; import { ownedJsonValueSchema } from "../jsonValue.js"; @@ -11,14 +11,16 @@ import { EvidenceIntegrityError } from "../evidenceErrors.js"; export const validateAnalysisViewSubject = ( subject: Evidence["subject"] | undefined, artifactSha256: string | null | undefined, -): Result => - subject == null || subject.digest.sha256 === artifactSha256 +): Result => { + const file = evidenceFileTarget({ subject }); + return file === undefined || file.sha256 === artifactSha256 ? ok(undefined) : err( new EvidenceIntegrityError( - `Parent subject SHA-256 ${subject.digest.sha256} differs from analysis artifact SHA-256 ${artifactSha256 ?? "unknown"}.`, + `Parent subject SHA-256 ${file.sha256} differs from analysis artifact SHA-256 ${artifactSha256 ?? "unknown"}.`, ), ); +}; /** Parent record already resolved from inline Evidence or a session reference. */ export interface AnalysisViewParent { diff --git a/src/domain/analysisView/androidPackageView.ts b/src/domain/analysisView/androidPackageView.ts index 20dccb9f2a..3662d0fffe 100644 --- a/src/domain/analysisView/androidPackageView.ts +++ b/src/domain/analysisView/androidPackageView.ts @@ -31,6 +31,7 @@ import { analysisTextPage, analysisTextPageItemSchema, } from "./analysisViewText.js"; +import { evidenceSubjectTarget } from "../evidence.js"; const packageSchema = androidResultSchemas.inspect_android_package; const readReport = createAnalysisViewResultReader(packageSchema); @@ -130,7 +131,8 @@ export const projectAndroidPackageView = ( const parsed = readReport(parent); if (!parsed.ok) return parsed; // The engine digest identifies the JAR, never the authenticated APK subject. - if (parent.subject == null) + const subject = evidenceSubjectTarget(parent.subject); + if (subject === undefined) return err( analysisViewInputError([ { @@ -146,10 +148,7 @@ export const projectAndroidPackageView = ( parent_evidence_id: parent.evidenceId, parent_operation: "inspect_android_package" as const, parent_digest: parent.evidenceId.slice(3), - artifact: { - path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, - }, + artifact: { path: subject.path, sha256: subject.sha256 }, limitations: [...parent.limitations], unknowns: [ "APK signatures were not verified; package declarations do not establish authenticity or runtime behavior.", diff --git a/src/domain/analysisView/androidSymbolView.test.ts b/src/domain/analysisView/androidSymbolView.test.ts index 6d923c1fd9..c84a395e6d 100644 --- a/src/domain/analysisView/androidSymbolView.test.ts +++ b/src/domain/analysisView/androidSymbolView.test.ts @@ -1,3 +1,4 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it, vi } from "vitest"; import { z } from "zod"; import { androidComponentsViewRequestSchema } from "../android/androidPackageQuery.js"; @@ -262,7 +263,10 @@ it.each(["inspect_android_class", "inspect_android_method"] as const)( operation === "inspect_android_class" ? classReport() : methodReport(), ); expect( - projectAnalysisView({ ...parent, subject: null }, { kind: "summary" }), + projectAnalysisView( + { ...parent, subject: UNKNOWN_EVIDENCE_SUBJECT }, + { kind: "summary" }, + ), ).toMatchObject({ ok: false, error: { diff --git a/src/domain/analysisView/androidSymbolView.ts b/src/domain/analysisView/androidSymbolView.ts index 329d84fd4d..9a6456ecf5 100644 --- a/src/domain/analysisView/androidSymbolView.ts +++ b/src/domain/analysisView/androidSymbolView.ts @@ -15,6 +15,7 @@ import { } from "./analysisViewCoverage.js"; import { analysisViewInputError } from "./analysisViewErrors.js"; import { createAnalysisViewResultReader } from "./analysisViewParent.js"; +import { evidenceSubjectTarget } from "../evidence.js"; /** Exact requested facts; only the parent Evidence's raw protocol calls are omitted. */ export const androidClassSummarySchema = @@ -81,7 +82,8 @@ export const projectAndroidSymbolSummary = ( ]), ); // The engine artifact digest is the JAR; it cannot identify the APK. - if (parent.subject == null) + const subject = evidenceSubjectTarget(parent.subject); + if (subject === undefined) return err( analysisViewInputError([ { @@ -97,10 +99,7 @@ export const projectAndroidSymbolSummary = ( view, parent_evidence_id: parent.evidenceId, parent_digest: parent.evidenceId.slice(3), - artifact: { - path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, - }, + artifact: { path: subject.path, sha256: subject.sha256 }, coverage: completeWithinViewCoverage(1), limitations: boundedViewMessages( parent.limitations, diff --git a/src/domain/analysisView/apkSignatureView.ts b/src/domain/analysisView/apkSignatureView.ts index b436cebeb7..1b28f1ab61 100644 --- a/src/domain/analysisView/apkSignatureView.ts +++ b/src/domain/analysisView/apkSignatureView.ts @@ -28,6 +28,7 @@ import { completeWithinViewCoverage, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceSubjectTarget } from "../evidence.js"; const identityFields = new Set([ "id", @@ -99,12 +100,10 @@ const read = (parent: AnalysisViewParent): Result => { const reusable = isImmutableJsonSnapshot(report); const cached = reusable ? checked.get(report) : undefined; // Parent identity is checked on every read, independently of reusable facts. + const subject = evidenceSubjectTarget(parent.subject); if ( - parent.subject != null && - !apkSignatureMatchesSubject(report.artifact, { - sha256: parent.subject.digest.sha256, - format: parent.subject.format, - }) + subject !== undefined && + !apkSignatureMatchesSubject(report.artifact, subject) ) return err( analysisViewInputError([ diff --git a/src/domain/analysisView/artifactInventoryView.test.ts b/src/domain/analysisView/artifactInventoryView.test.ts index 0e85b89b50..28f1c38fca 100644 --- a/src/domain/analysisView/artifactInventoryView.test.ts +++ b/src/domain/analysisView/artifactInventoryView.test.ts @@ -14,6 +14,7 @@ import { projectArtifactInventoryView, } from "./artifactInventoryView.js"; import type { AnalysisViewParent } from "./analysisViewParent.js"; +import { changedEvidenceSubject } from "../../../tests/fixtures/evidenceSubject.js"; const carrier = ARTIFACT_COMPARISON_EXAMPLE.left; const freshInventory = (version: "current" | "historical" = "current") => { @@ -88,10 +89,10 @@ const parent = (normalizedResult: unknown): AnalysisViewParent => ({ predicateType: carrier.predicate_type, evidenceId: carrier.evidence_id, operation: "inventory_artifact", - subject: - carrier.subject === null - ? null - : { ...carrier.subject, format: "zip", architecture: null }, + subject: changedEvidenceSubject(carrier.subject, { + format: "zip", + architecture: null, + }), normalizedResult, sealedResult: true, limitations: [], @@ -327,13 +328,13 @@ it("binds reused facts to the current Evidence ID and validates its subject on e .inventory_evidence_ids, ).toEqual([next.evidenceId]); const subject = next.subject; - if (subject === null || subject === undefined) + if (subject === undefined || subject.identity.kind !== "file") throw new Error("Expected a subject"); expect(() => page( { ...next, - subject: { ...subject, digest: { sha256: "f".repeat(64) } }, + subject: changedEvidenceSubject(subject, { sha256: "f".repeat(64) }), }, { kind: "inventory", collection: "nodes" }, ), diff --git a/src/domain/analysisView/artifactInventoryView.ts b/src/domain/analysisView/artifactInventoryView.ts index 8ac7991e6a..edb681071b 100644 --- a/src/domain/analysisView/artifactInventoryView.ts +++ b/src/domain/analysisView/artifactInventoryView.ts @@ -185,7 +185,7 @@ const parseSource = ( if (cached !== undefined && cached.operation === parent.operation) { try { validateArtifactInventorySubject( - parent.subject ?? null, + parent.subject, cached.source.inventory.manifest, ); } catch (cause: unknown) { @@ -210,14 +210,14 @@ const parseSourceUncached = ( return ok({ inventory: parseArtifactInventoryResult( parent.normalizedResult, - parent.subject ?? null, + parent.subject, ), evidenceIds: [], inspection: null, }); const parsed = parseArtifactInspectionInventoryResult( parent.normalizedResult, - parent.subject ?? null, + parent.subject, ); return ok({ inventory: parsed.inventory, diff --git a/src/domain/analysisView/commandObservationView.ts b/src/domain/analysisView/commandObservationView.ts index 24d0ae1b7c..a9d37feddc 100644 --- a/src/domain/analysisView/commandObservationView.ts +++ b/src/domain/analysisView/commandObservationView.ts @@ -4,7 +4,7 @@ import { gdbCommandResultSchema, } from "../commandObservation.js"; import { digestSchema } from "../digests.js"; -import { providerSchema } from "../evidence.js"; +import { providerSchema, evidenceSubjectTarget } from "../evidence.js"; import { analysisInputErrorFromIssues } from "../inputIssueProjection.js"; import { jsonValueSchema } from "../jsonValue.js"; import { err, ok } from "../result.js"; @@ -81,15 +81,16 @@ export const projectCommandObservationView = ( { cause: parameters.error }, ), ); + const subject = + parent.subject === undefined + ? undefined + : evidenceSubjectTarget(parent.subject); const artifact = - parent.subject === null - ? null - : parent.subject === undefined - ? (parent.artifact ?? null) - : { - path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, - }; + parent.subject === undefined + ? (parent.artifact ?? null) + : subject === undefined + ? null + : { path: subject.path, sha256: subject.sha256 }; const shared = { kind: "summary" as const, view, diff --git a/src/domain/analysisView/dartAotView.ts b/src/domain/analysisView/dartAotView.ts index 00ddcd3b8a..ddca44324e 100644 --- a/src/domain/analysisView/dartAotView.ts +++ b/src/domain/analysisView/dartAotView.ts @@ -1,3 +1,4 @@ +import { evidenceFileTarget } from "../evidence.js"; import { analysisViewInputError } from "./analysisViewErrors.js"; import { z } from "zod"; import { flutterResultSchemas } from "../flutter/flutterBuildAnalysis.js"; @@ -84,7 +85,7 @@ export const projectDartAotView = ( unknowns: [ "String-pool entries are byte-pattern observations, not recovered typed classes or functions.", "Counts ending in _at_least remain lower bounds; exhausting returned strings does not establish a complete snapshot inventory.", - ...(parent.subject == null + ...(evidenceFileTarget(parent) === undefined ? [ "The parent has no recorded subject; its normalized target identity cannot be cross-checked against a subject digest.", ] diff --git a/src/domain/analysisView/desktopApplicationView.ts b/src/domain/analysisView/desktopApplicationView.ts index 038117f64f..ecd1b49f4c 100644 --- a/src/domain/analysisView/desktopApplicationView.ts +++ b/src/domain/analysisView/desktopApplicationView.ts @@ -23,6 +23,7 @@ import { type SummaryAnalysisView, } from "./analysisViewShape.js"; import { ok, err } from "../result.js"; +import { evidenceFileTarget } from "../evidence.js"; // Bound diagnostic context independently of the retained report size. Previews // are display values; stable file IDs select the original paths and all issues. @@ -184,12 +185,11 @@ export const projectDesktopApplicationView = ( validatedParents.add(key); } } - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( subject === undefined || - subject === null || subject.format !== "directory" || - subject.digest.sha256 !== report.root.snapshot_sha256 + subject.sha256 !== report.root.snapshot_sha256 ) return err( analysisViewInputError([ diff --git a/src/domain/analysisView/environmentManifestView.test.ts b/src/domain/analysisView/environmentManifestView.test.ts index 466c30a4bd..5e0ba9144e 100644 --- a/src/domain/analysisView/environmentManifestView.test.ts +++ b/src/domain/analysisView/environmentManifestView.test.ts @@ -1,4 +1,8 @@ import { expect, it } from "vitest"; +import { + changedEvidenceSubject, + UNKNOWN_EVIDENCE_SUBJECT, +} from "../../../tests/fixtures/evidenceSubject.js"; import { analysisViewCaptureEvidence, analysisViewLayoutEvidence, @@ -1174,17 +1178,18 @@ it("refuses a parent whose subject is absent or names another digest", () => { const { subject, ...withoutSubject } = parent; expect(projectAnalysisView(withoutSubject, view())).toMatchObject(refusal); expect( - projectAnalysisView({ ...withoutSubject, subject: null }, view()), + projectAnalysisView( + { ...withoutSubject, subject: UNKNOWN_EVIDENCE_SUBJECT }, + view(), + ), ).toMatchObject(refusal); - if (subject == null) throw new Error("Fixture evidence carries a subject"); + if (subject.identity.kind !== "file") + throw new Error("Fixture evidence carries a subject"); expect( projectAnalysisView( { ...parent, - subject: { - ...subject, - digest: { ...subject.digest, sha256: "0".repeat(64) }, - }, + subject: changedEvidenceSubject(subject, { sha256: "0".repeat(64) }), }, view(), ), diff --git a/src/domain/analysisView/evmInterfaceView.ts b/src/domain/analysisView/evmInterfaceView.ts index c6f8e3114c..f8f609e391 100644 --- a/src/domain/analysisView/evmInterfaceView.ts +++ b/src/domain/analysisView/evmInterfaceView.ts @@ -18,6 +18,7 @@ import { analysisTextPage, analysisTextPageItemSchema, } from "./analysisViewText.js"; +import { evidenceFileTarget } from "../evidence.js"; /** Retained inferred candidates or exact text; offsets for text count UTF-16 code units. */ export const evmViewRequestSchema = z.strictObject({ @@ -69,11 +70,11 @@ export const projectEvmInterfaceView = ( const parsed = parseAnalysisViewResult(evmInterfaceSchema, parent); if (!parsed.ok) return parsed; const report = parsed.value; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( subject == null || subject.format !== "file" || - subject.digest.sha256 !== report.artifact.sha256 + subject.sha256 !== report.artifact.sha256 ) return err( analysisViewInputError([ diff --git a/src/domain/analysisView/goBinaryView.test.ts b/src/domain/analysisView/goBinaryView.test.ts index 751e3ba550..c7ce87ca82 100644 --- a/src/domain/analysisView/goBinaryView.test.ts +++ b/src/domain/analysisView/goBinaryView.test.ts @@ -1,4 +1,8 @@ import { freezeOwnedJsonTreeSnapshot } from "../immutableJson.js"; +import { + changedEvidenceSubject, + fileIdentity, +} from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { AnalysisInputError } from "../analysisErrorCore.js"; import { createEvidence } from "../evidence.js"; @@ -74,11 +78,12 @@ it.each(["digest", "format"] as const)( "rejects a Go parent whose authenticated %s conflicts with its report", (field) => { const input = parent(); - if (input.subject == null) throw new Error("Expected artifact subject"); - const subject = { - ...input.subject, - ...(field === "digest" ? { digest: { sha256: "b".repeat(64) } } : {}), - }; + if (input.subject === undefined || input.subject.identity.kind !== "file") + throw new Error("Expected artifact subject"); + const subject = changedEvidenceSubject( + input.subject, + field === "digest" ? { sha256: "b".repeat(64) } : {}, + ); const result = projectAnalysisView( { ...input, @@ -108,12 +113,14 @@ it.each([ "checks report architecture %j against subject %j for every Go view", (architecture, subjectArchitecture, accepted) => { const input = parent(); - if (input.subject?.format !== "elf") + if ( + input.subject === undefined || + fileIdentity(input.subject).format !== "elf" + ) throw new Error("Expected ELF subject"); - const subject = { - ...input.subject, + const subject = changedEvidenceSubject(input.subject, { architecture: subjectArchitecture, - }; + }); const normalizedResult = { ...report, architecture }; for (const view of [ { kind: "summary" }, @@ -136,12 +143,15 @@ it("revalidates the parent subject after immutable Go report facts have been cac sealedResult: true, }; expect(projectAnalysisView(input, { kind: "summary" }).ok).toBe(true); - if (input.subject == null) throw new Error("Expected artifact subject"); + if (input.subject === undefined || input.subject.identity.kind !== "file") + throw new Error("Expected artifact subject"); expect( projectAnalysisView( { ...input, - subject: { ...input.subject, digest: { sha256: "b".repeat(64) } }, + subject: changedEvidenceSubject(input.subject, { + sha256: "b".repeat(64), + }), }, { kind: "summary" }, ).ok, diff --git a/src/domain/analysisView/goBinaryView.ts b/src/domain/analysisView/goBinaryView.ts index b8ceac0775..ed1f5eacf6 100644 --- a/src/domain/analysisView/goBinaryView.ts +++ b/src/domain/analysisView/goBinaryView.ts @@ -25,6 +25,7 @@ import { import { analysisViewInputError } from "./analysisViewErrors.js"; import { createAnalysisViewResultReader } from "./analysisViewParent.js"; import { selectViewRows } from "./selectViewRows.js"; +import { evidenceFileTarget } from "../evidence.js"; const indexSchema = z.number().int().nonnegative(); const count = z.number().int().nonnegative(); @@ -146,10 +147,10 @@ export const projectGoBinaryView = ( const parsed = parseReport(parent); if (!parsed.ok) return parsed; const report = parsed.value; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( subject == null || - subject.digest.sha256 !== report.artifact.sha256 || + subject.sha256 !== report.artifact.sha256 || subject.format !== metadataReportSubjectFormat(report) || subject.architecture !== (binaryMetadataArchitecture(report.architecture) ?? null) diff --git a/src/domain/analysisView/gpuCodeObjectsView.ts b/src/domain/analysisView/gpuCodeObjectsView.ts index 68a4ac265f..ff771dc45b 100644 --- a/src/domain/analysisView/gpuCodeObjectsView.ts +++ b/src/domain/analysisView/gpuCodeObjectsView.ts @@ -32,6 +32,7 @@ import { err, ok, type Result } from "../result.js"; import type { JsonValue } from "../jsonValue.js"; import { jsonValueByteLength } from "../jsonValueByteLength.js"; import { AnalysisResourceConstraintError } from "../analysisErrorCore.js"; +import { evidenceFileTarget } from "../evidence.js"; export const gpuCodeObjectsViewRequestSchema = z.discriminatedUnion( "collection", [ @@ -197,11 +198,8 @@ const readGpuFacts = ( }; if (reusable) checkedGpu.set(report, checked); } - const subject = parent.subject; - if ( - subject != null && - subject.digest.sha256 !== checked.report.artifact.sha256 - ) + const subject = evidenceFileTarget(parent); + if (subject != null && subject.sha256 !== checked.report.artifact.sha256) return err( analysisViewInputError([ { diff --git a/src/domain/analysisView/il2cppMetadataView.ts b/src/domain/analysisView/il2cppMetadataView.ts index a2cbc157ef..a452479552 100644 --- a/src/domain/analysisView/il2cppMetadataView.ts +++ b/src/domain/analysisView/il2cppMetadataView.ts @@ -35,6 +35,7 @@ import { completeWithinViewCoverage, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceFileTarget } from "../evidence.js"; const countsSchema = z.strictObject({ sections: z.number().int().nonnegative(), @@ -539,11 +540,10 @@ export const projectIl2cppMetadataView = ( const parsed = parseMetadataReport(parent); if (!parsed.ok) return parsed; const { report, counts } = parsed.value; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( subject != null && - (subject.format !== "file" || - subject.digest.sha256 !== report.artifact.sha256) + (subject.format !== "file" || subject.sha256 !== report.artifact.sha256) ) return err( analysisViewInputError([ @@ -633,7 +633,7 @@ export const projectIl2cppMetadataView = ( : report.binary.generic_methods == null ? "Addresses come from static binary tables; runtime behavior and generic instance code remain unknown." : "Addresses come from static binary tables; runtime behavior and generic instances outside genericMethodTable remain unknown.", - ...(parent.subject == null + ...(evidenceFileTarget(parent) === undefined ? [ "The parent has no recorded subject; its normalized artifact identity cannot be cross-checked against a subject digest.", ] diff --git a/src/domain/analysisView/interfaceBuilderView.test.ts b/src/domain/analysisView/interfaceBuilderView.test.ts index c8e9562a7b..91baf4c8ca 100644 --- a/src/domain/analysisView/interfaceBuilderView.test.ts +++ b/src/domain/analysisView/interfaceBuilderView.test.ts @@ -1,9 +1,14 @@ import { describe, expect, it, vi } from "vitest"; +import { + changedEvidenceSubject, + UNKNOWN_EVIDENCE_SUBJECT, +} from "../../../tests/fixtures/evidenceSubject.js"; import { interfaceBuilderAnalysisSchema } from "../apple/interfaceBuilderGraph.js"; import { freezeJsonSnapshot } from "../immutableJson.js"; import { projectAnalysisView } from "./analysisView.js"; import type { AnalysisViewParent } from "./analysisViewParent.js"; +import { evidenceSubject } from "../evidence.js"; import { analysisViewResultSchema } from "./analysisViewResult.js"; const target = "a".repeat(64); @@ -93,13 +98,13 @@ const parent = ( evidenceId: `ev_${"c".repeat(64)}`, operation: "decode_interface_builder", normalizedResult, - subject: { + subject: evidenceSubject({ name: "Fixture", - digest: { sha256 }, + sha256, format: "mach-o", architecture: "arm64", - local_path: "/Applications/Fixture.app/Contents/MacOS/Fixture", - }, + path: "/Applications/Fixture.app/Contents/MacOS/Fixture", + }), limitations: [], }); @@ -124,7 +129,9 @@ describe("Interface Builder immutable interpretation", () => { expect(parse).toHaveBeenCalledTimes(1); const changed = { ...source, - subject: { ...source.subject!, digest: { sha256: "d".repeat(64) } }, + subject: changedEvidenceSubject(source.subject!, { + sha256: "d".repeat(64), + }), }; const rejected = projectAnalysisView(changed, { kind: "summary" }); if (rejected.ok) @@ -211,7 +218,7 @@ describe("Interface Builder analysis views", () => { it("keeps resource-root provenance in both summary and detail views without a subject", () => { const source: AnalysisViewParent = { ...parent(resourceReport()), - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, }; const summary = projectAnalysisView(source, { kind: "summary" }); const detail = projectAnalysisView(source, { diff --git a/src/domain/analysisView/interfaceBuilderView.ts b/src/domain/analysisView/interfaceBuilderView.ts index c8016bb302..76907ce77a 100644 --- a/src/domain/analysisView/interfaceBuilderView.ts +++ b/src/domain/analysisView/interfaceBuilderView.ts @@ -25,6 +25,7 @@ import { completeWithinViewCoverage, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceFileTarget, evidenceSubjectDisplay } from "../evidence.js"; const page = { kind: z.literal("interface-builder"), @@ -132,10 +133,10 @@ const parseInterfaceBuilderReport = ( const parsed = readReport(parent); if (!parsed.ok) return parsed; const report = parsed.value; + const subject = evidenceFileTarget(parent); if ( report.graph.target_sha256 !== report.target_sha256 || - (parent.subject != null && - parent.subject.digest.sha256 !== report.target_sha256) + (subject !== undefined && subject.sha256 !== report.target_sha256) ) return err( analysisViewInputError([ @@ -214,7 +215,7 @@ export const projectInterfaceBuilderView = ( parent_digest: parent.evidenceId.slice(3), artifact: { path: - parent.subject?.local_path ?? + evidenceSubjectDisplay(parent)?.local_path ?? report.resource_root?.canonical_path ?? "", sha256: report.target_sha256, diff --git a/src/domain/analysisView/javascriptRoutesView.test.ts b/src/domain/analysisView/javascriptRoutesView.test.ts index 1442c9785d..51c0ab707e 100644 --- a/src/domain/analysisView/javascriptRoutesView.test.ts +++ b/src/domain/analysisView/javascriptRoutesView.test.ts @@ -1,3 +1,4 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../../tests/fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { analyzeJavaScriptStaticSource } from "../../../tests/fixtures/javascriptStaticAnalysis.js"; import { completeSemanticSteps } from "../javascript/javascriptSemanticTraversal.js"; @@ -6,6 +7,7 @@ import { freezeJsonSnapshot } from "../immutableJson.js"; import { projectAnalysisError } from "../analysisErrorProjection.js"; import { projectAnalysisView } from "./analysisView.js"; import type { AnalysisViewParent } from "./analysisViewParent.js"; +import { evidenceSubject } from "../evidence.js"; import { analysisViewRequestSchema } from "./analysisViewRequest.js"; const inventory = ( @@ -150,7 +152,7 @@ it("accepts captured-page Evidence with an explicitly absent local artifact", () { ...parent(), operation: "analyze_web_bundle", - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, normalizedResult: { capture: { target_url: "https://example.test/" }, route_inventory: inventory(), @@ -176,13 +178,12 @@ it("checks subject identity again after warming an immutable parent", () => { const result = projectAnalysisView( { ...sealed, - subject: { + subject: evidenceSubject({ name: "app", - local_path: "/different", - digest: { sha256: "d".repeat(64) }, + path: "/different", + sha256: "d".repeat(64), format: "javascript-bundle", - architecture: null, - }, + }), }, analysisViewRequestSchema.parse({ kind: "javascript-routes", diff --git a/src/domain/analysisView/javascriptRoutesView.ts b/src/domain/analysisView/javascriptRoutesView.ts index d08f0e7a6e..d2428e445c 100644 --- a/src/domain/analysisView/javascriptRoutesView.ts +++ b/src/domain/analysisView/javascriptRoutesView.ts @@ -32,6 +32,7 @@ import { completeWithinViewCoverage, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceFileTarget } from "../evidence.js"; const identity = { kind: z.literal("javascript-routes") }; const paging = { @@ -348,8 +349,8 @@ export const projectJavaScriptRoutesView = ( path: identity.data.input_path, sha256: identity.data.root_artifact_sha256, }; - const subject = parent.subject; - if (subject != null && subject.digest.sha256 !== artifact.sha256) + const subject = evidenceFileTarget(parent); + if (subject != null && subject.sha256 !== artifact.sha256) return err( inputError( "Parent subject does not match its application artifact identity.", diff --git a/src/domain/analysisView/machoView.test.ts b/src/domain/analysisView/machoView.test.ts index f5a1d44f5c..b396cb090d 100644 --- a/src/domain/analysisView/machoView.test.ts +++ b/src/domain/analysisView/machoView.test.ts @@ -1,8 +1,10 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../../tests/fixtures/evidenceSubject.js"; import { describe, expect, it } from "vitest"; import { inspectMachoSchema } from "../native/nativeInspection.js"; import { projectAnalysisView } from "./analysisView.js"; import type { AnalysisViewParent } from "./analysisViewParent.js"; +import { evidenceSubject } from "../evidence.js"; import { analysisViewResultSchema } from "./analysisViewResult.js"; it("binds every Mach-O facet to its rows, including empty pages", () => { @@ -201,13 +203,13 @@ const report = { }; const parent = ( normalizedResult: unknown = report, - subject: AnalysisViewParent["subject"] = { + subject: AnalysisViewParent["subject"] = evidenceSubject({ name: "tool", - digest: { sha256: "b".repeat(64) }, + sha256: "b".repeat(64), format: "mach-o", architecture: "arm64", - local_path: "/bin/tool", - }, + path: "/bin/tool", + }), ): AnalysisViewParent => ({ predicateType: "rea.analysis", evidenceId: `ev_${"c".repeat(64)}`, @@ -417,9 +419,12 @@ describe("Mach-O analysis views", () => { describe("Mach-O view uncertainty", () => { it("keeps a missing subject unknown instead of inventing identity", () => { - const projected = projectAnalysisView(parent(report, null), { - kind: "summary", - }); + const projected = projectAnalysisView( + parent(report, UNKNOWN_EVIDENCE_SUBJECT), + { + kind: "summary", + }, + ); if (!projected.ok) throw projected.error; expect(projected.value.artifact).toEqual({ path: "", sha256: null }); expect(projected.value.unknowns).toContain( @@ -445,13 +450,15 @@ describe("Mach-O view uncertainty", () => { ], }); const contradictory = projectAnalysisView( - parent(report, { - name: "tool", - digest: { sha256: "b".repeat(64) }, - format: "elf", - architecture: null, - local_path: "/bin/tool", - }), + parent( + report, + evidenceSubject({ + name: "tool", + sha256: "b".repeat(64), + format: "elf", + path: "/bin/tool", + }), + ), { kind: "summary" }, ); if (contradictory.ok) throw new Error("expected a subject refusal"); diff --git a/src/domain/analysisView/machoView.ts b/src/domain/analysisView/machoView.ts index d130040a97..f072fade0c 100644 --- a/src/domain/analysisView/machoView.ts +++ b/src/domain/analysisView/machoView.ts @@ -17,6 +17,7 @@ import { completeWithinViewCoverage, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceFileTarget, evidenceSubjectTarget } from "../evidence.js"; const MACHO_COLLECTIONS = [ "entrypoints", @@ -96,7 +97,8 @@ const parseMachoReport = ( ): Result => { const parsed = parseAnalysisViewResult(inspectMachoSchema, parent); if (!parsed.ok) return parsed; - if (parent.subject != null && !isMachOFormat(parent.subject.format)) + const file = evidenceFileTarget(parent); + if (file !== undefined && !isMachOFormat(file.format)) return err( analysisViewInputError([ { @@ -175,24 +177,22 @@ export const projectMachoView = ( const incomplete = MACHO_COLLECTIONS.filter( (name) => !report[name].exhaustive, ); + const subject = evidenceSubjectTarget(parent.subject); const shared = { parent_evidence_id: parent.evidenceId, parent_operation: "inspect_macho" as const, parent_digest: parent.evidenceId.slice(3), artifact: - parent.subject == null + subject === undefined ? { path: "", sha256: null } - : { - path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, - }, + : { path: subject.path, sha256: subject.sha256 }, unknowns: [ ...(incomplete.length === 0 ? [] : [ `Inspection did not establish exhaustive ${incomplete.join(", ")}; page exhaustion does not establish absence of unreturned rows.`, ]), - ...(parent.subject == null + ...(evidenceFileTarget(parent) === undefined ? [ "The parent has no recorded subject, so the inspected artifact path and SHA-256 are unknown.", ] diff --git a/src/domain/analysisView/managedArtifactView.ts b/src/domain/analysisView/managedArtifactView.ts index cdcfc4b93a..32949b908d 100644 --- a/src/domain/analysisView/managedArtifactView.ts +++ b/src/domain/analysisView/managedArtifactView.ts @@ -1,3 +1,4 @@ +import { evidenceFileTarget } from "../evidence.js"; import { analysisViewInputError } from "./analysisViewErrors.js"; import { z } from "zod"; import { uniqueSorted } from "../canonicalOrdering.js"; @@ -57,7 +58,7 @@ export const managedViewIdentityUnknowns = ( mvid: string | null, ): string[] => [ "Metadata tokens are build-local coordinates bound to the recorded artifact SHA-256 and module MVID; this view does not load or execute the assembly.", - ...(parent.subject == null + ...(evidenceFileTarget(parent) === undefined ? [ "The parent has no recorded subject; its normalized artifact identity cannot be cross-checked against a subject digest.", ] diff --git a/src/domain/analysisView/modelArtifactView.ts b/src/domain/analysisView/modelArtifactView.ts index bc90767d09..6200a69106 100644 --- a/src/domain/analysisView/modelArtifactView.ts +++ b/src/domain/analysisView/modelArtifactView.ts @@ -28,6 +28,7 @@ import { boundedViewMessages, pageViewCoverage, } from "./analysisViewCoverage.js"; +import { evidenceFileTarget } from "../evidence.js"; const HEADLINE_TEXT_LIMIT = 512; @@ -146,8 +147,8 @@ const read = (parent: AnalysisViewParent): Result => { const report = parsed.value; const reusable = isImmutableJsonSnapshot(report); const cached = reusable ? checked.get(report) : undefined; - const subject = parent.subject; - if (subject != null && subject.digest.sha256 !== report.artifact.sha256) + const subject = evidenceFileTarget(parent); + if (subject != null && subject.sha256 !== report.artifact.sha256) return err( analysisViewInputError([ { diff --git a/src/domain/analysisView/nativeInventoryView.test.ts b/src/domain/analysisView/nativeInventoryView.test.ts index 425f151632..a0b75a262c 100644 --- a/src/domain/analysisView/nativeInventoryView.test.ts +++ b/src/domain/analysisView/nativeInventoryView.test.ts @@ -1,3 +1,4 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../../tests/fixtures/evidenceSubject.js"; import { afterEach, expect, it, vi } from "vitest"; import { freezeJsonSnapshot } from "../immutableJson.js"; import { nativeInventoryRowsSchemas } from "../native/nativeInventory.js"; @@ -24,7 +25,7 @@ const parent = (normalizedResult: unknown): AnalysisViewParent => ({ sealedResult: true, provider: { id: "fixture", name: "Fixture", version: "1" }, artifact: null, - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, parameters: { pattern: "a", mode: "literal", case_sensitive: false }, limitations: ["Provider discovery is partial."], }); diff --git a/src/domain/analysisView/nativeObservationView.ts b/src/domain/analysisView/nativeObservationView.ts index 95549d7d7f..1eaefb23d7 100644 --- a/src/domain/analysisView/nativeObservationView.ts +++ b/src/domain/analysisView/nativeObservationView.ts @@ -1,6 +1,6 @@ import type { AnalysisError } from "../analysisErrorBase.js"; import { z } from "zod"; -import { evidenceSubjectIdentity } from "../evidence.js"; +import { evidenceTargetIdentity } from "../evidence.js"; import { digestCanonicalValue } from "../canonicalDigest.js"; import { jsonValueSchema } from "../jsonValue.js"; import { analysisInputErrorFromIssues } from "../inputIssueProjection.js"; @@ -286,7 +286,7 @@ export const projectNativeObservationView = ( digest: digestCanonicalValue( { ...context.value, - subject: evidenceSubjectIdentity(context.value.subject), + subject: evidenceTargetIdentity(context.value), }, "Native source context", ), diff --git a/src/domain/analysisView/pcapCaptureView.ts b/src/domain/analysisView/pcapCaptureView.ts index 0bfd0e17ac..8cd1d2e8b2 100644 --- a/src/domain/analysisView/pcapCaptureView.ts +++ b/src/domain/analysisView/pcapCaptureView.ts @@ -15,6 +15,7 @@ import { pageViewCoverage, } from "./analysisViewCoverage.js"; import { analysisTextPage } from "./analysisViewText.js"; +import { evidenceFileTarget } from "../evidence.js"; const captureSchema = pcapResultSchemas.inspect_pcap_capture; const fields = captureSchema.shape; @@ -126,8 +127,8 @@ const parseParent = ( ): Result => { const parsed = parseAnalysisViewResult(captureSchema, parent); if (!parsed.ok) return parsed; - const subject = parent.subject; - if (subject == null || subject.digest.sha256 !== parsed.value.target.sha256) + const subject = evidenceFileTarget(parent); + if (subject == null || subject.sha256 !== parsed.value.target.sha256) return err( analysisViewInputError([ { diff --git a/src/domain/analysisView/protobufCaptureView.test.ts b/src/domain/analysisView/protobufCaptureView.test.ts index 18d737fd1c..06ce8c02e9 100644 --- a/src/domain/analysisView/protobufCaptureView.test.ts +++ b/src/domain/analysisView/protobufCaptureView.test.ts @@ -1,4 +1,5 @@ import { expect, it } from "vitest"; +import { changedEvidenceSubject } from "../../../tests/fixtures/evidenceSubject.js"; import { createEvidence } from "../evidence.js"; import { projectAnalysisView } from "./analysisView.js"; import { webNetworkCaptureSchema } from "../webNetworkCapture.js"; @@ -210,7 +211,9 @@ it("omits large values by default, returns requested text inline and preserves p const changedSubject = projectAnalysisView( { ...parent, - subject: { ...parent.subject!, digest: { sha256: "e".repeat(64) } }, + subject: changedEvidenceSubject(parent.subject, { + sha256: "e".repeat(64), + }), }, { kind: "protobuf", collection: "bodies", offset: 0, limit: 1 }, ); diff --git a/src/domain/analysisView/recordedArrayView.test.ts b/src/domain/analysisView/recordedArrayView.test.ts index 5e49460d34..fc6c7f6734 100644 --- a/src/domain/analysisView/recordedArrayView.test.ts +++ b/src/domain/analysisView/recordedArrayView.test.ts @@ -1,3 +1,5 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../../tests/fixtures/evidenceSubject.js"; +import { unknownTarget } from "../targetIdentity.js"; import { expect, it } from "vitest"; import { createEvidence } from "../evidence.js"; import { MAX_JSON_DEPTH, type JsonValue } from "../jsonValue.js"; @@ -24,7 +26,7 @@ const parent = ( sealedResult: true, provider: { id: "fixture", name: "Fixture", version: "1" }, artifact: null, - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, parameters, limitations: [], }); @@ -45,7 +47,7 @@ it("omits parent parameters that would exceed Evidence depth by one level", () = // leaf at depth 1000 there, and one level deeper under normalized_result. const parameters = nested(MAX_JSON_DEPTH - 1); const admitted = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "xrefs", @@ -65,7 +67,7 @@ it("omits parent parameters that would exceed Evidence depth by one level", () = expect(projected.value.limitations.join("\n")).toContain("JSON depth"); expect(() => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "view", name: "View", version: "1" }, { operation: "inspect_analysis_view", diff --git a/src/domain/analysisView/rustBinaryView.test.ts b/src/domain/analysisView/rustBinaryView.test.ts index 8e47b109b1..dd02b9192a 100644 --- a/src/domain/analysisView/rustBinaryView.test.ts +++ b/src/domain/analysisView/rustBinaryView.test.ts @@ -1,4 +1,8 @@ import { expect, it } from "vitest"; +import { + changedEvidenceSubject, + fileIdentity, +} from "../../../tests/fixtures/evidenceSubject.js"; import { createEvidence } from "../evidence.js"; import { freezeJsonSnapshot } from "../immutableJson.js"; import type { RustBinary } from "../rust/rustBinary.js"; @@ -112,12 +116,18 @@ it("checks exact artifact identity and subject architecture for every Rust view" for (const changed of [ { format: "pe" as const }, { architecture: "arm64" as const }, - { digest: { sha256: "b".repeat(64) } }, + { sha256: "b".repeat(64) }, ]) { const source = parent(); - if (source.subject == null || source.subject.format !== "elf") + if ( + source.subject === undefined || + fileIdentity(source.subject).format !== "elf" + ) throw new Error("Missing ELF source"); - const input = { ...source, subject: { ...source.subject, ...changed } }; + const input = { + ...source, + subject: changedEvidenceSubject(source.subject, changed), + }; expect(projectAnalysisView(input, { kind: "summary" }).ok).toBe(false); expect( projectAnalysisView(input, { diff --git a/src/domain/analysisView/rustBinaryView.ts b/src/domain/analysisView/rustBinaryView.ts index e0d8d6dd06..901b494aa6 100644 --- a/src/domain/analysisView/rustBinaryView.ts +++ b/src/domain/analysisView/rustBinaryView.ts @@ -27,6 +27,7 @@ import { } from "./analysisViewCoverage.js"; import { analysisViewInputError } from "./analysisViewErrors.js"; import { selectViewRows } from "./selectViewRows.js"; +import { evidenceFileTarget } from "../evidence.js"; const count = z.number().int().nonnegative(); export const rustBinarySummarySchema = z.strictObject({ @@ -132,10 +133,10 @@ export const projectRustBinaryView = ( const parsed = parseReport(parent); if (!parsed.ok) return parsed; const report = parsed.value; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( subject == null || - subject.digest.sha256 !== report.artifact.sha256 || + subject.sha256 !== report.artifact.sha256 || subject.format !== metadataReportSubjectFormat(report) || subject.architecture !== (binaryMetadataArchitecture(report.architecture) ?? null) diff --git a/src/domain/analysisView/wasmArtifactView.ts b/src/domain/analysisView/wasmArtifactView.ts index e6939d305b..2211c04a59 100644 --- a/src/domain/analysisView/wasmArtifactView.ts +++ b/src/domain/analysisView/wasmArtifactView.ts @@ -21,6 +21,7 @@ import { analysisTextPage, analysisTextPageItemSchema, } from "./analysisViewText.js"; +import { evidenceSubjectTarget } from "../evidence.js"; /** Source forms and text from completed WASM Evidence; this never executes a VM. */ export const wasmViewRequestSchema = z.strictObject({ @@ -95,12 +96,7 @@ export const projectWasmArtifactView = ( if ( !wasmArtifactMatchesSubject( report.artifact, - parent.subject == null - ? null - : { - sha256: parent.subject.digest.sha256, - format: parent.subject.format, - }, + evidenceSubjectTarget(parent.subject), ) ) return err( diff --git a/src/domain/analysisView/webNetworkCaptureView.test.ts b/src/domain/analysisView/webNetworkCaptureView.test.ts index 336a57d46b..27663159aa 100644 --- a/src/domain/analysisView/webNetworkCaptureView.test.ts +++ b/src/domain/analysisView/webNetworkCaptureView.test.ts @@ -1,4 +1,8 @@ import { expect, it, vi } from "vitest"; +import { + changedEvidenceSubject, + UNKNOWN_EVIDENCE_SUBJECT, +} from "../../../tests/fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { createEvidence } from "../evidence.js"; import { freezeJsonSnapshot } from "../immutableJson.js"; @@ -152,14 +156,20 @@ it("checks each parent's subject even after its immutable capture has been valid }; expect(projectAnalysisView(source, { kind: "summary" }).ok).toBe(true); expect( - projectAnalysisView({ ...source, subject: null }, { kind: "summary" }).ok, + projectAnalysisView( + { ...source, subject: UNKNOWN_EVIDENCE_SUBJECT }, + { kind: "summary" }, + ).ok, ).toBe(false); - if (source.subject === null) throw new Error("Expected fixture subject"); + if (source.subject.identity.kind !== "file") + throw new Error("Expected fixture subject"); expect( projectAnalysisView( { ...source, - subject: { ...source.subject, digest: { sha256: "e".repeat(64) } }, + subject: changedEvidenceSubject(source.subject, { + sha256: "e".repeat(64), + }), }, { kind: "summary" }, ).ok, @@ -225,7 +235,7 @@ it("retains explicitly unknown digests and rejects a different subject digest", const unknown = projectAnalysisView( { ...parent, - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, normalizedResult: { ...report, artifact: { ...report.artifact, sha256: null }, @@ -239,11 +249,14 @@ it("retains explicitly unknown digests and rejects a different subject digest", expect(unknown.ok && unknown.value.unknowns.join(" ")).toContain( "excluded artifact digest", ); - if (parent.subject === null) throw new Error("Expected fixture subject"); + if (parent.subject.identity.kind !== "file") + throw new Error("Expected fixture subject"); const mismatched = projectAnalysisView( { ...parent, - subject: { ...parent.subject, digest: { sha256: "e".repeat(64) } }, + subject: changedEvidenceSubject(parent.subject, { + sha256: "e".repeat(64), + }), }, { kind: "summary" }, ); diff --git a/src/domain/analysisView/webNetworkCaptureView.ts b/src/domain/analysisView/webNetworkCaptureView.ts index cc1f4e4334..0ef76625ef 100644 --- a/src/domain/analysisView/webNetworkCaptureView.ts +++ b/src/domain/analysisView/webNetworkCaptureView.ts @@ -36,6 +36,7 @@ import { summarizeQlogCapture, projectQlogCapturePage, } from "./qlogCaptureView.js"; +import { evidenceFileTarget } from "../evidence.js"; /** Offsets page the parent's retained record order, preserving producer ordinals. */ export const captureViewRequestSchema = z.strictObject({ @@ -467,10 +468,10 @@ const parseCaptureParent = ( const parsed = parseAnalysisViewResult(captureParser, parent); if (!parsed.ok) return parsed; const report = parsed.value; - const subject = parent.subject; + const subject = evidenceFileTarget(parent); if ( report.artifact.sha256 !== null && - (subject == null || subject.digest.sha256 !== report.artifact.sha256) + (subject == null || subject.sha256 !== report.artifact.sha256) ) return err( analysisViewInputError([ diff --git a/src/domain/apple/appleApplication.ts b/src/domain/apple/appleApplication.ts index 8a75300e78..1b19f11c0f 100644 --- a/src/domain/apple/appleApplication.ts +++ b/src/domain/apple/appleApplication.ts @@ -1,3 +1,4 @@ +import { evidenceSubjectDisplay } from "../evidence.js"; import { z } from "zod"; import { AnalysisInputError } from "../analysisErrorCore.js"; @@ -114,7 +115,7 @@ export const projectAppleInventory = ( projectedInventoryEntries(inventory); const inventoried = projectedFileComponents(entries); const { roots, bundles } = projectAppleBundleAnatomy(entries, { - name: evidence[0]?.subject?.name ?? "", + name: evidenceSubjectDisplay(evidence[0] ?? {})?.name ?? "", format: rootFormat, }); const { all, unattributed } = attributeComponents( diff --git a/src/domain/artifactComparison.test.ts b/src/domain/artifactComparison.test.ts index 50d45305fc..13301173fd 100644 --- a/src/domain/artifactComparison.test.ts +++ b/src/domain/artifactComparison.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { expect, it } from "vitest"; import { ARTIFACT_COMPARISON_EXAMPLE } from "../contracts/artifactComparisonExample.js"; import { compareArtifacts } from "./artifactComparison.js"; @@ -875,11 +876,15 @@ it("names the constraint an unchanged comparison with changes violates", () => { ARTIFACT_COMPARISON_EXAMPLE.right, ); const read = readComparisonResult( - createEvidence(undefined, ARTIFACT_COMPARISON_EXAMPLE.left.provider, { - operation: "compare_artifacts", - parameters: {}, - result: { ...changed, status: "unchanged" }, - }), + createEvidence( + unknownTarget("not-observed"), + ARTIFACT_COMPARISON_EXAMPLE.left.provider, + { + operation: "compare_artifacts", + parameters: {}, + result: { ...changed, status: "unchanged" }, + }, + ), "compare_artifacts", ); if (read.ok) throw new Error("Expected the comparison to be refused"); diff --git a/src/domain/artifactInventoryEvidence.test.ts b/src/domain/artifactInventoryEvidence.test.ts index 1f49a7264a..5149425895 100644 --- a/src/domain/artifactInventoryEvidence.test.ts +++ b/src/domain/artifactInventoryEvidence.test.ts @@ -1,3 +1,7 @@ +import { + fileSubjectTarget, + changedEvidenceSubject, +} from "../../tests/fixtures/evidenceSubject.js"; import { artifactInventoryResultSchema } from "./artifactGraph.js"; import { artifactIdForContent, @@ -23,21 +27,13 @@ const target = inventoryEvidence.subject; if (target === null) throw new Error("Artifact fixture has no target"); const inspectionEvidence = (result: unknown, subject = target) => - createEvidence( - { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, - }, - inventoryEvidence.provider, - { - operation: "inspect_artifact", - parameters: {}, - result, - confidence: "observed", - authority: "shipped-artifact", - }, - ); + createEvidence(fileSubjectTarget(subject), inventoryEvidence.provider, { + operation: "inspect_artifact", + parameters: {}, + result, + confidence: "observed", + authority: "shipped-artifact", + }); const inspection = createArtifactInspection(inventoryEvidence); @@ -52,11 +48,7 @@ it.each([ inventoryEvidence.normalized_result, ); const carrier = createEvidence( - { - path: target.local_path, - sha256: target.digest.sha256, - format: target.format, - }, + fileSubjectTarget(target), inventoryEvidence.provider, { operation: "inventory_artifact", @@ -82,10 +74,10 @@ it("accepts an inspection whose carrier, declaration, and substep identities agr }); it("rejects an inspection carrier whose Evidence subject disagrees with its nested inventory", () => { - const carrier = inspectionEvidence(inspection, { - ...target, - digest: { sha256: "a".repeat(64) }, - }); + const carrier = inspectionEvidence( + inspection, + changedEvidenceSubject(target, { sha256: "a".repeat(64) }), + ); try { parseArtifactInventoryEvidence(carrier); throw new Error("Expected the mismatched subject to be rejected"); @@ -177,26 +169,18 @@ it("keeps a commitment failure discovered across individually incomplete pages a ), }; const page = (includeNodes: boolean) => - createEvidence( - { - path: target.local_path, - sha256: target.digest.sha256, - format: target.format, + createEvidence(fileSubjectTarget(target), inventoryEvidence.provider, { + operation: "inventory_artifact", + parameters: {}, + confidence: "observed", + authority: "shipped-artifact", + result: { + ...complete, + manifest, + nodes: includeNodes ? complete.nodes : [], + occurrences: includeNodes ? [] : complete.occurrences, }, - inventoryEvidence.provider, - { - operation: "inventory_artifact", - parameters: {}, - confidence: "observed", - authority: "shipped-artifact", - result: { - ...complete, - manifest, - nodes: includeNodes ? complete.nodes : [], - occurrences: includeNodes ? [] : complete.occurrences, - }, - }, - ); + }); const nodes = page(true); const occurrences = page(false); expect(parseArtifactInventoryEvidence(nodes).inventory.complete).toBe(false); @@ -257,28 +241,20 @@ it.each( }; const manifest = { ...inventory.manifest, edge_count: 1 }; const page = (indices: readonly number[]) => - createEvidence( - { - path: target.local_path, - sha256: target.digest.sha256, - format: target.format, + createEvidence(fileSubjectTarget(target), inventoryEvidence.provider, { + operation: "inventory_artifact", + parameters: {}, + confidence: "observed", + authority: "shipped-artifact", + result: { + ...inventory, + manifest, + nodes: [], + occurrences: [], + edges: [], + [member]: indices.map((index) => members[member][index]!), }, - inventoryEvidence.provider, - { - operation: "inventory_artifact", - parameters: {}, - confidence: "observed", - authority: "shipped-artifact", - result: { - ...inventory, - manifest, - nodes: [], - occurrences: [], - edges: [], - [member]: indices.map((index) => members[member][index]!), - }, - }, - ); + }); const first = page([0]); const second = page([1]); expect(parseArtifactInventoryEvidence(first).inventory.complete).toBe( diff --git a/src/domain/artifactInventoryEvidence.ts b/src/domain/artifactInventoryEvidence.ts index 497f43679f..681b09ae36 100644 --- a/src/domain/artifactInventoryEvidence.ts +++ b/src/domain/artifactInventoryEvidence.ts @@ -22,10 +22,11 @@ import { artifactManifestId, occurrenceIdForLocation, } from "./artifactIdentity.js"; -import type { Evidence } from "./evidence.js"; +import { evidenceFileTarget, type Evidence } from "./evidence.js"; import { z } from "zod"; import { EvidenceIntegrityError } from "./evidenceErrors.js"; import { readEvidence, safeParseEvidence } from "./evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "./evidenceFormat.js"; import { artifactInspectionResultSchema, type ArtifactInspectionResult, @@ -142,7 +143,7 @@ export const parseArtifactInventoryEvidence = ( const parseInspectionEvidencePayload = ( input: unknown, - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): readonly ArtifactInventoryResult[] => { try { return parseInspectionInventoryPayload(input, subject).pages; @@ -155,7 +156,7 @@ const parseInspectionEvidencePayload = ( /** Parse and authenticate an already-owned inspection payload and its pages. */ export const parseArtifactInspectionInventoryResult = ( input: unknown, - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): ParsedArtifactInspectionInventory => { const parsed = parseInspectionInventoryPayload(input, subject); return { @@ -168,7 +169,7 @@ export const parseArtifactInspectionInventoryResult = ( /** Shared owner boundary for full Evidence and already-authenticated parents. */ const parseInspectionInventoryPayload = ( input: unknown, - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): { readonly inspection: ArtifactInspectionResult; readonly pages: readonly ArtifactInventoryResult[]; @@ -193,7 +194,9 @@ const parseInspectionInventoryPayload = ( const sourceEvidence = immutableJsonSnapshotMember(sealedStep, "evidence") ?? step.evidence; const parsedEvidence = safeParseEvidence(sourceEvidence); - if (!parsedEvidence.ok) + if (!parsedEvidence.ok) { + if (isUnsupportedEvidenceFormat(parsedEvidence.error)) + throw parsedEvidence.error; throw Object.assign( new z.ZodError( parsedEvidence.error.issues.map((issue) => ({ @@ -203,6 +206,7 @@ const parseInspectionInventoryPayload = ( ), { cause: parsedEvidence.error }, ); + } const evidence = canBorrowParsedJsonSnapshot( sourceEvidence, parsedEvidence.value, @@ -234,7 +238,7 @@ const parseInspectionInventoryPayload = ( /** Ensure the inspection declaration and carrier identify its inventory. */ const validateInspectionSubject = ( - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, inspection: ArtifactInspectionResult, manifest: ArtifactInventoryResult["manifest"], ): void => { @@ -256,14 +260,14 @@ const validateInspectionSubject = ( /** Validate one already authenticated parent payload with the same graph proofs. */ export const parseArtifactInventoryResult = ( input: unknown, - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): InventorySet => assembleInventoryResults([parseInventoryPage(input, subject)]); /** Parse one already authenticated inventory result into its validated facts. */ const parseInventoryPage = ( input: unknown, - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): ArtifactInventoryResult => { const parsed = artifactInventoryResultSchema.parse(input); const inventory = canBorrowParsedJsonSnapshot(input, parsed) @@ -293,16 +297,20 @@ const parseInventoryEvidencePage = ( }; const subjectMatchesInventoryRoot = ( - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, manifest: ArtifactInventoryResult["manifest"], -): boolean => - subject !== null && - subject.digest.sha256 === manifest.root_sha256 && - subject.format === manifest.root_format; +): boolean => { + const target = evidenceFileTarget({ subject }); + return ( + target !== undefined && + target.sha256 === manifest.root_sha256 && + target.format === manifest.root_format + ); +}; /** Both inventory carriers require the same authenticated root identity. */ export const validateArtifactInventorySubject = ( - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, manifest: ArtifactInventoryResult["manifest"], ): void => { if (!subjectMatchesInventoryRoot(subject, manifest)) diff --git a/src/domain/bundleComparison.test.ts b/src/domain/bundleComparison.test.ts index 24ec3251e0..fa18348460 100644 --- a/src/domain/bundleComparison.test.ts +++ b/src/domain/bundleComparison.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { @@ -17,7 +18,7 @@ import { const PROVIDER = { id: "fixture", name: "Fixture", version: "1" } as const; const evidence = (label: string) => - createEvidence(undefined, PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROVIDER, { operation: "observe", parameters: { label }, result: { label }, diff --git a/src/domain/callPath.test.ts b/src/domain/callPath.test.ts index a49d83e15b..feb2ccb0ba 100644 --- a/src/domain/callPath.test.ts +++ b/src/domain/callPath.test.ts @@ -8,7 +8,11 @@ import { import { buildCallPath } from "./callPath.js"; import { combineFunctionRelationshipCoverage } from "./functionCallCoverage.js"; import { callPathResultSchema, type CallPathInput } from "./callPathSchemas.js"; -import { createEvidence, type Evidence } from "./evidence.js"; +import { + createEvidence, + type Evidence, + type EvidenceSubjectTarget, +} from "./evidence.js"; import type { JsonValue } from "./jsonValue.js"; import type { RelationshipCoverage } from "./relationshipCoverage.js"; import { createFunctionCoordinateContext } from "./native/functionCoordinateContext.js"; @@ -23,6 +27,7 @@ const observe = ( readonly relationshipCoverage?: RelationshipCoverage; readonly calleeUnavailable?: string; readonly analysisProfile?: AnalysisProfileCommitment; + readonly target?: EvidenceSubjectTarget; } = {}, ): Evidence => { const value = { @@ -69,7 +74,11 @@ const observe = ( }), } satisfies JsonValue; return createEvidence( - { path: "/tmp/a", sha256: "a".repeat(64), format: "mach-o" }, + options.target ?? { + path: "/tmp/a", + sha256: "a".repeat(64), + format: "mach-o", + }, { id: provider, name: provider, version: "1" }, { operation: "analyze_function", @@ -794,6 +803,38 @@ describe("call path evidence admission", () => { ).toThrow(); }); + it("refuses functions from the same bytes opened at different entry points", () => { + const raw = (entryPoint: string): EvidenceSubjectTarget => ({ + path: "/tmp/a.bin", + sha256: "a".repeat(64), + format: "raw-binary", + architecture: "arm64", + selection: { kind: "entry-point", entry_point: entryPoint }, + }); + const start = observe("0x1000", ["0x4000"], "rea-workflow", { + target: raw("0x0"), + }); + expect( + run([ + start, + observe("0x4000", [], "rea-workflow", { target: raw("0x0") }), + ]).status, + ).toBe("found"); + let refused: unknown; + try { + run([ + start, + observe("0x4000", [], "rea-workflow", { target: raw("0x100") }), + ]); + } catch (cause: unknown) { + refused = cause; + } + expect(refused).toBeInstanceOf(AnalysisInputError); + expect(JSON.stringify((refused as AnalysisInputError).issues)).toContain( + "Call-path Evidence mixes artifact subjects", + ); + }); + it("requires an observed start function", () => { expect(() => run([observe("0x2000", [])])).toThrow(AnalysisInputError); }); diff --git a/src/domain/callPath.ts b/src/domain/callPath.ts index 6745adf9a9..38d097b6f4 100644 --- a/src/domain/callPath.ts +++ b/src/domain/callPath.ts @@ -22,6 +22,7 @@ import { import { isCallerOnlyIncompleteCoverage } from "./functionCallCoverage.js"; import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js"; import { appendAll } from "./appendAll.js"; +import { sameTargetIdentity } from "./targetIdentity.js"; /** Minimal directed caller-to-callee adjacency for call-path search. */ class CallGraph { @@ -218,11 +219,7 @@ const assertCompatible = ( if (firstEntry.done) return; const first = firstEntry.value; for (const snapshot of snapshots.values()) { - if ( - snapshot.subject.digest.sha256 !== first.subject.digest.sha256 || - snapshot.subject.format !== first.subject.format || - snapshot.subject.architecture !== first.subject.architecture - ) + if (!sameTargetIdentity(snapshot.target, first.target)) throw invalidCallPathSelection( ["functions"], "Call-path Evidence mixes artifact subjects", diff --git a/src/domain/changedBehavior.test.ts b/src/domain/changedBehavior.test.ts index 84d8e94c72..3d4e0ecf2c 100644 --- a/src/domain/changedBehavior.test.ts +++ b/src/domain/changedBehavior.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { FUNCTION_COMPARISON_EVIDENCE } from "../contracts/investigationExamples.js"; import { @@ -5,7 +6,11 @@ import { findChangedBehavior, type ChangedBehaviorResult, } from "./changedBehavior.js"; -import { createEvidence, type Evidence } from "./evidence.js"; +import { + createEvidence, + type Evidence, + evidenceSubjectInput, +} from "./evidence.js"; import { functionComparisonResultSchema } from "./functionComparisonSchemas.js"; import type { JsonValue } from "./jsonValue.js"; @@ -33,7 +38,7 @@ const comparison = ( ): Evidence => { const process = operation === "compare_process_captures"; return createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: process ? "rea-process" : "rea-artifact-comparison", name: process @@ -328,7 +333,7 @@ describe("changed-behavior input and Evidence validation", () => { it("rejects a comparison operation unsupported by this workflow", () => { const bundle = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-bundle-comparison", name: "Bundle", version: "1" }, { predicateType: "rea.bundle-comparison", @@ -410,19 +415,23 @@ describe("changed-behavior input and Evidence validation", () => { ...dimension, evidence_links: [...dimension.evidence_links, `ev_${"f".repeat(64)}`], })); - const danglingNested = createEvidence(undefined, base.provider, { - predicateType: base.predicate_type, - operation: base.operation, - parameters: base.parameters, - result: functionComparisonResultSchema.parse({ - ...result, - dimensions, - changes: dimensions.filter(({ status }) => status !== "unchanged"), - }), - confidence: base.confidence, - authority: base.authority, - evidenceLinks: base.evidence_links, - }); + const danglingNested = createEvidence( + evidenceSubjectInput(base.subject), + base.provider, + { + predicateType: base.predicate_type, + operation: base.operation, + parameters: base.parameters, + result: functionComparisonResultSchema.parse({ + ...result, + dimensions, + changes: dimensions.filter(({ status }) => status !== "unchanged"), + }), + confidence: base.confidence, + authority: base.authority, + evidenceLinks: base.evidence_links, + }, + ); expect(() => aggregate([danglingNested])).toThrowError( expect.toSatisfy( (error: { _tag?: unknown; message?: unknown; cause?: unknown }) => diff --git a/src/domain/comparisonEvidenceIdentity.ts b/src/domain/comparisonEvidenceIdentity.ts index 82d48b4949..a1a4e232c2 100644 --- a/src/domain/comparisonEvidenceIdentity.ts +++ b/src/domain/comparisonEvidenceIdentity.ts @@ -1,3 +1,4 @@ +import { unknownTarget, sameTargetIdentity } from "./targetIdentity.js"; import type { Evidence } from "./evidence.js"; import { createAnalysisProfile } from "./analysisProfile.js"; import { @@ -63,6 +64,9 @@ export const hasComparisonEvidenceIdentity = (evidence: Evidence): boolean => { providerMatches && evidence.confidence === "derived" && evidence.authority === "analyst-inference" && - evidence.subject === null + sameTargetIdentity( + evidence.subject.identity, + unknownTarget("derived-from-linked-evidence"), + ) ); }; diff --git a/src/domain/evidence.test.ts b/src/domain/evidence.test.ts index c1b0277e02..fc182de15f 100644 --- a/src/domain/evidence.test.ts +++ b/src/domain/evidence.test.ts @@ -1,3 +1,5 @@ +import { displayedEvidenceSubject } from "../../tests/fixtures/evidenceSubject.js"; +import { unknownTarget } from "./targetIdentity.js"; import { PRE_66_NULL_COVERAGE_EVIDENCE } from "./evidenceLegacy.fixture.js"; import { fc, it } from "@fast-check/vitest"; import { describe, expect } from "vitest"; @@ -15,6 +17,8 @@ import { immutableEvidence, withEvidenceCallerInputPath, rebindEvidenceToTargetPath, + evidenceFileTarget, + evidenceSubjectDisplay, } from "./evidence.js"; import { MAX_JSON_DEPTH, @@ -24,6 +28,7 @@ import { import { AnalysisResourceConstraintError } from "./analysisErrorCore.js"; import { projectAnalysisError } from "./analysisErrorProjection.js"; import { createEvidenceBundle } from "./evidenceBundle.js"; +import { RECREATE_EVIDENCE_GUIDANCE } from "./evidenceFormat.js"; import { freezeJsonSnapshot } from "./immutableJson.js"; const TARGET: BinaryTarget = { @@ -37,6 +42,129 @@ const TARGET: BinaryTarget = { const PROVIDER = { id: "fixture", name: "Fixture provider", version: "1" }; const PROFILE = createAnalysisProfile(PROVIDER, { loader: "default" }); +describe("subject target identity", () => { + const raw = (entryPoint: string): BinaryTarget => ({ + path: "/tmp/firmware.bin", + sha256: "b".repeat(64), + kind: "executable", + format: "raw-binary", + architecture: "arm", + availableArchitectures: ["arm"], + entryPoint, + entryPointSource: "caller", + }); + const observe = (target: BinaryTarget) => + createEvidence(target, PROVIDER, { + operation: "inspect", + parameters: {}, + result: null, + }); + + it("commits to the selection, so entry points of the same bytes are different subjects", () => { + const first = observe(raw("0x0")); + const second = observe(raw("0x100")); + expect(evidenceFileTarget(first)).toEqual({ + kind: "file", + sha256: "b".repeat(64), + format: "raw-binary", + architecture: "arm", + selection: { kind: "entry-point", entry_point: "0x0" }, + }); + expect(first.evidence_format).toBe(2); + expect(first.evidence_id).not.toBe(second.evidence_id); + }); + + it("keeps the ID when only the display path changes", () => { + const original = observe(raw("0x0")); + const rebound = rebindEvidenceToTargetPath(original, { + ...raw("0x0"), + path: "/elsewhere/firmware.bin", + }); + expect(evidenceSubjectDisplay(rebound)).toEqual({ + name: "firmware.bin", + local_path: "/elsewhere/firmware.bin", + }); + expect(rebound.evidence_id).toBe(original.evidence_id); + // A different selection is a different target, so the path is not rebound. + expect( + rebindEvidenceToTargetPath(original, { + ...raw("0x100"), + path: "/elsewhere/firmware.bin", + }), + ).toBe(original); + }); + + it("names the subject only by its identity and display facts", () => { + const record = observe(raw("0x0")); + expect(Object.keys(record.subject ?? {}).sort()).toEqual([ + "identity", + "local_path", + "name", + ]); + const serialized = JSON.parse(JSON.stringify(record)); + // A record that still declares the removed duplicate members is refused. + expect(() => + parseEvidence({ + ...serialized, + subject: { + ...serialized.subject, + digest: { sha256: "b".repeat(64) }, + format: "raw-binary", + architecture: "arm", + }, + }), + ).toThrow(/digest|format|architecture/u); + }); + + it("refuses a subject identity that its format does not admit", () => { + const record = JSON.parse(JSON.stringify(observe(raw("0x0")))); + const forged = (identity: Record) => ({ + ...record, + subject: { + ...record.subject, + identity: { ...record.subject.identity, ...identity }, + }, + }); + // The schema has no ID check, so only the format-owned declaration can refuse it. + expect( + evidenceSchema.safeParse( + forged({ + format: "gamecube-dol", + architecture: "arm", + selection: null, + }), + ).success, + ).toBe(false); + expect( + evidenceSchema.safeParse( + forged({ + format: "gamecube-dol", + architecture: "powerpc", + selection: { kind: "entry-point", entry_point: "0x80003100" }, + }), + ).success, + ).toBe(true); + expect(() => + parseEvidence( + forged({ + selection: { + kind: "esp-flash", + flash_offset: 0, + partition_table_offset: null, + }, + }), + ), + ).toThrow(/esp-flash selection does not apply to format raw-binary/u); + expect(() => + parseEvidence( + forged({ + selection: { kind: "entry-point", entry_point: "not-an-address" }, + }), + ), + ).toThrow(/hexadecimal address/u); + }); +}); + it.each(RAW_ONLY_ARCHITECTURES)( "rejects a detected Evidence subject with the raw-only %s architecture", (architecture) => { @@ -52,7 +180,7 @@ it.each(RAW_ONLY_ARCHITECTURES)( parameters: {}, result: null, }).subject, - ).toMatchObject({ format: "raw-binary", architecture }); + ).toMatchObject({ identity: { format: "raw-binary", architecture } }); const malformed = { ...selected, format: "pe" as const, @@ -80,7 +208,7 @@ it("keeps 6502 confined to explicit raw Evidence subjects alongside iNES", () => parameters: {}, result: null, }).subject, - ).toMatchObject({ format: "raw-binary", architecture: "6502" }); + ).toMatchObject({ identity: { format: "raw-binary", architecture: "6502" } }); expect( createEvidence( { @@ -91,7 +219,7 @@ it("keeps 6502 confined to explicit raw Evidence subjects alongside iNES", () => PROVIDER, { operation: "inspect", parameters: {}, result: null }, ).subject, - ).toMatchObject({ format: "ines", architecture: null }); + ).toMatchObject({ identity: { format: "ines", architecture: null } }); for (const format of ["pe", "ines"] as const) { expect(() => createEvidence({ ...selected, format }, PROVIDER, { @@ -588,7 +716,7 @@ describe("analysis evidence identity", () => { expect(parseEvidence(evidence)).toEqual(evidence); expect(evidence).toMatchObject({ provider: PROVIDER, - subject: { digest: { sha256: "a".repeat(64) } }, + subject: { identity: { sha256: "a".repeat(64) } }, confidence: "observed", authority: "shipped-artifact", raw_result: { token: "" }, @@ -669,10 +797,10 @@ it("rejects a subject local path containing NUL while admitting an empty path", parameters: {}, result: true, }); - expect(evidence.subject).not.toBeNull(); + expect(evidence.subject.identity.kind).toBe("file"); const withPath = (path: string) => ({ ...evidence, - subject: { ...evidence.subject, local_path: path }, + subject: displayedEvidenceSubject(evidence.subject, { local_path: path }), }); expect(evidenceSchema.safeParse(withPath("/tmp/fixture")).success).toBe(true); expect(evidenceSchema.safeParse(withPath("")).success).toBe(true); @@ -680,18 +808,27 @@ it("rejects a subject local path containing NUL while admitting an empty path", }); it("binds an explicit unknown-subject reason into the semantic Evidence identity", () => { - const reason = "Caller excluded the observed digest."; const observation = { operation: "health", parameters: {}, result: true }; - const explicit = createEvidence(undefined, PROVIDER, { - ...observation, - subjectUnavailableReason: reason, + const explicit = createEvidence( + unknownTarget("derived-from-linked-evidence"), + PROVIDER, + observation, + ); + const defaulted = createEvidence( + unknownTarget("not-observed"), + PROVIDER, + observation, + ); + expect(explicit.subject).toEqual({ + identity: { kind: "unknown", reason: "derived-from-linked-evidence" }, + name: null, + local_path: null, }); - const defaulted = createEvidence(undefined, PROVIDER, observation); - expect(explicit.subject).toBeNull(); - expect(explicit.limitations).toEqual([reason]); - expect(defaulted.limitations).toEqual([ - expect.stringMatching(/artifact identity.*unavailable/iu), - ]); + expect(evidenceFileTarget(explicit)).toBeUndefined(); + expect(evidenceSubjectDisplay(explicit)).toBeUndefined(); + // The closed reason replaces the generic missing-subject limitation. + expect(explicit.limitations).toEqual([]); + expect(defaulted.limitations).toEqual([]); expect(explicit.evidence_id).not.toBe(defaulted.evidence_id); expect(parseEvidence(explicit)).toEqual(explicit); }); @@ -703,7 +840,7 @@ it("derives byte-stable bundle manifests independent of record order", () => { result: true, }); const captureEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "process", name: "Process capture", version: "1" }, { predicateType: "rea.process-capture", @@ -744,8 +881,7 @@ describe("DOS analysis evidence identity", () => { const observation = { operation: "health", parameters: {}, result: true }; const evidence = createEvidence(target, PROVIDER, observation); expect(parseEvidence(evidence).subject).toMatchObject({ - format: "dos-mz", - architecture: "x86", + identity: { format: "dos-mz", architecture: "x86" }, }); expect(evidence.evidence_id).not.toBe( createEvidence({ ...target, format: "pe" }, PROVIDER, observation) @@ -888,21 +1024,22 @@ it("borrows a previously sealed envelope only after authenticating all semantic expect(() => immutableEvidence(changed)).toThrow(); }); -it("diagnoses a previous explicit-null coverage commitment without admitting or rewriting its ID", () => { +it("refuses a record from an earlier format without admitting or rewriting its ID", () => { const historical = structuredClone(PRE_66_NULL_COVERAGE_EVIDENCE); - expect(() => parseEvidence(historical)).toThrow( - /earlier relationship_coverage identity commitment/u, + expect(() => parseEvidence(historical)).toThrow(RECREATE_EVIDENCE_GUIDANCE); + expect(() => parseEvidence({ ...historical, evidence_format: 1 })).toThrow( + /Evidence record format 1 is not format 2/u, ); expect(historical).toEqual(PRE_66_NULL_COVERAGE_EVIDENCE); - const corrupted = { ...historical, normalized_result: { observed: false } }; - expect(() => parseEvidence(corrupted)).toThrow( - /semantic identifier does not match/u, + const current = createEvidence( + unknownTarget("not-observed"), + historical.provider, + { + operation: "inspect", + parameters: {}, + result: { observed: true }, + }, ); - const current = createEvidence(undefined, historical.provider, { - operation: "inspect", - parameters: {}, - result: { observed: true }, - }); expect(parseEvidence(current)).toEqual(current); }); diff --git a/src/domain/evidence.ts b/src/domain/evidence.ts index 216c33f22d..3d4a4d53e2 100644 --- a/src/domain/evidence.ts +++ b/src/domain/evidence.ts @@ -1,4 +1,8 @@ -import { RECREATE_EVIDENCE_GUIDANCE } from "./evidenceFormat.js"; +import { + admitEvidenceRecordFormat, + EVIDENCE_FORMAT_REVISION, + evidenceFormatSchema, +} from "./evidenceFormat.js"; import { isDeepStrictEqual } from "node:util"; import { basename } from "node:path"; import { z } from "zod"; @@ -8,6 +12,16 @@ import { withEvidenceSubjectDeclaration } from "./evidenceSubject.js"; import { digestCanonicalValue } from "./canonicalDigest.js"; import { canonicalJsonDigestSteps } from "./canonicalJsonDigestSteps.js"; import { nulFreeStringSchema } from "./localPath.js"; +import { + binaryTargetIdentity, + fileTargetSelectionSchema, + unknownTargetIdentitySchema, + type UnknownTargetIdentity, + sameTargetIdentity, + type FileTargetIdentity, + type FileTargetSelection, + type TargetIdentity, +} from "./targetIdentity.js"; import { analysisProfileSchema, @@ -36,8 +50,6 @@ import { /** Predicate shared by ordinary provider analysis observations. */ export const ANALYSIS_EVIDENCE_PREDICATE = "rea.analysis"; -export const MISSING_EVIDENCE_SUBJECT_LIMITATION = - "Artifact identity is unavailable for this observation."; /** Provider identity schema shared by evidence-bearing persistence formats. */ export const providerSchema = z.strictObject({ @@ -45,12 +57,44 @@ export const providerSchema = z.strictObject({ name: z.string().min(1), version: z.string().nullable(), }); -const subjectBaseSchema = z.strictObject({ +/** Formats whose identity carries each selection kind. */ +const SELECTION_FORMATS: Readonly< + Record +> = { + "entry-point": ["raw-binary", "gamecube-dol"], + "esp-flash": ["esp-flash-image"], +}; +/** The file identity an Evidence subject commits to, with its format-owned declaration. */ +const subjectIdentitySchema = withEvidenceSubjectDeclaration( + z.strictObject({ + kind: z.literal("file"), + sha256: digestSchema, + selection: fileTargetSelectionSchema.nullable(), + }), +).superRefine((identity, context) => { + if ( + identity.selection !== null && + !SELECTION_FORMATS[identity.selection.kind].includes(identity.format) + ) + context.addIssue({ + code: "custom", + path: ["selection"], + message: `A ${identity.selection.kind} selection does not apply to format ${identity.format}`, + }); +}); +const fileSubjectSchema = z.strictObject({ + /** The committed target identity; the remaining members are display facts. */ + identity: subjectIdentitySchema, name: z.string().min(1), - digest: z.strictObject({ sha256: digestSchema }), local_path: nulFreeStringSchema, }); -const subjectSchema = withEvidenceSubjectDeclaration(subjectBaseSchema); +/** A subject REA did not identify has no display facts to show. */ +const unknownSubjectSchema = z.strictObject({ + identity: unknownTargetIdentitySchema, + name: z.null(), + local_path: z.null(), +}); +const subjectSchema = z.union([fileSubjectSchema, unknownSubjectSchema]); /** Source location attached to an evidence observation. */ /** Source-location schema shared by evidence-bearing persistence formats. */ export const evidenceLocationSchema = z.discriminatedUnion("kind", [ @@ -99,7 +143,9 @@ export type CallerInputPaths = Readonly< const evidenceBaseSchema = z .object({ evidence_id: prefixedDigestSchema("ev"), - subject: subjectSchema.nullable(), + /** Selects the reader; not part of the committed content. */ + evidence_format: evidenceFormatSchema, + subject: subjectSchema, provider: providerSchema, analysis_profile: analysisProfileSchema.nullable(), predicate_type: z.string().min(1), @@ -160,9 +206,7 @@ const authenticatedEvidenceSchema = evidenceSchema.superRefine( context.addIssue({ code: "custom", path: ["evidence_id"], - message: usesPre66NullCoverageIdentity(withoutId, evidenceId) - ? `Evidence uses an earlier relationship_coverage identity commitment: explicit null was omitted from that digest. ${RECREATE_EVIDENCE_GUIDANCE}` - : "Evidence semantic identifier does not match its record", + message: "Evidence semantic identifier does not match its record", }); }, ); @@ -187,45 +231,119 @@ export type EvidenceLocation = z.infer; export interface EvidenceSubjectTarget { readonly path: string; readonly sha256: string; - readonly format: z.infer["format"]; + readonly format: z.infer["format"]; readonly architecture?: BinaryArchitecture; + /** What the observation selected inside the bytes; absent selects nothing. */ + readonly selection?: FileTargetSelection; /** Preserve an existing Evidence subject's display name when deriving observations. */ readonly name?: string; } -/** Preserve the complete subject when deriving a new Evidence observation. */ +/** What a producer names as an Evidence subject: a file target, or an explicit unknown. */ +export type EvidenceSubjectInput = + | EvidenceSubjectTarget + | BinaryTarget + | UnknownTargetIdentity; + +type FileEvidenceSubject = z.infer; + +/** Whether a subject names a file; only a file subject has display facts. */ +const isFileSubject = ( + subject: Evidence["subject"] | undefined, +): subject is FileEvidenceSubject => subject?.identity.kind === "file"; + +/** Preserve the complete file subject when deriving a new Evidence observation. */ export const evidenceSubjectTarget = ( - subject: Evidence["subject"], + subject: Evidence["subject"] | undefined, ): EvidenceSubjectTarget | undefined => - subject === null + !isFileSubject(subject) ? undefined : { path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + sha256: subject.identity.sha256, + format: subject.identity.format, name: subject.name, - ...(subject.architecture === null + ...(subject.identity.architecture === null ? {} - : { architecture: subject.architecture }), + : { architecture: subject.identity.architecture }), + ...(subject.identity.selection === null + ? {} + : { selection: subject.identity.selection }), }; -const sameEvidenceSubjectTargetIdentity = ( - subject: EvidenceSubjectTarget, - target: EvidenceSubjectTarget, -): boolean => - subject.sha256 === target.sha256 && - subject.format === target.format && - (subject.architecture ?? null) === (target.architecture ?? null); +/** Name the same subject in a derived observation: the file target, or the same unknown. */ +export const evidenceSubjectInput = ( + subject: Evidence["subject"], +): EvidenceSubjectInput => + isFileSubject(subject) + ? (evidenceSubjectTarget(subject) as EvidenceSubjectTarget) + : (subject.identity as UnknownTargetIdentity); + +/** The one projection of a producer's subject input into its target identity. */ +export const evidenceSubjectTargetIdentity = ( + target: EvidenceSubjectTarget | BinaryTarget, +): FileTargetIdentity => + "kind" in target + ? binaryTargetIdentity(target) + : { + kind: "file", + sha256: target.sha256, + format: target.format, + architecture: target.architecture ?? null, + selection: target.selection ?? null, + }; /** Rebind a matching immutable artifact subject to the caller's selected path. */ export const rebindEvidenceSubjectTargetPath = ( subject: EvidenceSubjectTarget, - target: EvidenceSubjectTarget, + target: EvidenceSubjectTarget | BinaryTarget, ): EvidenceSubjectTarget => - sameEvidenceSubjectTargetIdentity(subject, target) + sameTargetIdentity( + evidenceSubjectTargetIdentity(subject), + evidenceSubjectTargetIdentity(target), + ) ? { ...subject, path: target.path } : subject; +/** The one builder of a persisted Evidence subject from a producer's target. */ +export const evidenceSubject = ( + target: EvidenceSubjectInput, +): Evidence["subject"] => + subjectSchema.parse( + "path" in target + ? { + identity: evidenceSubjectTargetIdentity(target), + name: + ("name" in target ? target.name : undefined) ?? + (basename(target.path) || "artifact"), + local_path: target.path, + } + : { identity: target, name: null, local_path: null }, + ); + +/** The target identity an Evidence record commits to; absent only for a partial record. */ +export const evidenceTargetIdentity = (evidence: { + readonly subject?: Evidence["subject"] | undefined; +}): TargetIdentity | null => evidence.subject?.identity ?? null; + +/** The file identity an Evidence record names, when its subject is a file. */ +export const evidenceFileTarget = (evidence: { + readonly subject?: Evidence["subject"] | undefined; +}): FileTargetIdentity | undefined => { + const identity = evidenceTargetIdentity(evidence); + return identity?.kind === "file" ? identity : undefined; +}; + +/** Display facts beside the subject identity; never part of the Evidence ID. */ +export const evidenceSubjectDisplay = (evidence: { + readonly subject?: Evidence["subject"] | undefined; +}): { readonly name: string; readonly local_path: string } | undefined => { + const subject = evidence.subject; + return isFileSubject(subject) + ? { name: subject.name, local_path: subject.local_path } + : undefined; +}; + type EvidenceAuthority = z.infer; type ExecutionEnvironment = z.infer; @@ -244,8 +362,6 @@ export interface EvidenceObservationInput { readonly environment?: ExecutionEnvironment | null; readonly limitations?: readonly string[]; readonly relationshipCoverage?: RelationshipCoverage; - /** Reason the subject identity is unavailable, when no target identity is supplied. */ - readonly subjectUnavailableReason?: string; readonly locations?: readonly EvidenceLocation[]; readonly evidenceLinks?: readonly string[]; } @@ -259,21 +375,11 @@ export interface EvidenceObservation extends EvidenceObservationInput { type EvidenceWithoutId = Omit; -/** Target identity shared by semantic commitments, excluding caller-selected display paths. */ -export const evidenceSubjectIdentity = (subject: Evidence["subject"]) => - subject === null - ? null - : { - digest: subject.digest, - format: subject.format, - architecture: subject.architecture, - }; - /** Content committed by an Evidence ID, excluding local request/display metadata. */ export const evidenceSemanticContent = ( evidence: EvidenceWithoutId, ): Record => ({ - subject: evidenceSubjectIdentity(evidence.subject), + subject: evidence.subject.identity, provider: evidence.provider, analysis_profile: evidence.analysis_profile, predicate_type: evidence.predicate_type, @@ -294,20 +400,6 @@ export const evidenceSemanticContent = ( const computeEvidenceId = (evidence: EvidenceWithoutId): string => `ev_${digestCanonicalValue(evidenceSemanticContent(evidence), "Evidence")}`; -/** Recognize an obsolete commitment for diagnosis only; never admit or rewrite it. */ -const usesPre66NullCoverageIdentity = ( - evidence: EvidenceWithoutId, - evidenceId: string, -): boolean => { - if (evidence.relationship_coverage !== null) return false; - const legacyProjection = evidenceSemanticContent(evidence); - delete legacyProjection.relationship_coverage; - return ( - evidenceId === - `ev_${digestCanonicalValue(legacyProjection, "Historical Evidence identity")}` - ); -}; - /** Parse evidence and reject a syntactically valid but tampered semantic ID. */ export const parseEvidence = (input: unknown): Evidence => { const immutable = @@ -315,6 +407,7 @@ export const parseEvidence = (input: unknown): Evidence => { ? immutableEvidenceSnapshots.get(input) : undefined; if (immutable !== undefined) return immutable; + admitEvidenceRecordFormat(input); return authenticatedEvidenceSchema.parse(input); }; @@ -328,16 +421,6 @@ export const evidenceDisplayMetadataAgree = ( left.caller_input_path === right.caller_input_path && isDeepStrictEqual(left.caller_input_paths, right.caller_input_paths); -/** Recognize authenticated Evidence in a union of partial observations. */ -export const tryParseEvidence = (input: unknown): Evidence | undefined => { - if (typeof input !== "object" || input === null || !("evidence_id" in input)) - return undefined; - const immutable = immutableEvidenceSnapshots.get(input); - if (immutable !== undefined) return immutable; - const parsed = authenticatedEvidenceSchema.safeParse(input); - return parsed.success ? parsed.data : undefined; -}; - /** Authenticate and seal a ledger-owned snapshot; external mutable values are copied first. */ export const immutableEvidence = (input: unknown): Evidence => { const parsed = parseEvidence(input); @@ -352,9 +435,9 @@ export const rebindEvidenceToTargetPath = ( target: EvidenceSubjectTarget, ): Evidence => { const subject = evidence.subject; - if (subject === null) return evidence; + if (!isFileSubject(subject)) return evidence; if ( - !sameEvidenceSubjectTargetIdentity(evidenceSubjectTarget(subject)!, target) + !sameTargetIdentity(subject.identity, evidenceSubjectTargetIdentity(target)) ) return evidence; if ( @@ -438,7 +521,7 @@ export interface EvidenceCreationOptions { /** Admit payloads into deterministic Evidence bound to an immutable artifact subject. */ export const createEvidence = ( - target: EvidenceSubjectTarget | BinaryTarget | undefined, + target: EvidenceSubjectInput, provider: EvidenceProvider, observation: EvidenceObservationInput, options?: EvidenceCreationOptions, @@ -465,7 +548,7 @@ export const createEvidence = ( /** Create Evidence from owned immutable JSON while exposing cooperative computation steps. */ export function* createImmutableEvidenceSteps( - target: EvidenceSubjectTarget | BinaryTarget | undefined, + target: EvidenceSubjectInput, provider: EvidenceProvider, observation: EvidenceObservation, ): Generator { @@ -490,26 +573,16 @@ export function* createImmutableEvidenceSteps( }); } -/** Borrow input collections for admission; callers account for a missing-subject limitation separately. */ +/** Borrow input collections for admission. */ export const evidenceEnvelopeForAdmission = ( - target: EvidenceSubjectTarget | BinaryTarget | undefined, + target: EvidenceSubjectInput, provider: EvidenceProvider, observation: EvidenceObservationInput, ) => { - const subject = - target === undefined - ? null - : { - name: - ("name" in target ? target.name : undefined) ?? - (basename(target.path) || "artifact"), - digest: { sha256: target.sha256 }, - format: target.format, - architecture: target.architecture ?? null, - local_path: target.path, - }; + const subject = evidenceSubject(target); return { evidence_id: `ev_${"0".repeat(64)}`, + evidence_format: EVIDENCE_FORMAT_REVISION, subject, provider: { id: provider.id, @@ -535,22 +608,11 @@ export const evidenceEnvelopeForAdmission = ( }; const normalizeEvidenceObservation = ( - target: EvidenceSubjectTarget | BinaryTarget | undefined, + target: EvidenceSubjectInput, provider: EvidenceProvider, observation: EvidenceObservationInput, ) => { - const borrowed = evidenceEnvelopeForAdmission(target, provider, observation); - const envelope = - target === undefined - ? { - ...borrowed, - limitations: [ - observation.subjectUnavailableReason ?? - MISSING_EVIDENCE_SUBJECT_LIMITATION, - ...borrowed.limitations, - ], - } - : borrowed; + const envelope = evidenceEnvelopeForAdmission(target, provider, observation); const sharedResult = typeof observation.result === "object" && observation.result !== null && diff --git a/src/domain/evidenceBundle.test.ts b/src/domain/evidenceBundle.test.ts index 02533f9214..29108b065f 100644 --- a/src/domain/evidenceBundle.test.ts +++ b/src/domain/evidenceBundle.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createEvidence } from "./evidence.js"; @@ -53,7 +54,7 @@ describe("artifact manifest projection", () => { describe("evidence bundle failure classification", () => { it("tags valid-shaped bundles that fail canonical ordering", () => { const records = ["first", "second"].map((label) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "observe", parameters: { label }, result: { label }, @@ -87,7 +88,7 @@ describe("evidence bundle failure classification", () => { "names only the noncanonical sections (%s)", (sections, change) => { const records = ["first", "second"].map((label) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "observe", parameters: { label }, result: { label }, @@ -106,7 +107,7 @@ describe("evidence bundle failure classification", () => { ); it("treats only authenticated standalone Evidence as the wrong input kind", () => { - const record = createEvidence(undefined, provider, { + const record = createEvidence(unknownTarget("not-observed"), provider, { operation: "observe", parameters: {}, result: { observed: true }, @@ -144,7 +145,7 @@ const makeUnknown = ( ? [] : [{ type: "depends-on", unknown_id: dependency }], }); - const mutation = createEvidence(undefined, provider, { + const mutation = createEvidence(unknownTarget("not-observed"), provider, { predicateType: "rea.residual-unknown-mutation", operation: "record_unknown", parameters: { domain: input.domain, severity: input.severity }, @@ -163,7 +164,7 @@ const makeUnknown = ( }; it("retains only linked cross-target source closure in a target snapshot", () => { - const leaf = createEvidence(undefined, provider, { + const leaf = createEvidence(unknownTarget("not-observed"), provider, { operation: "source_leaf", parameters: {}, result: "leaf", @@ -401,7 +402,7 @@ describe("evidenceBundleForTarget relationship pruning", () => { describe("immutable serialization bundles", () => { it("authenticates sealed records while revalidating detached and malformed input", () => { - const evidence = createEvidence(undefined, provider, { + const evidence = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: { nested: [true] }, diff --git a/src/domain/evidenceBundle.ts b/src/domain/evidenceBundle.ts index 1609d1ab74..b9bd9e42ba 100644 --- a/src/domain/evidenceBundle.ts +++ b/src/domain/evidenceBundle.ts @@ -15,6 +15,7 @@ import canonicalize from "canonicalize"; import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js"; import { + evidenceFileTarget, evidenceSchema, immutableEvidence, parseEvidence, @@ -123,17 +124,18 @@ export const createEvidenceBundle = ( return { evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: uniqueSorted( - sortedRecords.flatMap(({ subject }) => - subject === null + sortedRecords.flatMap((record) => { + const file = evidenceFileTarget(record); + return file === undefined ? [] : [ artifactManifestSchema.parse({ - digest: subject.digest, - format: subject.format, - architecture: subject.architecture, + digest: { sha256: file.sha256 }, + format: file.format, + architecture: file.architecture, }), - ], - ), + ]; + }), ), providers: uniqueSorted(sortedRecords.map(({ provider }) => provider)), environments: uniqueSorted( @@ -197,7 +199,8 @@ export const evidenceBundleForTarget = ( // Mutation subjects record the target active at the time of an edit, // which need not be the question's immutable investigation scope. return ( - record?.subject?.digest.sha256 === sha256 || + (record !== undefined && + evidenceFileTarget(record)?.sha256 === sha256) || (mutationEvidenceIds.has(evidenceId) && record?.predicate_type === "rea.residual-unknown-mutation") ); @@ -236,7 +239,7 @@ export const evidenceBundleForTarget = ( bundle.records .filter( (record) => - record.subject?.digest.sha256 === sha256 || + evidenceFileTarget(record)?.sha256 === sha256 || mutationIds.has(record.evidence_id), ) .map((record) => record.evidence_id), @@ -295,7 +298,13 @@ const describeEvidenceBundleFailure = ( message: `Expected an Evidence bundle with records and manifest arrays, but this JSON is one Evidence record (${record.evidence_id}). Export a session bundle with the MCP export_evidence_bundle tool and supply that file.`, }; } catch (recordFailure: unknown) { - if (!(recordFailure instanceof z.ZodError)) throw recordFailure; + // An earlier-format record is not a current record either; the bundle + // failure below already carries the recreate guidance. + if ( + !(recordFailure instanceof z.ZodError) && + !isUnsupportedEvidenceFormat(recordFailure) + ) + throw recordFailure; // The format owner decides earlier bundles once; its message carries the // recreate guidance instead of per-field schema failures. if (isUnsupportedEvidenceFormat(cause)) diff --git a/src/domain/evidenceFormat.test.ts b/src/domain/evidenceFormat.test.ts index 23a5027043..4f256f02f3 100644 --- a/src/domain/evidenceFormat.test.ts +++ b/src/domain/evidenceFormat.test.ts @@ -1,6 +1,7 @@ +import { unknownTarget } from "./targetIdentity.js"; import { expect, it } from "vitest"; -import { createEvidence } from "./evidence.js"; +import { createEvidence, parseEvidence } from "./evidence.js"; import { createEvidenceBundle, readEvidenceBundle, @@ -11,9 +12,11 @@ import { RECREATE_EVIDENCE_GUIDANCE, } from "./evidenceFormat.js"; import { ParseFailureError } from "./parseFailure.js"; +import { EvidenceIntegrityError } from "./evidenceErrors.js"; +import { readEvidence, readImmutableEvidence } from "./evidenceValidation.js"; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", parameters: {}, result: { observed: true } }, ); @@ -63,6 +66,36 @@ it.each([ }); }); +it.each([ + ["an unmarked record", undefined], + ["a revision 1 record", 1], +])( + "refuses %s alone or inside a current bundle, with the recreate guidance", + (_name, format) => { + const { evidence_format: _current, ...unmarked } = record; + const earlier = + format === undefined + ? unmarked + : { ...unmarked, evidence_format: format }; + expect(() => parseEvidence(earlier)).toThrow(RECREATE_EVIDENCE_GUIDANCE); + for (const read of [readEvidence, readImmutableEvidence]) { + const refused = read(earlier); + if (refused.ok) throw new Error("Expected the earlier record refused"); + expect(refused.error).toBeInstanceOf(EvidenceIntegrityError); + expect(refused.error.userMessage).toContain(RECREATE_EVIDENCE_GUIDANCE); + } + const parsed = safeParseEvidenceBundle({ + ...createEvidenceBundle([record]), + records: [earlier], + }); + if (parsed.ok) throw new Error("Expected the earlier record to be refused"); + expect(parsed.error.kind).toBe("unsupported-format"); + expect(parsed.error.cause).toMatchObject({ + failure: { format: "evidence-record", field: "evidence_format" }, + }); + }, +); + it("still names a standalone Evidence record as the wrong input kind", () => { const parsed = safeParseEvidenceBundle(record); if (parsed.ok) throw new Error("Expected a record to be refused"); diff --git a/src/domain/evidenceFormat.ts b/src/domain/evidenceFormat.ts index 69f4ccd4fc..a76f7699d7 100644 --- a/src/domain/evidenceFormat.ts +++ b/src/domain/evidenceFormat.ts @@ -1,69 +1,109 @@ import { z } from "zod"; +import { isRecord } from "./isRecord.js"; import { ParseFailureError, unsupportedInput } from "./parseFailure.js"; /** * The Evidence format revision this REA release writes and reads. * - * This module owns Evidence format evolution. A bundle declares its revision - * in `evidence_format`, and readers admit only the current one; anything - * older is refused with {@link RECREATE_EVIDENCE_GUIDANCE} rather than - * admitted one optional field at a time. A field added after a revision is - * optional only while its revision note below names it, and becomes required - * when the revision advances. + * This module owns Evidence format evolution. A bundle and each record declare + * their revision in `evidence_format`, and readers admit only the current one; + * anything older is refused with {@link RECREATE_EVIDENCE_GUIDANCE} rather + * than admitted one optional field at a time. A field added after a revision + * is optional only while its revision note below names it, and becomes + * required when the revision advances. * * Revision 1: the first marked format. Bundles without `evidence_format` * (REA 6.x and earlier) are refused, and the 6.7-era artifact inventory * summary identities are no longer rebuilt. + * + * Revision 2: the Evidence subject names its target identity + * (`subject.identity`, docs/adr/evidence/target-identity.md). The Evidence ID + * commits to that identity, including its kind and selection, instead of the + * subject's digest, format and architecture, so every Evidence ID changes. + * Each record also declares `evidence_format`, so a standalone record names + * its format too. */ -export const EVIDENCE_FORMAT_REVISION = 1; +export const EVIDENCE_FORMAT_REVISION = 2; /** The single recovery for Evidence from an earlier format. */ export const RECREATE_EVIDENCE_GUIDANCE = "Recreate observations with the current REA release; re-exporting an earlier bundle does not update its format or identities."; -/** A bundle member naming the format revision it was written in. */ +/** A bundle or record member naming the format revision it was written in. */ export const evidenceFormatSchema = z.literal(EVIDENCE_FORMAT_REVISION, { error: `evidence_format must be ${String(EVIDENCE_FORMAT_REVISION)}. ${RECREATE_EVIDENCE_GUIDANCE}`, }); -/** The ParseFailure format name for an Evidence bundle. */ +/** The ParseFailure format names for an Evidence bundle and a standalone record. */ const EVIDENCE_BUNDLE_FORMAT = "evidence-bundle"; +const EVIDENCE_RECORD_FORMAT = "evidence-record"; -/** A bundle written in a format this release does not read. */ +/** A bundle or record written in a format this release does not read. */ export type UnsupportedEvidenceFormat = ParseFailureError<"unsupported">; -/** Recognize this module's refusal of a bundle from another format. */ +/** Recognize this module's refusal of Evidence from another format. */ export const isUnsupportedEvidenceFormat = ( cause: unknown, ): cause is UnsupportedEvidenceFormat => cause instanceof ParseFailureError && cause.kind === "unsupported" && - cause.failure.format === EVIDENCE_BUNDLE_FORMAT; + (cause.failure.format === EVIDENCE_BUNDLE_FORMAT || + cause.failure.format === EVIDENCE_RECORD_FORMAT); + +const admitFormat = ( + input: object, + format: typeof EVIDENCE_BUNDLE_FORMAT | typeof EVIDENCE_RECORD_FORMAT, + noun: string, +): void => { + const found: unknown = Reflect.get(input, "evidence_format"); + if (found === EVIDENCE_FORMAT_REVISION) return; + throw unsupportedInput( + format, + `${ + found === undefined + ? `This ${noun} predates format revision ${String(EVIDENCE_FORMAT_REVISION)}` + : `${noun} format ${JSON.stringify(found)} is not format ${String(EVIDENCE_FORMAT_REVISION)}` + }, which this REA release reads. ${RECREATE_EVIDENCE_GUIDANCE}`, + { field: "evidence_format", undecodedContent: true }, + ); +}; + +/** Members every Evidence record has carried, in every release and revision. */ +const RECORD_MEMBERS = [ + "evidence_id", + "provider", + "predicate_type", + "operation", + "normalized_result", +] as const; /** - * Refuse a bundle from another format before reading its shape, so an earlier + * Refuse a standalone Evidence record from another format before reading its + * shape, with the same single decision as a bundle. A record declares its + * revision; an unmarked object is an earlier record only when it has every + * member records have always carried. Anything else is left to the record + * schema, so a malformed record reports its schema issues. + */ +export const admitEvidenceRecordFormat = (input: unknown): void => { + if (!isRecord(input) || !Object.hasOwn(input, "evidence_id")) return; + if ( + Object.hasOwn(input, "evidence_format") || + RECORD_MEMBERS.every((member) => Object.hasOwn(input, member)) + ) + admitFormat(input, EVIDENCE_RECORD_FORMAT, "Evidence record"); +}; + +/** + * Refuse a bundle, or a record it carries, from another format before reading its shape, so an earlier * bundle is reported as one format decision instead of per-field schema * failures. Input without a `records` member is not a bundle and is left to * the bundle schema (including a standalone Evidence record). */ export const admitEvidenceBundleFormat = (input: unknown): void => { - if ( - typeof input !== "object" || - input === null || - Array.isArray(input) || - !Object.hasOwn(input, "records") - ) - return; - const found: unknown = Reflect.get(input, "evidence_format"); - if (found !== EVIDENCE_FORMAT_REVISION) - throw unsupportedInput( - EVIDENCE_BUNDLE_FORMAT, - `${ - found === undefined - ? "This Evidence bundle predates format revisions" - : `Evidence bundle format ${JSON.stringify(found)} is not format ${String(EVIDENCE_FORMAT_REVISION)}` - }, which this REA release reads. ${RECREATE_EVIDENCE_GUIDANCE}`, - { field: "evidence_format", undecodedContent: true }, - ); + if (!isRecord(input) || !Object.hasOwn(input, "records")) return; + admitFormat(input, EVIDENCE_BUNDLE_FORMAT, "Evidence bundle"); + // A current bundle may still carry a record copied from an earlier one. + if (Array.isArray(input.records)) + for (const record of input.records) admitEvidenceRecordFormat(record); }; diff --git a/src/domain/evidenceLegacy.fixture.ts b/src/domain/evidenceLegacy.fixture.ts index df9da34538..8ceb1b7492 100644 --- a/src/domain/evidenceLegacy.fixture.ts +++ b/src/domain/evidenceLegacy.fixture.ts @@ -1,6 +1,6 @@ -/** ASCII golden for the rea-agents-6.5.0 semanticProjection rule in evidence.ts. - * Its independently computed canonical SHA-256 omits explicit null coverage. - * This is a schema/identity fixture, not a claim of a released-provider run. +/** ASCII golden of a rea-agents-6.5.0 Evidence record, which predates format + * revisions: readers refuse it with the recreate guidance instead of checking + * its ID. This is a schema fixture, not a claim of a released-provider run. */ export const PRE_66_NULL_COVERAGE_EVIDENCE = { evidence_id: diff --git a/src/domain/evidenceRecordSummary.ts b/src/domain/evidenceRecordSummary.ts index 870d2bf49c..02f4c214c9 100644 --- a/src/domain/evidenceRecordSummary.ts +++ b/src/domain/evidenceRecordSummary.ts @@ -2,7 +2,11 @@ import { z } from "zod"; import { uniqueSorted } from "./canonicalOrdering.js"; import { digestSchema, prefixedDigestSchema } from "./digests.js"; -import { evidenceSchema, type Evidence } from "./evidence.js"; +import { + evidenceFileTarget, + evidenceSchema, + type Evidence, +} from "./evidence.js"; import type { EvidenceBundle } from "./evidenceBundle.js"; import { nativeValueFlowMetadataSchema } from "./native/nativeValueFlow.js"; @@ -139,7 +143,7 @@ function* matchingEvidenceRecords( (filters.operation !== undefined && filters.operation !== evidence.operation) || (filters.target_sha256 !== undefined && - filters.target_sha256 !== evidence.subject?.digest.sha256) || + filters.target_sha256 !== evidenceFileTarget(evidence)?.sha256) || (filters.analysis_profile_digest !== undefined && filters.analysis_profile_digest !== evidence.analysis_profile?.digest) ) diff --git a/src/domain/evidenceSteps.test.ts b/src/domain/evidenceSteps.test.ts index c8105d54f8..d8a83cac65 100644 --- a/src/domain/evidenceSteps.test.ts +++ b/src/domain/evidenceSteps.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createAnalysisProfile } from "./analysisProfile.js"; import { @@ -66,8 +67,16 @@ describe("cooperative immutable Evidence", () => { it("retains scalar results and unavailable-subject limitations", () => { const observation = { operation: "inspect", parameters: {}, result: null }; expect( - finish(createImmutableEvidenceSteps(undefined, provider, observation)), - ).toEqual(createEvidence(undefined, provider, observation)); + finish( + createImmutableEvidenceSteps( + unknownTarget("not-observed"), + provider, + observation, + ), + ), + ).toEqual( + createEvidence(unknownTarget("not-observed"), provider, observation), + ); }); it("rejects mutable results and mismatched producer profiles", () => { diff --git a/src/domain/evidenceSubject.test.ts b/src/domain/evidenceSubject.test.ts index 03140e829f..1c272d9d00 100644 --- a/src/domain/evidenceSubject.test.ts +++ b/src/domain/evidenceSubject.test.ts @@ -21,10 +21,14 @@ describe("persisted observation subject declarations", () => { ]) { const declaration = { format, architecture }; const evidence = evidenceSubject.safeParse({ - ...declaration, + identity: { + kind: "file", + sha256: digest, + ...declaration, + selection: null, + }, name: "fixture", local_path: "/tmp/fixture", - digest: { sha256: digest }, }); const snapshot = snapshotSubject.safeParse({ ...declaration, @@ -53,11 +57,15 @@ describe("persisted observation subject declarations", () => { it("preserves each persistence envelope's handling of additional fields", () => { expect( evidenceSubject.safeParse({ - format: "pe", - architecture: null, + identity: { + kind: "file", + sha256: digest, + format: "pe", + architecture: null, + selection: null, + }, name: "fixture", local_path: "/tmp/fixture", - digest: { sha256: digest }, extra: true, }).success, ).toBe(false); diff --git a/src/domain/evidenceValidation.ts b/src/domain/evidenceValidation.ts index ea38e41bb5..f9a80ec970 100644 --- a/src/domain/evidenceValidation.ts +++ b/src/domain/evidenceValidation.ts @@ -2,23 +2,58 @@ import { z } from "zod"; import { parseEvidence, immutableEvidence, type Evidence } from "./evidence.js"; import { EvidenceIntegrityError } from "./evidenceErrors.js"; +import { + isUnsupportedEvidenceFormat, + type UnsupportedEvidenceFormat, +} from "./evidenceFormat.js"; import { describeValidationFailure, firstValidationIssue, } from "./validationFailure.js"; import { err, ok, type Result } from "./result.js"; +/** A record that fails its schema, or one written in another format revision. */ +export type EvidenceReadFailure = z.ZodError | UnsupportedEvidenceFormat; + /** Expected authentication failures, independent of a caller's error contract. */ export const safeParseEvidence = ( input: unknown, -): Result => authenticateEvidence(input, parseEvidence); +): Result => + authenticateEvidence(input, parseEvidence); /** Authenticate and seal source records while retaining typed validation failures. */ export const safeParseImmutableEvidence = ( input: unknown, -): Result => +): Result => authenticateEvidence(input, immutableEvidence); +/** + * Recognize Evidence in a union of partial observations. Input that names no + * `evidence_id` is not an Evidence record. A record that names one but fails + * authentication, or was written in another format revision, is a refusal, + * never absent: callers must not read it as "no Evidence". + */ +export const recognizeEvidence = ( + input: unknown, +): Result => + typeof input === "object" && input !== null && "evidence_id" in input + ? readEvidence(input) + : ok(undefined); + +/** + * The single refusal of Evidence from another format revision: an integrity + * mismatch whose message carries the recreate guidance, as for bundles. + */ +export const unsupportedEvidenceFormatError = ( + cause: UnsupportedEvidenceFormat, + side?: "left" | "right", +): EvidenceIntegrityError => + new EvidenceIntegrityError(cause.message, { + cause, + userMessage: cause.message, + ...(side === undefined ? {} : { side }), + }); + /** * Where a source record sits in a two-sided request, and where a validated * payload sits inside its Evidence record, so failures name both. @@ -53,12 +88,13 @@ export const readImmutableEvidence = ( const authenticateEvidence = ( input: unknown, parse: (input: unknown) => Evidence, -): Result => { +): Result => { try { return ok(parse(input)); } catch (cause: unknown) { - if (!(cause instanceof z.ZodError)) throw cause; - return err(cause); + if (cause instanceof z.ZodError || isUnsupportedEvidenceFormat(cause)) + return err(cause); + throw cause; } }; @@ -96,9 +132,11 @@ export const validationIssueOptions = ( }; const integrityFailure = ( - cause: z.ZodError, + cause: EvidenceReadFailure, location: EvidenceSourceLocation | undefined, ): EvidenceIntegrityError => { + if (isUnsupportedEvidenceFormat(cause)) + return unsupportedEvidenceFormatError(cause, location?.side); const message = `Evidence validation failed ${describeValidationFailure(cause)}`; return new EvidenceIntegrityError(message, { cause, diff --git a/src/domain/explicitSensitiveFailure.test.ts b/src/domain/explicitSensitiveFailure.test.ts index f354853c64..a14205cf1e 100644 --- a/src/domain/explicitSensitiveFailure.test.ts +++ b/src/domain/explicitSensitiveFailure.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { EvidenceFileError } from "./evidenceErrors.js"; import { AnalysisAccessDeniedError, @@ -56,7 +57,7 @@ it.each([ new ProviderAdapterError("provider", "inspect", context), ])("preserves sanitized common context for $._tag", (error) => { const observation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Owner facts", version: "1" }, { operation: "inspect", diff --git a/src/domain/functionComparison.test.ts b/src/domain/functionComparison.test.ts index 1e5d3fb912..b495d970ea 100644 --- a/src/domain/functionComparison.test.ts +++ b/src/domain/functionComparison.test.ts @@ -6,7 +6,11 @@ import { enhancedInputSchemas } from "../contracts/enhancedInputs.js"; import { functionComparisonResultSchema } from "./functionComparisonSchemas.js"; import { createFunctionCoordinateContext } from "./native/functionCoordinateContext.js"; import { createAnalysisProfile } from "./analysisProfile.js"; -import { createEvidence, type Evidence } from "./evidence.js"; +import { + createEvidence, + type Evidence, + type EvidenceSubjectTarget, +} from "./evidence.js"; import { functionDossierSchema } from "./native/functionDossier.js"; import { canonicalJson } from "./comparisonSemantics.js"; import { digestCanonicalValue } from "./canonicalDigest.js"; @@ -124,14 +128,15 @@ const observe = ( callees: { status: "complete" }, }, }, + target: EvidenceSubjectTarget = { + path: `/tmp/function-${digit}`, + sha256: digit.repeat(64), + format: "mach-o", + architecture: "arm64", + }, ): Evidence => createEvidence( - { - path: `/tmp/function-${digit}`, - sha256: digit.repeat(64), - format: "mach-o", - architecture: "arm64", - }, + target, { id: providerId, name: providerId, version: "1" }, { operation: "analyze_function", @@ -1053,6 +1058,34 @@ describe("function comparison normalization and provenance", () => { ).toThrow(/identifier/u); }); + it("matches entries by address only within the same opened target", () => { + const raw = (entryPoint: string): EvidenceSubjectTarget => ({ + path: "/tmp/function.bin", + sha256: "9".repeat(64), + format: "raw-binary", + architecture: "arm64", + selection: { kind: "entry-point", entry_point: entryPoint }, + }); + const at = (entryPoint: string, body: string) => + functionSnapshotFixture( + observe( + "9", + dossier(body, "0x1000"), + "rea-workflow", + undefined, + raw(entryPoint), + ), + ); + const left = at("0x0", "return 0;\n"); + expect( + compareFunctions(left, at("0x0", "return 1;\n")).function_match, + ).toMatchObject({ status: "matched", method: "same-entry" }); + // The same bytes opened at another entry point do not share coordinates. + expect( + compareFunctions(left, at("0x100", "return 1;\n")).function_match.method, + ).not.toBe("same-entry"); + }); + it("reports fully observed identical dossiers as unchanged", () => { const left = observe("7", dossier("return 0;\n", "0x1000")); const right = observe("8", dossier("return 0;\n", "0x2000")); diff --git a/src/domain/functionComparison.ts b/src/domain/functionComparison.ts index 97a02858c2..afdb85bb5c 100644 --- a/src/domain/functionComparison.ts +++ b/src/domain/functionComparison.ts @@ -34,8 +34,8 @@ export const compareFunctions = ( return functionComparisonResultSchema.parse({ status: overallStatus(dimensions, match.status), function_match: match, - left_subject_sha256: left.subject.digest.sha256, - right_subject_sha256: right.subject.digest.sha256, + left_subject_sha256: left.target.sha256, + right_subject_sha256: right.target.sha256, summary: summarize(dimensions), dimensions, changes, diff --git a/src/domain/functionDossierEvidence.ts b/src/domain/functionDossierEvidence.ts index 51d19a9ee6..904a95565e 100644 --- a/src/domain/functionDossierEvidence.ts +++ b/src/domain/functionDossierEvidence.ts @@ -1,4 +1,12 @@ -import { ANALYSIS_EVIDENCE_PREDICATE, type Evidence } from "./evidence.js"; +import { + ANALYSIS_EVIDENCE_PREDICATE, + evidenceFileTarget, + type Evidence, +} from "./evidence.js"; +import { + sameTargetIdentity, + type FileTargetIdentity, +} from "./targetIdentity.js"; import { AnalysisInputError } from "./analysisErrorCore.js"; import type { EvidenceIntegrityError } from "./evidenceErrors.js"; import { @@ -19,7 +27,8 @@ import { functionCoordinateContextsEqual } from "./native/functionCoordinateCont /** Complete function observation parsed from one analyze_function Evidence record. */ export interface FunctionSnapshot { readonly evidence: Evidence; - readonly subject: NonNullable; + /** The file the function was analysed in, selection included. */ + readonly target: FileTargetIdentity; readonly dossier: FunctionDossier; readonly limitations: readonly string[]; readonly callCoverageBlockers: readonly string[]; @@ -39,11 +48,11 @@ export const functionSnapshotCoordinateContext = ( left: FunctionSnapshot, right: FunctionSnapshot, ): FunctionSnapshotCoordinateContext => { - if (left.subject.digest.sha256 !== right.subject.digest.sha256) - return "cross-artifact"; - return left.subject.format === right.subject.format && - left.subject.architecture !== null && - left.subject.architecture === right.subject.architecture && + if (left.target.sha256 !== right.target.sha256) return "cross-artifact"; + // The same bytes share coordinates only when opened as the same target: + // format, architecture and selection (a raw entry point or flash offset). + return left.target.architecture !== null && + sameTargetIdentity(left.target, right.target) && functionCoordinateContextsEqual( left.evidence.analysis_profile, right.evidence.analysis_profile, @@ -107,7 +116,8 @@ export const parseFunctionEvidence = ( }, ); } - if (evidence.subject === null) + const target = evidenceFileTarget(evidence); + if (target === undefined) return invalidSelection( "Function analysis requires artifact-bound Evidence", ); @@ -123,7 +133,7 @@ export const parseFunctionEvidence = ( ); return ok({ evidence, - subject: evidence.subject, + target, dossier: dossier.value, limitations: [ ...new Set([...evidence.limitations, ...dossier.value.limitations]), diff --git a/src/domain/gpu/gpuCodeObjectsEvidence.ts b/src/domain/gpu/gpuCodeObjectsEvidence.ts index 5036fb2251..0b0b4ceb79 100644 --- a/src/domain/gpu/gpuCodeObjectsEvidence.ts +++ b/src/domain/gpu/gpuCodeObjectsEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { createEvidence, type Evidence, @@ -49,13 +50,15 @@ export const createGpuCodeObjectsPartialEvidence = ( provider: EvidenceProvider, parameters: GpuCodeObjectsInput, ): Evidence => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_gpu_code_objects", parameters: gpuParameters(parameters), result: report, confidence: "observed", - subjectUnavailableReason: - "The interrupted inspection did not complete final file identity verification; root digest and completeness are unknown.", + locations: [{ kind: "artifact-path", path: report.artifact.path }], - limitations: report.limitations, + limitations: [ + "The interrupted inspection did not complete final file identity verification; root digest and completeness are unknown.", + ...report.limitations, + ], }); diff --git a/src/domain/javascript/javascriptApplicationVersionComparison.test.ts b/src/domain/javascript/javascriptApplicationVersionComparison.test.ts index f8c9928650..71715b88f4 100644 --- a/src/domain/javascript/javascriptApplicationVersionComparison.test.ts +++ b/src/domain/javascript/javascriptApplicationVersionComparison.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createEvidence } from "../evidence.js"; @@ -128,7 +129,7 @@ const unrelatedGraph = (artifactSha: string): JavaScriptApplicationGraph => { const nativeEvidence = (sha256: string | undefined, ordinal: number) => createEvidence( sha256 === undefined - ? undefined + ? unknownTarget("not-observed") : { path: `/fixture/native-${ordinal}.js`, sha256, diff --git a/src/domain/javascript/javascriptApplicationVersionItems.ts b/src/domain/javascript/javascriptApplicationVersionItems.ts index 034bda717c..f6621a69ca 100644 --- a/src/domain/javascript/javascriptApplicationVersionItems.ts +++ b/src/domain/javascript/javascriptApplicationVersionItems.ts @@ -1,7 +1,7 @@ import { absenceClaimable, canonicalJson } from "../comparisonSemantics.js"; import { digestCanonicalValue } from "../canonicalDigest.js"; import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js"; -import type { Evidence } from "../evidence.js"; +import { evidenceFileTarget, type Evidence } from "../evidence.js"; import type { ApplicationEdge, ApplicationNode, @@ -773,8 +773,9 @@ const indexNativeEvidence = ( evidence: readonly Evidence[], ): ReadonlyMap => { const evidenceByDigest = new Map(); - for (const { evidence_id: id, subject } of evidence) { - const digest = subject?.digest.sha256; + for (const record of evidence) { + const id = record.evidence_id; + const digest = evidenceFileTarget(record)?.sha256; if (digest === undefined) continue; const ids = evidenceByDigest.get(digest); if (ids === undefined) evidenceByDigest.set(digest, [id]); diff --git a/src/domain/javascript/javascriptNativeHandoff.ts b/src/domain/javascript/javascriptNativeHandoff.ts index e5fb31ff33..1b7a5c2482 100644 --- a/src/domain/javascript/javascriptNativeHandoff.ts +++ b/src/domain/javascript/javascriptNativeHandoff.ts @@ -1,5 +1,5 @@ import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js"; -import type { Evidence } from "../evidence.js"; +import { evidenceFileTarget, type Evidence } from "../evidence.js"; import type { ApplicationEdge, ApplicationNode, @@ -30,7 +30,7 @@ export const buildJavaScriptNativeHandoffs = ( if (node.identity.strategy !== "content-digest") return []; const digest = node.identity.sha256; const linked = nativeEvidence.filter( - ({ subject }) => subject?.digest.sha256 === digest, + (evidence) => evidenceFileTarget(evidence)?.sha256 === digest, ); nodeById ??= new Map( graph.nodes.map((candidate) => [candidate.node_id, candidate]), diff --git a/src/domain/javascript/javascriptRuntimeReconciliationInputValidation.ts b/src/domain/javascript/javascriptRuntimeReconciliationInputValidation.ts index e35b2ff704..984ef4280f 100644 --- a/src/domain/javascript/javascriptRuntimeReconciliationInputValidation.ts +++ b/src/domain/javascript/javascriptRuntimeReconciliationInputValidation.ts @@ -3,7 +3,11 @@ import type { z } from "zod"; import { AnalysisInputError } from "../analysisErrorCore.js"; import { projectInputIssues } from "../inputIssueProjection.js"; import type { Evidence } from "../evidence.js"; -import { safeParseEvidence } from "../evidenceValidation.js"; +import { + safeParseEvidence, + unsupportedEvidenceFormatError, +} from "../evidenceValidation.js"; +import { isUnsupportedEvidenceFormat } from "../evidenceFormat.js"; const OPERATION = "reconcile_javascript_runtime"; @@ -26,6 +30,8 @@ export const authenticateRuntimeEvidence = ( ): Evidence => { const parsed = safeParseEvidence(input); if (parsed.ok) return parsed.value; + if (isUnsupportedEvidenceFormat(parsed.error)) + throw unsupportedEvidenceFormatError(parsed.error); throw inputErrorAtPath(parsed.error.issues, input, path, parsed.error); }; diff --git a/src/domain/javascript/javascriptRuntimeReconciliationParsing.ts b/src/domain/javascript/javascriptRuntimeReconciliationParsing.ts index 523ff03c3f..f6d9715962 100644 --- a/src/domain/javascript/javascriptRuntimeReconciliationParsing.ts +++ b/src/domain/javascript/javascriptRuntimeReconciliationParsing.ts @@ -1,5 +1,9 @@ import { digestCanonicalValue } from "../canonicalDigest.js"; -import type { Evidence } from "../evidence.js"; +import { + evidenceFileTarget, + evidenceSubjectDisplay, + type Evidence, +} from "../evidence.js"; import { javascriptApplicationAnalysisResultSchema, type JavaScriptApplicationAnalysisResult, @@ -50,11 +54,12 @@ export const parseStaticLayer = ( }, evidencePath, ); + const target = evidenceFileTarget(evidence); if ( - evidence.subject === null || - evidence.subject.digest.sha256 !== result.root_artifact_sha256 || - evidence.subject.format !== result.format || - evidence.subject.local_path !== result.input_path + target === undefined || + target.sha256 !== result.root_artifact_sha256 || + target.format !== result.format || + evidenceSubjectDisplay(evidence)?.local_path !== result.input_path ) throw invalidInput( [...evidencePath, "subject"], diff --git a/src/domain/managed/managedInspectionEvidence.ts b/src/domain/managed/managedInspectionEvidence.ts index 9832b2ba8b..896bff6efc 100644 --- a/src/domain/managed/managedInspectionEvidence.ts +++ b/src/domain/managed/managedInspectionEvidence.ts @@ -1,4 +1,4 @@ -import type { Evidence } from "../evidence.js"; +import { evidenceFileTarget, type Evidence } from "../evidence.js"; import { AnalysisInputError } from "../analysisErrorCore.js"; import { EvidenceIntegrityError } from "../evidenceErrors.js"; import { readEvidence, readEvidencePayload } from "../evidenceValidation.js"; @@ -59,7 +59,7 @@ export const readManagedInspectionEvidence = < if (!payload.ok) return payload; const result = payload.value; const artifactSha256 = result.artifact.sha256; - const subjectSha256 = evidence.subject?.digest.sha256; + const subjectSha256 = evidenceFileTarget(evidence)?.sha256; if (subjectSha256 !== undefined && artifactSha256 !== subjectSha256) return err( integrityFailure( diff --git a/src/domain/managed/managedNativeVerificationSource.test.ts b/src/domain/managed/managedNativeVerificationSource.test.ts index 340dcbd9e7..a743c294e9 100644 --- a/src/domain/managed/managedNativeVerificationSource.test.ts +++ b/src/domain/managed/managedNativeVerificationSource.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { describe, expect, it } from "vitest"; import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../contracts/managed/managedWorkflowExamples.js"; @@ -14,13 +15,17 @@ describe("managed/native verification source", () => { ); const { encryption: _omitted, ...withoutEncryption } = inspectMachoSchema.parse(original.normalized_result); - const evidence = createEvidence(undefined, original.provider, { - operation: "inspect_macho", - parameters: original.parameters, - result: withoutEncryption, - rawResult: null, - limitations: [], - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + original.provider, + { + operation: "inspect_macho", + parameters: original.parameters, + result: withoutEncryption, + rawResult: null, + limitations: [], + }, + ); const source = readManagedNativeVerificationSource({ managed_boundaries: MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries, diff --git a/src/domain/managed/managedNativeVerificationSource.ts b/src/domain/managed/managedNativeVerificationSource.ts index bd0747794c..a7a99d83ad 100644 --- a/src/domain/managed/managedNativeVerificationSource.ts +++ b/src/domain/managed/managedNativeVerificationSource.ts @@ -2,7 +2,11 @@ import { isMachOFormat } from "../binaryTargetTypes.js"; import { getEvidenceInputContract } from "../evidenceInputContract.js"; import { managedNativeVerificationRequestSchema } from "./managedNativeVerificationSchemas.js"; -import type { Evidence } from "../evidence.js"; +import { + evidenceFileTarget, + type Evidence, + evidenceSubjectDisplay, +} from "../evidence.js"; import { AnalysisInputError } from "../analysisErrorCore.js"; import type { AnalysisError } from "../analysisErrorBase.js"; import { EvidenceIntegrityError } from "../evidenceErrors.js"; @@ -63,7 +67,7 @@ const readNativeObservation = ( const read = readEvidence(raw); if (!read.ok) return read; const evidence = read.value; - const format = evidence.subject?.format; + const format = evidenceFileTarget(evidence)?.format; const platform: ManagedNativePlatform = isMachOFormat(format) ? "mach-o" : format === "pe" || format === "elf" @@ -89,8 +93,8 @@ const readNativeObservation = ( operation: evidence.operation, name: symbol.name, address: symbol.address, - module_name: evidence.subject?.name ?? null, - module_path: evidence.subject?.local_path ?? null, + module_name: evidenceSubjectDisplay(evidence)?.name ?? null, + module_path: evidenceSubjectDisplay(evidence)?.local_path ?? null, source: "macho-export" as const, })), }); @@ -112,8 +116,8 @@ const readNativeObservation = ( operation: evidence.operation, name: payload.value.procedure.name, address: payload.value.procedure.address, - module_name: evidence.subject?.name ?? null, - module_path: evidence.subject?.local_path ?? null, + module_name: evidenceSubjectDisplay(evidence)?.name ?? null, + module_path: evidenceSubjectDisplay(evidence)?.local_path ?? null, source: "function-dossier" as const, }, ], diff --git a/src/domain/managed/managedReconstruction.test.ts b/src/domain/managed/managedReconstruction.test.ts index a1b5837ba2..5d0493cb65 100644 --- a/src/domain/managed/managedReconstruction.test.ts +++ b/src/domain/managed/managedReconstruction.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createEvidence } from "../evidence.js"; @@ -6,7 +7,7 @@ import { managedReconstructionImportInputSchema } from "./managedReconstruction. describe("managed reconstruction import input", () => { it("accepts more than the former 50-method and 100-note ceilings", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_managed_members", @@ -51,7 +52,7 @@ describe("managed reconstruction import input", () => { it("accepts decompiler text and metadata without arbitrary length ceilings", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_managed_members", diff --git a/src/domain/model/modelArtifactEvidence.ts b/src/domain/model/modelArtifactEvidence.ts index 09d79b06ce..fe78940c49 100644 --- a/src/domain/model/modelArtifactEvidence.ts +++ b/src/domain/model/modelArtifactEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { createEvidence, type Evidence, @@ -18,7 +19,7 @@ export const createModelArtifactEvidence = ( const source = report.artifact; return createEvidence( source.sha256 === null - ? undefined + ? unknownTarget("not-observed") : { path: source.path, sha256: source.sha256, format: "file" }, provider, { @@ -26,13 +27,18 @@ export const createModelArtifactEvidence = ( parameters: { path: parameters.path, hash: parameters.hash }, result: report, confidence: "observed", - subjectUnavailableReason: - "Full-file identity is unknown in header-only mode; normalized_result.artifact records a scoped header SHA-256 and exact source path/extent.", locations: [ { kind: "artifact-path", path: source.path }, { kind: "file-offset-range", start: 0, end: source.header_length }, ], - limitations: report.limitations, + limitations: [ + ...(source.sha256 === null + ? [ + "Full-file identity is unknown in header-only mode; normalized_result.artifact records a scoped header SHA-256 and exact source path/extent.", + ] + : []), + ...report.limitations, + ], }, ); }; @@ -43,14 +49,16 @@ export const createModelArtifactPartialEvidence = ( provider: EvidenceProvider, parameters: ModelArtifactInput, ): Evidence => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_model_artifact", parameters: { path: parameters.path, hash: parameters.hash }, result: partial, confidence: "observed", - subjectUnavailableReason: - "The interrupted read did not complete final file identity verification; digest and identity remain unknown.", + // Each retained row already owns its exact source offset and length. locations: [{ kind: "artifact-path", path: partial.artifact.path }], - limitations: partial.limitations, + limitations: [ + "The interrupted read did not complete final file identity verification; digest and identity remain unknown.", + ...partial.limitations, + ], }); diff --git a/src/domain/native/functionStructuralCandidate.ts b/src/domain/native/functionStructuralCandidate.ts index 5fcb4d7e85..8123f5009c 100644 --- a/src/domain/native/functionStructuralCandidate.ts +++ b/src/domain/native/functionStructuralCandidate.ts @@ -1,4 +1,4 @@ -import type { Evidence } from "../evidence.js"; +import { evidenceFileTarget, type Evidence } from "../evidence.js"; import type { FunctionDossier } from "../native/functionDossier.js"; import { digestCanonicalValue } from "../canonicalDigest.js"; import { normalizeCfg } from "../functionComparisonNormalization.js"; @@ -11,8 +11,9 @@ export const functionStructuralCandidate = ( evidence: Evidence, dossier: FunctionDossier, ): string | null => { + const architecture = evidenceFileTarget(evidence)?.architecture; if ( - evidence.subject?.architecture == null || + architecture == null || dossier.facet_availability?.cfg?.available !== true || dossier.facet_availability?.callees?.available !== true || dossier.facet_availability?.strings_names?.available !== true || @@ -44,7 +45,7 @@ export const functionStructuralCandidate = ( return digestCanonicalValue({ algorithm: "observed-cfg-calls-strings-v1", profile: evidence.analysis_profile.digest, - architecture: evidence.subject.architecture, + architecture, cfg, calls, strings, diff --git a/src/domain/pcap/pcapEvidence.ts b/src/domain/pcap/pcapEvidence.ts index 14892f533b..daf5c78072 100644 --- a/src/domain/pcap/pcapEvidence.ts +++ b/src/domain/pcap/pcapEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { createEvidence } from "../evidence.js"; import type { JsonValue } from "../jsonValue.js"; import type { PcapRequest } from "./pcapAnalysis.js"; @@ -19,16 +20,20 @@ export const createPcapEvidence = ( request: PcapRequest, observation: PcapObservation, ) => - createEvidence(observation.subject ?? undefined, observation.provider, { - operation: request.operation, - parameters: request.input, - result: observation.result, - rawResult: observation.rawResult, - limitations: observation.limitations, - locations: observation.locations, - confidence: - request.operation === "inspect_pcap_capture" ? "derived" : "observed", - ...(request.operation === "inspect_pcap_capture" - ? { authority: "historical-reference" as const } - : {}), - }); + createEvidence( + observation.subject ?? unknownTarget("not-observed"), + observation.provider, + { + operation: request.operation, + parameters: request.input, + result: observation.result, + rawResult: observation.rawResult, + limitations: observation.limitations, + locations: observation.locations, + confidence: + request.operation === "inspect_pcap_capture" ? "derived" : "observed", + ...(request.operation === "inspect_pcap_capture" + ? { authority: "historical-reference" as const } + : {}), + }, + ); diff --git a/src/domain/process/processComparisonEvidence.ts b/src/domain/process/processComparisonEvidence.ts index 2aa42ba9ee..00023cee89 100644 --- a/src/domain/process/processComparisonEvidence.ts +++ b/src/domain/process/processComparisonEvidence.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../targetIdentity.js"; import { createEvidence, type Evidence } from "../evidence.js"; import type { ProcessCapture } from "./processCaptureParsing.js"; import { @@ -23,27 +24,31 @@ export const compareProcessCaptureEvidence = ( right.capture, options, ); - const evidence = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-comparison", - operation: "compare_process_captures", - parameters: { - left_evidence_id: left.record.evidence_id, - right_evidence_id: right.record.evidence_id, - left_normalization: left.capture.normalization, - right_normalization: right.capture.normalization, - ...(options.maxCaptureAgeMs === undefined - ? {} - : { max_capture_age_ms: options.maxCaptureAgeMs }), - ...(options.traceSpecification === undefined - ? {} - : { trace_spec: options.traceSpecification }), + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-comparison", + operation: "compare_process_captures", + parameters: { + left_evidence_id: left.record.evidence_id, + right_evidence_id: right.record.evidence_id, + left_normalization: left.capture.normalization, + right_normalization: right.capture.normalization, + ...(options.maxCaptureAgeMs === undefined + ? {} + : { max_capture_age_ms: options.maxCaptureAgeMs }), + ...(options.traceSpecification === undefined + ? {} + : { trace_spec: options.traceSpecification }), + }, + result: comparison, + confidence: "derived", + authority: "analyst-inference", + limitations: comparison.limitations, + locations: [...left.record.locations, ...right.record.locations], + evidenceLinks: [left.record.evidence_id, right.record.evidence_id], }, - result: comparison, - confidence: "derived", - authority: "analyst-inference", - limitations: comparison.limitations, - locations: [...left.record.locations, ...right.record.locations], - evidenceLinks: [left.record.evidence_id, right.record.evidence_id], - }); + ); return { comparison, evidence }; }; diff --git a/src/domain/reconstructionCoverage.fixture.ts b/src/domain/reconstructionCoverage.fixture.ts index 22f012f8e4..19648e5493 100644 --- a/src/domain/reconstructionCoverage.fixture.ts +++ b/src/domain/reconstructionCoverage.fixture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { createHash } from "node:crypto"; import canonicalize from "canonicalize"; @@ -45,7 +46,7 @@ const digest = (character: string): string => character.repeat(64); const EVIDENCE_RECORDS = ["1", "2", "3", "4", "5"].map((character) => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.coverage-fixture", diff --git a/src/domain/reconstructionCoverageEvidence.test.ts b/src/domain/reconstructionCoverageEvidence.test.ts index 5d585ef121..db9c777417 100644 --- a/src/domain/reconstructionCoverageEvidence.test.ts +++ b/src/domain/reconstructionCoverageEvidence.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { expect, it } from "vitest"; import { createEvidence, type Evidence } from "./evidence.js"; @@ -16,7 +17,7 @@ const proof = ( confidence: Evidence["confidence"], ) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "proof-test", name: "Proof fixture", version: "1" }, { operation: "verify", diff --git a/src/domain/reconstructionCoverageScope.fixture.ts b/src/domain/reconstructionCoverageScope.fixture.ts index b19f185818..f5443a1237 100644 --- a/src/domain/reconstructionCoverageScope.fixture.ts +++ b/src/domain/reconstructionCoverageScope.fixture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { createEvidence } from "./evidence.js"; import { createEvidenceBundle } from "./evidenceBundle.js"; import { @@ -25,7 +26,7 @@ const conflictingPackageProof = ( status: "fail" | "unknown", ): string => { const evidence = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "package-proof-fixture", name: "Package proof fixture", diff --git a/src/domain/reconstructionVerification.functionSources.test.ts b/src/domain/reconstructionVerification.functionSources.test.ts index 4e62f7fa5b..ca41fb98f0 100644 --- a/src/domain/reconstructionVerification.functionSources.test.ts +++ b/src/domain/reconstructionVerification.functionSources.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { AnalysisInputError } from "./analysisErrorCore.js"; @@ -82,7 +83,7 @@ const source = ( sha256: digit.repeat(64), format: "file", } - : undefined, + : unknownTarget("not-observed"), { id: "fixture", name: "Fixture function analysis", version: "1" }, { operation: "analyze_function", @@ -141,20 +142,24 @@ const comparison = ( ...dimension, evidence_links: links, })); - return createEvidence(identity.target, identity.provider ?? provider, { - predicateType: "rea.function-comparison", - operation: "compare_functions", - parameters, - result: jsonValueSchema.parse({ - ...resultInput, - dimensions, - changes: dimensions.filter(({ status }) => status !== "unchanged"), - }), - confidence: "derived", - authority: "analyst-inference", - evidenceLinks: links, - ...observation, - }); + return createEvidence( + identity.target ?? unknownTarget("derived-from-linked-evidence"), + identity.provider ?? provider, + { + predicateType: "rea.function-comparison", + operation: "compare_functions", + parameters, + result: jsonValueSchema.parse({ + ...resultInput, + dimensions, + changes: dimensions.filter(({ status }) => status !== "unchanged"), + }), + confidence: "derived", + authority: "analyst-inference", + evidenceLinks: links, + ...observation, + }, + ); }; const specification = (evidence: Evidence, dimension = "pseudocode") => ({ @@ -847,7 +852,7 @@ describe("function reconstruction evidence integrity", () => { it("retains active source unknowns as a gating result", () => { const evidence = comparison(singular); - const mutation = createEvidence(undefined, provider, { + const mutation = createEvidence(unknownTarget("not-observed"), provider, { predicateType: "rea.residual-unknown-mutation", operation: "record_unknown", parameters: {}, diff --git a/src/domain/reconstructionVerification.test.ts b/src/domain/reconstructionVerification.test.ts index cdef927ba9..cf9f3520ae 100644 --- a/src/domain/reconstructionVerification.test.ts +++ b/src/domain/reconstructionVerification.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createEvidence, type Evidence } from "./evidence.js"; @@ -111,7 +112,7 @@ const processComparison = ( extraLinks: readonly string[] = [], ): Evidence => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-process", name: "REA deterministic process harness", @@ -136,7 +137,7 @@ const multiSourceProcessComparison = ( right: readonly Evidence[], ): Evidence => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-process", name: "REA deterministic process harness", @@ -207,7 +208,7 @@ const artifactComparison = ( result?: JsonValue, ): Evidence => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-artifact-comparison", name: "REA artifact comparison", @@ -631,7 +632,7 @@ describe("reconstruction verification integrity", () => { const comparison = processComparison(left, right, processResult()); const mutations = Array.from({ length: 101 }, (_, index) => createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.residual-unknown-mutation", diff --git a/src/domain/reconstructionVerification.ts b/src/domain/reconstructionVerification.ts index ff8c0e4d6b..2a1ce7b487 100644 --- a/src/domain/reconstructionVerification.ts +++ b/src/domain/reconstructionVerification.ts @@ -1,3 +1,4 @@ +import { evidenceFileTarget } from "./evidence.js"; import { ArtifactInventoryCarrierError, parseArtifactInventoryEvidence, @@ -497,7 +498,7 @@ const authorityLimitations = ( ); if ( claim.kind !== "behavioral" && - sources.some(({ subject }) => subject === null) + sources.some((source) => evidenceFileTarget(source) === undefined) ) limitations.push("Structural source artifact identity is unavailable."); if (claim.kind === "behavioral") { diff --git a/src/domain/staticRuntimeCorrelation.test.ts b/src/domain/staticRuntimeCorrelation.test.ts index ba307e120d..b0da146d3f 100644 --- a/src/domain/staticRuntimeCorrelation.test.ts +++ b/src/domain/staticRuntimeCorrelation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { ARTIFACT_COMPARISON_EXAMPLE } from "../contracts/artifactComparisonExample.js"; import { FUNCTION_COMPARISON_EVIDENCE } from "../contracts/investigationExamples.js"; @@ -7,7 +8,11 @@ import { } from "./artifactComparison.js"; import { findChangedBehavior } from "./changedBehavior.js"; import { ARTIFACT_COMPARISON_PROVIDER } from "./comparisonEvidenceIdentity.js"; -import { createEvidence, type Evidence } from "./evidence.js"; +import { + createEvidence, + type Evidence, + evidenceSubjectInput, +} from "./evidence.js"; import { functionComparisonResultSchema } from "./functionComparisonSchemas.js"; import { jsonValueSchema, type JsonValue } from "./jsonValue.js"; import { FUNCTION_COMPARISON_EXAMPLE } from "../contracts/functionComparisonExample.js"; @@ -23,7 +28,7 @@ import { const staticComparison = FUNCTION_COMPARISON_EVIDENCE; const artifactComparison = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), ARTIFACT_COMPARISON_PROVIDER, { predicateType: "rea.artifact-comparison", @@ -47,7 +52,7 @@ const artifactComparison = createEvidence( const capture = (digit: string): Evidence => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.process-capture", @@ -94,7 +99,7 @@ const processComparison = ( limitations: terminal === "unknown" ? ["Terminal unavailable."] : [], } satisfies JsonValue; return createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-process", name: "REA deterministic process harness", @@ -166,19 +171,23 @@ it("keeps text, assembly and unavailable CFG caveats on their selected correlati functionSnapshotFixture(left), functionSnapshotFixture(right), ); - const comparison = createEvidence(undefined, staticComparison.provider, { - predicateType: "rea.function-comparison", - operation: "compare_functions", - parameters: { - left_evidence_id: left.evidence_id, - right_evidence_id: right.evidence_id, + const comparison = createEvidence( + unknownTarget("derived-from-linked-evidence"), + staticComparison.provider, + { + predicateType: "rea.function-comparison", + operation: "compare_functions", + parameters: { + left_evidence_id: left.evidence_id, + right_evidence_id: right.evidence_id, + }, + result: computed, + confidence: "derived", + authority: "analyst-inference", + limitations: computed.limitations, + evidenceLinks: [left.evidence_id, right.evidence_id], }, - result: computed, - confidence: "derived", - authority: "analyst-inference", - limitations: computed.limitations, - evidenceLinks: [left.evidence_id, right.evidence_id], - }); + ); const input = mapping(processComparison("unchanged"), "static_only"); const result = correlateStaticAndRuntime({ ...input, @@ -447,18 +456,22 @@ describe("static/runtime correlation selection", () => { describe("static/runtime correlation Evidence validation", () => { it("rejects comparison citations that disagree with source parameters", () => { const runtime = processComparison("changed"); - const forged = createEvidence(undefined, runtime.provider, { - predicateType: runtime.predicate_type, - operation: runtime.operation, - parameters: { - left_evidence_id: leftCapture.evidence_id, - right_evidence_id: staticComparison.evidence_id, + const forged = createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + predicateType: runtime.predicate_type, + operation: runtime.operation, + parameters: { + left_evidence_id: leftCapture.evidence_id, + right_evidence_id: staticComparison.evidence_id, + }, + result: runtime.normalized_result, + confidence: runtime.confidence, + authority: runtime.authority, + evidenceLinks: runtime.evidence_links, }, - result: runtime.normalized_result, - confidence: runtime.confidence, - authority: runtime.authority, - evidenceLinks: runtime.evidence_links, - }); + ); const input = mapping(forged, "cochanged"); expect(() => correlateStaticAndRuntime(input)).toThrowError( expect.toSatisfy( @@ -475,15 +488,19 @@ describe("static/runtime correlation Evidence validation", () => { it("retains invalid authenticated result payloads as Evidence failures", () => { const valid = processComparison("changed"); - const malformed = createEvidence(undefined, valid.provider, { - predicateType: valid.predicate_type, - operation: valid.operation, - parameters: valid.parameters, - result: { status: "changed" }, - confidence: valid.confidence, - authority: valid.authority, - evidenceLinks: valid.evidence_links, - }); + const malformed = createEvidence( + evidenceSubjectInput(valid.subject), + valid.provider, + { + predicateType: valid.predicate_type, + operation: valid.operation, + parameters: valid.parameters, + result: { status: "changed" }, + confidence: valid.confidence, + authority: valid.authority, + evidenceLinks: valid.evidence_links, + }, + ); expect(() => correlateStaticAndRuntime(mapping(malformed, "cochanged")), ).toThrowError( @@ -499,15 +516,19 @@ describe("static/runtime correlation citation closure", () => { it("accepts extra parent citations for changed behavior but rejects them for correlation", () => { const runtime = processComparison("changed"); const extra = staticComparison.evidence_id; - const extended = createEvidence(undefined, runtime.provider, { - predicateType: runtime.predicate_type, - operation: runtime.operation, - parameters: runtime.parameters, - result: runtime.normalized_result, - confidence: runtime.confidence, - authority: runtime.authority, - evidenceLinks: [...runtime.evidence_links, extra], - }); + const extended = createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + predicateType: runtime.predicate_type, + operation: runtime.operation, + parameters: runtime.parameters, + result: runtime.normalized_result, + confidence: runtime.confidence, + authority: runtime.authority, + evidenceLinks: [...runtime.evidence_links, extra], + }, + ); const aggregated = findChangedBehavior({ comparisons: [extended] }); expect(aggregated.result.behavior_status).toBe("observed_changed"); expect(aggregated.result.evidence_links).toContain(extra); @@ -560,15 +581,19 @@ describe("static/runtime correlation citation closure", () => { })), }); } - const danglingNested = createEvidence(undefined, base.provider, { - predicateType: base.predicate_type, - operation: base.operation, - parameters: base.parameters, - result, - confidence: base.confidence, - authority: base.authority, - evidenceLinks: base.evidence_links, - }); + const danglingNested = createEvidence( + evidenceSubjectInput(base.subject), + base.provider, + { + predicateType: base.predicate_type, + operation: base.operation, + parameters: base.parameters, + result, + confidence: base.confidence, + authority: base.authority, + evidenceLinks: base.evidence_links, + }, + ); const input = mapping(processComparison("changed"), "cochanged"); expect(() => correlateStaticAndRuntime({ diff --git a/src/domain/targetIdentity.ts b/src/domain/targetIdentity.ts index 3b1adfaf84..124f7dd250 100644 --- a/src/domain/targetIdentity.ts +++ b/src/domain/targetIdentity.ts @@ -1,18 +1,45 @@ import { createHash } from "node:crypto"; import canonicalize from "canonicalize"; +import { z } from "zod"; + +import type { BinaryTarget } from "./binaryTargetTypes.js"; +import { digestSchema } from "./digests.js"; +import { rawBinaryEntryPointSchema } from "./rawBinary.js"; + +const flashOffsetSchema = z.number().int().min(0).max(0xffff_ffff).nullable(); + +/** Persisted facts inside a file's bytes that select what was analysed. */ +export const fileTargetSelectionSchema = z.discriminatedUnion("kind", [ + z.strictObject({ + kind: z.literal("entry-point"), + entry_point: rawBinaryEntryPointSchema, + }), + z.strictObject({ + kind: z.literal("esp-flash"), + flash_offset: flashOffsetSchema, + partition_table_offset: flashOffsetSchema, + }), +]); /** * Facts inside a file's bytes that select what was analysed. Two observations * of the same bytes with different selections are different targets. */ -export type FileTargetSelection = - | { readonly kind: "entry-point"; readonly entry_point: string } - | { - readonly kind: "esp-flash"; - readonly flash_offset: number | null; - readonly partition_table_offset: number | null; - }; +export type FileTargetSelection = z.infer; + +/** + * A hashed local file, path-free. Format and architecture are validated by + * the persistence format that embeds the identity (for Evidence, the + * format-owned subject declaration). + */ +export const fileTargetIdentitySchema = z.strictObject({ + kind: z.literal("file"), + sha256: digestSchema, + format: z.string().min(1), + architecture: z.string().min(1).nullable(), + selection: fileTargetSelectionSchema.nullable(), +}); /** A hashed local file, path-free. */ export interface FileTargetIdentity { @@ -23,11 +50,64 @@ export interface FileTargetIdentity { readonly selection: FileTargetSelection | null; } +/** + * Why an observation names no target: it derives from linked Evidence that + * already commits to its sources, the producer did not observe the target's + * identity, or the target is not a kind REA can identify. + */ +export const unknownTargetReasonSchema = z.enum([ + "derived-from-linked-evidence", + "not-observed", + "unsupported-subject", +]); + +/** A target whose identity is unknown, with the reason it is unknown. */ +export const unknownTargetIdentitySchema = z.strictObject({ + kind: z.literal("unknown"), + reason: unknownTargetReasonSchema, +}); + +/** A target whose identity is unknown, with the reason it is unknown. */ +export interface UnknownTargetIdentity { + readonly kind: "unknown"; + readonly reason: z.infer; +} + +/** The explicit identity of a target REA did not identify. */ +export const unknownTarget = ( + reason: UnknownTargetIdentity["reason"], +): UnknownTargetIdentity => ({ kind: "unknown", reason }); + /** * What an observation or cache entry is about. Tagged by `kind`; see * docs/adr/evidence/target-identity.md for the kinds later slices add. */ -export type TargetIdentity = FileTargetIdentity; +export type TargetIdentity = FileTargetIdentity | UnknownTargetIdentity; + +/** The selection an open binary target makes inside its bytes, if any. */ +export const binaryTargetSelection = ( + target: BinaryTarget, +): FileTargetSelection | null => + target.format === "raw-binary" || target.format === "gamecube-dol" + ? { kind: "entry-point", entry_point: target.entryPoint } + : target.format === "esp-flash-image" + ? { + kind: "esp-flash", + flash_offset: target.espFlash.flashOffset, + partition_table_offset: target.espFlash.partitionTableOffset, + } + : null; + +/** The one projection of an open binary target into its target identity. */ +export const binaryTargetIdentity = ( + target: BinaryTarget, +): FileTargetIdentity => ({ + kind: "file", + sha256: target.sha256, + format: target.format, + architecture: target.architecture ?? null, + selection: binaryTargetSelection(target), +}); /** The only comparison of two target identities: an RFC 8785 canonical digest. */ export const targetIdentityKey = (identity: TargetIdentity): string => { diff --git a/src/domain/wasm/wasmArtifact.ts b/src/domain/wasm/wasmArtifact.ts index 474fee5d13..14269153f2 100644 --- a/src/domain/wasm/wasmArtifact.ts +++ b/src/domain/wasm/wasmArtifact.ts @@ -7,7 +7,6 @@ import { z } from "zod"; import { knownCoverageStatusSchema } from "../coverage.js"; import { createHash } from "node:crypto"; import { constants as bufferConstants } from "node:buffer"; -import type { EvidenceSubjectTarget } from "../evidence.js"; import { absoluteLocalPathStringSchema } from "../localPath.js"; /** Exact upstream release whose tool profile REA verified. */ @@ -271,10 +270,11 @@ export type InspectWasmArtifactInput = z.infer< export type WasmArtifact = z.infer; /** Semantic WASM subject identity excludes delivery-only local paths. */ -export type WasmArtifactSubject = Pick< - EvidenceSubjectTarget, - "sha256" | "format" ->; +/** The file facts a WASM artifact is matched against (a subject or target identity). */ +export interface WasmArtifactSubject { + readonly sha256: string; + readonly format: string; +} type WasmArtifactFileSubject = WasmArtifactSubject & { readonly format: "file"; }; diff --git a/src/domain/webBundleAnalyzer.test.ts b/src/domain/webBundleAnalyzer.test.ts index 0e30b438a9..7625ddf9c1 100644 --- a/src/domain/webBundleAnalyzer.test.ts +++ b/src/domain/webBundleAnalyzer.test.ts @@ -1,3 +1,4 @@ +import { UNKNOWN_EVIDENCE_SUBJECT } from "../../tests/fixtures/evidenceSubject.js"; import { projectAnalysisView } from "./analysisView/analysisView.js"; import { analysisViewRequestSchema } from "./analysisView/analysisViewRequest.js"; import { describe, expect, it } from "vitest"; @@ -2091,7 +2092,7 @@ it("keeps known capture omissions in compact route summaries and queryable gap f operation: "analyze_web_bundle", normalizedResult: report, limitations: report.limitations, - subject: null, + subject: UNKNOWN_EVIDENCE_SUBJECT, }; const summary = projectAnalysisView( parent, diff --git a/src/domain/webMcpDiscovery.test.ts b/src/domain/webMcpDiscovery.test.ts index 29c57973a0..8afa792ef9 100644 --- a/src/domain/webMcpDiscovery.test.ts +++ b/src/domain/webMcpDiscovery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "./targetIdentity.js"; import { describe, expect, it } from "vitest"; import { createEvidence } from "./evidence.js"; @@ -101,7 +102,7 @@ describe("WebMCP discovery consequential annotation", () => { consequential: true, autosubmit: null, }); - const evidence = createEvidence(undefined, PROVIDER, { + const evidence = createEvidence(unknownTarget("not-observed"), PROVIDER, { predicateType: "rea.webmcp-discovery", operation: "discover_webmcp_tools", parameters: {}, diff --git a/src/electron/ElectronFuseArchitecture.test.ts b/src/electron/ElectronFuseArchitecture.test.ts index b9df79e185..6dd78a7b94 100644 --- a/src/electron/ElectronFuseArchitecture.test.ts +++ b/src/electron/ElectronFuseArchitecture.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../tests/fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -72,7 +73,7 @@ it("keeps a truncated COFF header unknown without refusing a recognized PE conta expect(result).toMatchObject({ ok: true, value: { - subject: { architecture: null }, + subject: { identity: { architecture: null } }, normalized_result: { slices: [{ architecture: null, sentinel_count: 0 }], }, @@ -97,8 +98,8 @@ const assertArchitecture = async ( new ElectronFuseProvider(), ).inspect({ path }); if (!result.ok) throw result.error; - expect(result.value.subject?.architecture).toBe(architecture); - expect(result.value.subject?.digest.sha256).toBe( + expect(fileIdentity(result.value.subject).architecture).toBe(architecture); + expect(fileIdentity(result.value.subject).sha256).toBe( createHash("sha256").update(image.bytes).digest("hex"), ); expect(result.value.normalized_result).toMatchObject({ diff --git a/src/electron/ElectronFuseCompletion.test.ts b/src/electron/ElectronFuseCompletion.test.ts index 932d8fb4d8..c0a157b8e9 100644 --- a/src/electron/ElectronFuseCompletion.test.ts +++ b/src/electron/ElectronFuseCompletion.test.ts @@ -101,7 +101,7 @@ it("retains completed Evidence and resolved bundle identity after successful-clo cause: reason, cleanupIncomplete: false, partialObservation: { - subject: { local_path: path, architecture: "arm64" }, + subject: { local_path: path, identity: { architecture: "arm64" } }, parameters: { path: bundle }, normalized_result: { artifact: { selected_path: bundle, resolved_path: path }, diff --git a/src/gdb/GdbSessionManager.ts b/src/gdb/GdbSessionManager.ts index 959a6b0711..b3cfee220c 100644 --- a/src/gdb/GdbSessionManager.ts +++ b/src/gdb/GdbSessionManager.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { gdbMiConstText, gdbMiResultHeader, @@ -841,7 +842,7 @@ export class GdbSessionManager { const startupEvidence = startupEvidencePayload === undefined ? undefined - : createEvidence(undefined, session.provider, { + : createEvidence(unknownTarget("not-observed"), session.provider, { predicateType: "rea.debugger.startup-observation", operation: "start_gdb_session", parameters: { @@ -856,9 +857,8 @@ export class GdbSessionManager { ...startupEvidencePayload, records: [...startupEvidencePayload.records], }, - subjectUnavailableReason: - "No usable debugger session became ready during GDB startup.", limitations: [ + "No usable debugger session became ready during GDB startup.", "GDB startup failed before a usable session could be established; captured startup records are incomplete.", ...(session.invalidUtf8Observed ? [ @@ -1050,60 +1050,63 @@ export class GdbSessionManager { command, accepted.value, ); - const evidence = createEvidence(undefined, session.provider, { - predicateType: "rea.debugger.console-observation", - operation: "gdb_console", - parameters: { session_id: sessionId, command }, - result: { - command, - mi: result.mi, - records: [...result.records], - console: result.console, - target: result.target, - log: result.log, - output_truncated: result.output_truncated, - ...(result.output_limits === undefined - ? {} - : { output_limits: result.output_limits }), - ...(result.output_invalid_utf8 - ? { output_invalid_utf8: true as const } - : {}), - completion_status: result.completion_status, + const evidence = createEvidence( + unknownTarget("not-observed"), + session.provider, + { + predicateType: "rea.debugger.console-observation", + operation: "gdb_console", + parameters: { session_id: sessionId, command }, + result: { + command, + mi: result.mi, + records: [...result.records], + console: result.console, + target: result.target, + log: result.log, + output_truncated: result.output_truncated, + ...(result.output_limits === undefined + ? {} + : { output_limits: result.output_limits }), + ...(result.output_invalid_utf8 + ? { output_invalid_utf8: true as const } + : {}), + completion_status: result.completion_status, + }, + rawResult: { + command, + mi: result.mi, + records: [...result.records], + console: result.console, + target: result.target, + log: result.log, + output_truncated: result.output_truncated, + ...(result.output_limits === undefined + ? {} + : { output_limits: result.output_limits }), + ...(result.output_invalid_utf8 + ? { output_invalid_utf8: true as const } + : {}), + completion_status: result.completion_status, + }, + limitations: [ + "The active GDB inferior identity is not established by the debugger session identifier.", + ...(result.mi.length === 0 + ? [ + "A separately tokenized read-only query confirmed return to GDB's command loop. The original result record could not be framed independently from raw stdout; its bytes remain in records and its result class is unknown.", + ] + : []), + "MI records are returned as decoded text; their semantics depend on GDB version and target.", + ...gdbRetainedOutputLimitations(result, acceptedOutput), + ...(result.output_invalid_utf8 + ? [ + "MI stream bytes were not valid UTF-8; returned text contains replacement characters.", + ] + : []), + "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", + ], }, - rawResult: { - command, - mi: result.mi, - records: [...result.records], - console: result.console, - target: result.target, - log: result.log, - output_truncated: result.output_truncated, - ...(result.output_limits === undefined - ? {} - : { output_limits: result.output_limits }), - ...(result.output_invalid_utf8 - ? { output_invalid_utf8: true as const } - : {}), - completion_status: result.completion_status, - }, - subjectUnavailableReason: - "The active GDB inferior identity is not established by the debugger session identifier.", - limitations: [ - ...(result.mi.length === 0 - ? [ - "A separately tokenized read-only query confirmed return to GDB's command loop. The original result record could not be framed independently from raw stdout; its bytes remain in records and its result class is unknown.", - ] - : []), - "MI records are returned as decoded text; their semantics depend on GDB version and target.", - ...gdbRetainedOutputLimitations(result, acceptedOutput), - ...(result.output_invalid_utf8 - ? [ - "MI stream bytes were not valid UTF-8; returned text contains replacement characters.", - ] - : []), - "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", - ], - }); + ); return ok({ result, evidence }); } catch (cause) { if (cause instanceof AnalysisCancelledError) return err(cause); @@ -1121,19 +1124,22 @@ export class GdbSessionManager { ...processExit.partial, command, }; - const evidence = createEvidence(undefined, session.provider, { - predicateType: "rea.debugger.console-observation", - operation: "gdb_console", - parameters: { session_id: sessionId, command }, - result: { ...result, records: [...result.records] }, - rawResult: { ...result, records: [...result.records] }, - subjectUnavailableReason: - "The active GDB inferior identity is not established by the debugger session identifier.", - limitations: [ - "GDB exited before returning a correlated MI result record; only records retained for the active command are returned raw.", - ...gdbRetainedOutputLimitations(result, acceptedOutput), - ], - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + session.provider, + { + predicateType: "rea.debugger.console-observation", + operation: "gdb_console", + parameters: { session_id: sessionId, command }, + result: { ...result, records: [...result.records] }, + rawResult: { ...result, records: [...result.records] }, + limitations: [ + "The active GDB inferior identity is not established by the debugger session identifier.", + "GDB exited before returning a correlated MI result record; only records retained for the active command are returned raw.", + ...gdbRetainedOutputLimitations(result, acceptedOutput), + ], + }, + ); const stopped = await this.#stopDebuggerOnly(session); if (stopped.status === "incomplete") return err( @@ -1694,7 +1700,7 @@ export class GdbSessionManager { const partialObservation = partial === undefined ? undefined - : createEvidence(undefined, session.provider, { + : createEvidence(unknownTarget("not-observed"), session.provider, { predicateType: "rea.debugger.console-observation", operation: "gdb_console", parameters: { @@ -1703,9 +1709,8 @@ export class GdbSessionManager { }, result: { ...partial, records: [...partial.records] }, rawResult: { ...partial, records: [...partial.records] }, - subjectUnavailableReason: - "The active GDB inferior identity is not established by the debugger session identifier.", limitations: [ + "The active GDB inferior identity is not established by the debugger session identifier.", "The GDB MI protocol failed; retained records are partial and command completion is unknown.", "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", ], @@ -1926,27 +1931,30 @@ export class GdbSessionManager { ), }, ); - const evidence = createEvidence(undefined, session.provider, { - predicateType: - operation === "start_gdb_session" - ? "rea.debugger.startup-observation" - : "rea.debugger.console-observation", - operation, - parameters: { - session_id: session.id, - command: pending.evidenceCommand, + const evidence = createEvidence( + unknownTarget("not-observed"), + session.provider, + { + predicateType: + operation === "start_gdb_session" + ? "rea.debugger.startup-observation" + : "rea.debugger.console-observation", + operation, + parameters: { + session_id: session.id, + command: pending.evidenceCommand, + }, + result: { ...partial, records: [...partial.records] }, + rawResult: { ...partial, records: [...partial.records] }, + limitations: [ + "The active GDB inferior identity is not established by the debugger session identifier.", + `The GDB command exceeded its ${String(acceptedDeadline.value)} ms deadline (deadlineExpired). ${debuggerAdmissionRecovery(acceptedDeadline)} Retained MI and stream records are partial and command completion is unknown.`, + ...gdbRetainedOutputLimitations(partial, acceptedOutput), + "Cleanup of the owned GDB process was requested because output correlation could no longer be guaranteed.", + "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", + ], }, - result: { ...partial, records: [...partial.records] }, - rawResult: { ...partial, records: [...partial.records] }, - subjectUnavailableReason: - "The active GDB inferior identity is not established by the debugger session identifier.", - limitations: [ - `The GDB command exceeded its ${String(acceptedDeadline.value)} ms deadline (deadlineExpired). ${debuggerAdmissionRecovery(acceptedDeadline)} Retained MI and stream records are partial and command completion is unknown.`, - ...gdbRetainedOutputLimitations(partial, acceptedOutput), - "Cleanup of the owned GDB process was requested because output correlation could no longer be guaranteed.", - "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", - ], - }); + ); void this.#stopDebuggerOnly(session).then((stopped) => { if ( stopped.status === "incomplete" && @@ -2019,24 +2027,27 @@ export class GdbSessionManager { : {}), completion_status: "unknown", }; - const evidence = createEvidence(undefined, session.provider, { - predicateType: "rea.debugger.console-observation", - operation: "gdb_console", - parameters: { - session_id: session.id, - command: pending.evidenceCommand, + const evidence = createEvidence( + unknownTarget("not-observed"), + session.provider, + { + predicateType: "rea.debugger.console-observation", + operation: "gdb_console", + parameters: { + session_id: session.id, + command: pending.evidenceCommand, + }, + result: { ...partial, records: [...partial.records] }, + rawResult: { ...partial, records: [...partial.records] }, + limitations: [ + "The active GDB inferior identity is not established by the debugger session identifier.", + "The GDB command was cancelled; retained MI records are partial and command completion is unknown.", + ...gdbRetainedOutputLimitations(partial, acceptedOutput), + "Shutdown of the owned GDB process was requested because output correlation could no longer be guaranteed.", + "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", + ], }, - result: { ...partial, records: [...partial.records] }, - rawResult: { ...partial, records: [...partial.records] }, - subjectUnavailableReason: - "The active GDB inferior identity is not established by the debugger session identifier.", - limitations: [ - "The GDB command was cancelled; retained MI records are partial and command completion is unknown.", - ...gdbRetainedOutputLimitations(partial, acceptedOutput), - "Shutdown of the owned GDB process was requested because output correlation could no longer be guaranteed.", - "The unrestricted GDB console can access local shell, filesystem, network, and target controls.", - ], - }); + ); session.pending.delete(token); session.protocolError = { code: "command-cancelled", diff --git a/src/native/NativeMachoSourceProvider.test.ts b/src/native/NativeMachoSourceProvider.test.ts index 6b3e4e8183..3943a5dc9b 100644 --- a/src/native/NativeMachoSourceProvider.test.ts +++ b/src/native/NativeMachoSourceProvider.test.ts @@ -88,7 +88,7 @@ it.each( expect(result.error.partialObservation).toMatchObject({ operation, parameters: { native_command_timeout_ms: 5000 }, - subject: { local_path: path, digest: { sha256: target.sha256 } }, + subject: { local_path: path, identity: { sha256: target.sha256 } }, normalized_result: { provenance: expect.any(Array) }, locations: expect.any(Array), }); @@ -194,7 +194,7 @@ it.each( } else { expect(result.error.partialObservation).toMatchObject({ operation, - subject: { local_path: path, digest: { sha256: target.sha256 } }, + subject: { local_path: path, identity: { sha256: target.sha256 } }, normalized_result: { provenance: expect.any(Array) }, }); } diff --git a/src/process/ArtifactAnalysisResources.test.ts b/src/process/ArtifactAnalysisResources.test.ts index d77d9cfa80..acfa5d7bc0 100644 --- a/src/process/ArtifactAnalysisResources.test.ts +++ b/src/process/ArtifactAnalysisResources.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { AnalysisCleanupLease } from "../resources/AnalysisCleanupLease.js"; import { artifactResourceDialect, @@ -251,7 +252,7 @@ it("preserves the primary error and resolves cleanup status after retry", async "producer returned malformed output", { partialObservation: createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", @@ -324,7 +325,7 @@ it("resolves each returned cleanup error with its own retained root", async () = }, }); const partial = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: null }, { operation: "fixture-operation", diff --git a/src/rizin/RizinDebugSessionManager.ts b/src/rizin/RizinDebugSessionManager.ts index c33dccc799..72c88f6706 100644 --- a/src/rizin/RizinDebugSessionManager.ts +++ b/src/rizin/RizinDebugSessionManager.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { readRuntimeSetting } from "../config/runtimeAnalysisSettings.js"; import { RIZIN_DEBUGGER_PROVIDER_IDENTITY } from "./RizinDebuggerProviderIdentity.js"; import { persistentDebuggerHostSupported } from "../process/PersistentDebuggerHost.js"; @@ -112,34 +113,37 @@ const createRizinCommandEvidence = ({ launchProvenance, limitations, }: RizinCommandEvidenceInput): Evidence => - createEvidence(undefined, RIZIN_DEBUGGER_PROVIDER_IDENTITY, { - predicateType: "rea.debugger.command-observation", - operation: "rizin_debug_command", - parameters: { - session_id: sessionId, - command, - inferior_tty: inferiorTty, - launch_provenance: { ...launchProvenance }, + createEvidence( + unknownTarget("not-observed"), + RIZIN_DEBUGGER_PROVIDER_IDENTITY, + { + predicateType: "rea.debugger.command-observation", + operation: "rizin_debug_command", + parameters: { + session_id: sessionId, + command, + inferior_tty: inferiorTty, + launch_provenance: { ...launchProvenance }, + }, + result: { ...result }, + rawResult: { ...result }, + limitations: [ + "The current debugger target identity is not established by the Rizin session identifier.", + ...limitations, + ...(result.completion_status === "unknown" + ? [ + "Interrupted output may include an incomplete completion-marker prefix; it is retained because it cannot be distinguished from command diagnostics.", + ] + : []), + ...(result.output_invalid_utf8 + ? [ + "Collected command frames contained invalid UTF-8 bytes; decoded text may contain replacement characters.", + ] + : []), + RIZIN_LAUNCH_PROVENANCE_LIMITATION, + ], }, - result: { ...result }, - rawResult: { ...result }, - subjectUnavailableReason: - "The current debugger target identity is not established by the Rizin session identifier.", - limitations: [ - ...limitations, - ...(result.completion_status === "unknown" - ? [ - "Interrupted output may include an incomplete completion-marker prefix; it is retained because it cannot be distinguished from command diagnostics.", - ] - : []), - ...(result.output_invalid_utf8 - ? [ - "Collected command frames contained invalid UTF-8 bytes; decoded text may contain replacement characters.", - ] - : []), - RIZIN_LAUNCH_PROVENANCE_LIMITATION, - ], - }); + ); type RizinOutputLimit = | "command_output_bytes" diff --git a/src/server/BundleResourcesMcp.test.ts b/src/server/BundleResourcesMcp.test.ts index eec15cbbe4..9d20d09531 100644 --- a/src/server/BundleResourcesMcp.test.ts +++ b/src/server/BundleResourcesMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../tests/fixtures/canonicalOutputSchema.js"; import type { Client } from "@modelcontextprotocol/client"; import { Ajv2020 } from "ajv/dist/2020.js"; @@ -24,6 +25,13 @@ import { build } from "plist"; import { createApplicationMcpHarness } from "../../tests/fixtures/applicationMcpHarness.js"; import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js"; +const UNOBSERVED = unknownTarget("not-observed"); + +/** The subject of an observation whose target identity was not observed. */ +const UNOBSERVED_SUBJECT = { + identity: { kind: "unknown", reason: "not-observed" }, +} as const; + const identity: ProviderIdentity = { id: "bundle-resource-mcp-fixture", name: "Bundle resource MCP fixture", @@ -166,7 +174,7 @@ it("routes bundle resource MCP calls with null executable identity and retained inspected.structuredContent, ); expect(evidence).toMatchObject({ - subject: null, + subject: UNOBSERVED_SUBJECT, normalized_result: { source_path: plistPath, resource_root: { executable_sha256: null }, @@ -176,7 +184,7 @@ it("routes bundle resource MCP calls with null executable identity and retained .object({ evidence_id: z.string() }) .parse(evidence).evidence_id; expect(session.evidenceById(evidenceId)).toMatchObject({ - subject: null, + subject: UNOBSERVED_SUBJECT, operation: "inspect_plist", normalized_result: { resource_root: { canonical_path: bundle, executable_sha256: null }, @@ -238,7 +246,7 @@ it("exposes the production resource session through the MCP SDK for a keyless bu "decode_interface_builder", ).outputSchema.parse(decoded.structuredContent); expect(decodedEvidence).toMatchObject({ - subject: null, + subject: UNOBSERVED_SUBJECT, normalized_result: { target_sha256: null, resource_root: { @@ -293,7 +301,7 @@ it("exposes the production resource session through the MCP SDK for a keyless bu inspected.structuredContent, ); expect(evidence).toMatchObject({ - subject: null, + subject: UNOBSERVED_SUBJECT, normalized_result: { archive_path: "Resources/Archive.plist", target_sha256: null, @@ -311,7 +319,7 @@ it("exposes the production resource session through the MCP SDK for a keyless bu .object({ evidence_id: z.string() }) .parse(evidence).evidence_id; expect(session.evidenceById(evidenceId)).toMatchObject({ - subject: null, + subject: UNOBSERVED_SUBJECT, operation: "inspect_keyed_archive", normalized_result: { resource_root: { @@ -413,7 +421,7 @@ const expectResourceSchemaBranches = async (client: Client): Promise => { } as const; for (const { name, validResult } of schemaCases) { const contract = toolContract(name); - const validEvidence = createEvidence(undefined, identity, { + const validEvidence = createEvidence(UNOBSERVED, identity, { operation: name, parameters: {}, result: validResult, @@ -432,7 +440,7 @@ const expectResourceSchemaBranches = async (client: Client): Promise => { target_sha256: null, }; } - const malformedEvidence = createEvidence(undefined, identity, { + const malformedEvidence = createEvidence(UNOBSERVED, identity, { operation: name, parameters: {}, result: malformedResult, @@ -460,7 +468,7 @@ const expectResourceSchemaBranches = async (client: Client): Promise => { target_sha256: null, }; } - const resourceEvidence = createEvidence(undefined, identity, { + const resourceEvidence = createEvidence(UNOBSERVED, identity, { operation: name, parameters: {}, result: resourceResult, diff --git a/src/server/EvidenceMcpServerCore.ts b/src/server/EvidenceMcpServerCore.ts index 65e26f6203..b1bbf253b3 100644 --- a/src/server/EvidenceMcpServerCore.ts +++ b/src/server/EvidenceMcpServerCore.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import type { AnalysisSettings } from "../application/AnalysisSettings.js"; import { AsyncLocalStorage } from "node:async_hooks"; import { DEFAULT_MCP_MAX_INPUT_ELEMENTS } from "../config/mcpInputBudget.js"; @@ -938,7 +939,7 @@ class ErrorEvidenceTransport implements Transport { // The SDK error contains its rendered issue, not a separate argument bag; // transport authentication and caller arguments are never added here. const evidence = createEvidence( - undefined, + unknownTarget("unsupported-subject"), { id: "rea-mcp", name: "REA MCP delivery", version: "1" }, { operation: "mcp_tool_error", diff --git a/src/server/ToolResultDelivery.partialRetention.test.ts b/src/server/ToolResultDelivery.partialRetention.test.ts index 80bf00b0f3..2b2ced599f 100644 --- a/src/server/ToolResultDelivery.partialRetention.test.ts +++ b/src/server/ToolResultDelivery.partialRetention.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { expect, it } from "vitest"; import { AnalysisOutputError } from "../domain/analysisErrorCore.js"; @@ -6,7 +7,7 @@ import { err } from "../domain/result.js"; import { ToolResultDelivery } from "./ToolResultDelivery.js"; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", parameters: {}, result: { observed: true } }, ); diff --git a/src/server/ToolResultDelivery.ts b/src/server/ToolResultDelivery.ts index ba7ec93835..a7136e9d7d 100644 --- a/src/server/ToolResultDelivery.ts +++ b/src/server/ToolResultDelivery.ts @@ -17,7 +17,6 @@ import type { AnalysisError } from "../domain/analysisErrorBase.js"; import { NoBinaryOpenError } from "../domain/configurationErrors.js"; import type { JsonValue } from "../domain/jsonValue.js"; import type { Result } from "../domain/result.js"; -import { estimateJsonStorage } from "../application/JsonAuthenticationHeadroom.js"; import { AnalysisResourceConstraintError } from "../domain/analysisErrorCore.js"; import { MCP_TRANSPORT_EVIDENCE_DISCOVERY, @@ -31,6 +30,7 @@ import { } from "../config/mcpResponseBudget.js"; import { encodeToolResult, + errorTextWireBytes, measureMcpResultWithinBudget, MCP_RESULT_STRING_LIMIT, NODE_MAX_STRING_LENGTH, @@ -440,10 +440,7 @@ export class ToolResultDelivery { const candidates = [...unretainedEvidenceCandidates(candidateProjection)] .map((candidate) => ({ candidate, - size: estimateJsonStorage(candidate.value, { - maximumValueBytes: this.resultBudgetBytes, - includeSerialized: false, - }).valueBytes, + size: errorTextWireBytes(candidate.value, this.resultBudgetBytes), })) .sort((left, right) => right.size - left.size); let next: AnalysisErrorProjection | undefined; diff --git a/src/server/registerBundleComparisonTool.ts b/src/server/registerBundleComparisonTool.ts index af0f891731..b51294f62b 100644 --- a/src/server/registerBundleComparisonTool.ts +++ b/src/server/registerBundleComparisonTool.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import type { EvidenceMcpServer } from "./EvidenceMcpServer.js"; import type { BinarySessionPort } from "../application/binary/BinarySessionPort.js"; @@ -64,7 +65,7 @@ export const registerBundleComparisonTool = ( if (!recordedSources.ok) return server.delivery.toCallToolResult(recordedSources, contract); const evidence = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), BUNDLE_COMPARISON_PROVIDER, { predicateType: "rea.bundle-comparison", diff --git a/src/server/registerInvestigationTools.ts b/src/server/registerInvestigationTools.ts index 2497661240..e165d73c2c 100644 --- a/src/server/registerInvestigationTools.ts +++ b/src/server/registerInvestigationTools.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import type { EvidenceMcpServer } from "./EvidenceMcpServer.js"; import type { BinarySessionPort } from "../application/binary/BinarySessionPort.js"; import { resolveInvestigationEvidenceClosure } from "../application/investigation/InvestigationEvidence.js"; @@ -136,24 +137,28 @@ const registerReconstruction = ( if (!closure.ok) return server.delivery.toCallToolResult(closure, contract); const links = closure.value; - const evidence = createEvidence(undefined, RECONSTRUCTION_PROVIDER, { - predicateType: "rea.reconstruction-verification", - operation: contract.name, - analysisProfile: createAnalysisProfile(RECONSTRUCTION_PROVIDER, { - workflow_revision: 2, - }), - parameters: { - specification_sha256: result.specification_sha256, - claim_ids: input.specification.claims.map( - ({ claim_id: id }) => id, - ), + const evidence = createEvidence( + unknownTarget("derived-from-linked-evidence"), + RECONSTRUCTION_PROVIDER, + { + predicateType: "rea.reconstruction-verification", + operation: contract.name, + analysisProfile: createAnalysisProfile(RECONSTRUCTION_PROVIDER, { + workflow_revision: 2, + }), + parameters: { + specification_sha256: result.specification_sha256, + claim_ids: input.specification.claims.map( + ({ claim_id: id }) => id, + ), + }, + result, + confidence: "derived", + authority: "analyst-inference", + limitations: result.limitations, + evidenceLinks: links, }, - result, - confidence: "derived", - authority: "analyst-inference", - limitations: result.limitations, - evidenceLinks: links, - }); + ); return server.delivery.toEvidenceToolResult( evidence, contract, diff --git a/src/server/toolResultEncoding.test.ts b/src/server/toolResultEncoding.test.ts index 1e9aee5ac7..3960c35e13 100644 --- a/src/server/toolResultEncoding.test.ts +++ b/src/server/toolResultEncoding.test.ts @@ -4,6 +4,7 @@ import type { JsonValue } from "../domain/jsonValue.js"; import { carriesTargetContentMarker, encodeToolResult, + errorTextWireBytes, TARGET_CONTENT_RESULT_META, } from "./toolResultEncoding.js"; @@ -138,3 +139,25 @@ describe("MCP result encoding budget", () => { expect(encodeToolResult(candidate, 1000).ok).toBe(false); }); }); + +describe("error text wire size", () => { + it("ranks values by escaped UTF-8 bytes, not by code units", () => { + const quotes = { text: '"'.repeat(10_000) }; + const cjk = { text: "\u4e2d".repeat(15_000) }; + const budget = 1_000_000; + // Quotes escape twice in error text (4 bytes each); each CJK character + // is 3 UTF-8 bytes, so the CJK value is larger on the wire. + expect(errorTextWireBytes(cjk, budget)).toBeGreaterThan( + errorTextWireBytes(quotes, budget), + ); + }); + + it("keeps a value over the budget ranked above any value that fits", () => { + const budget = 4096; + const over = errorTextWireBytes({ text: "x".repeat(8192) }, budget); + expect(over).toBeGreaterThan(budget); + expect(over).toBeGreaterThan( + errorTextWireBytes({ text: "x".repeat(2048) }, budget), + ); + }); +}); diff --git a/src/server/toolResultEncoding.ts b/src/server/toolResultEncoding.ts index bec3e967a0..7bd057ff15 100644 --- a/src/server/toolResultEncoding.ts +++ b/src/server/toolResultEncoding.ts @@ -125,3 +125,17 @@ export const encodeToolResult = ( } return { ok: true, text: parts.join(""), bytes }; }; + +/** + * A value's wire size inside an error result's text, measured exactly as the + * encoder counts it (escaped UTF-8), stopping once it exceeds the budget. A + * value over the budget cannot be delivered alone, so its clipped size still + * ranks it above every value that fits. + */ +export const errorTextWireBytes = ( + value: JsonValue, + budgetBytes: number, +): number => { + const encoded = encodeToolResult(value, budgetBytes, "error-text"); + return encoded.ok ? encoded.bytes : encoded.bytesAtLeast; +}; diff --git a/src/wasm/WabtArtifactProvider.ts b/src/wasm/WabtArtifactProvider.ts index 4c2f3ac5cc..574afb2dfd 100644 --- a/src/wasm/WabtArtifactProvider.ts +++ b/src/wasm/WabtArtifactProvider.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../domain/targetIdentity.js"; import { capturedProviderOutput } from "../process/capturedProviderOutput.js"; import { decodeStrictUtf8 } from "../domain/strictUtf8.js"; import { WabtAdmissionError } from "./WabtAdmissionError.js"; @@ -191,7 +192,7 @@ export class WabtArtifactProvider implements WasmArtifactPort { ? undefined : createEvidence( artifact === undefined - ? undefined + ? unknownTarget("not-observed") : { path: artifact.path, format: "file", diff --git a/tests/acceptance/apkZip64FramingCli.test.ts b/tests/acceptance/apkZip64FramingCli.test.ts index ff1895e800..321b92058e 100644 --- a/tests/acceptance/apkZip64FramingCli.test.ts +++ b/tests/acceptance/apkZip64FramingCli.test.ts @@ -44,7 +44,7 @@ const expectUnsignedArchive = async ( const evidence = parseEvidence(value); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256 }, + identity: { sha256 }, }); expect( apkSignatureResultSchema.parse(evidence.normalized_result), diff --git a/tests/acceptance/applications/applicationWorkflowCli.test.ts b/tests/acceptance/applications/applicationWorkflowCli.test.ts index 6b79a53c24..9c1b5bdc01 100644 --- a/tests/acceptance/applications/applicationWorkflowCli.test.ts +++ b/tests/acceptance/applications/applicationWorkflowCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { execFile } from "node:child_process"; import { INLINE_EVIDENCE_MCP_ENVIRONMENT } from "../../../scripts/lib/mcp-verification-environment.mjs"; import { createHash } from "node:crypto"; @@ -1947,10 +1948,9 @@ const runCliWithRequestFile = async ( /** The CLI keeps complete trace JSON; the shared view owner selects from the saved file. */ const assertTraceFileView = async (root: string, traced: unknown) => { const parent = parseEvidence(traced); - if (parent.subject === null) throw new Error("Expected trace subject"); const artifact = { path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, + sha256: fileIdentity(parent.subject).sha256, }; const tracePath = join(root, "trace.json"); await writeFile(tracePath, JSON.stringify(parent)); diff --git a/tests/acceptance/applications/artifactComparisonCoverage.test.ts b/tests/acceptance/applications/artifactComparisonCoverage.test.ts index 7b1693dbd4..7b744f9f2c 100644 --- a/tests/acceptance/applications/artifactComparisonCoverage.test.ts +++ b/tests/acceptance/applications/artifactComparisonCoverage.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { chmod, mkdir, symlink, writeFile } from "node:fs/promises"; import { createServer } from "node:net"; import { join } from "node:path"; @@ -136,7 +140,7 @@ const assertMalformedImportsRejected = async ( const sha256 = "f".repeat(64); const oversized = createEvidence( { - path: right.subject!.local_path, + path: fileSubjectDisplay(right.subject).local_path, sha256: inventory.manifest.root_sha256, format: inventory.manifest.root_format, }, @@ -203,7 +207,7 @@ const assertMalformedImportsRejected = async ( ]) { const malformed = createEvidence( { - path: right.subject!.local_path, + path: fileSubjectDisplay(right.subject).local_path, sha256: inventory.manifest.root_sha256, format: inventory.manifest.root_format, }, @@ -452,7 +456,9 @@ cliTest.skipIf(process.platform === "win32")( const left = inventoryEvidence(result.json); const { call, inspect } = await connectArtifactComparisonMcp(); const right = await inspect(rightPath); - expect(right.subject?.digest.sha256).toBe(left.subject?.digest.sha256); + expect(fileIdentity(right.subject).sha256).toBe( + fileIdentity(left.subject).sha256, + ); const comparison = await call("compare_artifacts", { left, right }); expect(comparison.isError, JSON.stringify(comparison)).not.toBe(true); expect( diff --git a/tests/acceptance/applications/bundleResourceTargetIdentity.test.ts b/tests/acceptance/applications/bundleResourceTargetIdentity.test.ts index f3e885e6ba..a6ef3ca50d 100644 --- a/tests/acceptance/applications/bundleResourceTargetIdentity.test.ts +++ b/tests/acceptance/applications/bundleResourceTargetIdentity.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { mkdir, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -49,7 +50,7 @@ cliTest.for([ const before = await call(operation, parameters); expect(before.isError).not.toBe(true); const initial = parseEvidence(before.structuredContent); - expect(initial.subject?.digest.sha256).toBe( + expect(fileIdentity(initial.subject).sha256).toBe( createHash("sha256").update(original).digest("hex"), ); @@ -77,7 +78,7 @@ cliTest.for([ const after = await call(operation, parameters); expect(after.isError).not.toBe(true); const refreshed = parseEvidence(after.structuredContent); - expect(refreshed.subject?.digest.sha256).toBe( + expect(fileIdentity(refreshed.subject).sha256).toBe( createHash("sha256").update(changed).digest("hex"), ); const nibHash = createHash("sha256").update(changedNib).digest("hex"); diff --git a/tests/acceptance/applications/javascriptSourceSelectionCli.test.ts b/tests/acceptance/applications/javascriptSourceSelectionCli.test.ts index 1c8c9454ea..70185ad0b7 100644 --- a/tests/acceptance/applications/javascriptSourceSelectionCli.test.ts +++ b/tests/acceptance/applications/javascriptSourceSelectionCli.test.ts @@ -250,7 +250,7 @@ cliTest.for([ if (format === "asar") { expect(evidence.subject).toMatchObject({ local_path: target, - digest: { + identity: { sha256: createHash("sha256") .update(await readFile(target)) .digest("hex"), diff --git a/tests/acceptance/applications/peResources.test.ts b/tests/acceptance/applications/peResources.test.ts index 5d0b920352..a4f0c3a698 100644 --- a/tests/acceptance/applications/peResources.test.ts +++ b/tests/acceptance/applications/peResources.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { withCanonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { Client } from "@modelcontextprotocol/client"; import { createHash } from "node:crypto"; @@ -267,10 +268,12 @@ const expectPeInventoriesAcrossAdapters = async ( expect(result.exitCode).toBe(0); const evidence = contract.outputSchema.parse(result.json); const report = peResourcesSchema.parse(evidence.normalized_result); - expect(evidence.subject?.digest).toMatchObject({ + expect(evidence.subject?.identity).toMatchObject({ sha256: createHash("sha256").update(fixture.bytes).digest("hex"), }); - expect(evidence.subject?.architecture).toBe(plus ? "x86_64" : "x86"); + expect(fileIdentity(evidence.subject).architecture).toBe( + plus ? "x86_64" : "x86", + ); expect(report.coverage).toMatchObject({ status: "complete", resources: 5, @@ -406,7 +409,7 @@ const expectPeEmptyBranchesAcrossAdapters = async ( entry_locations: resource.entry_locations.slice(0, 2), }); } - expect(evidence.subject?.digest?.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(fixture.bytes).digest("hex"), ); expect(Buffer.compare(await readFile(path), fixture.bytes)).toBe(0); diff --git a/tests/acceptance/applications/staticObservedEndpoints.test.ts b/tests/acceptance/applications/staticObservedEndpoints.test.ts index ca5c89f33e..aa553a1e3d 100644 --- a/tests/acceptance/applications/staticObservedEndpoints.test.ts +++ b/tests/acceptance/applications/staticObservedEndpoints.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { mkdir, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { createHash } from "node:crypto"; @@ -368,7 +369,7 @@ cliTest( capture.normalized_result, ); const replacement = (parameters: object, result: unknown) => - createEvidence(undefined, capture.provider, { + createEvidence(unknownTarget("not-observed"), capture.provider, { operation: capture.operation, parameters, result, diff --git a/tests/acceptance/artifactAdmittedIdentityMcp.test.ts b/tests/acceptance/artifactAdmittedIdentityMcp.test.ts index 84b59a483e..5631a25e6e 100644 --- a/tests/acceptance/artifactAdmittedIdentityMcp.test.ts +++ b/tests/acceptance/artifactAdmittedIdentityMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; @@ -32,7 +33,7 @@ it("refuses changed admitted archives over stdio MCP before publishing extractio const inspected = await call("inspect_artifact", { detail: "complete" }); expect(inspected.isError, JSON.stringify(inspected)).not.toBe(true); const evidence = parseEvidence(inspected.structuredContent); - expect(evidence.subject?.digest.sha256).toBe(digest); + expect(fileIdentity(evidence.subject).sha256).toBe(digest); const inspection = artifactInspectionResultSchema.parse( evidence.normalized_result, ); diff --git a/tests/acceptance/artifactComparisonHistoricalSummary.test.ts b/tests/acceptance/artifactComparisonHistoricalSummary.test.ts index 0c1a4ee99f..8e6aa148af 100644 --- a/tests/acceptance/artifactComparisonHistoricalSummary.test.ts +++ b/tests/acceptance/artifactComparisonHistoricalSummary.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -52,8 +53,8 @@ it("refuses a historical alias summary with recreate guidance and rejects reseal const alias = join(root, "caller-selected-alias.plist"); const aliasedParent = rebindEvidenceToTargetPath(parent, { path: alias, - sha256: parent.subject!.digest.sha256, - format: parent.subject!.format, + sha256: fileIdentity(parent.subject).sha256, + format: fileIdentity(parent.subject).format, }); expect(aliasedParent.evidence_id).toBe(parent.evidence_id); const projected = await call("inspect_analysis_view", { diff --git a/tests/acceptance/artifactSelectedNameCli.test.ts b/tests/acceptance/artifactSelectedNameCli.test.ts index 496fde4dd5..11e9c5a477 100644 --- a/tests/acceptance/artifactSelectedNameCli.test.ts +++ b/tests/acceptance/artifactSelectedNameCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { readFile, rm, symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { TextReader, Uint8ArrayWriter, ZipWriter } from "@zip.js/zip.js"; @@ -55,7 +56,9 @@ cliTest ], }); expect(projection.exitCode, projection.stdout + projection.stderr).toBe(0); - expect(parseEvidence(projection.json).subject?.format).toBe("apk"); + expect(fileIdentity(parseEvidence(projection.json).subject).format).toBe( + "apk", + ); const extracted = await cli.run({ arguments: ["extract-artifact", selected, "--json"], }); diff --git a/tests/acceptance/cliTokenWindowUnicode.test.ts b/tests/acceptance/cliTokenWindowUnicode.test.ts index 246365745b..82d1526ad4 100644 --- a/tests/acceptance/cliTokenWindowUnicode.test.ts +++ b/tests/acceptance/cliTokenWindowUnicode.test.ts @@ -39,13 +39,13 @@ workspaceCliTest( }, ); - const fullDigest = await run("subject.digest.sha256"); + const fullDigest = await run("subject.identity.sha256"); expect( fullDigest.exitCode, `${fullDigest.stderr}\n${fullDigest.stdout}`, ).toBe(0); const firstPage = await run( - "subject.digest.sha256", + "subject.identity.sha256", "--token-limit", "10", "--token-offset", @@ -63,7 +63,7 @@ workspaceCliTest( offset === 0 ? firstPage : await run( - "subject.digest.sha256", + "subject.identity.sha256", "--token-limit", "10", "--token-offset", diff --git a/tests/acceptance/derivedEvidenceReplay.test.ts b/tests/acceptance/derivedEvidenceReplay.test.ts index 36c71c79cf..f27d7c41ba 100644 --- a/tests/acceptance/derivedEvidenceReplay.test.ts +++ b/tests/acceptance/derivedEvidenceReplay.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -20,7 +21,7 @@ import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js"; const resultEnvelope = z.object({ result: z.unknown() }); const capture = (changed: boolean) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: {}, diff --git a/tests/acceptance/electronFusesCli.test.ts b/tests/acceptance/electronFusesCli.test.ts index 9ca06b37ff..d71155e60f 100644 --- a/tests/acceptance/electronFusesCli.test.ts +++ b/tests/acceptance/electronFusesCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { mkdir, realpath, symlink, writeFile } from "node:fs/promises"; import { dirname, join, parse } from "node:path"; import { createHash } from "node:crypto"; @@ -78,7 +79,7 @@ cliTest.skipIf(process.platform === "win32").for([ expect(evidence.subject?.local_path).toBe( evidence.normalized_result.artifact.resolved_path, ); - expect(evidence.subject?.digest.sha256).toBe(digest); + expect(fileIdentity(evidence.subject).sha256).toBe(digest); expect(evidence.normalized_result.runtime_implications).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -169,10 +170,10 @@ cliTest( "inspect_electron_fuses", ).outputSchema.parse(thinResult.json); expect(thinEvidence.subject?.local_path).toBe(join(root, "thin")); - expect(thinEvidence.subject?.digest.sha256).toBe( + expect(fileIdentity(thinEvidence.subject).sha256).toBe( createHash("sha256").update(thin.bytes).digest("hex"), ); - expect(thinEvidence.subject?.architecture).toBe("arm64"); + expect(fileIdentity(thinEvidence.subject).architecture).toBe("arm64"); expect( thinEvidence.normalized_result.slices[0]?.sentinels[0], ).toMatchObject({ @@ -196,7 +197,7 @@ cliTest( expect(universalEvidence.normalized_result.artifact.format).toBe( "mach-o-universal", ); - expect(universalEvidence.subject?.architecture).toBeNull(); + expect(fileIdentity(universalEvidence.subject).architecture).toBeNull(); expect( universalEvidence.normalized_result.slices.map((slice) => ({ file_offset: slice.file_offset, @@ -245,7 +246,7 @@ cliTest.for([ result.json, ); expect(evidence.normalized_result.artifact.format).toBe(format); - expect(evidence.subject?.architecture).toBe(architecture); + expect(fileIdentity(evidence.subject).architecture).toBe(architecture); expect(evidence.normalized_result.slices).toMatchObject([ { architecture, diff --git a/tests/acceptance/elfNoteCoreProfile.test.ts b/tests/acceptance/elfNoteCoreProfile.test.ts index 6d36d98d48..1dba88a0ad 100644 --- a/tests/acceptance/elfNoteCoreProfile.test.ts +++ b/tests/acceptance/elfNoteCoreProfile.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -46,7 +47,7 @@ cliTest.for([ const schema = toolContract("inspect_elf_notes").outputSchema; for (const raw of [output.json, response.structuredContent]) { const evidence = schema.parse(raw); - expect(evidence.subject?.digest.sha256).toBe(hash); + expect(fileIdentity(evidence.subject).sha256).toBe(hash); const report = evidence.normalized_result; expect(report.coverage).toMatchObject({ status: "complete", diff --git a/tests/acceptance/elfNotesAbiEndian.test.ts b/tests/acceptance/elfNotesAbiEndian.test.ts index c971da4ea2..783461a36a 100644 --- a/tests/acceptance/elfNotesAbiEndian.test.ts +++ b/tests/acceptance/elfNotesAbiEndian.test.ts @@ -64,7 +64,7 @@ for (const { bits, ownership, machine } of [ const evidence = schema.parse(value); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256: descriptorHash(bytes) }, + identity: { sha256: descriptorHash(bytes) }, }); const report = evidence.normalized_result; expect(report).toMatchObject({ diff --git a/tests/acceptance/elfNotesCore.test.ts b/tests/acceptance/elfNotesCore.test.ts index d2c7fadcd5..e92e043251 100644 --- a/tests/acceptance/elfNotesCore.test.ts +++ b/tests/acceptance/elfNotesCore.test.ts @@ -166,7 +166,7 @@ cliTest( const evidence = schema.parse(raw); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256: descriptorHash(bytes) }, + identity: { sha256: descriptorHash(bytes) }, }); const report = evidence.normalized_result; expect(report).toMatchObject({ diff --git a/tests/acceptance/erlangBeamCli.test.ts b/tests/acceptance/erlangBeamCli.test.ts index a2286f6dbe..8ac1ab887c 100644 --- a/tests/acceptance/erlangBeamCli.test.ts +++ b/tests/acceptance/erlangBeamCli.test.ts @@ -78,7 +78,7 @@ cliTest( const evidence = completeBeamEvidenceSchema.parse(result.json); expect(evidence).toMatchObject({ confidence: "observed", - subject: { local_path: path, format: "file" }, + subject: { local_path: path, identity: { format: "file" } }, }); expect(evidence.normalized_result).toMatchObject({ atom_encoding: "utf8", diff --git a/tests/acceptance/flutterAnalysis.test.ts b/tests/acceptance/flutterAnalysis.test.ts index 1c8ea71347..ae4b6f2814 100644 --- a/tests/acceptance/flutterAnalysis.test.ts +++ b/tests/acceptance/flutterAnalysis.test.ts @@ -65,7 +65,7 @@ cliTest( expect(report.libapp.sections).toHaveLength(4); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256: report.target.sha256 }, + identity: { sha256: report.target.sha256 }, }); reports.push({ sections: report.libapp.sections, @@ -135,8 +135,7 @@ cliTest( expect(mcp.subject).toEqual(evidence.subject); expect(mcp.subject).toMatchObject({ local_path: path, - format: "apk", - digest: { sha256: complete.target.sha256 }, + identity: { format: "apk", sha256: complete.target.sha256 }, }); expect(mcp.evidence_id).toBe(evidence.evidence_id); if (name === "inspect_dart_aot") { diff --git a/tests/acceptance/goBinaryCli.test.ts b/tests/acceptance/goBinaryCli.test.ts index 7bbc641e6c..732c0b0e89 100644 --- a/tests/acceptance/goBinaryCli.test.ts +++ b/tests/acceptance/goBinaryCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { goBinarySchema } from "../../src/domain/go/goBinary.js"; import { evidenceResultOf } from "../../src/contracts/toolOutputSchemaPrimitives.js"; import { readFile, writeFile } from "node:fs/promises"; @@ -329,7 +330,7 @@ for (const bits of [32, 64] as const) { }); expect(result.exitCode, result.stderr).toBe(0); const evidence = evidenceResultOf(goBinarySchema).parse(result.json); - expect(evidence.subject?.digest.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(bytes).digest("hex"), ); expect(evidence.normalized_result.build_info).toMatchObject({ @@ -516,7 +517,7 @@ for (const format of ["elf", "pe", "macho"] as const) { const evidence = evidenceResultOf(goBinarySchema).parse(result.json); expect(evidence.raw_result).toBeNull(); expect(evidence.subject?.local_path).toBe(path); - expect(evidence.subject?.digest.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(fixture.bytes).digest("hex"), ); const report = evidence.normalized_result; @@ -587,7 +588,7 @@ cliTest("preserves MIPS identity in Go CLI Evidence", async ({ cli }) => { }); expect(result.exitCode, result.stderr).toBe(0); const evidence = evidenceResultOf(goBinarySchema).parse(result.json); - expect(evidence.subject?.architecture).toBe("mips"); + expect(fileIdentity(evidence.subject).architecture).toBe("mips"); expect(evidence.normalized_result).toMatchObject({ architecture: "mips", bits: 64, diff --git a/tests/acceptance/goBinaryP32PointerCli.test.ts b/tests/acceptance/goBinaryP32PointerCli.test.ts index 632bb35f44..530951b38e 100644 --- a/tests/acceptance/goBinaryP32PointerCli.test.ts +++ b/tests/acceptance/goBinaryP32PointerCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -26,7 +27,7 @@ cliTest( expect(result.exitCode, result.stderr).toBe(0); const evidence = evidenceResultOf(goBinarySchema).parse(result.json); - expect(evidence.subject?.architecture).toBe("x86_64"); + expect(fileIdentity(evidence.subject).architecture).toBe("x86_64"); expect(evidence.normalized_result).toMatchObject({ format: "elf", architecture: "amd64", diff --git a/tests/acceptance/goBinaryPointerMappingsCli.test.ts b/tests/acceptance/goBinaryPointerMappingsCli.test.ts index 92a293e0d2..f70bc7c983 100644 --- a/tests/acceptance/goBinaryPointerMappingsCli.test.ts +++ b/tests/acceptance/goBinaryPointerMappingsCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -51,7 +52,7 @@ cliTest( bytes: fixture.moduleBytes.length, }, }); - expect(evidence.subject?.digest?.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(fixture.bytes).digest("hex"), ); const response = await call("inspect_go_binary", { path }); diff --git a/tests/acceptance/gpuCodeObjectsCli.test.ts b/tests/acceptance/gpuCodeObjectsCli.test.ts index ff8ee7b25c..e260e92731 100644 --- a/tests/acceptance/gpuCodeObjectsCli.test.ts +++ b/tests/acceptance/gpuCodeObjectsCli.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { expect, it } from "vitest"; import { writeFile, unlink } from "node:fs/promises"; import { join } from "node:path"; @@ -1204,11 +1205,15 @@ it("rejects forged duplicate object IDs and mismatched Evidence subjects through ); forgedHeaderReport.objects[1]!.cuda_target_header!.location.container_id = forgedHeaderReport.objects[0]!.id; - const forgedHeader = createEvidence(undefined, parent.provider, { - operation: parent.operation, - parameters: parent.parameters, - result: forgedHeaderReport, - }); + const forgedHeader = createEvidence( + unknownTarget("not-observed"), + parent.provider, + { + operation: parent.operation, + parameters: parent.parameters, + result: forgedHeaderReport, + }, + ); expect( parseMcpToolError( await call("inspect_analysis_view", { @@ -1218,11 +1223,15 @@ it("rejects forged duplicate object IDs and mismatched Evidence subjects through ).error, ).toMatchObject({ code: "invalid_request" }); report.objects[1]!.id = report.objects[0]!.id; - const forged = createEvidence(undefined, parent.provider, { - operation: "inspect_gpu_code_objects", - parameters: parent.parameters, - result: report, - }); + const forged = createEvidence( + unknownTarget("not-observed"), + parent.provider, + { + operation: "inspect_gpu_code_objects", + parameters: parent.parameters, + result: report, + }, + ); const failure = parseMcpToolError( await call("inspect_analysis_view", { source: { kind: "inline", evidence: forged }, diff --git a/tests/acceptance/il2cppMetadataCli.test.ts b/tests/acceptance/il2cppMetadataCli.test.ts index db638a4759..6e9bd053d9 100644 --- a/tests/acceptance/il2cppMetadataCli.test.ts +++ b/tests/acceptance/il2cppMetadataCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { desktopSummarySchema } from "../../src/domain/analysisView/desktopApplicationView.js"; import { createHash } from "node:crypto"; import { @@ -768,7 +769,7 @@ it("imports historical metadata Evidence with unavailable member collections wit const historical = createEvidence( { path, - sha256: original.subject!.digest.sha256, + sha256: fileIdentity(original.subject).sha256, format: "file", }, original.provider, diff --git a/tests/acceptance/inesContainer.test.ts b/tests/acceptance/inesContainer.test.ts index 74e82be581..3f00f81a33 100644 --- a/tests/acceptance/inesContainer.test.ts +++ b/tests/acceptance/inesContainer.test.ts @@ -86,8 +86,7 @@ cliTest( const inventoryFrom = (input: unknown) => { const evidence = parseEvidence(input); expect(evidence.subject).toMatchObject({ - format: "ines", - architecture: null, + identity: { format: "ines", architecture: null }, }); const inspection = artifactInspectionResultSchema.parse( evidence.normalized_result, diff --git a/tests/acceptance/kernelBuildConfigCli.test.ts b/tests/acceptance/kernelBuildConfigCli.test.ts index 1894d3663c..42f943ac2f 100644 --- a/tests/acceptance/kernelBuildConfigCli.test.ts +++ b/tests/acceptance/kernelBuildConfigCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -36,7 +37,7 @@ cliTest( matched_count: 1, entries: [{ name: "CONFIG_SECURITY_SELINUX", kind: "y", value: "y" }], }); - expect(evidence.subject?.format).toBe("elf"); + expect(fileIdentity(evidence.subject).format).toBe("elf"); }, ); diff --git a/tests/acceptance/kernelModuleCli.test.ts b/tests/acceptance/kernelModuleCli.test.ts index 2a66dc9072..6a6dab8e32 100644 --- a/tests/acceptance/kernelModuleCli.test.ts +++ b/tests/acceptance/kernelModuleCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -165,6 +166,6 @@ cliTest( next_probe: { operation: "external_decompression" }, modinfo: null, }); - expect(evidence.subject?.format).toBe("file"); + expect(fileIdentity(evidence.subject).format).toBe("file"); }, ); diff --git a/tests/acceptance/localPathAdmissionCli.test.ts b/tests/acceptance/localPathAdmissionCli.test.ts index 84eb2d83f6..75b983a2d0 100644 --- a/tests/acceptance/localPathAdmissionCli.test.ts +++ b/tests/acceptance/localPathAdmissionCli.test.ts @@ -192,7 +192,7 @@ cliTest( operation: "inspect_python_pyc", subject: { local_path: path, - digest: { sha256: createHash("sha256").update(bytes).digest("hex") }, + identity: { sha256: createHash("sha256").update(bytes).digest("hex") }, }, }); }, diff --git a/tests/acceptance/managedCliOutput.test.ts b/tests/acceptance/managedCliOutput.test.ts index e9193ddcde..1bd68c6bcc 100644 --- a/tests/acceptance/managedCliOutput.test.ts +++ b/tests/acceptance/managedCliOutput.test.ts @@ -107,7 +107,7 @@ cliTest( expect(complete.exitCode, complete.stderr).toBe(0); expect(complete.json).toMatchObject({ subject: { - digest: { sha256: createHash("sha256").update(bytes).digest("hex") }, + identity: { sha256: createHash("sha256").update(bytes).digest("hex") }, }, parameters: { max_snapshot_bytes: bytes.length, diff --git a/tests/acceptance/managedMemberPointers.test.ts b/tests/acceptance/managedMemberPointers.test.ts index 4f5740f99b..ebf9b929b5 100644 --- a/tests/acceptance/managedMemberPointers.test.ts +++ b/tests/acceptance/managedMemberPointers.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -33,8 +34,8 @@ cliTest( expect(mcpEvidence.normalized_result).toEqual( cliEvidence.normalized_result, ); - expect(mcpEvidence.subject?.digest.sha256).toBe(sha256); - expect(cliEvidence.subject?.digest.sha256).toBe(sha256); + expect(fileIdentity(mcpEvidence.subject).sha256).toBe(sha256); + expect(fileIdentity(cliEvidence.subject).sha256).toBe(sha256); expect(mcpEvidence.normalized_result).toMatchObject({ coverage: { state: "complete", issues: [] }, }); diff --git a/tests/acceptance/managedMemberRecovery.test.ts b/tests/acceptance/managedMemberRecovery.test.ts index c183595130..97a536747d 100644 --- a/tests/acceptance/managedMemberRecovery.test.ts +++ b/tests/acceptance/managedMemberRecovery.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../fixtures/canonicalOutputSchema.js"; import { artifactMcpCall } from "../../scripts/lib/artifact-e2e.mjs"; import { createHash } from "node:crypto"; @@ -80,8 +81,8 @@ cliTest( expect(mcpEvidence.normalized_result).toEqual( cliEvidence.normalized_result, ); - expect(mcpEvidence.subject?.digest.sha256).toBe(sha256); - expect(cliEvidence.subject?.digest.sha256).toBe(sha256); + expect(fileIdentity(mcpEvidence.subject).sha256).toBe(sha256); + expect(fileIdentity(cliEvidence.subject).sha256).toBe(sha256); const report = managedMemberInspectionSchema.parse( mcpEvidence.normalized_result, ); diff --git a/tests/acceptance/managedMetadataExtraData.test.ts b/tests/acceptance/managedMetadataExtraData.test.ts index a5c401d448..a4d68ad5d1 100644 --- a/tests/acceptance/managedMetadataExtraData.test.ts +++ b/tests/acceptance/managedMetadataExtraData.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -33,8 +34,8 @@ cliTest( expect(mcpEvidence.normalized_result).toEqual( cliEvidence.normalized_result, ); - expect(mcpEvidence.subject?.digest.sha256).toBe(sha256); - expect(cliEvidence.subject?.digest.sha256).toBe(sha256); + expect(fileIdentity(mcpEvidence.subject).sha256).toBe(sha256); + expect(fileIdentity(cliEvidence.subject).sha256).toBe(sha256); expect(mcpEvidence.normalized_result).toMatchObject({ module: { name: "Fixture.dll", diff --git a/tests/acceptance/modelArtifactCli.test.ts b/tests/acceptance/modelArtifactCli.test.ts index 7f7dff80d9..424c03af5e 100644 --- a/tests/acceptance/modelArtifactCli.test.ts +++ b/tests/acceptance/modelArtifactCli.test.ts @@ -1,3 +1,5 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { readFile, writeFile, unlink } from "node:fs/promises"; import { join } from "node:path"; @@ -638,11 +640,15 @@ it("keeps generated headline keys and imported compound metadata out of compact { key: `${architecture}.context_length`, value: 2048 }, ]); report.metadata[0]!.value = { future: architecture }; - const imported = createEvidence(undefined, full.provider, { - operation: "inspect_model_artifact", - parameters: full.parameters, - result: report, - }); + const imported = createEvidence( + unknownTarget("not-observed"), + full.provider, + { + operation: "inspect_model_artifact", + parameters: full.parameters, + result: report, + }, + ); const page = await call("inspect_analysis_view", { source: { kind: "inline", evidence: imported }, view: { kind: "summary" }, @@ -685,11 +691,15 @@ it("rejects noncanonical imported model indexes and duplicate identities through for (const corrupt of corruptions) { const result = structuredClone(report); corrupt(result); - const evidence = createEvidence(undefined, complete.provider, { - operation: "inspect_model_artifact", - parameters: complete.parameters, - result, - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + complete.provider, + { + operation: "inspect_model_artifact", + parameters: complete.parameters, + result, + }, + ); const failure = parseMcpToolError( await call("inspect_analysis_view", { source: { kind: "inline", evidence }, @@ -928,7 +938,7 @@ cliTest( const report = modelArtifactSchema.parse(evidence.normalized_result); expect(report.format).toBe(format); expect(report.artifact.sha256).toBeNull(); - expect(evidence.subject).toBeNull(); + expect(evidence.subject.identity.kind).toBe("unknown"); const complete = await call("inspect_model_artifact", { path, detail: "complete", @@ -944,7 +954,7 @@ cliTest( }); expect(hashed.isError, JSON.stringify(hashed)).not.toBe(true); expect( - parseEvidence(hashed.structuredContent).subject?.digest.sha256, + fileIdentity(parseEvidence(hashed.structuredContent).subject).sha256, ).toBe(createHash("sha256").update(fixture.bytes).digest("hex")); const summary = await call("inspect_model_artifact", { path }); expect(summary.isError, JSON.stringify(summary)).not.toBe(true); diff --git a/tests/acceptance/nativeElfArchitecture.test.ts b/tests/acceptance/nativeElfArchitecture.test.ts index e9fa56b141..b0aa12ad8d 100644 --- a/tests/acceptance/nativeElfArchitecture.test.ts +++ b/tests/acceptance/nativeElfArchitecture.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { goBinarySchema } from "../../src/domain/go/goBinary.js"; import { rustBinarySchema } from "../../src/domain/rust/rustBinary.js"; import { expect } from "vitest"; @@ -51,7 +52,9 @@ cliTest( ? goBinarySchema.parse(cliEvidence.normalized_result) : rustBinarySchema.parse(cliEvidence.normalized_result); expect(cliReport.architecture).toBe(item.architecture); - expect(cliEvidence.subject?.architecture).toBe(item.subject); + expect(fileIdentity(cliEvidence.subject).architecture).toBe( + item.subject, + ); const mcpResponse = await call(operation, { path }); expect(mcpResponse.isError, JSON.stringify(mcpResponse)).not.toBe(true); @@ -63,7 +66,9 @@ cliTest( ? goBinarySchema.parse(mcpEvidence.normalized_result) : rustBinarySchema.parse(mcpEvidence.normalized_result); expect(mcpReport.architecture).toBe(item.architecture); - expect(mcpEvidence.subject?.architecture).toBe(item.subject); + expect(fileIdentity(mcpEvidence.subject).architecture).toBe( + item.subject, + ); } const malformed = diff --git a/tests/acceptance/peCertificatesCli.test.ts b/tests/acceptance/peCertificatesCli.test.ts index e4aa45f812..e1b86d6ca1 100644 --- a/tests/acceptance/peCertificatesCli.test.ts +++ b/tests/acceptance/peCertificatesCli.test.ts @@ -273,7 +273,10 @@ cliTest( ); expect(evidence).toMatchObject({ confidence: "observed", - subject: { local_path: path, format: "pe", architecture: "x86" }, + subject: { + local_path: path, + identity: { format: "pe", architecture: "x86" }, + }, normalized_result: { artifact: { path, diff --git a/tests/acceptance/peImportsCli.test.ts b/tests/acceptance/peImportsCli.test.ts index a26015719a..423b5f7d1d 100644 --- a/tests/acceptance/peImportsCli.test.ts +++ b/tests/acceptance/peImportsCli.test.ts @@ -192,9 +192,11 @@ cliTest( confidence: "observed", subject: { local_path: path, - format: "pe", - architecture: "x86_64", - digest: { sha256: createHash("sha256").update(bytes).digest("hex") }, + identity: { + format: "pe", + architecture: "x86_64", + sha256: createHash("sha256").update(bytes).digest("hex"), + }, }, normalized_result: { artifact: { path, bytes: bytes.length }, diff --git a/tests/acceptance/retainedComparisonAggregation.test.ts b/tests/acceptance/retainedComparisonAggregation.test.ts index 35b6181467..5b3baf3b60 100644 --- a/tests/acceptance/retainedComparisonAggregation.test.ts +++ b/tests/acceptance/retainedComparisonAggregation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -92,16 +93,23 @@ it.each(["compact"] as const)( async (profile) => { // Distinct authenticated observations may have identical derived contents. const comparisons = Array.from({ length: 12 }, (_, observation) => - createEvidence(undefined, FUNCTION_COMPARISON_EVIDENCE.provider, { - operation: "compare_functions", - predicateType: "rea.function-comparison", - parameters: { ...FUNCTION_COMPARISON_EVIDENCE.parameters, observation }, - result: FUNCTION_COMPARISON_EVIDENCE.normalized_result, - confidence: "derived", - authority: "analyst-inference", - limitations: FUNCTION_COMPARISON_EVIDENCE.limitations, - evidenceLinks: FUNCTION_COMPARISON_EVIDENCE.evidence_links, - }), + createEvidence( + unknownTarget("derived-from-linked-evidence"), + FUNCTION_COMPARISON_EVIDENCE.provider, + { + operation: "compare_functions", + predicateType: "rea.function-comparison", + parameters: { + ...FUNCTION_COMPARISON_EVIDENCE.parameters, + observation, + }, + result: FUNCTION_COMPARISON_EVIDENCE.normalized_result, + confidence: "derived", + authority: "analyst-inference", + limitations: FUNCTION_COMPARISON_EVIDENCE.limitations, + evidenceLinks: FUNCTION_COMPARISON_EVIDENCE.evidence_links, + }, + ), ); const directory = await createTestTempDirectory( "rea-retained-comparisons-", diff --git a/tests/acceptance/rizinCommandOutcomes.test.ts b/tests/acceptance/rizinCommandOutcomes.test.ts index 180e2ab161..acab8dcbe1 100644 --- a/tests/acceptance/rizinCommandOutcomes.test.ts +++ b/tests/acceptance/rizinCommandOutcomes.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { chmod, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -80,7 +81,7 @@ cliTest.skipIf(process.platform === "win32").for(outcomes)( artifact_changed: false, }); expect(evidence.raw_result).toEqual(evidence.normalized_result); - expect(evidence.subject?.digest.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(content).digest("hex"), ); expect(evidence.parameters.command).toBe(outcome.command); diff --git a/tests/acceptance/rustBinaryCli.test.ts b/tests/acceptance/rustBinaryCli.test.ts index f9f22e94ca..b2da13e9af 100644 --- a/tests/acceptance/rustBinaryCli.test.ts +++ b/tests/acceptance/rustBinaryCli.test.ts @@ -333,8 +333,7 @@ cliTest( result.json, ); expect(evidence.subject).toMatchObject({ - format: "mach-o", - architecture: "arm64_32", + identity: { format: "mach-o", architecture: "arm64_32" }, }); expect(rustBinarySchema.parse(evidence.normalized_result)).toMatchObject({ architecture: "arm64_32", diff --git a/tests/acceptance/rustDependencyViews.test.ts b/tests/acceptance/rustDependencyViews.test.ts index a5f68bda09..46ef80a876 100644 --- a/tests/acceptance/rustDependencyViews.test.ts +++ b/tests/acceptance/rustDependencyViews.test.ts @@ -1,3 +1,4 @@ +import { fileSubjectArchitecture } from "../fixtures/evidenceSubject.js"; import { readFile, unlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -281,16 +282,12 @@ cliTest( await assertRetainedPages(call, full.evidence_id, exported); const malformed = structuredClone(report); malformed.auditable_metadata!.dependency_edges[0]!.to_index = 999; - if (full.subject == null) - throw new Error("Missing complete Rust subject"); const invalid = createEvidence( { path, sha256: report.artifact.sha256, format: format === "macho" ? "mach-o" : format, - ...(full.subject.architecture === null - ? {} - : { architecture: full.subject.architecture }), + ...fileSubjectArchitecture(full.subject), }, full.provider, { @@ -332,16 +329,12 @@ cliTest( const report = rustBinarySchema.parse(full.normalized_result); const metadata = report.auditable_metadata; if (metadata === null) throw new Error("Expected Rust dependency metadata"); - if (full.subject == null) - throw new Error("Expected Rust artifact identity"); const historical = createEvidence( { path, sha256: report.artifact.sha256, format: "elf", - ...(full.subject.architecture === null - ? {} - : { architecture: full.subject.architecture }), + ...fileSubjectArchitecture(full.subject), }, full.provider, { diff --git a/tests/acceptance/sqliteDatabaseCli.test.ts b/tests/acceptance/sqliteDatabaseCli.test.ts index 0e7a0b1834..e1e0ae0ea2 100644 --- a/tests/acceptance/sqliteDatabaseCli.test.ts +++ b/tests/acceptance/sqliteDatabaseCli.test.ts @@ -784,7 +784,7 @@ cliTest expect(result.json).toMatchObject({ operation: "inspect_sqlite_database", confidence: "observed", - subject: { local_path: path, digest: { sha256: digest(original) } }, + subject: { local_path: path, identity: { sha256: digest(original) } }, normalized_result: { artifact: { path, sha256: digest(original), bytes: original.length }, wal: null, @@ -1167,7 +1167,7 @@ cliTest.runIf(SQLITE_NATIVE_LIMITS_AVAILABLE)( schema_scope: "database", }); const expectedSchema = { - subject: { local_path: path, digest: { sha256: digest(before.bytes) } }, + subject: { local_path: path, identity: { sha256: digest(before.bytes) } }, normalized_result: { rows: null, schema: { diff --git a/tests/acceptance/tools/localToolContracts.test.ts b/tests/acceptance/tools/localToolContracts.test.ts index 2eec0250cf..ef8c9a5ac8 100644 --- a/tests/acceptance/tools/localToolContracts.test.ts +++ b/tests/acceptance/tools/localToolContracts.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { execFile } from "node:child_process"; import { access, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -46,7 +47,7 @@ it("keeps overall replay verification unknown when capture divergence is unknown readonly exitCode?: number; } = {}, ) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, diff --git a/tests/acceptance/tools/nativeFunctionMatching.test.ts b/tests/acceptance/tools/nativeFunctionMatching.test.ts index 995722cc39..7c29e438d9 100644 --- a/tests/acceptance/tools/nativeFunctionMatching.test.ts +++ b/tests/acceptance/tools/nativeFunctionMatching.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -25,22 +26,34 @@ import { nativeFunctionMatchingSchema } from "../../../src/domain/native/functio const createMatchingFixture = async () => { const root = await createTestTempDirectory("rea-native-matching-"); - const ancestor = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_provenance", - parameters: {}, - result: { source: "Synthetic ancestor" }, - }); - const unrelated = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_unrelated", - parameters: {}, - result: { source: "Unselected synthetic record" }, - }); - const dependency = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_dependency", - parameters: {}, - result: { source: "Synthetic dependency" }, - evidenceLinks: [ancestor.evidence_id], - }); + const ancestor = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_provenance", + parameters: {}, + result: { source: "Synthetic ancestor" }, + }, + ); + const unrelated = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_unrelated", + parameters: {}, + result: { source: "Unselected synthetic record" }, + }, + ); + const dependency = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_dependency", + parameters: {}, + result: { source: "Synthetic dependency" }, + evidenceLinks: [ancestor.evidence_id], + }, + ); const left = nativeMatchingInventory( "1", [ diff --git a/tests/acceptance/tools/reconstructionScopedUnknowns.test.ts b/tests/acceptance/tools/reconstructionScopedUnknowns.test.ts index e0a4426a02..613c2c46ac 100644 --- a/tests/acceptance/tools/reconstructionScopedUnknowns.test.ts +++ b/tests/acceptance/tools/reconstructionScopedUnknowns.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { evidenceBundleSchema } from "../../../src/domain/evidenceBundle.js"; import { expect, it } from "vitest"; @@ -16,9 +20,9 @@ const unchangedLeft = () => { const fixture = FUNCTION_COMPARISON_EXAMPLE.left; return createEvidence( { - path: fixture.subject!.local_path, - sha256: fixture.subject!.digest.sha256, - format: fixture.subject!.format, + path: fileSubjectDisplay(fixture.subject).local_path, + sha256: fileIdentity(fixture.subject).sha256, + format: fileIdentity(fixture.subject).format, }, fixture.provider, { diff --git a/tests/acceptance/tools/unavailableNativeCollectionViews.test.ts b/tests/acceptance/tools/unavailableNativeCollectionViews.test.ts index c44d47d826..c928071e76 100644 --- a/tests/acceptance/tools/unavailableNativeCollectionViews.test.ts +++ b/tests/acceptance/tools/unavailableNativeCollectionViews.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -21,7 +22,7 @@ cliTest( version: "1", }; const load = (result: unknown) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_native_load_image", parameters: {}, result, @@ -39,12 +40,12 @@ cliTest( limitations: [], }); const raw = load(nativeRawLoadImageFixture()); - const primitive = createEvidence(undefined, provider, { + const primitive = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_callees", parameters: {}, result: [], }); - const graph = createEvidence(undefined, provider, { + const graph = createEvidence(unknownTarget("not-observed"), provider, { operation: "get_call_graph", parameters: {}, result: { graph: {}, limitations: [] }, diff --git a/tests/boundary/browser/historicalWebCapture.test.ts b/tests/boundary/browser/historicalWebCapture.test.ts index 61dc4d3ce9..66e02156a3 100644 --- a/tests/boundary/browser/historicalWebCapture.test.ts +++ b/tests/boundary/browser/historicalWebCapture.test.ts @@ -300,7 +300,7 @@ it("reads actual upstream HAR packages in an owned process and retains selected const called = await cli(path, "har", ["--record", "1", "--record", "0"]); expect(called.ok, called.stdout).toBe(true); const result = { value: parseEvidence(JSON.parse(called.stdout)) }; - expect(result.value.subject?.digest).toMatchObject({ + expect(result.value.subject?.identity).toMatchObject({ sha256: createHash("sha256").update(text).digest("hex"), }); expect(result.value.normalized_result).toMatchObject({ diff --git a/tests/boundary/cli/analysisViewCli.test.ts b/tests/boundary/cli/analysisViewCli.test.ts index 5ef2188780..7af30119ce 100644 --- a/tests/boundary/cli/analysisViewCli.test.ts +++ b/tests/boundary/cli/analysisViewCli.test.ts @@ -1,3 +1,8 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { apiSurfaceHar, environmentManifestHar, @@ -130,7 +135,7 @@ cliTest( const path = join(root, "bundle.json"); const body = "int main(void) { return 0; }"; const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "batch_decompile", @@ -526,7 +531,10 @@ cliTest( parent_evidence_id: parent.evidence_id, kind: "inventory", source_complete: true, - artifact: { path: archive, sha256: parent.subject?.digest.sha256 }, + artifact: { + path: archive, + sha256: fileIdentity(parent.subject).sha256, + }, items: [expect.objectContaining({ logical_path: "main.js" })], coverage: { total: 1, exhausted: true, next_offset: null }, }, @@ -554,12 +562,12 @@ cliTest( ).substeps[0]!.evidence; const path = join(root, "view.json"); const reseal = (carrier: Evidence, result: JsonValue) => { - const subject = carrier.subject!; + const subject = carrier.subject; return createEvidence( { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + path: fileSubjectDisplay(subject).local_path, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, carrier.provider, { operation: carrier.operation, parameters: {}, result }, @@ -813,7 +821,7 @@ cliTest( const path = join(root, "partial.json"); const absent = analysisViewLayoutEvidence(); const linked = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "trace_feature", @@ -1248,7 +1256,7 @@ cliTest( }); expect(capture.exitCode, capture.stdout).toBe(0); const parent = parseEvidence(capture.json); - expect(parent.subject?.digest.sha256).toBe( + expect(fileIdentity(parent.subject).sha256).toBe( createHash("sha256").update(bytes).digest("hex"), ); expect(JSON.stringify(parent)).not.toContain("password"); @@ -1557,7 +1565,10 @@ cliTest( name: "grafana-example", templated_groups: 6, coverage: { total: 22, exhausted: true }, - artifact: { path: capturePath, sha256: parent.subject?.digest.sha256 }, + artifact: { + path: capturePath, + sha256: fileIdentity(parent.subject).sha256, + }, records: expect.arrayContaining([ { ordinal: 3, diff --git a/tests/boundary/cli/artifactCallerSelection.test.ts b/tests/boundary/cli/artifactCallerSelection.test.ts index 73d774fc75..f75f16de94 100644 --- a/tests/boundary/cli/artifactCallerSelection.test.ts +++ b/tests/boundary/cli/artifactCallerSelection.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { artifactInspectionResultSchema } from "../../../src/domain/artifactInspection.js"; import { readFile, symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -30,7 +31,9 @@ cliTest.skipIf(process.platform === "win32")( expect(observed.parameters).toMatchObject({ input_path: alias }); expect(observed.subject?.local_path).toBe(join(root, alias)); expect(direct.subject?.local_path).toBe(target); - expect(observed.subject?.digest.sha256).toBe(direct.subject?.digest.sha256); + expect(fileIdentity(observed.subject).sha256).toBe( + fileIdentity(direct.subject).sha256, + ); const selectedInspection = artifactInspectionResultSchema.parse( observed.normalized_result, ); diff --git a/tests/boundary/cli/artifactZstandardWindow.test.ts b/tests/boundary/cli/artifactZstandardWindow.test.ts index ed2433c0d9..bde4a60299 100644 --- a/tests/boundary/cli/artifactZstandardWindow.test.ts +++ b/tests/boundary/cli/artifactZstandardWindow.test.ts @@ -71,7 +71,7 @@ cliTest.for(["small", "large", "corrupt"] as const)( expect.arrayContaining([ expect.objectContaining({ subject: expect.objectContaining({ - digest: expect.objectContaining({ sha256 }), + identity: expect.objectContaining({ sha256 }), }), }), ]), diff --git a/tests/boundary/cli/bundleComparisonCli.test.ts b/tests/boundary/cli/bundleComparisonCli.test.ts index 72dfa6cf80..accfc78e6c 100644 --- a/tests/boundary/cli/bundleComparisonCli.test.ts +++ b/tests/boundary/cli/bundleComparisonCli.test.ts @@ -1,3 +1,4 @@ +import { displayedEvidenceSubject } from "../../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -54,11 +55,10 @@ cliTest( records: [ { ...record, - subject: { - ...record.subject!, + subject: displayedEvidenceSubject(record.subject, { name: "renamed.elf", local_path: join(root, "renamed.elf"), - }, + }), }, ], }; diff --git a/tests/boundary/cli/callerPathSymlinkParentCli.test.ts b/tests/boundary/cli/callerPathSymlinkParentCli.test.ts index f1ad000572..843818ceb0 100644 --- a/tests/boundary/cli/callerPathSymlinkParentCli.test.ts +++ b/tests/boundary/cli/callerPathSymlinkParentCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { mkdir, symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -41,9 +42,10 @@ describe.skipIf(process.platform === "win32")( const evidence = toolContract(operation).outputSchema.parse( result.json, ); - expect(evidence.subject?.digest.sha256, `${command} ${path}`).toBe( - selectedDigest, - ); + expect( + fileIdentity(evidence.subject).sha256, + `${command} ${path}`, + ).toBe(selectedDigest); } }, ); @@ -80,7 +82,9 @@ describe.skipIf(process.platform === "win32")( const evidence = toolContract( "inspect_pe_resources", ).outputSchema.parse(result.json); - expect(evidence.subject?.digest.sha256, path).toBe(selectedDigest); + expect(fileIdentity(evidence.subject).sha256, path).toBe( + selectedDigest, + ); } }, ); diff --git a/tests/boundary/cli/captureCleanup.test.ts b/tests/boundary/cli/captureCleanup.test.ts index 40013d6a15..1e28f280e2 100644 --- a/tests/boundary/cli/captureCleanup.test.ts +++ b/tests/boundary/cli/captureCleanup.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Cli } from "incur"; import { expect, it } from "vitest"; import { registerCaptureCommands } from "../../../src/cli/captureCommands.js"; @@ -11,7 +12,7 @@ it.each([false, true])( "awaits cleanup retry and preserves completed output when retry failure is %s", async (failAgain) => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Completed capture fixture", version: "1" }, { operation: "inspect_packet_capture", diff --git a/tests/boundary/cli/commandEvidenceDelivery.test.ts b/tests/boundary/cli/commandEvidenceDelivery.test.ts index 839ad3720f..2a24b87c0d 100644 --- a/tests/boundary/cli/commandEvidenceDelivery.test.ts +++ b/tests/boundary/cli/commandEvidenceDelivery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { closeVerifierResources } from "../../../scripts/lib/verifier-cleanup.mjs"; import { Cli, z } from "incur"; import pino from "pino"; @@ -49,7 +50,7 @@ const fixture = async (kind: (typeof kinds)[number]) => { output_truncated: false, }; const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gdb", name: "GDB", version: null }, { operation: "gdb_console", @@ -172,8 +173,8 @@ it.each(kinds)( expect(f.closeService).toHaveBeenCalledOnce(); } if (kind !== "objdump") { - expect(parent.subject).toBeNull(); - expect(selected.subject).toBeNull(); + expect(parent.subject.identity.kind).toBe("unknown"); + expect(selected.subject.identity.kind).toBe("unknown"); expect(selected.normalized_result).toMatchObject({ artifact: null }); } }, diff --git a/tests/boundary/cli/electronFuseCleanupCli.test.ts b/tests/boundary/cli/electronFuseCleanupCli.test.ts index dd48c95a97..d5be25757e 100644 --- a/tests/boundary/cli/electronFuseCleanupCli.test.ts +++ b/tests/boundary/cli/electronFuseCleanupCli.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { jsonObjectSchema } from "../../../src/domain/jsonValue.js"; import { readFile, writeFile } from "node:fs/promises"; import { join, resolve } from "node:path"; @@ -55,9 +56,11 @@ cliTest.for([ if (mode === "normal") { expect(result.exitCode, result.stderr).toBe(0); expect( - toolContract("inspect_electron_fuses").outputSchema.parse( - JSON.parse(result.stdout), - ).subject?.architecture, + fileIdentity( + toolContract("inspect_electron_fuses").outputSchema.parse( + JSON.parse(result.stdout), + ).subject, + ).architecture, ).toBe("arm64"); } else { expect(result.exitCode, result.stderr).toBe(1); @@ -87,7 +90,7 @@ cliTest.for([ } if (mode === "close-once") expect(parseEvidence(details.partial_observation)).toMatchObject({ - subject: { local_path: path, architecture: "arm64" }, + subject: { local_path: path, identity: { architecture: "arm64" } }, normalized_result: { slices: [{ sentinel_count: 1 }] }, }); } diff --git a/tests/boundary/cli/evidenceBundleCommands.test.ts b/tests/boundary/cli/evidenceBundleCommands.test.ts index 9bc15bc446..0bdef52f1d 100644 --- a/tests/boundary/cli/evidenceBundleCommands.test.ts +++ b/tests/boundary/cli/evidenceBundleCommands.test.ts @@ -1,4 +1,8 @@ -import { EVIDENCE_FORMAT_REVISION } from "../../../src/domain/evidenceFormat.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; +import { + EVIDENCE_FORMAT_REVISION, + RECREATE_EVIDENCE_GUIDANCE, +} from "../../../src/domain/evidenceFormat.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { PRE_66_NULL_COVERAGE_EVIDENCE } from "../../../src/domain/evidenceLegacy.fixture.js"; import { @@ -28,7 +32,7 @@ import { cliTest } from "../../support/cli/cliFixture.js"; const revisionBundle = () => { const records = ["open", "investigate"].map((operation) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation, parameters: {}, result: { observed: operation } }, ), @@ -408,7 +412,7 @@ cliTest( JSON.parse('{"__proto__":{"answer":7},"normal":{"answer":7}}'), ); const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", parameters: {}, result }, ); @@ -451,7 +455,7 @@ cliTest( literal: "©
", }; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", @@ -482,13 +486,13 @@ cliTest( ); cliTest( - "diagnoses an obsolete explicit-null Evidence commitment", + "refuses an earlier-format record inside a current bundle", async ({ cli }) => { const root = await createTestTempDirectory("rea-legacy-coverage-identity-"); const path = join(root, "legacy.json"); const record = PRE_66_NULL_COVERAGE_EVIDENCE; - // A current-format bundle carrying the earlier record reaches the - // record-level identity diagnosis; an unmarked one is refused earlier. + // A current-format bundle carrying an earlier record is refused by the + // record's own format marker, before its ID is checked. const bundle = { evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: [], @@ -507,9 +511,7 @@ cliTest( expect(imported.json).toMatchObject({ code: "evidence_integrity_mismatch", retryable: false, - message: expect.stringContaining( - "earlier relationship_coverage identity commitment", - ), + message: expect.stringContaining(RECREATE_EVIDENCE_GUIDANCE), }); const call = await cli.sharedMcpCall?.(); if (call === undefined) throw new Error("Expected shared MCP session"); @@ -519,9 +521,7 @@ cliTest( error: { code: "evidence_integrity_mismatch", retryable: false, - message: expect.stringContaining( - "earlier relationship_coverage identity commitment", - ), + message: expect.stringContaining(RECREATE_EVIDENCE_GUIDANCE), }, }); }, diff --git a/tests/boundary/cli/foreignUniversalMachoCli.test.ts b/tests/boundary/cli/foreignUniversalMachoCli.test.ts index 116f4aa7d5..3c6248e1c4 100644 --- a/tests/boundary/cli/foreignUniversalMachoCli.test.ts +++ b/tests/boundary/cli/foreignUniversalMachoCli.test.ts @@ -49,11 +49,11 @@ cliTest.skipIf(process.platform !== "darwin")( expect(result.exitCode, result.stderr).toBe(0); const evidence = z .object({ - subject: z.object({ format: z.string() }), + subject: z.object({ identity: z.object({ format: z.string() }) }), normalized_result: listArchitecturesSchema, }) .parse(result.json); - expect(evidence.subject.format).toBe("mach-o-universal"); + expect(evidence.subject.identity.format).toBe("mach-o-universal"); expect(evidence.normalized_result.architectures).toMatchObject({ total: 1, exhaustive: true, diff --git a/tests/boundary/cli/fridaStatusViewCli.test.ts b/tests/boundary/cli/fridaStatusViewCli.test.ts index 501367d585..113a5b5639 100644 --- a/tests/boundary/cli/fridaStatusViewCli.test.ts +++ b/tests/boundary/cli/fridaStatusViewCli.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -11,7 +12,7 @@ cliTest( async ({ cli }) => { const id = "00000000-0000-4000-8000-000000000001"; const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "frida", name: "Frida", version: null }, { operation: "frida_session_status", diff --git a/tests/boundary/cli/inlineEvidenceBundleKind.test.ts b/tests/boundary/cli/inlineEvidenceBundleKind.test.ts index 1c996881d0..304f92b8d7 100644 --- a/tests/boundary/cli/inlineEvidenceBundleKind.test.ts +++ b/tests/boundary/cli/inlineEvidenceBundleKind.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -13,7 +14,7 @@ cliTest( "inline reconstruction distinguishes an authenticated record from a corrupt bundle", async ({ cli }) => { const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", diff --git a/tests/boundary/cli/jsonInputSchema.test.ts b/tests/boundary/cli/jsonInputSchema.test.ts index 4429040919..76e899975b 100644 --- a/tests/boundary/cli/jsonInputSchema.test.ts +++ b/tests/boundary/cli/jsonInputSchema.test.ts @@ -1,3 +1,4 @@ +import { EVIDENCE_FORMAT_REVISION } from "../../../src/domain/evidenceFormat.js"; import { beforeAll, expect, it } from "vitest"; import { Ajv2020 } from "ajv/dist/2020.js"; import type { AnySchema } from "ajv"; @@ -340,7 +341,7 @@ it("validates representative parsed documents with the advertised schema", async validateFormats: false, }).compile(input.contentSchema as AnySchema); const evidence_bundle = { - evidence_format: 1, + evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: [], providers: [], environments: [], diff --git a/tests/boundary/cli/managedMemberListOrdering.test.ts b/tests/boundary/cli/managedMemberListOrdering.test.ts index e39480a945..43e553dc20 100644 --- a/tests/boundary/cli/managedMemberListOrdering.test.ts +++ b/tests/boundary/cli/managedMemberListOrdering.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -41,7 +42,7 @@ cliTest.for(["decreasing", "ordered"] as const)( ); if (parent === undefined) throw new Error("Missing complete member Evidence"); - expect(parent.subject?.digest.sha256).toBe(sha256); + expect(fileIdentity(parent.subject).sha256).toBe(sha256); const report = managedMemberInspectionSchema.parse( parent.normalized_result, ); diff --git a/tests/boundary/cli/managedNativeVerificationLargeInventory.test.ts b/tests/boundary/cli/managedNativeVerificationLargeInventory.test.ts index 5f499922b5..e2fad6947e 100644 --- a/tests/boundary/cli/managedNativeVerificationLargeInventory.test.ts +++ b/tests/boundary/cli/managedNativeVerificationLargeInventory.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -22,7 +26,7 @@ const EXPORTS = 130_000; /** Recreate the example's Mach-O Evidence with `count` exports, keeping its matching first row. */ const machoExports = (count: number): Evidence => { const [source] = MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations; - if (source?.subject == null) throw new Error("Missing native example"); + if (source === undefined) throw new Error("Missing native example"); const result = inspectMachoSchema.parse(source.normalized_result); const [match] = result.exports.items; if (match === undefined) throw new Error("Missing matching export"); @@ -38,9 +42,9 @@ const machoExports = (count: number): Evidence => { }); return createEvidence( { - path: source.subject.local_path, - sha256: source.subject.digest.sha256, - format: source.subject.format, + path: fileSubjectDisplay(source.subject).local_path, + sha256: fileIdentity(source.subject).sha256, + format: fileIdentity(source.subject).format, }, source.provider, { diff --git a/tests/boundary/cli/markdownLiteralCells.test.ts b/tests/boundary/cli/markdownLiteralCells.test.ts index 1c37a8052a..197e73430c 100644 --- a/tests/boundary/cli/markdownLiteralCells.test.ts +++ b/tests/boundary/cli/markdownLiteralCells.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -130,7 +131,7 @@ cliTest( }; const result = { scalar: { [literal]: literal }, rows: [row] }; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", parameters: {}, result }, ); @@ -191,7 +192,7 @@ cliTest( const path = join(root, "bundle.json"); const literal = `left${"\u00a0\u202f\u2003".repeat(80_000)}right`; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", @@ -265,7 +266,7 @@ cliTest( after: "still visible", }; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", parameters: {}, result }, ); @@ -386,7 +387,7 @@ cliTest( nested: { value: 1 }, }; const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "ordinary-json", parameters: {}, result }, ); diff --git a/tests/boundary/cli/nativeEfficiencyComparison.test.ts b/tests/boundary/cli/nativeEfficiencyComparison.test.ts index 227b84fbf8..0868dacf85 100644 --- a/tests/boundary/cli/nativeEfficiencyComparison.test.ts +++ b/tests/boundary/cli/nativeEfficiencyComparison.test.ts @@ -28,7 +28,7 @@ const build=async digit=>{ if(name==='open_binary'||name==='close_binary')return {}; if(name==='inspect_native_load_image')return {evidence_id:'ev_'+digit.repeat(63)+'6',normalized_result:{status:'verified',target_sha256:stale?'f'.repeat(64):sha,entry:{linear_address:'0x1000'}}}; if(name==='resolve_containing_procedure')return {evidence_id:'ev_'+digit.repeat(63)+'7',normalized_result:{found:true}}; - if(name==='analyze_function')return {evidence_id:parent,subject:{digest:{sha256:sha}},normalized_result:dossier}; + if(name==='analyze_function')return {evidence_id:parent,subject:{identity:{sha256:sha}},normalized_result:dossier}; const id='ev_'+digit.repeat(63)+(collision==='containing-collision'?7:collision==='load-collision'?6:duplicate?1:++ordinal); if(args.view.kind==='summary')return {evidence_id:id}; const facet=args.view.facet; diff --git a/tests/boundary/cli/nativeFeatureTraceDelivery.test.ts b/tests/boundary/cli/nativeFeatureTraceDelivery.test.ts index a340e48f6a..0f7316eea6 100644 --- a/tests/boundary/cli/nativeFeatureTraceDelivery.test.ts +++ b/tests/boundary/cli/nativeFeatureTraceDelivery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { Cli } from "incur"; @@ -87,7 +88,7 @@ it.each([ const snapshot = join(root, "snapshot.json"); let allowProvider = true; await writeFile(path, "synthetic analysis database"); - const history = createEvidence(undefined, identity, { + const history = createEvidence(unknownTarget("not-observed"), identity, { operation: "health", parameters: { facet: "historical-project-analysis-reports" }, result: { origin: "caller-project" }, diff --git a/tests/boundary/cli/nativeMachoArm64_32Cli.test.ts b/tests/boundary/cli/nativeMachoArm64_32Cli.test.ts index 71a03e2de3..f45e04e474 100644 --- a/tests/boundary/cli/nativeMachoArm64_32Cli.test.ts +++ b/tests/boundary/cli/nativeMachoArm64_32Cli.test.ts @@ -14,7 +14,9 @@ const environment = { } as const; const resultSchema = z.object({ - subject: z.object({ format: z.string(), architecture: z.string() }), + subject: z.object({ + identity: z.object({ format: z.string(), architecture: z.string() }), + }), normalized_result: z.record(z.string(), z.unknown()), }); @@ -53,8 +55,7 @@ describe.skipIf(process.platform !== "darwin")( expect(result.exitCode, `${command}: ${result.stdout}`).toBe(0); const parsed = resultSchema.parse(result.json); expect(parsed.subject).toMatchObject({ - format: "mach-o", - architecture: "arm64_32", + identity: { format: "mach-o", architecture: "arm64_32" }, }); if (command === "list-architectures") expect( diff --git a/tests/boundary/cli/nativeMachoDylibIdentityCli.test.ts b/tests/boundary/cli/nativeMachoDylibIdentityCli.test.ts index 8c55433dd6..973aac8a08 100644 --- a/tests/boundary/cli/nativeMachoDylibIdentityCli.test.ts +++ b/tests/boundary/cli/nativeMachoDylibIdentityCli.test.ts @@ -66,7 +66,7 @@ describe.skipIf(process.platform !== "darwin")( expect(fat.format).toBe("mach-o-universal"); expect(fat.architectures.items).toHaveLength(1); expect(fatResult.json).toMatchObject({ - subject: { format: fat.format }, + subject: { identity: { format: fat.format } }, }); expect(inspected.format).toBe("mach-o"); }, diff --git a/tests/boundary/cli/procedureReferencesDelivery.test.ts b/tests/boundary/cli/procedureReferencesDelivery.test.ts index 28ee251d66..64306a32c5 100644 --- a/tests/boundary/cli/procedureReferencesDelivery.test.ts +++ b/tests/boundary/cli/procedureReferencesDelivery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { Cli } from "incur"; @@ -49,7 +50,7 @@ it.each([false, true])( const path = join(root, "fixture.hop"), output = join(root, "evidence.json"); await writeFile(path, "synthetic analysis database"); - const history = createEvidence(undefined, identity, { + const history = createEvidence(unknownTarget("not-observed"), identity, { operation: "health", parameters: {}, result: "project history", diff --git a/tests/boundary/cli/reconstructionObligationLedgerCli.test.ts b/tests/boundary/cli/reconstructionObligationLedgerCli.test.ts index 09636fefa8..ba1d75494f 100644 --- a/tests/boundary/cli/reconstructionObligationLedgerCli.test.ts +++ b/tests/boundary/cli/reconstructionObligationLedgerCli.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { reconstructionProofApplicabilityCases } from "../../fixtures/reconstructionProofApplicability.js"; import { execFile } from "node:child_process"; import { promisify } from "node:util"; @@ -83,7 +84,7 @@ describe("reconstruction obligation ledger CLI bundle validation", () => { it("reports non-canonical authenticated bundles as caller input", async () => { const records = ["first", "second"].map((label) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", diff --git a/tests/boundary/cli/reverseEngineeringCommands.test.ts b/tests/boundary/cli/reverseEngineeringCommands.test.ts index e8003bf59c..c5ca9dcbdd 100644 --- a/tests/boundary/cli/reverseEngineeringCommands.test.ts +++ b/tests/boundary/cli/reverseEngineeringCommands.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import pino from "pino"; import { Cli, z } from "incur"; import { afterEach, expect, it, vi } from "vitest"; @@ -41,7 +42,7 @@ afterEach(() => { const observation = (completionStatus: "complete" | "unknown") => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gnu.objdump", name: "GNU objdump", version: null }, { predicateType: "rea.reverse-engineering.command-observation", @@ -499,7 +500,7 @@ it.each([false, true])( }, } as unknown as CliInstance; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rizin.debugger", name: "Rizin debugger", version: null }, { predicateType: "rea.debugger.command-observation", @@ -619,7 +620,7 @@ it.each(["incomplete", "interrupt", "control"] as const)( } as unknown as CliInstance; const previous = process.exitCode; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rizin.debugger", name: "Rizin debugger", version: null }, { predicateType: "rea.debugger.command-observation", diff --git a/tests/boundary/cli/signalCleanup.test.ts b/tests/boundary/cli/signalCleanup.test.ts index dc706c17c0..f9681ef23f 100644 --- a/tests/boundary/cli/signalCleanup.test.ts +++ b/tests/boundary/cli/signalCleanup.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Cli } from "incur"; import { expect, it } from "vitest"; import { registerSignalCommands } from "../../../src/cli/signalCommands.js"; @@ -65,7 +66,7 @@ it.each([false, true])( "awaits cleanup retry and preserves completed output when retry failure is %s", async (failAgain) => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Completed decoder fixture", version: "1" }, { operation: "decode_signal_recording", diff --git a/tests/boundary/cli/strictPositionals.test.ts b/tests/boundary/cli/strictPositionals.test.ts index 258cc2fe8b..45e9d084aa 100644 --- a/tests/boundary/cli/strictPositionals.test.ts +++ b/tests/boundary/cli/strictPositionals.test.ts @@ -1,3 +1,4 @@ +import { EVIDENCE_FORMAT_REVISION } from "../../../src/domain/evidenceFormat.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { Cli, z } from "incur"; @@ -44,7 +45,7 @@ it("rejects surplus public CLI inputs before importing and retains the one-path await writeFile( path, JSON.stringify({ - evidence_format: 1, + evidence_format: EVIDENCE_FORMAT_REVISION, artifacts: [], captures: [], environments: [], diff --git a/tests/boundary/cli/wasmAcquiredInputsCli.test.ts b/tests/boundary/cli/wasmAcquiredInputsCli.test.ts index cb806720b1..fd2e1edd0d 100644 --- a/tests/boundary/cli/wasmAcquiredInputsCli.test.ts +++ b/tests/boundary/cli/wasmAcquiredInputsCli.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { chmod, mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -186,7 +187,7 @@ cliTest( ); const valid = withEvidenceCallerInputPath( createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture-wabt", name: "fixture", version: "1" }, { operation: "inspect_wasm_artifact", diff --git a/tests/boundary/evm/evmoleInterfaceProvider.test.ts b/tests/boundary/evm/evmoleInterfaceProvider.test.ts index 85ac420e61..99b6a48d75 100644 --- a/tests/boundary/evm/evmoleInterfaceProvider.test.ts +++ b/tests/boundary/evm/evmoleInterfaceProvider.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { access, readFile, symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -917,7 +918,7 @@ it }); const evidence = parseEvidence(result.error.partialObservation); expect(evidence.subject?.local_path).toBe(path); - expect(evidence.subject?.digest.sha256).toBe( + expect(fileIdentity(evidence.subject).sha256).toBe( createHash("sha256").update(source).digest("hex"), ); expect(Buffer.compare(await readFile(path), source)).toBe(0); diff --git a/tests/boundary/filesystem/apkSignatureViewIdentity.test.ts b/tests/boundary/filesystem/apkSignatureViewIdentity.test.ts index c5f4331d09..6db72b3f2f 100644 --- a/tests/boundary/filesystem/apkSignatureViewIdentity.test.ts +++ b/tests/boundary/filesystem/apkSignatureViewIdentity.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + changedEvidenceSubject, +} from "../../fixtures/evidenceSubject.js"; import { rebindEvidenceToTargetPath } from "../../../src/domain/evidence.js"; import { EvidenceLedger } from "../../../src/application/investigation/EvidenceLedger.js"; import { inspectAnalysisView } from "../../../src/application/analysisView/AnalysisViewService.js"; @@ -23,7 +27,7 @@ it("checks parent subject identity again when signing facts are already cached", const result = await service.inspect({ path, detail: "complete" }); if (!result.ok) throw result.error; const evidence = result.value; - if (evidence.subject === null || evidence.subject.format !== "apk") + if (fileIdentity(evidence.subject).format !== "apk") throw new Error("selected file subject missing"); const parent = { predicateType: evidence.predicate_type, @@ -39,14 +43,17 @@ it("checks parent subject identity again when signing facts are already cached", for (const format of ["file", "apk", "zip"] as const) expect( projectApkSignatureView( - { ...parent, subject: { ...evidence.subject, format } }, + { + ...parent, + subject: changedEvidenceSubject(evidence.subject, { format }), + }, { kind: "summary" }, ).ok, ).toBe(true); const rebound = rebindEvidenceToTargetPath(evidence, { path: join(root, "alias.apk"), - sha256: evidence.subject.digest.sha256, - format: evidence.subject.format, + sha256: fileIdentity(evidence.subject).sha256, + format: fileIdentity(evidence.subject).format, }); const exporting = new EvidenceLedger(); expect(exporting.record(rebound).ok).toBe(true); @@ -65,11 +72,8 @@ it("checks parent subject identity again when signing facts are already cached", artifact: { path }, }); for (const subject of [ - { ...evidence.subject, format: "directory" as const }, - { - ...evidence.subject, - digest: { ...evidence.subject.digest, sha256: "00".repeat(32) }, - }, + changedEvidenceSubject(evidence.subject, { format: "directory" }), + changedEvidenceSubject(evidence.subject, { sha256: "00".repeat(32) }), ]) { const invalid = projectApkSignatureView( { ...parent, subject }, diff --git a/tests/boundary/filesystem/appleApplication.test.ts b/tests/boundary/filesystem/appleApplication.test.ts index 9398f008bc..89e6a2df0b 100644 --- a/tests/boundary/filesystem/appleApplication.test.ts +++ b/tests/boundary/filesystem/appleApplication.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { projectCliAnalysisResult } from "../../../src/cli/projectCliAnalysisResult.js"; import { mkdir, symlink, writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; @@ -421,9 +422,9 @@ describe("macOS application projection", () => { const projection = appleApplicationProjectionResultSchema.parse( requireSuccessfulProjection(result).normalized_result, ); - expect(requireSuccessfulProjection(result).subject?.format).toBe( - "directory", - ); + expect( + fileIdentity(requireSuccessfulProjection(result).subject).format, + ).toBe("directory"); expect(projection).toMatchObject({ root_format: "directory", platforms: ["macos"], diff --git a/tests/boundary/filesystem/artifactComparison.test.ts b/tests/boundary/filesystem/artifactComparison.test.ts index 716d2056f9..71ec26e2bc 100644 --- a/tests/boundary/filesystem/artifactComparison.test.ts +++ b/tests/boundary/filesystem/artifactComparison.test.ts @@ -1,3 +1,8 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { chmod, mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -136,9 +141,9 @@ describe("leaf artifact comparison", () => { const { coverage: _coverage, ...withoutCoverage } = parsed; const malformed = createEvidence( { - path: left.subject!.local_path, - sha256: left.subject!.digest.sha256, - format: left.subject!.format, + path: fileSubjectDisplay(left.subject).local_path, + sha256: fileIdentity(left.subject).sha256, + format: fileIdentity(left.subject).format, }, PROVIDER, { @@ -298,9 +303,9 @@ describe("artifact inventory coverage", () => { ); const unknownCoverage = createEvidence( { - path: complete.subject!.local_path, - sha256: complete.subject!.digest.sha256, - format: complete.subject!.format, + path: fileSubjectDisplay(complete.subject).local_path, + sha256: fileIdentity(complete.subject).sha256, + format: fileIdentity(complete.subject).format, }, PROVIDER, { @@ -340,9 +345,9 @@ describe("artifact inventory coverage", () => { ); const mixed = createEvidence( { - path: fragment.subject!.local_path, - sha256: fragment.subject!.digest.sha256, - format: fragment.subject!.format, + path: fileSubjectDisplay(fragment.subject).local_path, + sha256: fileIdentity(fragment.subject).sha256, + format: fileIdentity(fragment.subject).format, }, PROVIDER, { @@ -441,7 +446,7 @@ describe("artifact comparison", () => { const incomplete = createEvidence( { path: root, - sha256: complete.subject?.digest.sha256 ?? "0".repeat(64), + sha256: fileIdentity(complete.subject).sha256 ?? "0".repeat(64), format: "directory", }, PROVIDER, @@ -949,7 +954,7 @@ describe("artifact comparison fragment integrity", () => { const conflictingScope = createEvidence( { path: leftPath, - sha256: left.subject?.digest.sha256 ?? "", + sha256: fileIdentity(left.subject).sha256 ?? "", format: "directory", }, PROVIDER, @@ -982,11 +987,15 @@ describe("artifact comparison fragment integrity", () => { expect(() => compareArtifacts({ ...evidence, operation: "binary_overview" }, evidence), ).toThrow(/identifier/u); - const wrongOperation = createEvidence(undefined, PROVIDER, { - operation: "binary_overview", - parameters: {}, - result: evidence.normalized_result, - }); + const wrongOperation = createEvidence( + unknownTarget("not-observed"), + PROVIDER, + { + operation: "binary_overview", + parameters: {}, + result: evidence.normalized_result, + }, + ); expect(() => compareArtifacts(wrongOperation, evidence)).toThrowError( expect.objectContaining({ _tag: "AnalysisInputError", diff --git a/tests/boundary/filesystem/binaryTarget.test.ts b/tests/boundary/filesystem/binaryTarget.test.ts index 0f1accbed6..478b35a4e4 100644 --- a/tests/boundary/filesystem/binaryTarget.test.ts +++ b/tests/boundary/filesystem/binaryTarget.test.ts @@ -169,8 +169,7 @@ it.each([{ cpus: [0x0100000c] }, { cpus: [0x01000007, 0x0100000c] }])( expect( parseEvidence(JSON.parse(JSON.stringify(evidence))).subject, ).toMatchObject({ - format: "mach-o-universal", - architecture: "arm64", + identity: { format: "mach-o-universal", architecture: "arm64" }, }); }, ); diff --git a/tests/boundary/filesystem/desktopApplication.test.ts b/tests/boundary/filesystem/desktopApplication.test.ts index 35f07be76c..1675d1b8d2 100644 --- a/tests/boundary/filesystem/desktopApplication.test.ts +++ b/tests/boundary/filesystem/desktopApplication.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { mkdir, writeFile, @@ -1776,8 +1777,8 @@ it("keeps snapshot identity stable across limits that preserve source observatio expect(first.report.root.snapshot_sha256).toBe( second.report.root.snapshot_sha256, ); - expect(first.evidence.subject?.digest.sha256).toBe( - second.evidence.subject?.digest.sha256, + expect(fileIdentity(first.evidence.subject).sha256).toBe( + fileIdentity(second.evidence.subject).sha256, ); expect(first.evidence.evidence_id).not.toBe(second.evidence.evidence_id); expect(first.evidence.parameters).toMatchObject({ diff --git a/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts b/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts index a8586775a5..dcd74bcdb3 100644 --- a/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts +++ b/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { withVerifierCleanup } from "../../../scripts/lib/verifier-cleanup.mjs"; import { parseEvidenceBundle, @@ -606,11 +607,15 @@ describe("snapshot output cleanup lifecycle", () => { ["fixture provider"], {}, { - partialObservation: createEvidence(undefined, IDENTITY, { - operation: "health", - parameters: {}, - result: "cleanup facts", - }), + partialObservation: createEvidence( + unknownTarget("not-observed"), + IDENTITY, + { + operation: "health", + parameters: {}, + result: "cleanup facts", + }, + ), }, ) : new AnalysisCancelledError("close_binary"); diff --git a/tests/boundary/filesystem/evidenceBundleFiles.test.ts b/tests/boundary/filesystem/evidenceBundleFiles.test.ts index 89d3df231d..ef3ef5011c 100644 --- a/tests/boundary/filesystem/evidenceBundleFiles.test.ts +++ b/tests/boundary/filesystem/evidenceBundleFiles.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { lstat, mkdir, @@ -68,7 +69,7 @@ vi.mock("node:v8", async (importOriginal) => { const bundle = (result = true) => createEvidenceBundle([ createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "health", parameters: {}, result }, ), @@ -122,7 +123,7 @@ it("admits the live process-payload validation working set before writing an own // This minimal authored process fixture proves the format boundary. It does // not claim a real process/provider capture or an actual heap exhaustion. const capture = createEvidence( - undefined, + unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", @@ -225,7 +226,7 @@ it("merges CLI identities for repeated inspection sources", async () => { await writeFile(input, "artifact contents"); const inventory = await inventoryArtifact(input); const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inventory_artifact", @@ -235,7 +236,7 @@ it("merges CLI identities for repeated inspection sources", async () => { ); const inspection = createArtifactInspection(source); const complete = withEvidenceCallerInputPath( - createEvidence(undefined, source.provider, { + createEvidence(unknownTarget("not-observed"), source.provider, { operation: "inspect_artifact", parameters: {}, result: { @@ -270,7 +271,7 @@ it("merges CLI identities for repeated inspection sources", async () => { it("retains a malformed artifact parent and refuses its publication", async () => { const root = await createTestTempDirectory("rea-malformed-delivery-"); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_artifact", parameters: {}, result: {} }, ); @@ -960,18 +961,22 @@ describe("evidence bundle process-capture payloads", () => { // Authenticate the enclosing Evidence correctly while breaking its // capture commitment, so generic bundle authentication still succeeds. const capture = EMPTY_PROCESS_CAPTURE_EXAMPLE; - const record = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: { - ...capture, - manifest: { - ...capture.manifest, - full_scenario_sha256: "0".repeat(64), + const record = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: { + ...capture, + manifest: { + ...capture.manifest, + full_scenario_sha256: "0".repeat(64), + }, }, }, - }); + ); const value = createEvidenceBundle([record]); const rejected = await writeBundle(value, path, overwrite); if (rejected.ok) throw new Error("Expected invalid capture rejection"); @@ -1037,7 +1042,7 @@ describe("evidence bundle process-capture payloads", () => { ); const path = join(directory, "bundle.json"); const value = createEvidenceBundle([ - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation, predicateType, result, diff --git a/tests/boundary/filesystem/harmony/application.test.ts b/tests/boundary/filesystem/harmony/application.test.ts index 33c6f05e01..1ffdbca190 100644 --- a/tests/boundary/filesystem/harmony/application.test.ts +++ b/tests/boundary/filesystem/harmony/application.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../../fixtures/evidenceSubject.js"; import { projectCliAnalysisResult } from "../../../../src/cli/projectCliAnalysisResult.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -220,7 +224,7 @@ describe("HarmonyOS application projection", () => { stageHapEntries, ); const inventory = await inventoryApplicationPackage(path); - expect(inventory.subject?.format).toBe("hap"); + expect(fileIdentity(inventory.subject).format).toBe("hap"); const left = requireDeterministicProjection( projectHarmonyApplicationEvidence, inventory, @@ -286,7 +290,7 @@ describe("HarmonyOS application projection", () => { }, ]); const inventory = await inventoryApplicationPackage(path); - expect(inventory.subject?.format).toBe("app-pack"); + expect(fileIdentity(inventory.subject).format).toBe("app-pack"); const projection = requireDeterministicProjection( projectHarmonyApplicationEvidence, inventory, @@ -322,7 +326,7 @@ describe("HarmonyOS packaging boundaries", () => { }, ]); const inventory = await inventoryApplicationPackage(path); - expect(inventory.subject?.format).toBe("ipa"); + expect(fileIdentity(inventory.subject).format).toBe("ipa"); const occurrences = ( inventory.normalized_result as { occurrences: Array<{ @@ -434,15 +438,14 @@ describe("HarmonyOS partial inventory classification", () => { ], ); const inventory = await inventoryApplicationPackage(path); - if (inventory.subject === null) throw new Error("Missing fixture subject"); const result = artifactInventoryResultSchema.parse( inventory.normalized_result, ); const partial = createEvidence( { - path: inventory.subject.local_path, - sha256: inventory.subject.digest.sha256, - format: inventory.subject.format, + path: fileSubjectDisplay(inventory.subject).local_path, + sha256: fileIdentity(inventory.subject).sha256, + format: fileIdentity(inventory.subject).format, }, inventory.provider, { diff --git a/tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts b/tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts index dad21e441c..8d382d2d6c 100644 --- a/tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts +++ b/tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts @@ -61,7 +61,7 @@ describe("static Electron application analysis", () => { provider: { id: "rea-javascript-application" }, authority: "shipped-artifact", confidence: "derived", - subject: { local_path: root, format: "directory" }, + subject: { local_path: root, identity: { format: "directory" } }, normalized_result: { input_path: root, summary: { browser_windows: 3 }, diff --git a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts index 847ad3a0fb..1affba27cf 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts @@ -8,7 +8,10 @@ import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js import { createElectronActiveEvidence } from "../../../../src/application/javascript/ElectronActiveEvidence.js"; import { javascriptApplicationAnalysisResultSchema } from "../../../../src/domain/javascript/javascriptApplicationAnalysis.js"; import { reconcileJavaScriptRuntimeEvidence } from "../../../../src/application/javascript/JavaScriptRuntimeReconciliationService.js"; -import { createEvidence } from "../../../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSubjectInput, +} from "../../../../src/domain/evidence.js"; import { mappedRuntimePaths } from "../../../../src/domain/javascript/javascriptRuntimeStaticCandidates.js"; import { projectRuntimeCaptures } from "../../../../src/domain/javascript/javascriptRuntimeReconciliationRuntime.js"; import { parseRuntimeCapture } from "../../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; @@ -62,14 +65,18 @@ it.each([ const root = await applicationFixture(); const application = await analyzeFixture(root); const runtime = electronRuntimeEvidence(root, SOURCE); - const invalidRuntime = createEvidence(undefined, runtime.provider, { - predicateType: runtime.predicate_type, - operation: runtime.operation, - parameters: { ...runtime.parameters, [parameter]: value }, - result: runtime.normalized_result, - confidence: runtime.confidence, - authority: runtime.authority, - }); + const invalidRuntime = createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + predicateType: runtime.predicate_type, + operation: runtime.operation, + parameters: { ...runtime.parameters, [parameter]: value }, + result: runtime.normalized_result, + confidence: runtime.confidence, + authority: runtime.authority, + }, + ); const result = reconcileJavaScriptRuntimeEvidence({ static_layers: [{ role: "application", analysis: application }], @@ -369,35 +376,39 @@ it("preserves unknown Electron frame provenance without linking it to an authori const inspection = electronPageInspectionSchema.parse( recorded.normalized_result, ); - const evidence = createEvidence(undefined, recorded.provider, { - predicateType: recorded.predicate_type, - operation: recorded.operation, - parameters: recorded.parameters, - confidence: recorded.confidence, - authority: recorded.authority, - result: { - ...inspection, - completeness: { - ...inspection.completeness, - status: "attach_limited", - conditions: ["attach_limited"], - attach_limited_sections: ["scripts"], - }, - scripts: { - ...inspection.scripts, - items: inspection.scripts.items.map((script) => ({ - ...script, - frame_scope: "unknown", - has_source_url: true, - reported_url: "file:///reported-label.js", - frame_claims: { - script_event_frame_id: "declared-frame", - execution_context_frame_id: "context-frame", - }, - })), + const evidence = createEvidence( + evidenceSubjectInput(recorded.subject), + recorded.provider, + { + predicateType: recorded.predicate_type, + operation: recorded.operation, + parameters: recorded.parameters, + confidence: recorded.confidence, + authority: recorded.authority, + result: { + ...inspection, + completeness: { + ...inspection.completeness, + status: "attach_limited", + conditions: ["attach_limited"], + attach_limited_sections: ["scripts"], + }, + scripts: { + ...inspection.scripts, + items: inspection.scripts.items.map((script) => ({ + ...script, + frame_scope: "unknown", + has_source_url: true, + reported_url: "file:///reported-label.js", + frame_claims: { + script_event_frame_id: "declared-frame", + execution_context_frame_id: "context-frame", + }, + })), + }, }, }, - }); + ); const captures = [parseRuntimeCapture(evidence, ["runtime_observations", 0])]; expect(captures[0]?.scriptsCompleteWithinScope).toBe(false); const projected = projectRuntimeCaptures(captures); @@ -529,14 +540,18 @@ it("refuses active Electron Evidence without its admitted execution paths", asyn input, ); const { resolved_paths: _resolved, ...parameters } = runtime.parameters; - const withoutPaths = createEvidence(undefined, runtime.provider, { - predicateType: runtime.predicate_type, - operation: runtime.operation, - parameters, - result: runtime.normalized_result, - confidence: runtime.confidence, - authority: runtime.authority, - }); + const withoutPaths = createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + predicateType: runtime.predicate_type, + operation: runtime.operation, + parameters, + result: runtime.normalized_result, + confidence: runtime.confidence, + authority: runtime.authority, + }, + ); expect( reconcileJavaScriptRuntimeEvidence({ @@ -706,14 +721,18 @@ const sourceFreeRuntime = (runtimeRoot: string, scriptFile: string) => { ); for (const script of observation.scripts.items) script.source = { included: false, reason: "not-requested" }; - return createEvidence(undefined, runtime.provider, { - operation: runtime.operation, - predicateType: runtime.predicate_type, - parameters: runtime.parameters, - result: observation, - confidence: runtime.confidence, - authority: runtime.authority, - }); + return createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + operation: runtime.operation, + predicateType: runtime.predicate_type, + parameters: runtime.parameters, + result: observation, + confidence: runtime.confidence, + authority: runtime.authority, + }, + ); }; const reconcileScriptLocation = ( @@ -944,14 +963,18 @@ const rendererCapture = (runtimeRoot: string, filePath: string) => { ); observation.target.file_path = filePath; for (const frame of observation.frames) frame.file_path = filePath; - return createEvidence(undefined, runtime.provider, { - operation: runtime.operation, - predicateType: runtime.predicate_type, - parameters: runtime.parameters, - result: observation, - confidence: runtime.confidence, - authority: runtime.authority, - }); + return createEvidence( + evidenceSubjectInput(runtime.subject), + runtime.provider, + { + operation: runtime.operation, + predicateType: runtime.predicate_type, + parameters: runtime.parameters, + result: observation, + confidence: runtime.confidence, + authority: runtime.authority, + }, + ); }; it.skipIf(process.platform === "win32")( diff --git a/tests/boundary/filesystem/javascriptApplicationWorkflows.test.ts b/tests/boundary/filesystem/javascriptApplicationWorkflows.test.ts index 89a0e3e3dd..845a6f068a 100644 --- a/tests/boundary/filesystem/javascriptApplicationWorkflows.test.ts +++ b/tests/boundary/filesystem/javascriptApplicationWorkflows.test.ts @@ -1,3 +1,8 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { rm, writeFile } from "node:fs/promises"; import { join, relative, resolve } from "node:path"; @@ -12,7 +17,10 @@ import { traceApplicationFeatureEvidence, } from "../../../src/application/javascript/JavaScriptApplicationWorkflowService.js"; import { reconcileJavaScriptRuntimeEvidence } from "../../../src/application/javascript/JavaScriptRuntimeReconciliationService.js"; -import { createEvidence } from "../../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSubjectInput, +} from "../../../src/domain/evidence.js"; import { AnalysisInputError } from "../../../src/domain/analysisErrorCore.js"; import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascript/javascriptApplicationAnalysis.js"; @@ -202,7 +210,7 @@ describe("JavaScript application comparison workflows", () => { ); const applicationEvidence = (side: string) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.javascript-application-analysis", @@ -241,7 +249,7 @@ describe("historical native comparison projections", () => { const binding = original.graph.nodes.find( ({ kind }) => kind === "native-export", ); - if (binding === undefined || source.subject === null) + if (binding === undefined || source.subject.identity.kind !== "file") throw new Error("Missing fixture binding"); const historical = (name: string, explicitEmpty = false) => { const artifact = binding.observations[0]!.evidence.artifact; @@ -284,9 +292,9 @@ describe("historical native comparison projections", () => { }); return createEvidence( { - path: source.subject!.local_path, - sha256: source.subject!.digest.sha256, - format: source.subject!.format, + path: fileSubjectDisplay(source.subject).local_path, + sha256: fileIdentity(source.subject).sha256, + format: fileIdentity(source.subject).format, }, source.provider, { @@ -473,22 +481,26 @@ describe("Application graph Evidence envelopes", () => { ) : managedApplicationGraphResultSchema.parse(source.normalized_result); const extraLink = `ev_${"f".repeat(64)}`; - const malformed = createEvidence(undefined, source.provider, { - predicateType: source.predicate_type, - operation: source.operation, - parameters: source.parameters, - result: { - ...result, - evidence_links: [...result.evidence_links, extraLink], + const malformed = createEvidence( + evidenceSubjectInput(source.subject), + source.provider, + { + predicateType: source.predicate_type, + operation: source.operation, + parameters: source.parameters, + result: { + ...result, + evidence_links: [...result.evidence_links, extraLink], + }, + rawResult: source.raw_result, + confidence: source.confidence, + authority: source.authority, + environment: source.environment, + limitations: source.limitations, + locations: source.locations, + evidenceLinks: source.evidence_links, }, - rawResult: source.raw_result, - confidence: source.confidence, - authority: source.authority, - environment: source.environment, - limitations: source.limitations, - locations: source.locations, - evidenceLinks: source.evidence_links, - }); + ); const workflowInput = { application: source, seed: { kind: "route" as const, value: "/not-present" }, @@ -525,7 +537,8 @@ describe("JavaScript application workflow error diagnostics", () => { temporary.push(root); const evidence = await analyzeFixture(root); const subject = evidence.subject; - if (subject === null) throw new Error("Analysis Evidence subject missing"); + if (subject.identity.kind !== "file") + throw new Error("Analysis Evidence must name its file"); const inconsistentPath = "/different/application.js"; const inconsistent = { ...evidence, @@ -557,7 +570,6 @@ describe("JavaScript application workflow error diagnostics", () => { temporary.push(root); const evidence = await analyzeFixture(root); const subject = evidence.subject; - if (subject === null) throw new Error("Analysis Evidence subject missing"); const result = javascriptApplicationAnalysisResultSchema.parse( evidence.normalized_result, ); @@ -570,9 +582,9 @@ describe("JavaScript application workflow error diagnostics", () => { }; const malformedEvidence = createEvidence( { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + path: fileSubjectDisplay(subject).local_path, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, JAVASCRIPT_APPLICATION_PROVIDER, { @@ -682,25 +694,29 @@ describe("JavaScript runtime reconciliation local paths", () => { ); // Keep target and script coordinates consistent so an unrelated target // cannot activate the static layer after its script mapping was rejected. - const runtime = createEvidence(undefined, original.provider, { - predicateType: original.predicate_type, - operation: original.operation, - parameters: { ...original.parameters, include_script_sources: false }, - result: { - ...inspection, - target: { ...inspection.target, file_path: path }, - scripts: { - ...inspection.scripts, - items: inspection.scripts.items.map((script) => ({ - ...script, - file_path: path, - source: { included: false, reason: "not-requested" }, - })), + const runtime = createEvidence( + evidenceSubjectInput(original.subject), + original.provider, + { + predicateType: original.predicate_type, + operation: original.operation, + parameters: { ...original.parameters, include_script_sources: false }, + result: { + ...inspection, + target: { ...inspection.target, file_path: path }, + scripts: { + ...inspection.scripts, + items: inspection.scripts.items.map((script) => ({ + ...script, + file_path: path, + source: { included: false, reason: "not-requested" }, + })), + }, }, + confidence: original.confidence, + authority: original.authority, }, - confidence: original.confidence, - authority: original.authority, - }); + ); const reconciled = reconcileJavaScriptRuntimeEvidence({ static_layers: base.static_layers.map((layer) => ({ ...layer, diff --git a/tests/boundary/filesystem/kernelBuildConfig.test.ts b/tests/boundary/filesystem/kernelBuildConfig.test.ts index 4a5a35528e..bedc0676b8 100644 --- a/tests/boundary/filesystem/kernelBuildConfig.test.ts +++ b/tests/boundary/filesystem/kernelBuildConfig.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { describe, expect, it } from "vitest"; @@ -78,7 +79,7 @@ describe("kernel build config stable filesystem boundary", () => { try { const result = await service.inspect({ path }); if (!result.ok) throw result.error; - expect(result.value.subject?.format).toBe("elf"); + expect(fileIdentity(result.value.subject).format).toBe("elf"); expect(result.value.normalized_result).toMatchObject({ banner: { status: "present", version: "6.6.0" }, config: { status: "absent", entries: [] }, diff --git a/tests/boundary/filesystem/kernelModule.test.ts b/tests/boundary/filesystem/kernelModule.test.ts index 9c02377c84..7ece8468c8 100644 --- a/tests/boundary/filesystem/kernelModule.test.ts +++ b/tests/boundary/filesystem/kernelModule.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { symlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { describe, expect, it } from "vitest"; @@ -76,7 +77,7 @@ describe("kernel module stable filesystem boundary", () => { try { const result = await service.inspect({ path }); if (!result.ok) throw result.error; - expect(result.value.subject?.format).toBe("file"); + expect(fileIdentity(result.value.subject).format).toBe("file"); expect(result.value.normalized_result).toMatchObject({ applicability: "unsupported", compression: { codec: "gzip", status: "unsupported" }, diff --git a/tests/boundary/filesystem/keyedArchiveStandaloneSelection.test.ts b/tests/boundary/filesystem/keyedArchiveStandaloneSelection.test.ts index 6810a548b7..d271dfa376 100644 --- a/tests/boundary/filesystem/keyedArchiveStandaloneSelection.test.ts +++ b/tests/boundary/filesystem/keyedArchiveStandaloneSelection.test.ts @@ -52,7 +52,7 @@ it.skipIf(process.platform === "win32")( ); expect(evidence.subject).toMatchObject({ local_path: alias, - digest: { + identity: { sha256: createHash("sha256").update(bytes).digest("hex"), }, }); diff --git a/tests/boundary/filesystem/nativeExports.test.ts b/tests/boundary/filesystem/nativeExports.test.ts index 3ca8c8f1ca..6dd2ebb04f 100644 --- a/tests/boundary/filesystem/nativeExports.test.ts +++ b/tests/boundary/filesystem/nativeExports.test.ts @@ -32,7 +32,7 @@ describe("native export stable filesystem boundary", () => { const sha256 = createHash("sha256").update(bytes).digest("hex"); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256 }, + identity: { sha256 }, }); expect( nativeExportsSchema.parse(evidence.normalized_result), @@ -131,7 +131,7 @@ describe("native export stable filesystem boundary", () => { operation: "inspect_native_exports", provider: { id: "rea-native-exports" }, confidence: "observed", - subject: { local_path: path, format, digest: { sha256 } }, + subject: { local_path: path, identity: { format, sha256 } }, }); expect( nativeExportsSchema.parse(evidence.normalized_result), @@ -161,7 +161,7 @@ describe("native export text capacity", () => { const report = nativeExportsSchema.parse(evidence.normalized_result); expect(evidence.subject).toMatchObject({ local_path: path, - digest: { sha256: createHash("sha256").update(bytes).digest("hex") }, + identity: { sha256: createHash("sha256").update(bytes).digest("hex") }, }); expect(report).toMatchObject({ exports: [expect.objectContaining({ name: "kept" })], diff --git a/tests/boundary/filesystem/processCliFileInput.test.ts b/tests/boundary/filesystem/processCliFileInput.test.ts index 77a81c27e0..ed7ea2a560 100644 --- a/tests/boundary/filesystem/processCliFileInput.test.ts +++ b/tests/boundary/filesystem/processCliFileInput.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { open, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { describe, expect, it, onTestFinished, vi } from "vitest"; @@ -599,7 +600,7 @@ describe("process CLI UTF-8 input diagnostics", () => { }); const processCaptureEvidence = () => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: {}, diff --git a/tests/boundary/filesystem/sourceToBundlePaths.test.ts b/tests/boundary/filesystem/sourceToBundlePaths.test.ts index 589c77c94c..4ceb6aff2e 100644 --- a/tests/boundary/filesystem/sourceToBundlePaths.test.ts +++ b/tests/boundary/filesystem/sourceToBundlePaths.test.ts @@ -788,7 +788,8 @@ it("rejects static application Evidence whose subject path disagrees with its re const analyzed = await analyzeJavaScriptApplication({ input_path: root }); if (!analyzed.ok) throw analyzed.error; const subject = analyzed.value.subject; - if (subject === null) throw new Error("Analysis Evidence subject missing"); + if (subject.identity.kind !== "file") + throw new Error("Analysis Evidence subject missing"); const inconsistent = { ...analyzed.value, subject: { diff --git a/tests/boundary/filesystem/undeliveredSourceClosure.test.ts b/tests/boundary/filesystem/undeliveredSourceClosure.test.ts index cf4ae0afa7..30a19bd722 100644 --- a/tests/boundary/filesystem/undeliveredSourceClosure.test.ts +++ b/tests/boundary/filesystem/undeliveredSourceClosure.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readdir, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -33,7 +34,7 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = (name: string, links: readonly string[] = []) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_source", parameters: { name }, result: { name }, @@ -41,7 +42,7 @@ const source = (name: string, links: readonly string[] = []) => }); const observed = (links: readonly string[]) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_observation", parameters: {}, result: { completed: true }, @@ -165,7 +166,7 @@ it("leaves failures untouched unless a completed observation requested delivery" it("bounds records and listed omissions while counting everything", async () => { const root = await createTestTempDirectory("rea-closure-bounds-"); const held = Array.from({ length: 200 }, (_, index) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_source", parameters: { index }, result: { text: "x".repeat(4 * 1024) }, @@ -202,7 +203,7 @@ const digestLink = (index: number) => `ev_${index.toString(16).padStart(64, "0")}`; const wideSource = (links: readonly string[]) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_source", parameters: {}, result: { wide: true }, @@ -273,7 +274,7 @@ it("examines repeated links once across every captured source", async () => { () => shared.evidence_id, ); const first = wideSource(repeated); - const second = createEvidence(undefined, provider, { + const second = createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_source", parameters: { second: true }, result: { wide: true }, @@ -343,7 +344,7 @@ it.each([ it("spends the allowance on smaller later records after a record does not fit", async () => { const root = await createTestTempDirectory("rea-closure-greedy-"); - const large = createEvidence(undefined, provider, { + const large = createEvidence(unknownTarget("not-observed"), provider, { operation: "fixture_source", parameters: {}, result: { text: "x".repeat(128 * 1024) }, @@ -384,12 +385,12 @@ it("does not duplicate sources an artifact inspection already embeds", async () const root = await createTestTempDirectory("rea-closure-embedded-"); const input = join(root, "input.txt"); await writeFile(input, "artifact contents"); - const embedded = createEvidence(undefined, provider, { + const embedded = createEvidence(unknownTarget("not-observed"), provider, { operation: "inventory_artifact", parameters: {}, result: await inventoryArtifact(input), }); - const observation = createEvidence(undefined, provider, { + const observation = createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_artifact", parameters: {}, result: createArtifactInspection(embedded), @@ -728,12 +729,16 @@ it.each([false, true])( "rea-closure-invalid-inspection-", ); const held = source("held"); - const observation = createEvidence(undefined, provider, { - operation: "inspect_artifact", - parameters: {}, - result: { malformed: true }, - evidenceLinks: captured ? [held.evidence_id] : [], - }); + const observation = createEvidence( + unknownTarget("not-observed"), + provider, + { + operation: "inspect_artifact", + parameters: {}, + result: { malformed: true }, + evidenceLinks: captured ? [held.evidence_id] : [], + }, + ); const output = await publishCliAnalysisEvidence( err(cancelledWith(observation)), delivery(root, captured ? [held] : []), @@ -755,7 +760,7 @@ it.each([false, true])( it("reports missing links as unknown when an embedded source list cannot be read", async () => { const root = await createTestTempDirectory("rea-closure-invalid-missing-"); const missing = "ev_".padEnd(67, "a"); - const observation = createEvidence(undefined, provider, { + const observation = createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_artifact", parameters: {}, result: { malformed: true }, diff --git a/tests/boundary/firmware/firmwareIntegration.test.ts b/tests/boundary/firmware/firmwareIntegration.test.ts index 163b5a713d..bb6c000d7d 100644 --- a/tests/boundary/firmware/firmwareIntegration.test.ts +++ b/tests/boundary/firmware/firmwareIntegration.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { STDIO_DEFAULT_MAX_BUFFER_SIZE } from "@modelcontextprotocol/server"; import { access, mkdir, readFile, writeFile } from "node:fs/promises"; import { dirname } from "node:path"; @@ -115,7 +116,7 @@ it("binds region observations to exact bytes and preserves provider-reported unc size_basis: "provider_reported_validation_unknown", }); expect(result.value.subject?.local_path).toBe(fixture.path); - expect(result.value.subject?.format).toBe("file"); + expect(fileIdentity(result.value.subject).format).toBe("file"); expect(result.value.raw_result).toMatchObject({ report: [{ Analysis: { file_map: [{ id: "hit" }] } }], }); diff --git a/tests/boundary/firmware/firmwarePublicationPaths.test.ts b/tests/boundary/firmware/firmwarePublicationPaths.test.ts index 911ce82edb..171eb00e26 100644 --- a/tests/boundary/firmware/firmwarePublicationPaths.test.ts +++ b/tests/boundary/firmware/firmwarePublicationPaths.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { access, @@ -60,7 +61,7 @@ const validateAdvertisedFirmwareOutput = async ( expect(ajv.validateSchema(schema as AnySchema)).toBe(true); const validate = ajv.compile(schema as AnySchema); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "fixture", version: null }, { operation: "extract_firmware", diff --git a/tests/boundary/goRustSubjectArchitecture.test.ts b/tests/boundary/goRustSubjectArchitecture.test.ts index b72cdd0ae5..de80c310d1 100644 --- a/tests/boundary/goRustSubjectArchitecture.test.ts +++ b/tests/boundary/goRustSubjectArchitecture.test.ts @@ -38,8 +38,10 @@ it.each([ const result = await service.inspect({ path }); if (!result.ok) throw result.error; expect(result.value.subject).toMatchObject({ - architecture: canonical, - digest: { sha256: createHash("sha256").update(bytes).digest("hex") }, + identity: { + architecture: canonical, + sha256: createHash("sha256").update(bytes).digest("hex"), + }, }); expect(result.value.normalized_result).toMatchObject({ architecture: local, diff --git a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts index 0f47e1b001..fd6274faa0 100644 --- a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts +++ b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts @@ -25,7 +25,10 @@ import { observeJavaScriptRuntimeInputSchema, } from "../../../src/domain/javascript/javascriptRuntimeObservation.js"; import { inspectWebPageInputSchema } from "../../../src/domain/browserObservation.js"; -import { createEvidence } from "../../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSubjectInput, +} from "../../../src/domain/evidence.js"; import { javascriptRuntimeReconciliationResultSchema } from "../../../src/domain/javascript/javascriptRuntimeReconciliationSchemas.js"; import { parseRuntimeCapture } from "../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; import { startFakeV8Inspector } from "../../fixtures/inspector/fakeV8Inspector.js"; @@ -88,16 +91,20 @@ test("reports browser origin scope mismatch at the caller parameter path", async { source: jsonValueSchema.parse(observed.value), facts: observed.value }, provider.identity(), ); - const invalidEvidence = createEvidence(undefined, evidence.provider, { - predicateType: evidence.predicate_type, - operation: evidence.operation, - parameters: { ...evidence.parameters, allowed_origins: [] }, - result: evidence.normalized_result, - confidence: evidence.confidence, - authority: evidence.authority, - environment: evidence.environment, - limitations: evidence.limitations, - }); + const invalidEvidence = createEvidence( + evidenceSubjectInput(evidence.subject), + evidence.provider, + { + predicateType: evidence.predicate_type, + operation: evidence.operation, + parameters: { ...evidence.parameters, allowed_origins: [] }, + result: evidence.normalized_result, + confidence: evidence.confidence, + authority: evidence.authority, + environment: evidence.environment, + limitations: evidence.limitations, + }, + ); const result = reconcileJavaScriptRuntimeEvidence({ static_layers: JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE.static_layers, runtime_observations: [invalidEvidence], diff --git a/tests/boundary/javascript-recovery/wakaruIntegration.test.ts b/tests/boundary/javascript-recovery/wakaruIntegration.test.ts index 5bb9c7877b..3f5c8cd645 100644 --- a/tests/boundary/javascript-recovery/wakaruIntegration.test.ts +++ b/tests/boundary/javascript-recovery/wakaruIntegration.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { execFile } from "node:child_process"; import { access, @@ -460,7 +461,7 @@ describe.skipIf(process.platform !== "linux" || process.arch !== "x64")( }); expect(result.value.subject).toMatchObject({ local_path: selected, - digest: { sha256: sources[0]!.sha256 }, + identity: { sha256: sources[0]!.sha256 }, }); for (const [index, module] of value.modules.entries()) expect(module.provenance).toMatchObject({ @@ -532,7 +533,9 @@ describe.skipIf(process.platform !== "linux" || process.arch !== "x64")( expect(await readFile(sources[1]!.published_copy.path, "utf8")).toBe( content, ); - expect(result.value.subject?.digest.sha256).toBe(value.source.sha256); + expect(fileIdentity(result.value.subject).sha256).toBe( + value.source.sha256, + ); for (const [index, module] of value.modules.entries()) { const source = sources[index]!; expect(source.published_copy.sha256).toBe(source.sha256); diff --git a/tests/boundary/javascript/clientFixtureEvidence.test.ts b/tests/boundary/javascript/clientFixtureEvidence.test.ts index 746cc42638..fecf72e378 100644 --- a/tests/boundary/javascript/clientFixtureEvidence.test.ts +++ b/tests/boundary/javascript/clientFixtureEvidence.test.ts @@ -1,3 +1,4 @@ +import { displayedEvidenceSubject } from "../../fixtures/evidenceSubject.js"; import assert from "node:assert/strict"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -51,7 +52,9 @@ it("checks native client fixture Evidence, provenance, and every result observat assertClientJavaScriptFixtureEvidence( { ...evidence, - subject: { ...evidence.subject, local_path: target + "/other" }, + subject: displayedEvidenceSubject(evidence.subject, { + local_path: target + "/other", + }), }, target, ), diff --git a/tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts b/tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts index a7b74b8486..72d8b2258a 100644 --- a/tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts +++ b/tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { mkdir, readFile, @@ -137,8 +138,8 @@ cliTest( expect(physicalEvidence.normalized_result).toEqual( aliasEvidence.normalized_result, ); - expect(physicalEvidence.subject?.digest.sha256).toBe( - aliasEvidence.subject?.digest.sha256, + expect(fileIdentity(physicalEvidence.subject).sha256).toBe( + fileIdentity(aliasEvidence.subject).sha256, ); expect(physicalEvidence.evidence_id).not.toBe(aliasEvidence.evidence_id); const bundlePath = join(root, "retained-evidence.json"); diff --git a/tests/boundary/javascriptSemanticTraceEvidence.test.ts b/tests/boundary/javascriptSemanticTraceEvidence.test.ts index 9327c7d9f1..5385608621 100644 --- a/tests/boundary/javascriptSemanticTraceEvidence.test.ts +++ b/tests/boundary/javascriptSemanticTraceEvidence.test.ts @@ -1,3 +1,4 @@ +import { fileSubjectTarget } from "../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../fixtures/canonicalOutputSchema.js"; import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -53,16 +54,8 @@ it("reports invalid nested semantic graph Evidence as caller input through CLI a semanticGraph.graph_id = SEMANTIC_GRAPH_ID; const subject = sourceEvidence.subject; - if (subject === null) throw new Error("CLI Evidence must include a subject"); const malformedEvidence = createEvidence( - { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, - ...(subject.architecture === null - ? {} - : { architecture: subject.architecture }), - }, + fileSubjectTarget(subject), sourceEvidence.provider, { predicateType: sourceEvidence.predicate_type, diff --git a/tests/boundary/mcp/agentKnownAnswerMcp.test.ts b/tests/boundary/mcp/agentKnownAnswerMcp.test.ts index 5e0354bd4a..7bf2e32601 100644 --- a/tests/boundary/mcp/agentKnownAnswerMcp.test.ts +++ b/tests/boundary/mcp/agentKnownAnswerMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { appendFile, cp } from "node:fs/promises"; import { join, resolve } from "node:path"; @@ -136,8 +137,8 @@ describe("known-answer packaged artifact digest binding", () => { arguments: { input_path: targets.javascript }, }); const evidence = resultEvidence(result); - expect(evidence.subject?.digest.sha256).toEqual(expect.any(String)); - expect(evidence.subject?.digest.sha256).not.toBe( + expect(fileIdentity(evidence.subject).sha256).toEqual(expect.any(String)); + expect(fileIdentity(evidence.subject).sha256).not.toBe( targets.javascriptSha256, ); const manifest = claimManifest(claims, evidence); @@ -291,8 +292,9 @@ describe("Notes export known-answer evaluation", () => { await createPackage(join(root, "notes-electron"), path); } const workflow = await notesWorkflow(harness, path); - const digest = notesEvidence(workflow, "analyze_javascript_application") - .subject?.digest.sha256; + const digest = fileIdentity( + notesEvidence(workflow, "analyze_javascript_application").subject, + ).sha256; expect(digest === targets.notesElectronSha256).toBe(path === foreign); const assessment = grade( workflow.events, diff --git a/tests/boundary/mcp/analysisSnapshotProvenanceMcp.test.ts b/tests/boundary/mcp/analysisSnapshotProvenanceMcp.test.ts index 18581cc7d2..238890277a 100644 --- a/tests/boundary/mcp/analysisSnapshotProvenanceMcp.test.ts +++ b/tests/boundary/mcp/analysisSnapshotProvenanceMcp.test.ts @@ -1,3 +1,4 @@ +import { displayedEvidenceSubject } from "../../fixtures/evidenceSubject.js"; import { readFile, unlink, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -203,14 +204,13 @@ for (const missingSource of [false, true]) session.evidenceForAnalysis(parent.evidence_id), ); - if (source.subject === null) + if (source.subject.identity.kind !== "file") throw new Error("Expected a file-backed source"); const relocated = { ...source, - subject: { - ...source.subject, + subject: displayedEvidenceSubject(source.subject, { local_path: join(directory, "relocated.exe"), - }, + }), }; const imported = session.importEvidenceBundle( createEvidenceBundle([relocated]), @@ -226,14 +226,13 @@ for (const missingSource of [false, true]) ancestor.evidence_id, ]); expect(Object.isFrozen(refreshed.value.sourceEvidence?.[0])).toBe(true); - if (parent.subject === null) + if (parent.subject.identity.kind !== "file") throw new Error("Expected a file-backed parent"); const relocatedParent = { ...parent, - subject: { - ...parent.subject, + subject: displayedEvidenceSubject(parent.subject, { local_path: join(directory, "relocated-parent.exe"), - }, + }), }; const importedParent = session.importEvidenceBundle( createEvidenceBundle([relocatedParent]), diff --git a/tests/boundary/mcp/analyzeFunctionDetail.test.ts b/tests/boundary/mcp/analyzeFunctionDetail.test.ts index 9993d7fcef..c03b615173 100644 --- a/tests/boundary/mcp/analyzeFunctionDetail.test.ts +++ b/tests/boundary/mcp/analyzeFunctionDetail.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import pino from "pino"; import { expect, it, onTestFinished, vi } from "vitest"; @@ -113,7 +114,7 @@ it.each(["analyze_function", "decompile_all"] as const)( "retains plain-port source records before delivering %s links", async (operation) => { const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "ghidra", name: "Ghidra", version: "12.1.4" }, { operation: "health", @@ -148,7 +149,7 @@ it.each(["analyze_function", "decompile_all"] as const)( it("refuses source links when a plain-port adapter has no retention owner", async () => { const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "health", diff --git a/tests/boundary/mcp/androidPackageSummaryMcp.test.ts b/tests/boundary/mcp/androidPackageSummaryMcp.test.ts index f89de1b2e9..fa0bf5c094 100644 --- a/tests/boundary/mcp/androidPackageSummaryMcp.test.ts +++ b/tests/boundary/mcp/androidPackageSummaryMcp.test.ts @@ -1,3 +1,5 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -338,7 +340,7 @@ it.skipIf(process.platform === "win32")( ); expect(parent.operation).toBe("inspect_android_package"); expect(parent.parameters).toEqual({ path: apk }); - expect(view.artifact.sha256).toBe(parent.subject?.digest.sha256); + expect(view.artifact.sha256).toBe(fileIdentity(parent.subject).sha256); expect(view.artifact.sha256).not.toBe(report.engine.artifact_sha256); expect(receipt.evidence_id).not.toBe(parent.evidence_id); expect(receipt.evidence_links).toEqual([parent.evidence_id]); @@ -450,7 +452,7 @@ it("preserves partial manifest text and Unicode while rejecting missing APK iden createEvidence( hasSubject ? { path: "/original.apk", sha256: "a".repeat(64), format: "apk" } - : undefined, + : unknownTarget("not-observed"), { id: "jadx", name: "JADX", version: "0.7.1" }, { operation: "inspect_android_package", diff --git a/tests/boundary/mcp/applicationEvidenceMcp.test.ts b/tests/boundary/mcp/applicationEvidenceMcp.test.ts index e9a1bce2a1..287f092db5 100644 --- a/tests/boundary/mcp/applicationEvidenceMcp.test.ts +++ b/tests/boundary/mcp/applicationEvidenceMcp.test.ts @@ -1,3 +1,5 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import type { Client } from "@modelcontextprotocol/client"; @@ -35,7 +37,8 @@ async function runUnicodeSourceMapComparison( ): Promise { const baseApplication = SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE.application; const subject = baseApplication.subject; - if (subject === null) throw new Error("Application Evidence has no subject"); + if (subject.identity.kind !== "file") + throw new Error("Application Evidence has no subject"); const baseResult = javascriptApplicationAnalysisResultSchema.parse( baseApplication.normalized_result, ); @@ -81,8 +84,8 @@ async function runUnicodeSourceMapComparison( const unicodeApplication = createEvidence( { path: baseResult.input_path, - sha256: subject.digest.sha256, - format: subject.format, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, baseApplication.provider, { @@ -309,12 +312,12 @@ async function assertRejectedEvidenceReferences( session: BinarySession, ): Promise { const wrongOperation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inventory_artifact", parameters: {}, result: {} }, ); const wrongPredicate = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "fixture.application/v1", diff --git a/tests/boundary/mcp/artifactComparisonIntegrityMcp.test.ts b/tests/boundary/mcp/artifactComparisonIntegrityMcp.test.ts index f12040ffd7..b57b1d8aef 100644 --- a/tests/boundary/mcp/artifactComparisonIntegrityMcp.test.ts +++ b/tests/boundary/mcp/artifactComparisonIntegrityMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { expect, it, onTestFinished } from "vitest"; import { ARTIFACT_COMPARISON_EXAMPLE } from "../../../src/contracts/artifactComparisonExample.js"; @@ -12,7 +13,7 @@ it("rejects an unchanged artifact comparison that retains a changed row", async const left = ARTIFACT_COMPARISON_EXAMPLE.left; const right = ARTIFACT_COMPARISON_EXAMPLE.right; const comparison = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-artifact-comparison", name: "REA artifact comparison", @@ -89,7 +90,7 @@ it("does not fail a changed aggregate when source inventories are equal", async expect(equal.status).toBe("unchanged"); const changed = compareArtifacts(left, ARTIFACT_COMPARISON_EXAMPLE.right); const comparison = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-artifact-comparison", name: "REA artifact comparison", @@ -179,7 +180,7 @@ it("does not pass an unchanged aggregate over unavailable source coverage", asyn const actual = compareArtifacts(left, right); expect(actual.status).toBe("unknown"); const comparison = createEvidence( - undefined, + unknownTarget("derived-from-linked-evidence"), { id: "rea-artifact-comparison", name: "REA artifact comparison", diff --git a/tests/boundary/mcp/artifactMcp.inlineInventory.test.ts b/tests/boundary/mcp/artifactMcp.inlineInventory.test.ts index d4a608d6fc..5817ebf9b7 100644 --- a/tests/boundary/mcp/artifactMcp.inlineInventory.test.ts +++ b/tests/boundary/mcp/artifactMcp.inlineInventory.test.ts @@ -1,3 +1,5 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; +import { fileSubjectDisplay } from "../../fixtures/evidenceSubject.js"; import { canonicalInputSchema, withCanonicalOutputSchema, @@ -46,17 +48,15 @@ const assertInventorySubjectValidation = async ( .substeps[0]?.evidence.normalized_result : source.normalized_result; const inventory = artifactInventoryResultSchema.parse(result); - if (source.subject === null) - throw new Error("Fixture requires a known subject"); for (const target of [ - undefined, + unknownTarget("not-observed"), { - path: source.subject.local_path, + path: fileSubjectDisplay(source.subject).local_path, sha256: inventory.manifest.root_sha256, format: "file" as const, }, { - path: source.subject.local_path, + path: fileSubjectDisplay(source.subject).local_path, sha256: "f".repeat(64), format: inventory.manifest.root_format, }, diff --git a/tests/boundary/mcp/artifactMcp.test.ts b/tests/boundary/mcp/artifactMcp.test.ts index 2d5551b9db..f802ef16af 100644 --- a/tests/boundary/mcp/artifactMcp.test.ts +++ b/tests/boundary/mcp/artifactMcp.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { PROCESS_CAPTURE_REFERENCE, PROCESS_CAPTURE_RECONSTRUCTION, @@ -645,7 +649,7 @@ it("returns full artifact graphs inline and compares changed inventories", async if (evidence === undefined) throw new Error("missing inventory Evidence"); expect(evidence).toMatchObject({ provider: { id: "rea-artifact-graph" }, - subject: { format: "ipa" }, + subject: { identity: { format: "ipa" } }, }); const inventoryInspection = z .object({ @@ -917,12 +921,11 @@ const withForeignMetadataAndNestedZipMember = ( graphSha256, ); const subject = evidence.subject; - if (subject === null) throw new Error("missing inventory subject"); return createEvidence( { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + path: fileSubjectDisplay(subject).local_path, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, evidence.provider, { diff --git a/tests/boundary/mcp/batchDecompileViewsMcp.test.ts b/tests/boundary/mcp/batchDecompileViewsMcp.test.ts index 185bc945e2..fca88f6285 100644 --- a/tests/boundary/mcp/batchDecompileViewsMcp.test.ts +++ b/tests/boundary/mcp/batchDecompileViewsMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { withCanonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -612,7 +613,7 @@ it("reads historical batch Evidence with the prior null-pseudocode error", async limitations: [NO_BODY_REASON], } as const; const historical = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "batch_decompile", @@ -646,7 +647,7 @@ it("keeps the caller's own source when a page cannot fit, without retaining its pseudocode: body, }; const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "batch_decompile", @@ -889,7 +890,7 @@ it("binds views to their parent and each page to its own collection", async () = { kind: "inline", evidence: createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "batch_decompile", diff --git a/tests/boundary/mcp/batchSourcePublicationCleanup.test.ts b/tests/boundary/mcp/batchSourcePublicationCleanup.test.ts index 02a274a041..0fdcba46ce 100644 --- a/tests/boundary/mcp/batchSourcePublicationCleanup.test.ts +++ b/tests/boundary/mcp/batchSourcePublicationCleanup.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import type { CallToolResult } from "@modelcontextprotocol/server"; import { access, mkdir, rm, writeFile } from "node:fs/promises"; @@ -46,7 +47,7 @@ it("keeps a batch cleanup owner and its completed prefix after source retention owned = join(root, "owned"); await writeFile(target, Buffer.from([0xb8, 0, 0x4c, 0xcd, 0x21])); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "source", diff --git a/tests/boundary/mcp/batchSourcePublicationRecovery.test.ts b/tests/boundary/mcp/batchSourcePublicationRecovery.test.ts index cfc36f423d..4670b0926f 100644 --- a/tests/boundary/mcp/batchSourcePublicationRecovery.test.ts +++ b/tests/boundary/mcp/batchSourcePublicationRecovery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import pino from "pino"; import { expect, it, onTestFinished } from "vitest"; @@ -15,7 +16,7 @@ import { withAdmittedAnalysis } from "../../../src/server/analysisAdmission.js"; import { createToolResultDelivery } from "../../../src/server/toolResult.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; const provider = { id: "fixture", name: "Fixture", version: "1" }; -const source = createEvidence(undefined, provider, { +const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "source", diff --git a/tests/boundary/mcp/bundleComparisonCancellation.test.ts b/tests/boundary/mcp/bundleComparisonCancellation.test.ts index 285575ace4..c7069c96d7 100644 --- a/tests/boundary/mcp/bundleComparisonCancellation.test.ts +++ b/tests/boundary/mcp/bundleComparisonCancellation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -21,12 +22,12 @@ it("leaves the session unchanged after bundle comparison cancellation and permit const leftPath = join(root, "left.json"); const rightPath = join(root, "right.json"); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const left = createEvidence(undefined, provider, { + const left = createEvidence(unknownTarget("not-observed"), provider, { operation: "observation", parameters: { side: "left" }, result: { side: "left" }, }); - const right = createEvidence(undefined, provider, { + const right = createEvidence(unknownTarget("not-observed"), provider, { operation: "observation", parameters: { side: "right" }, result: { side: "right" }, @@ -46,7 +47,7 @@ it("leaves the session unchanged after bundle comparison cancellation and permit const session = createTestBinarySession(() => { throw new Error("Bundle comparison must not start a binary provider"); }); - const existing = createEvidence(undefined, provider, { + const existing = createEvidence(unknownTarget("not-observed"), provider, { operation: "existing_observation", parameters: {}, result: { retained: true }, diff --git a/tests/boundary/mcp/bundleComparisonMcp.test.ts b/tests/boundary/mcp/bundleComparisonMcp.test.ts index 212fdfa77d..932a60e12b 100644 --- a/tests/boundary/mcp/bundleComparisonMcp.test.ts +++ b/tests/boundary/mcp/bundleComparisonMcp.test.ts @@ -1,3 +1,5 @@ +import { displayedEvidenceSubject } from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { ok as resultOk } from "../../../src/domain/result.js"; import { writeFile } from "node:fs/promises"; @@ -25,7 +27,7 @@ import { observed } from "../../fixtures/analysisExecution.js"; const sourceEvidence = (label: string) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", @@ -62,11 +64,10 @@ describe("bundle comparison MCP semantic status", () => { const left = createEvidenceBundle([record]); const displayRecord = { ...record, - subject: { - ...record.subject!, + subject: displayedEvidenceSubject(record.subject, { name: "renamed.elf", local_path: join(root, "renamed.elf"), - }, + }), }; const displayOnly = { ...left, records: [displayRecord] }; const changedRecord = createEvidence( diff --git a/tests/boundary/mcp/callGraphCleanupIncomplete.test.ts b/tests/boundary/mcp/callGraphCleanupIncomplete.test.ts index c49e407464..35104d148a 100644 --- a/tests/boundary/mcp/callGraphCleanupIncomplete.test.ts +++ b/tests/boundary/mcp/callGraphCleanupIncomplete.test.ts @@ -385,7 +385,7 @@ it.each(tools)( const retained = await retainedPartial(client, session, error); expect(retained).toMatchObject({ operation: tool, - subject: { format: "dos-com" }, + subject: { identity: { format: "dos-com" } }, normalized_result: tool === "get_call_graph" ? { graph: { "0": [{ address: "0x1", status: "ok" }] } } diff --git a/tests/boundary/mcp/callPathSearchExtentMcp.test.ts b/tests/boundary/mcp/callPathSearchExtentMcp.test.ts index 5c0ff579c3..c57b33f76d 100644 --- a/tests/boundary/mcp/callPathSearchExtentMcp.test.ts +++ b/tests/boundary/mcp/callPathSearchExtentMcp.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { expect, it } from "vitest"; @@ -21,14 +25,12 @@ const observe = ( analysisProfile?: AnalysisProfileCommitment, ) => { const template = FUNCTION_COMPARISON_EXAMPLE.left; - if (template.subject === null) - throw new Error("Expected artifact-bound fixture"); const dossier = functionDossierSchema.parse(template.normalized_result); return createEvidence( { - path: template.subject.local_path, - sha256: template.subject.digest.sha256, - format: template.subject.format, + path: fileSubjectDisplay(template.subject).local_path, + sha256: fileIdentity(template.subject).sha256, + format: fileIdentity(template.subject).format, }, template.provider, { diff --git a/tests/boundary/mcp/commandObservationViews.test.ts b/tests/boundary/mcp/commandObservationViews.test.ts index aad99f126c..eb347cf581 100644 --- a/tests/boundary/mcp/commandObservationViews.test.ts +++ b/tests/boundary/mcp/commandObservationViews.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import pino from "pino"; import { expect, it, onTestFinished, vi } from "vitest"; @@ -44,7 +45,7 @@ const gdbEvidence = ( parameters = { session_id: sessionId, command: capture.command }, ) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gdb", name: "GDB", version: null }, { operation: "gdb_console", @@ -148,7 +149,7 @@ it("delivers ordered GDB records once and queries their retained parent after cl expect(parseEvidence(full.structuredContent)).toEqual(gdbEvidence()); const selected = parseEvidence(summary.structuredContent); expect(selected.raw_result).toBeNull(); - expect(selected.subject).toBeNull(); + expect(selected.subject.identity.kind).toBe("unknown"); expect(selected.normalized_result).toMatchObject({ parent_evidence_id: gdbEvidence().evidence_id, artifact: null, @@ -225,7 +226,7 @@ it("keeps pathless objdump observations subjectless and preserves the default co summary: parent.normalized_result, }); expect(summary.raw_result).toBeNull(); - expect(summary.subject).toBeNull(); + expect(summary.subject.identity.kind).toBe("unknown"); expect(ledger.get(parent.evidence_id)).toEqual(parent); }); @@ -263,11 +264,15 @@ it("rejects malformed historical GDB facts and conflicting source commands", asy }) ).ok, ).toBe(false); - const malformed = createEvidence(undefined, source.provider, { - operation: "gdb_console", - parameters: {}, - result: { ...capture, records: [123] }, - }); + const malformed = createEvidence( + unknownTarget("not-observed"), + source.provider, + { + operation: "gdb_console", + parameters: {}, + result: { ...capture, records: [123] }, + }, + ); expect( ( await inspectAnalysisView({ diff --git a/tests/boundary/mcp/comparisonUnknownsMcp.test.ts b/tests/boundary/mcp/comparisonUnknownsMcp.test.ts index 4f47530415..8874e78edc 100644 --- a/tests/boundary/mcp/comparisonUnknownsMcp.test.ts +++ b/tests/boundary/mcp/comparisonUnknownsMcp.test.ts @@ -1,3 +1,4 @@ +import { fileSubjectTarget } from "../../fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import { ARTIFACT_COMPARISON_EXAMPLE } from "../../../src/contracts/artifactComparisonExample.js"; @@ -33,13 +34,10 @@ const observeAgain = ( result = source.normalized_result, ) => createEvidence( - source.subject === null - ? undefined - : { - path: `/tmp/fixture-${observation}`, - sha256: source.subject.digest.sha256, - format: source.subject.format, - }, + { + ...fileSubjectTarget(source.subject), + path: `/tmp/fixture-${observation}`, + }, source.provider, { predicateType: source.predicate_type, diff --git a/tests/boundary/mcp/contractToolHandlerTargetContent.test.ts b/tests/boundary/mcp/contractToolHandlerTargetContent.test.ts index 0b6ed5169e..2788c69160 100644 --- a/tests/boundary/mcp/contractToolHandlerTargetContent.test.ts +++ b/tests/boundary/mcp/contractToolHandlerTargetContent.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { describe, expect, it, vi } from "vitest"; import type { @@ -41,7 +42,7 @@ const deliverPartialFailure = async (): Promise<{ readonly evidence: Evidence; }> => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Completed capture fixture", version: "1" }, { operation: "inspect_packet_capture", diff --git a/tests/boundary/mcp/dartAotSummaryMcp.test.ts b/tests/boundary/mcp/dartAotSummaryMcp.test.ts index f7374d4241..2e9e635d4b 100644 --- a/tests/boundary/mcp/dartAotSummaryMcp.test.ts +++ b/tests/boundary/mcp/dartAotSummaryMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -235,7 +236,7 @@ it("preserves null snapshot facts and pool lower bounds after exhaustion, reject ) => createEvidence( sha === null - ? undefined + ? unknownTarget("not-observed") : { path: "/source.apk", sha256: sha, format: "apk" }, { id: "flutter", name: "Flutter", version: null }, { diff --git a/tests/boundary/mcp/electronFusesMcp.test.ts b/tests/boundary/mcp/electronFusesMcp.test.ts index a9a62d33bb..d632b6bc24 100644 --- a/tests/boundary/mcp/electronFusesMcp.test.ts +++ b/tests/boundary/mcp/electronFusesMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -202,7 +203,7 @@ fuseMcpTest.for([ const evidence = toolContract("inspect_electron_fuses").outputSchema.parse( response.structuredContent, ); - expect(evidence.subject?.architecture).toBe(architecture); + expect(fileIdentity(evidence.subject).architecture).toBe(architecture); expect(evidence.normalized_result.slices).toMatchObject([ { architecture, diff --git a/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts b/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts index edf3dadb87..846d2edc69 100644 --- a/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts +++ b/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts @@ -126,7 +126,6 @@ describe("enhanced MCP graph caveats", () => { }); expect(graph.structuredContent).toMatchObject({ limitations: [ - expect.stringMatching(/artifact identity.*unavailable/iu), "Derived by an REA composed workflow.", `Fixture analysis provider (fixture 1) procedure_callees: ${caveat}`, `Fixture analysis provider (fixture 1) procedure_callees: ${leafCaveat}`, diff --git a/tests/boundary/mcp/enhancedTools.limitations.test.ts b/tests/boundary/mcp/enhancedTools.limitations.test.ts index f7e7bed861..c89f2d41a5 100644 --- a/tests/boundary/mcp/enhancedTools.limitations.test.ts +++ b/tests/boundary/mcp/enhancedTools.limitations.test.ts @@ -38,7 +38,6 @@ it("retains provider coverage caveats in a composed MCP overview without repeate expect(response.isError).not.toBe(true); const evidence = parseEvidence(response.structuredContent); expect(evidence.limitations).toEqual([ - expect.stringMatching(/artifact identity.*unavailable/iu), "Derived by an REA composed workflow.", `Fixture (fixture 1) current_document, list_procedures, list_segments, list_strings: ${limitation}`, ]); diff --git a/tests/boundary/mcp/errorEvidenceLifecycleMcp.test.ts b/tests/boundary/mcp/errorEvidenceLifecycleMcp.test.ts index a9d4d52e17..c6e4da02e6 100644 --- a/tests/boundary/mcp/errorEvidenceLifecycleMcp.test.ts +++ b/tests/boundary/mcp/errorEvidenceLifecycleMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { InMemoryTransport } from "@modelcontextprotocol/client"; import { isCallToolResult, @@ -60,7 +61,7 @@ const readBundle = async (path: string) => const authoredRecord = () => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Authored request publication fixture", @@ -103,7 +104,7 @@ it("publishes an oversized validation-error reference only after an earlier rese const checkpoint = join(root, "previous.json"); const exported = join(root, "current.json"); const previous = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Authored retained observation", version: "1" }, { operation: "fixture_observation", parameters: {}, result: true }, ); diff --git a/tests/boundary/mcp/evidenceBundleInline.test.ts b/tests/boundary/mcp/evidenceBundleInline.test.ts index 753b0a328d..517661a28f 100644 --- a/tests/boundary/mcp/evidenceBundleInline.test.ts +++ b/tests/boundary/mcp/evidenceBundleInline.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -114,7 +115,7 @@ it("preserves BOM recovery through public bundle import", async () => { it("returns the complete session Evidence bundle in the tool result", async () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", parameters: {}, result: { value: "seen" } }, ); @@ -260,7 +261,7 @@ const createBundleSourceSession = () => { result: { completed: true }, authority: "controlled-replay", }), - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: {}, @@ -317,8 +318,8 @@ const unsupportedBundleFields = ( ["provider manifest", ["providers", 0, "future_field"]], ["record subject", ["records", evidenceIndex, "subject", "future_field"]], [ - "subject digest", - ["records", evidenceIndex, "subject", "digest", "future_field"], + "subject identity", + ["records", evidenceIndex, "subject", "identity", "future_field"], ], ["artifact manifest", ["artifacts", 0, "future_field"]], [ diff --git a/tests/boundary/mcp/evidenceExportCancellation.test.ts b/tests/boundary/mcp/evidenceExportCancellation.test.ts index 2ea4195049..6f14d9c142 100644 --- a/tests/boundary/mcp/evidenceExportCancellation.test.ts +++ b/tests/boundary/mcp/evidenceExportCancellation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { readdir, readFile, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -19,7 +20,7 @@ it.each([false, true])( throw new Error("Evidence export must not start a binary provider"); }); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "large_observation", diff --git a/tests/boundary/mcp/evidenceImportCancellation.test.ts b/tests/boundary/mcp/evidenceImportCancellation.test.ts index 10492ff00f..62ecacae47 100644 --- a/tests/boundary/mcp/evidenceImportCancellation.test.ts +++ b/tests/boundary/mcp/evidenceImportCancellation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import type { ServerContext, ToolCallback } from "@modelcontextprotocol/server"; import { writeFile } from "node:fs/promises"; @@ -25,7 +26,7 @@ it("preserves the exact reason when import is cancelled after reading the bundle throw new Error("Evidence import must not start a binary provider"); }); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "imported_observation", @@ -87,14 +88,14 @@ it("keeps the complete session unchanged after SDK import cancellation and permi throw new Error("Evidence import must not start a binary provider"); }); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const existing = createEvidence(undefined, provider, { + const existing = createEvidence(unknownTarget("not-observed"), provider, { operation: "existing_observation", parameters: {}, result: { retained: true }, }); const recorded = session.recordEvidence(existing); if (!recorded.ok) throw recorded.error; - const imported = createEvidence(undefined, provider, { + const imported = createEvidence(unknownTarget("not-observed"), provider, { operation: "imported_observation", parameters: {}, result: { retained: "雪😀" }, @@ -212,12 +213,12 @@ it("retains a failed import close in the server scope through SDK error projecti throw new Error("Evidence import must not start a binary provider"); }); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const existing = createEvidence(undefined, provider, { + const existing = createEvidence(unknownTarget("not-observed"), provider, { operation: "existing_observation", parameters: {}, result: { retained: true }, }); - const imported = createEvidence(undefined, provider, { + const imported = createEvidence(unknownTarget("not-observed"), provider, { operation: "imported_observation", parameters: {}, result: { retained: "close failure" }, @@ -281,7 +282,7 @@ it("retries a transient import close failure before admitting the bundle", async throw new Error("Evidence import must not start a binary provider"); }); const imported = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "imported_observation", diff --git a/tests/boundary/mcp/evidenceImportLifecycle.test.ts b/tests/boundary/mcp/evidenceImportLifecycle.test.ts index bc70f3d73d..0669e7b79c 100644 --- a/tests/boundary/mcp/evidenceImportLifecycle.test.ts +++ b/tests/boundary/mcp/evidenceImportLifecycle.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -75,7 +76,7 @@ const connectImportSession = async () => { await client.connect(clientTransport); const importBundle = async (operation: string) => { const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation, parameters: {}, result: { retained: operation } }, ); diff --git a/tests/boundary/mcp/evidenceLinkInspectionMcp.test.ts b/tests/boundary/mcp/evidenceLinkInspectionMcp.test.ts index c26215d6c1..ed9e279145 100644 --- a/tests/boundary/mcp/evidenceLinkInspectionMcp.test.ts +++ b/tests/boundary/mcp/evidenceLinkInspectionMcp.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -275,13 +279,12 @@ it("pages selected link rows in a stable order without skips or duplicates", asy it("reports the source a composed workflow refuses, and clears it on import", async () => { const dossier = FUNCTION_COMPARISON_EXAMPLE.left; - if (dossier.subject === null) throw new Error("Expected a subject"); const health = record("get_project_health"); const linked = createEvidence( { - path: dossier.subject.local_path, - sha256: dossier.subject.digest.sha256, - format: dossier.subject.format, + path: fileSubjectDisplay(dossier.subject).local_path, + sha256: fileIdentity(dossier.subject).sha256, + format: fileIdentity(dossier.subject).format, }, dossier.provider, { diff --git a/tests/boundary/mcp/evidenceRetentionRecovery.test.ts b/tests/boundary/mcp/evidenceRetentionRecovery.test.ts index 338772e88e..c166abe475 100644 --- a/tests/boundary/mcp/evidenceRetentionRecovery.test.ts +++ b/tests/boundary/mcp/evidenceRetentionRecovery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { withCanonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -207,7 +208,7 @@ it("keeps an oversized unretained observation failure bounded and the connection it("bounds fallback when the retention error itself has oversized diagnostics", async () => { const records = new InvestigationRecords({ maximumRepresentationBytes: 0 }); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "address_name", parameters: {}, result: "entry" }, { immutable: true }, diff --git a/tests/boundary/mcp/evmInterfaceMcp.test.ts b/tests/boundary/mcp/evmInterfaceMcp.test.ts index 9505a7ba28..bb026d1254 100644 --- a/tests/boundary/mcp/evmInterfaceMcp.test.ts +++ b/tests/boundary/mcp/evmInterfaceMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -480,7 +481,7 @@ it.each(["valid", "wrong-subject", "no-subject"])( const { metadata: _metadata, ...historicalBytecode } = value.bytecode; const source = createEvidence( scenario === "no-subject" - ? undefined + ? unknownTarget("not-observed") : { path: value.artifact.path, sha256: diff --git a/tests/boundary/mcp/featureTraceViewsMcp.test.ts b/tests/boundary/mcp/featureTraceViewsMcp.test.ts index 42b6c4009e..e8508b3279 100644 --- a/tests/boundary/mcp/featureTraceViewsMcp.test.ts +++ b/tests/boundary/mcp/featureTraceViewsMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -141,13 +142,10 @@ it.each(["compact"] as const)( expect(summary.evidence.normalized_result).toMatchObject({ kind: "summary", parent_operation: "trace_application_feature", - artifact: - parent.subject === null - ? null - : { - path: parent.subject.local_path, - sha256: parent.subject.digest.sha256, - }, + artifact: { + path: parent.subject.local_path, + sha256: fileIdentity(parent.subject).sha256, + }, summary: { trace_id: full.trace_id, source_evidence_id: full.source_evidence_id, diff --git a/tests/boundary/mcp/fridaMcp.test.ts b/tests/boundary/mcp/fridaMcp.test.ts index 3345e75835..ca7c2367c2 100644 --- a/tests/boundary/mcp/fridaMcp.test.ts +++ b/tests/boundary/mcp/fridaMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -22,6 +23,8 @@ import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; import { parseMcpEvidenceBundle } from "../../fixtures/mcpEvidenceBundle.js"; import { createMcpSchemaValidation } from "../../fixtures/mcpSchemaValidation.js"; +const UNOBSERVED = unknownTarget("not-observed"); + const schemaValidation = createMcpSchemaValidation(); afterAll(() => schemaValidation.clear()); @@ -296,7 +299,7 @@ it("delivers Frida status summaries with complete retained Evidence for both tru expect(parseMcpEvidenceBundle(bundle).records).toContainEqual(parent); expect(session.evidenceById(parent.evidence_id)).toEqual(parent); // Inline/file projection validates the owning result and exact source selection. - const malformed = createEvidence(undefined, parent.provider ?? undefined, { + const malformed = createEvidence(UNOBSERVED, parent.provider ?? undefined, { operation: parent.operation, parameters: { session_id: "00000000-0000-4000-8000-000000000099" }, result: parent.normalized_result, diff --git a/tests/boundary/mcp/functionCallDirectionsMcp.test.ts b/tests/boundary/mcp/functionCallDirectionsMcp.test.ts index bd181aacdf..4c94db4c53 100644 --- a/tests/boundary/mcp/functionCallDirectionsMcp.test.ts +++ b/tests/boundary/mcp/functionCallDirectionsMcp.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { afterAll, expect, it } from "vitest"; import { createMcpSchemaValidation } from "../../fixtures/mcpSchemaValidation.js"; @@ -12,14 +16,12 @@ import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; const observe = (relationshipCoverage: RelationshipCoverage) => { const template = FUNCTION_COMPARISON_EXAMPLE.left; - if (template.subject === null) - throw new Error("Expected artifact-bound fixture"); const dossier = functionDossierSchema.parse(template.normalized_result); return createEvidence( { - path: template.subject.local_path, - sha256: template.subject.digest.sha256, - format: template.subject.format, + path: fileSubjectDisplay(template.subject).local_path, + sha256: fileIdentity(template.subject).sha256, + format: fileIdentity(template.subject).format, }, template.provider, { diff --git a/tests/boundary/mcp/functionComparisonCoverageMcp.test.ts b/tests/boundary/mcp/functionComparisonCoverageMcp.test.ts index 4c29ef5829..12acfea92a 100644 --- a/tests/boundary/mcp/functionComparisonCoverageMcp.test.ts +++ b/tests/boundary/mcp/functionComparisonCoverageMcp.test.ts @@ -1,9 +1,14 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { Ajv2020 } from "ajv/dist/2020.js"; import { expect, it } from "vitest"; import { FUNCTION_COMPARISON_EXAMPLE } from "../../../src/contracts/functionComparisonExample.js"; -import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; +import { + createEvidence, + parseEvidence, + evidenceSubjectInput, +} from "../../../src/domain/evidence.js"; import { functionDossierSchema } from "../../../src/domain/native/functionDossier.js"; import { jsonValueSchema } from "../../../src/domain/jsonValue.js"; import { createTestBinarySession } from "../../fixtures/binarySession.js"; @@ -17,13 +22,11 @@ const sourceWithCoverage = ( result: typeof template.normalized_result, relationshipCoverage: RelationshipCoverage, ) => { - if (template.subject === null) - throw new Error("Function comparison fixtures must be artifact-bound"); return createEvidence( { path: `${template.subject.local_path}/${observation}`, - sha256: template.subject.digest.sha256, - format: template.subject.format, + sha256: fileIdentity(template.subject).sha256, + format: fileIdentity(template.subject).format, }, template.provider, { @@ -111,24 +114,28 @@ const expectHistoricalDiscovery = async ( const current = functionComparisonResultSchema.parse( comparison.normalized_result, ); - const historical = createEvidence(undefined, comparison.provider, { - predicateType: comparison.predicate_type, - operation: comparison.operation, - parameters: comparison.parameters, - result: { - ...current, - dimensions: current.dimensions.map((dimension) => { - if (dimension.dimension !== "calls") return dimension; - const { discovery_status: _discovery, ...historicalDimension } = - dimension; - return { ...historicalDimension, limitations: [] }; - }), + const historical = createEvidence( + evidenceSubjectInput(comparison.subject), + comparison.provider, + { + predicateType: comparison.predicate_type, + operation: comparison.operation, + parameters: comparison.parameters, + result: { + ...current, + dimensions: current.dimensions.map((dimension) => { + if (dimension.dimension !== "calls") return dimension; + const { discovery_status: _discovery, ...historicalDimension } = + dimension; + return { ...historicalDimension, limitations: [] }; + }), + }, + confidence: comparison.confidence, + authority: comparison.authority, + limitations: comparison.limitations, + evidenceLinks: comparison.evidence_links, }, - confidence: comparison.confidence, - authority: comparison.authority, - limitations: comparison.limitations, - evidenceLinks: comparison.evidence_links, - }); + ); expect(session.recordEvidence(historical).ok).toBe(true); const prior = await verify( (name, arguments_) => client.callTool({ name, arguments: arguments_ }), @@ -533,14 +540,8 @@ it("keeps incomplete calls unknown through public comparison and verification wh FUNCTION_COMPARISON_EXAMPLE.left.normalized_result, { status: "unknown", reason: "Call graph unavailable." }, ); - expect(left.subject).not.toBeNull(); - expect(right.subject).not.toBeNull(); - expect(left.limitations).not.toContainEqual( - expect.stringMatching(/artifact identity.*unavailable/iu), - ); - expect(right.limitations).not.toContainEqual( - expect.stringMatching(/artifact identity.*unavailable/iu), - ); + expect(left.subject.identity.kind).toBe("file"); + expect(right.subject.identity.kind).toBe("file"); const compared = await client.callTool({ name: "compare_functions", arguments: { left, right }, diff --git a/tests/boundary/mcp/functionComparisonIntegrityMcp.test.ts b/tests/boundary/mcp/functionComparisonIntegrityMcp.test.ts index 3faaa0754f..8dd960b5cd 100644 --- a/tests/boundary/mcp/functionComparisonIntegrityMcp.test.ts +++ b/tests/boundary/mcp/functionComparisonIntegrityMcp.test.ts @@ -8,7 +8,11 @@ import { PROCESS_CAPTURE_RECONSTRUCTION, PROCESS_COMPARISON_EVIDENCE, } from "../../../src/contracts/investigationExamples.js"; -import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; +import { + createEvidence, + parseEvidence, + evidenceSubjectInput, +} from "../../../src/domain/evidence.js"; import { functionComparisonResultSchema, type FunctionComparisonResult, @@ -168,16 +172,20 @@ it.each([ async (scenario) => { const base = FUNCTION_COMPARISON_EVIDENCE; const result = functionComparisonResultSchema.parse(base.normalized_result); - const comparison = createEvidence(undefined, base.provider, { - predicateType: base.predicate_type, - operation: base.operation, - parameters: base.parameters, - result: scenario.result(result), - confidence: base.confidence, - authority: base.authority, - limitations: base.limitations, - evidenceLinks: base.evidence_links, - }); + const comparison = createEvidence( + evidenceSubjectInput(base.subject), + base.provider, + { + predicateType: base.predicate_type, + operation: base.operation, + parameters: base.parameters, + result: scenario.result(result), + confidence: base.confidence, + authority: base.authority, + limitations: base.limitations, + evidenceLinks: base.evidence_links, + }, + ); let providerLaunches = 0; const session = createTestBinarySession(() => { providerLaunches += 1; diff --git a/tests/boundary/mcp/functionComparisonMcp.test.ts b/tests/boundary/mcp/functionComparisonMcp.test.ts index fcd59d4cf3..82adb0c4a0 100644 --- a/tests/boundary/mcp/functionComparisonMcp.test.ts +++ b/tests/boundary/mcp/functionComparisonMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { Ajv2020 } from "ajv/dist/2020.js"; import type { AnySchema } from "ajv"; @@ -251,7 +252,7 @@ it.each([ const wrongKindFunctionEvidence = (mismatch: "operation" | "predicate") => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: @@ -476,17 +477,25 @@ it.each([ authority: "analyst-inference" as const, evidenceLinks: [left.evidence_id, right.evidence_id], }; - const consistent = createEvidence(undefined, provider, { - ...observation, - result: result, - }); + const consistent = createEvidence( + unknownTarget("derived-from-linked-evidence"), + provider, + { + ...observation, + result: result, + }, + ); const inconsistent = status === "unchanged" ? null - : createEvidence(undefined, provider, { - ...observation, - result: { ...result, status: "unchanged" }, - }); + : createEvidence( + unknownTarget("derived-from-linked-evidence"), + provider, + { + ...observation, + result: { ...result, status: "unchanged" }, + }, + ); const directory = await createTestTempDirectory("rea-function-status-"); const path = join(directory, "bundle.json"); await writeFile( diff --git a/tests/boundary/mcp/gdbCancellationMcp.test.ts b/tests/boundary/mcp/gdbCancellationMcp.test.ts index 7df48f8c5d..849400b493 100644 --- a/tests/boundary/mcp/gdbCancellationMcp.test.ts +++ b/tests/boundary/mcp/gdbCancellationMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; @@ -448,7 +449,7 @@ process.stdin.on("data", (chunk) => { it("records partial GDB Evidence from an MCP command error", async () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gnu.gdb", name: "GNU GDB", @@ -487,8 +488,7 @@ it("records partial GDB Evidence from an MCP command error", async () => { output_truncated: false, completion_status: "unknown", }, - subjectUnavailableReason: - "The debugger session does not identify an inferior.", + limitations: ["The debugger session does not identify an inferior."], }, ); expect( @@ -640,7 +640,7 @@ it("recovers only the owning debugger cleanup and reopens admitted analysis", as it("records partial GDB startup Evidence from an MCP start error", async () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gnu.gdb", name: "GNU GDB", @@ -676,8 +676,7 @@ it("records partial GDB startup Evidence from an MCP start error", async () => { output_truncated: false, completion_status: "unknown", }, - subjectUnavailableReason: - "No debugger session became ready before GDB exited.", + limitations: ["No debugger session became ready before GDB exited."], }, ); const manager = { diff --git a/tests/boundary/mcp/gdbRetirementCancellation.test.ts b/tests/boundary/mcp/gdbRetirementCancellation.test.ts index 3162e60d03..f5376077ed 100644 --- a/tests/boundary/mcp/gdbRetirementCancellation.test.ts +++ b/tests/boundary/mcp/gdbRetirementCancellation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import type { CallToolResult, McpServer } from "@modelcontextprotocol/server"; import { expect, it, vi } from "vitest"; import { phaseGate } from "../../support/lifecycleHarness.js"; @@ -44,7 +45,7 @@ it("compares cancellation before dispatch, during retirement, and an uncancelled expect((await session.open(target)).ok).toBe(true); const id = "00000000-0000-4000-8000-000000000001"; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gdb", name: "GDB", version: null }, { predicateType: "rea.debugger.command-observation", @@ -148,7 +149,7 @@ it.each(["completed", "failed"] as const)( expect((await session.open(target)).ok).toBe(true); const commandFailure = new AnalysisInputError("command"); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "gdb", name: "GDB", version: null }, { operation: "gdb_console", diff --git a/tests/boundary/mcp/goBinaryMcp.test.ts b/tests/boundary/mcp/goBinaryMcp.test.ts index 8132eb51ae..8141f67cd4 100644 --- a/tests/boundary/mcp/goBinaryMcp.test.ts +++ b/tests/boundary/mcp/goBinaryMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -113,7 +114,7 @@ mcpTest( const evidence = evidenceResultOf(goBinarySchema).parse( inspected.structuredContent, ); - expect(evidence.subject?.architecture).toBe("mips"); + expect(fileIdentity(evidence.subject).architecture).toBe("mips"); expect(evidence.normalized_result).toMatchObject({ architecture: "mips", bits: 32, diff --git a/tests/boundary/mcp/investigationAnalysisMcp.test.ts b/tests/boundary/mcp/investigationAnalysisMcp.test.ts index f1da542dee..fe68cacac1 100644 --- a/tests/boundary/mcp/investigationAnalysisMcp.test.ts +++ b/tests/boundary/mcp/investigationAnalysisMcp.test.ts @@ -1,3 +1,4 @@ +import { fileSubjectTarget } from "../../fixtures/evidenceSubject.js"; import { parseEvidence, createEvidence } from "../../../src/domain/evidence.js"; import { ok as resultOk } from "../../../src/domain/result.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; @@ -219,41 +220,29 @@ it("keeps call-path publication ahead of close_binary record draining", async () const dossierWithCallees = (addresses: readonly string[]) => { const base = FUNCTION_COMPARISON_EXAMPLE.left; - if (base.subject === null) throw new Error("missing dossier subject"); - return createEvidence( - { - path: base.subject.local_path, - sha256: base.subject.digest.sha256, - format: base.subject.format, - ...(base.subject.architecture === null - ? {} - : { architecture: base.subject.architecture }), + return createEvidence(fileSubjectTarget(base.subject), base.provider, { + predicateType: base.predicate_type, + operation: base.operation, + parameters: base.parameters, + result: { + ...jsonObjectSchema.parse(base.normalized_result), + callees: addresses.map((address) => ({ + address, + name: "next", + classification: null, + body: { + available: false, + reason: "The fixture has no callee body-extent observation.", + }, + })), }, - base.provider, - { - predicateType: base.predicate_type, - operation: base.operation, - parameters: base.parameters, - result: { - ...jsonObjectSchema.parse(base.normalized_result), - callees: addresses.map((address) => ({ - address, - name: "next", - classification: null, - body: { - available: false, - reason: "The fixture has no callee body-extent observation.", - }, - })), - }, - rawResult: base.raw_result, - confidence: base.confidence, - authority: base.authority, - limitations: base.limitations, - locations: base.locations, - evidenceLinks: base.evidence_links, - }, - ); + rawResult: base.raw_result, + confidence: base.confidence, + authority: base.authority, + limitations: base.limitations, + locations: base.locations, + evidenceLinks: base.evidence_links, + }); }; it.each([ @@ -336,7 +325,8 @@ it.each([ "preserves $label coverage through public analyze_function then build_call_path", async (scenario) => { const base = FUNCTION_COMPARISON_EXAMPLE.left; - if (base.subject === null) throw new Error("missing fixture subject"); + if (base.subject.identity.kind !== "file") + throw new Error("missing fixture subject"); const provider = { id: "fixture", name: "Fixture analysis provider", @@ -387,8 +377,10 @@ it.each([ provider, subject: { local_path: path, - digest: { sha256: session.activeTarget()?.sha256 }, - format: session.activeTarget()?.format, + identity: { + sha256: session.activeTarget()?.sha256, + format: session.activeTarget()?.format, + }, }, raw_result: rawResult, limitations: scenario.providerLimitations, @@ -651,11 +643,7 @@ it("keeps an aggregate function reconstruction unknown while a constituent dimen callees: { status: "complete" }, } as const; const left = createEvidence( - { - path: fixture.subject!.local_path, - sha256: fixture.subject!.digest.sha256, - format: fixture.subject!.format, - }, + fileSubjectTarget(fixture.subject), fixture.provider, { operation: fixture.operation, diff --git a/tests/boundary/mcp/investigationEvidenceReferencesMcp.test.ts b/tests/boundary/mcp/investigationEvidenceReferencesMcp.test.ts index 8a328e95d1..ad66987649 100644 --- a/tests/boundary/mcp/investigationEvidenceReferencesMcp.test.ts +++ b/tests/boundary/mcp/investigationEvidenceReferencesMcp.test.ts @@ -1,3 +1,7 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; import { mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; @@ -83,13 +87,12 @@ it("admits an independent inline dossier and composes its summary parent without it("keeps input capacity limits while composing dossiers that cannot be resent inline", async () => { const { session, client } = await harness("1024"); const base = FUNCTION_COMPARISON_EXAMPLE.left; - if (base.subject === null) throw new Error("Missing fixture subject"); const dossier = functionDossierSchema.parse(base.normalized_result); const source = createEvidence( { - path: base.subject.local_path, - sha256: base.subject.digest.sha256, - format: base.subject.format, + path: fileSubjectDisplay(base.subject).local_path, + sha256: fileIdentity(base.subject).sha256, + format: fileIdentity(base.subject).format, }, base.provider, { @@ -214,16 +217,15 @@ it("reports missing sources for a retained dossier with a large link set", async }), ); const base = FUNCTION_COMPARISON_EXAMPLE.left; - if (base.subject === null) throw new Error("Missing fixture subject"); const links = Array.from( { length: 150_000 }, (_, index) => `ev_${index.toString(16).padStart(64, "0")}`, ); const source = createEvidence( { - path: base.subject.local_path, - sha256: base.subject.digest.sha256, - format: base.subject.format, + path: fileSubjectDisplay(base.subject).local_path, + sha256: fileIdentity(base.subject).sha256, + format: fileIdentity(base.subject).format, }, base.provider, { diff --git a/tests/boundary/mcp/kernelModuleMcp.test.ts b/tests/boundary/mcp/kernelModuleMcp.test.ts index d423d316f2..f94ca81927 100644 --- a/tests/boundary/mcp/kernelModuleMcp.test.ts +++ b/tests/boundary/mcp/kernelModuleMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { writeFile } from "node:fs/promises"; import { Ajv2020 } from "ajv/dist/2020.js"; @@ -112,7 +113,7 @@ mcpTest( machine: 20, applicability: "applicable", }); - expect(evidence.subject?.architecture).toBe("powerpc"); + expect(fileIdentity(evidence.subject).architecture).toBe("powerpc"); expect(evidence.normalized_result.modinfo?.entries[0]).toMatchObject({ key: "license", value: "GPL", diff --git a/tests/boundary/mcp/largeToolResult.test.ts b/tests/boundary/mcp/largeToolResult.test.ts index f3d141119c..6c6ecd7b0c 100644 --- a/tests/boundary/mcp/largeToolResult.test.ts +++ b/tests/boundary/mcp/largeToolResult.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { Ajv2020 } from "ajv/dist/2020.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; @@ -303,7 +304,7 @@ describe("large complete Evidence MCP delivery", () => { }); it("does not claim retention without a recording acknowledgment", () => { - const evidence = createEvidence(undefined, provider, { + const evidence = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_pseudo_code", parameters: {}, result: "x".repeat(Math.ceil(STDIO_DEFAULT_MAX_BUFFER_SIZE / 2)), diff --git a/tests/boundary/mcp/managedArtifactSummaryMcp.test.ts b/tests/boundary/mcp/managedArtifactSummaryMcp.test.ts index f1e1df47f2..1ccbc374ed 100644 --- a/tests/boundary/mcp/managedArtifactSummaryMcp.test.ts +++ b/tests/boundary/mcp/managedArtifactSummaryMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -166,13 +167,17 @@ it("keeps malformed metadata, empty returned rows and historical null subjects e parent.normalized_result, ); expect(report.metadata.status).toBe("malformed"); - const historical = createEvidence(undefined, parent.provider, { - operation: parent.operation, - parameters: parent.parameters, - result: parent.normalized_result, - limitations: parent.limitations, - authority: parent.authority, - }); + const historical = createEvidence( + unknownTarget("not-observed"), + parent.provider, + { + operation: parent.operation, + parameters: parent.parameters, + result: parent.normalized_result, + limitations: parent.limitations, + authority: parent.authority, + }, + ); const original = JSON.stringify(historical); for (const view of [ { kind: "summary" }, @@ -183,7 +188,7 @@ it("keeps malformed metadata, empty returned rows and historical null subjects e view, }); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); const projected = analysisViewResultSchema.parse( result.value.normalized_result, ); diff --git a/tests/boundary/mcp/managedMcp.test.ts b/tests/boundary/mcp/managedMcp.test.ts index e0f5552c75..a3c768d778 100644 --- a/tests/boundary/mcp/managedMcp.test.ts +++ b/tests/boundary/mcp/managedMcp.test.ts @@ -110,7 +110,7 @@ it("runs every managed static inspection independently of an active native targe expect(artifact).toMatchObject({ operation: "inspect_managed_artifact", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, }); const misspelledPath = await client.callTool({ name: "inspect_managed_members", @@ -142,7 +142,7 @@ it("runs every managed static inspection independently of an active native targe expect(members).toMatchObject({ operation: "inspect_managed_members", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, }); const otherArtifact = structured( await client.callTool({ @@ -151,14 +151,14 @@ it("runs every managed static inspection independently of an active native targe }), ); expect(otherArtifact).toMatchObject({ - subject: { local_path: otherPath, format: "pe" }, + subject: { local_path: otherPath, identity: { format: "pe" } }, }); const reusedOtherTarget = structured( await client.callTool({ name: "inspect_managed_members", arguments: {} }), ); expect(reusedOtherTarget).toMatchObject({ operation: "inspect_managed_members", - subject: { local_path: otherPath, format: "pe" }, + subject: { local_path: otherPath, identity: { format: "pe" } }, }); await verifyManagedTypeSelection(client, path, otherPath); const boundaries = structured( @@ -170,7 +170,7 @@ it("runs every managed static inspection independently of an active native targe expect(boundaries).toMatchObject({ operation: "inspect_managed_native_boundaries", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, }); const partial = structured( await client.callTool({ @@ -179,7 +179,7 @@ it("runs every managed static inspection independently of an active native targe }), ); expect(partial).toMatchObject({ - subject: { local_path: partialPath, format: "pe" }, + subject: { local_path: partialPath, identity: { format: "pe" } }, normalized_result: { methods: [ { @@ -402,7 +402,7 @@ const inspectManagedStaticWorkflow = async ( expect(inlineEvidence(inspected)).toMatchObject({ operation: "inspect_managed_artifact", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, }); const members = inlineEvidence( structured( @@ -416,7 +416,7 @@ const inspectManagedStaticWorkflow = async ( expect(members).toMatchObject({ operation: "inspect_managed_members", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, normalized_result: { identity_scope: { token_identity: "build-local" }, methods: [expect.objectContaining({ token: expect.any(String) })], @@ -622,7 +622,7 @@ const verifyManagedTypeSelection = async ( }), ); expect(reselectedOtherTarget).toMatchObject({ - subject: { local_path: otherPath, format: "pe" }, + subject: { local_path: otherPath, identity: { format: "pe" } }, }); }; diff --git a/tests/boundary/mcp/managedMemberSummaryMcp.test.ts b/tests/boundary/mcp/managedMemberSummaryMcp.test.ts index e2ca9f8140..36d128c831 100644 --- a/tests/boundary/mcp/managedMemberSummaryMcp.test.ts +++ b/tests/boundary/mcp/managedMemberSummaryMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -338,13 +339,17 @@ it("keeps collections that member Evidence never examined unknown", async () => call_edges: [], field_accesses: [], }; - const unexamined = createEvidence(undefined, parent.provider, { - operation: parent.operation, - parameters: parent.parameters, - result: recorded, - limitations: parent.limitations, - authority: parent.authority, - }); + const unexamined = createEvidence( + unknownTarget("not-observed"), + parent.provider, + { + operation: parent.operation, + parameters: parent.parameters, + result: recorded, + limitations: parent.limitations, + authority: parent.authority, + }, + ); const summary = await inspectAnalysisView({ source: { kind: "inline", evidence: unexamined }, view: { kind: "summary" }, @@ -444,7 +449,7 @@ it("binds managed member views to their recorded token scope", async () => { format: "pe", sha256: report.artifact.sha256, } - : undefined, + : unknownTarget("not-observed"), original.provider, { operation: original.operation, @@ -518,17 +523,21 @@ it("rejects a contradictory managed token scope through MCP for inline and retai const report = managedMemberInspectionSchema.parse( original.normalized_result, ); - const evidence = createEvidence(undefined, original.provider, { - operation: original.operation, - parameters: original.parameters, - result: { - ...report, - identity_scope: { - ...report.identity_scope, - requires_artifact_sha256: "f".repeat(64), + const evidence = createEvidence( + unknownTarget("not-observed"), + original.provider, + { + operation: original.operation, + parameters: original.parameters, + result: { + ...report, + identity_scope: { + ...report.identity_scope, + requires_artifact_sha256: "f".repeat(64), + }, }, }, - }); + ); const { client, session } = await createHarness(); expect(session.recordEvidence(evidence).ok).toBe(true); for (const source of [ diff --git a/tests/boundary/mcp/managedNativeVerificationAdapters.test.ts b/tests/boundary/mcp/managedNativeVerificationAdapters.test.ts index 67affdb330..43bfa59376 100644 --- a/tests/boundary/mcp/managedNativeVerificationAdapters.test.ts +++ b/tests/boundary/mcp/managedNativeVerificationAdapters.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect } from "vitest"; @@ -36,7 +37,7 @@ cliTest( const source = createEvidence( variant === "subject-sha256" ? { path: members.artifact.path, format: "pe", sha256: otherDigest } - : undefined, + : unknownTarget("not-observed"), original.provider, { operation: original.operation, diff --git a/tests/boundary/mcp/managedWorkflowUnknownIdentityMcp.test.ts b/tests/boundary/mcp/managedWorkflowUnknownIdentityMcp.test.ts index 9e1d2cd3d8..5c06471e16 100644 --- a/tests/boundary/mcp/managedWorkflowUnknownIdentityMcp.test.ts +++ b/tests/boundary/mcp/managedWorkflowUnknownIdentityMcp.test.ts @@ -1,3 +1,9 @@ +import { + fileIdentity, + fileSubjectTarget, + fileSubjectArchitecture, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { expect, it, onTestFinished } from "vitest"; import { @@ -18,17 +24,15 @@ import { createTestBinarySession } from "../../fixtures/binarySession.js"; const emptyExportEvidence = () => { const original = MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0]; - if (original === undefined || original.subject === null) + if (original === undefined) throw new Error("Managed verification example is missing native Evidence"); const result = inspectMachoSchema.parse(original.normalized_result); return createEvidence( { path: "/fixtures/empty-exports.dylib", sha256: "8".repeat(64), - format: original.subject.format, - ...(original.subject.architecture === null - ? {} - : { architecture: original.subject.architecture }), + format: fileIdentity(original.subject).format, + ...fileSubjectArchitecture(original.subject), }, original.provider, { @@ -60,7 +64,7 @@ const secondDeclaration = () => { const pinvoke = pinvokes[0]; if (pinvoke === undefined) throw new Error("Managed verification example has invalid P/Invoke data"); - return createEvidence(undefined, original.provider, { + return createEvidence(unknownTarget("not-observed"), original.provider, { operation: "inspect_managed_native_boundaries", parameters: original.parameters, result: { @@ -146,16 +150,20 @@ it("records a residual question for partial verification with zero item counts", const report = managedNativeBoundaryInspectionSchema.parse( original.normalized_result, ); - const managed = createEvidence(undefined, original.provider, { - operation: "inspect_managed_native_boundaries", - parameters: {}, - result: { - ...report, - pinvoke_imports: [], - native_implementations: [], - coverage: { state: "partial", issues: [] }, + const managed = createEvidence( + unknownTarget("not-observed"), + original.provider, + { + operation: "inspect_managed_native_boundaries", + parameters: {}, + result: { + ...report, + pinvoke_imports: [], + native_implementations: [], + coverage: { state: "partial", issues: [] }, + }, }, - }); + ); const response = await harness.client.callTool({ name: "verify_managed_native_boundaries", arguments: { @@ -184,14 +192,13 @@ it("retains partial native export coverage after an observed match", async () => }); onTestFinished(harness.close); const original = MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0]; - if (original === undefined || original.subject === null) + if (original === undefined) throw new Error("Managed verification example is missing native Evidence"); const report = inspectMachoSchema.parse(original.normalized_result); const native = createEvidence( { + ...fileSubjectTarget(original.subject), path: original.subject.local_path!, - sha256: original.subject.digest.sha256, - format: original.subject.format, }, original.provider, { diff --git a/tests/boundary/mcp/mobileApplicationGraphMcp.test.ts b/tests/boundary/mcp/mobileApplicationGraphMcp.test.ts index a9830916b9..36cabc276f 100644 --- a/tests/boundary/mcp/mobileApplicationGraphMcp.test.ts +++ b/tests/boundary/mcp/mobileApplicationGraphMcp.test.ts @@ -1,3 +1,8 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { projectCliAnalysisResult } from "../../../src/cli/projectCliAnalysisResult.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -187,12 +192,11 @@ it("projects a single inventory page as partial and links only that source", asy inventory.normalized_result, ); const subject = inventory.subject; - if (subject === null) throw new Error("Expected an inventory subject"); const page = createEvidence( { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + path: fileSubjectDisplay(subject).local_path, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, inventory.provider, { @@ -277,7 +281,7 @@ it("projects a single inventory page as partial and links only that source", asy it("rejects a valid non-inventory carrier as caller-selected input", async () => { const client = await connect(); const wrongCarrier = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "analyze_binary", parameters: {}, result: {} }, ); diff --git a/tests/boundary/mcp/nativeFeatureTraceViews.test.ts b/tests/boundary/mcp/nativeFeatureTraceViews.test.ts index 339dafee30..0ac3e25756 100644 --- a/tests/boundary/mcp/nativeFeatureTraceViews.test.ts +++ b/tests/boundary/mcp/nativeFeatureTraceViews.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { join } from "node:path"; import { expect, it } from "vitest"; import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; @@ -29,7 +30,7 @@ it.each(["compact"] as const)( async (profile) => { const result = traceFixture(); const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-workflow", name: "REA workflow", version: "1" }, { operation: "trace_feature", diff --git a/tests/boundary/mcp/nativeInstructionReferencesView.test.ts b/tests/boundary/mcp/nativeInstructionReferencesView.test.ts index 3eea7f9c7e..64a6864898 100644 --- a/tests/boundary/mcp/nativeInstructionReferencesView.test.ts +++ b/tests/boundary/mcp/nativeInstructionReferencesView.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -285,7 +286,7 @@ it.each(["compact"] as const)( it("recovers the complete parent when a single reference exceeds the page budget", async () => { const oversized = { ...row, type: "x".repeat(1024 * 1024) }; - const parent = createEvidence(undefined, provider, { + const parent = createEvidence(unknownTarget("not-observed"), provider, { operation: "inspect_native_instruction", parameters: { address: "0x1000" }, result: { ...instruction("rows"), incoming_references: [row, oversized] }, diff --git a/tests/boundary/mcp/nativeInventoryViewsMcp.test.ts b/tests/boundary/mcp/nativeInventoryViewsMcp.test.ts index 601bae3d47..0b1b6eb8f8 100644 --- a/tests/boundary/mcp/nativeInventoryViewsMcp.test.ts +++ b/tests/boundary/mcp/nativeInventoryViewsMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -312,7 +313,7 @@ it("projects imported inventories with an unknown artifact without inventing a p throw new Error("Retained views must not open a provider"); }); const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "borrowed.native", name: "Borrowed engine", version: "1" }, { operation: "list_procedures", @@ -351,7 +352,9 @@ it("projects imported inventories with an unknown artifact without inventing a p if (reply.isError) throw new Error(JSON.stringify(reply)); const evidence = parseEvidence(reply.structuredContent); expect(evidence).toMatchObject({ - subject: null, + subject: { + identity: { kind: "unknown", reason: "derived-from-linked-evidence" }, + }, locations: [], evidence_links: [source.evidence_id], normalized_result: { diff --git a/tests/boundary/mcp/nativeMachoSummaryMcp.test.ts b/tests/boundary/mcp/nativeMachoSummaryMcp.test.ts index 9f76a0c2cd..9cbe5425a8 100644 --- a/tests/boundary/mcp/nativeMachoSummaryMcp.test.ts +++ b/tests/boundary/mcp/nativeMachoSummaryMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { copyFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -150,7 +151,7 @@ mcpTest( const { empty, segment, dependency, command, report } = binaryUncertainFixture(); const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_macho", @@ -231,7 +232,7 @@ mcpTest( sections: empty, }; const historical = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_macho", @@ -312,7 +313,7 @@ mcpTest( limitations: [], }); const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inspect_macho", diff --git a/tests/boundary/mcp/nativeProcedureReferenceViews.test.ts b/tests/boundary/mcp/nativeProcedureReferenceViews.test.ts index f5c0753f90..f9c63ac151 100644 --- a/tests/boundary/mcp/nativeProcedureReferenceViews.test.ts +++ b/tests/boundary/mcp/nativeProcedureReferenceViews.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { join } from "node:path"; import { expect, it } from "vitest"; import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; @@ -57,7 +58,7 @@ it.each(["compact"] as const)( "pages procedure reference Evidence across a %s offline handoff", async (profile) => { const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "procedure_references", @@ -203,12 +204,12 @@ it("bounds a requested page by bytes and keeps oversized-row recovery available" kind: { available: false as const, reason: largeReason }, })); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const parent = createEvidence(undefined, provider, { + const parent = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_references", parameters: {}, result: { ...fixture, references: rows }, }); - const oversize = createEvidence(undefined, provider, { + const oversize = createEvidence(unknownTarget("not-observed"), provider, { operation: "procedure_references", parameters: {}, result: { diff --git a/tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts b/tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts index e8ea4d756d..8d1b137a98 100644 --- a/tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts +++ b/tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts @@ -177,7 +177,7 @@ it.each(["mach-o", "mach-o-universal"] as const)( JSON.stringify(inspected.structuredContent), ).not.toBe(true); expect(inspected.structuredContent).toMatchObject({ - subject: { format }, + subject: { identity: { kind: "file", format } }, normalized_result: { signed: true, identifier: "com.example.fixture" }, }); } finally { diff --git a/tests/boundary/mcp/nativeValueTraceCleanupIncomplete.test.ts b/tests/boundary/mcp/nativeValueTraceCleanupIncomplete.test.ts index b5ca5bed77..63e97cf73d 100644 --- a/tests/boundary/mcp/nativeValueTraceCleanupIncomplete.test.ts +++ b/tests/boundary/mcp/nativeValueTraceCleanupIncomplete.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -291,7 +292,7 @@ it("keeps the stopped trace and source-publication failure together", async () = const { port } = failingDiamond({ "analyze_function:0x2000": childFailure("analyze_function", true), }); - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "analyze_function", parameters: { procedure: "0x1000" }, result: { source: "observed" }, @@ -368,7 +369,7 @@ it("retains the admitted trace and its completed sources as session Evidence", a const retained = session.evidenceForAnalysis(reference.evidence_id); expect(retained).toMatchObject({ operation: "trace_native_values", - subject: { format: "dos-com" }, + subject: { identity: { format: "dos-com" } }, }); expect( nativeValueTraceSchema.parse(retained?.normalized_result).traversal, diff --git a/tests/boundary/mcp/nativeViewPredicateMcp.test.ts b/tests/boundary/mcp/nativeViewPredicateMcp.test.ts index 66826e49d9..257592187a 100644 --- a/tests/boundary/mcp/nativeViewPredicateMcp.test.ts +++ b/tests/boundary/mcp/nativeViewPredicateMcp.test.ts @@ -1,3 +1,5 @@ +import { fileSubjectTarget } from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -20,13 +22,7 @@ import { createMcpSchemaValidation } from "../../fixtures/mcpSchemaValidation.js import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; const fixture = FUNCTION_COMPARISON_EXAMPLE.left; -if (fixture.subject === null) - throw new Error("Expected artifact-bound fixture"); -const subject = { - path: fixture.subject.local_path, - sha256: fixture.subject.digest.sha256, - format: fixture.subject.format, -}; +const subject = fileSubjectTarget(fixture.subject); const selected = ( operation: string, result: Evidence["normalized_result"], @@ -42,7 +38,7 @@ const selected = ( }); const wrongMatchingPredicate = (matching: Evidence) => - createEvidence(undefined, matching.provider, { + createEvidence(unknownTarget("not-observed"), matching.provider, { operation: matching.operation, parameters: matching.parameters, result: matching.normalized_result, diff --git a/tests/boundary/mcp/observationPartialEvidenceDelivery.test.ts b/tests/boundary/mcp/observationPartialEvidenceDelivery.test.ts index fddf480046..d6aaceb44c 100644 --- a/tests/boundary/mcp/observationPartialEvidenceDelivery.test.ts +++ b/tests/boundary/mcp/observationPartialEvidenceDelivery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { afterEach, expect, it } from "vitest"; @@ -32,7 +33,7 @@ it.each(operations)( })); const makeEvidence = (operation: ObservationOperation): Evidence => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "observation-fixture", name: "Observation fixture", diff --git a/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts b/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts index d57477c8b1..3909537c1c 100644 --- a/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts +++ b/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { createHash } from "node:crypto"; @@ -218,7 +219,7 @@ mcpTest( }; const evidence = (result: JsonValue) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "ghidra", name: "Controlled bridge result", version: "12.1.4" }, { operation: contract.name, parameters: {}, result }, ); diff --git a/tests/boundary/mcp/packetCaptureMcp.test.ts b/tests/boundary/mcp/packetCaptureMcp.test.ts index cb3d5381b5..f30f3a3d09 100644 --- a/tests/boundary/mcp/packetCaptureMcp.test.ts +++ b/tests/boundary/mcp/packetCaptureMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { createEvidence } from "../../../src/domain/evidence.js"; import { AnalysisCancelledError } from "../../../src/domain/analysisErrorCore.js"; @@ -68,7 +69,7 @@ it.each(["cancelled", "cleanup"])( fields: ["ip.addr"], }; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Completed capture fixture", version: "1" }, { operation: "inspect_packet_capture", diff --git a/tests/boundary/mcp/processComparisonDiagnosticsMcp.test.ts b/tests/boundary/mcp/processComparisonDiagnosticsMcp.test.ts index 9b5903bd4f..5bbdb20c78 100644 --- a/tests/boundary/mcp/processComparisonDiagnosticsMcp.test.ts +++ b/tests/boundary/mcp/processComparisonDiagnosticsMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -39,7 +40,7 @@ const captureEvidence = ( EMPTY_PROCESS_CAPTURE_EXAMPLE, ), ) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, @@ -451,11 +452,15 @@ it("rejects a deep trace cycle as an input error through CLI and MCP", async () it("names the side and constraint when Evidence is not a usable capture", async () => { const client = await connect(); const capture = captureEvidence("right"); - const unrelated = createEvidence(undefined, PROCESS_PROVIDER, { - operation: "other", - parameters: {}, - result: {}, - }); + const unrelated = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + operation: "other", + parameters: {}, + result: {}, + }, + ); const wrongKind = await client.callTool({ name: "compare_process_captures", arguments: { left: unrelated, right: capture }, @@ -526,12 +531,16 @@ it("names the side and constraint when Evidence is not a usable capture", async const rightPath = join(root, "right.json"); await writeFile(leftPath, JSON.stringify(capture)); for (const { result, issuePath } of invalidCaptures) { - const invalidResult = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: result, - }); + const invalidResult = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: result, + }, + ); expect(parseEvidence(invalidResult)).toEqual(invalidResult); const malformed = await client.callTool({ name: "compare_process_captures", @@ -570,24 +579,28 @@ it("keeps structural capture issues alongside semantic ones through MCP and the exit, ...rest } = FINALIZED_PROCESS_CAPTURE_EXAMPLE; - const mixed = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: { - ...rest, - manifest, - exit: { - ...exit, - finalization: { - ...exit.finalization, - signals: [ - { ...exit.finalization.signals[0], reason: "not allowed here" }, - ], + const mixed = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: { + ...rest, + manifest, + exit: { + ...exit, + finalization: { + ...exit.finalization, + signals: [ + { ...exit.finalization.signals[0], reason: "not allowed here" }, + ], + }, }, }, }, - }); + ); const response = await client.callTool({ name: "compare_process_captures", arguments: { left: capture, right: mixed }, diff --git a/tests/boundary/mcp/processComparisonVerificationMcp.test.ts b/tests/boundary/mcp/processComparisonVerificationMcp.test.ts index 5f23638e65..f872213b29 100644 --- a/tests/boundary/mcp/processComparisonVerificationMcp.test.ts +++ b/tests/boundary/mcp/processComparisonVerificationMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -19,7 +20,7 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; it("rejects an inconsistent imported process comparison while retaining its Evidence", async () => { const dimension = "terminal" as const; const source = (side: string) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, @@ -41,22 +42,26 @@ it("rejects an inconsistent imported process comparison while retaining its Evid ); expect(nativeResult.status).toBe("unchanged"); const comparison = (status: "unchanged" | "contradiction") => - createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-comparison", - operation: "compare_process_captures", - parameters: { - left_evidence_id: left.evidence_id, - right_evidence_id: right.evidence_id, + createEvidence( + unknownTarget("derived-from-linked-evidence"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-comparison", + operation: "compare_process_captures", + parameters: { + left_evidence_id: left.evidence_id, + right_evidence_id: right.evidence_id, + }, + result: { + ...nativeResult, + [dimension]: "contradiction", + status, + }, + confidence: "derived", + authority: "analyst-inference", + evidenceLinks: [left.evidence_id, right.evidence_id], }, - result: { - ...nativeResult, - [dimension]: "contradiction", - status, - }, - confidence: "derived", - authority: "analyst-inference", - evidenceLinks: [left.evidence_id, right.evidence_id], - }); + ); const inconsistent = comparison("unchanged"); const consistent = comparison("contradiction"); const root = await createTestTempDirectory("rea-process-verification-"); @@ -166,7 +171,7 @@ it("keeps omitted rendered observations unknown through trace comparison and imp ], }); const source = (side: string) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, diff --git a/tests/boundary/mcp/processEvidenceIdentityMcp.test.ts b/tests/boundary/mcp/processEvidenceIdentityMcp.test.ts index 8fbbceaef6..8f8d2989c8 100644 --- a/tests/boundary/mcp/processEvidenceIdentityMcp.test.ts +++ b/tests/boundary/mcp/processEvidenceIdentityMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -19,6 +20,7 @@ import { createEvidence, parseEvidence, type Evidence, + evidenceSubjectInput, } from "../../../src/domain/evidence.js"; import { createEvidenceBundle } from "../../../src/domain/evidenceBundle.js"; import { correlateStaticAndRuntime } from "../../../src/domain/staticRuntimeCorrelation.js"; @@ -36,7 +38,7 @@ const captureEvidence = ( side: "left" | "right", result: Evidence["normalized_result"] = EMPTY_PROCESS_CAPTURE_EXAMPLE, ) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, @@ -212,33 +214,19 @@ const rehashedComparison = ( change: IdentityChange, ): Evidence => { const next = { ...base, ...change }; - const subject = next.subject; - return createEvidence( - subject === null - ? undefined - : { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, - ...(subject.architecture === null - ? {} - : { architecture: subject.architecture }), - }, - next.provider, - { - predicateType: next.predicate_type, - operation: next.operation, - parameters: next.parameters, - result: next.normalized_result, - rawResult: next.raw_result, - confidence: next.confidence, - authority: next.authority, - environment: next.environment, - limitations: next.limitations, - locations: next.locations, - evidenceLinks: next.evidence_links, - }, - ); + return createEvidence(evidenceSubjectInput(next.subject), next.provider, { + predicateType: next.predicate_type, + operation: next.operation, + parameters: next.parameters, + result: next.normalized_result, + rawResult: next.raw_result, + confidence: next.confidence, + authority: next.authority, + environment: next.environment, + limitations: next.limitations, + locations: next.locations, + evidenceLinks: next.evidence_links, + }); }; it.each(providerNames)( diff --git a/tests/boundary/mcp/processTraceAdaptersParity.test.ts b/tests/boundary/mcp/processTraceAdaptersParity.test.ts index 8562a1e584..ab407c2b54 100644 --- a/tests/boundary/mcp/processTraceAdaptersParity.test.ts +++ b/tests/boundary/mcp/processTraceAdaptersParity.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { ok as resultOk } from "../../../src/domain/result.js"; import { rm, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -22,7 +23,7 @@ const temporaryRoots: string[] = []; const { capture, traceSpecification } = processTraceCaptureFixture(); const captureEvidence = (side: "left" | "right") => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: { side }, diff --git a/tests/boundary/mcp/promptCompletion.test.ts b/tests/boundary/mcp/promptCompletion.test.ts index 6efd2fc77f..e122fd079f 100644 --- a/tests/boundary/mcp/promptCompletion.test.ts +++ b/tests/boundary/mcp/promptCompletion.test.ts @@ -1,3 +1,8 @@ +import { + fileIdentity, + fileSubjectDisplay, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { ok as resultOk } from "../../../src/domain/result.js"; import { mkdir, rm, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -92,24 +97,32 @@ describe("guided prompt completion from live analysis", () => { it("offers only captures admitted by the process comparison identity", async () => { const session = createTestBinarySession(() => client([])); const captureResult = jsonValueSchema.parse(EMPTY_PROCESS_CAPTURE_EXAMPLE); - const unsupportedProvider = createEvidence(undefined, fixtureProvider, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: captureResult, - confidence: "observed", - authority: "controlled-replay", - environment: fixtureEnvironment, - }); - const wrongPredicate = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.other-process-data", - operation: "capture_process_scenario", - parameters: {}, - result: captureResult, - confidence: "observed", - authority: "controlled-replay", - environment: fixtureEnvironment, - }); + const unsupportedProvider = createEvidence( + unknownTarget("not-observed"), + fixtureProvider, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: captureResult, + confidence: "observed", + authority: "controlled-replay", + environment: fixtureEnvironment, + }, + ); + const wrongPredicate = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.other-process-data", + operation: "capture_process_scenario", + parameters: {}, + result: captureResult, + confidence: "observed", + authority: "controlled-replay", + environment: fixtureEnvironment, + }, + ); for (const evidence of [ PROCESS_CAPTURE_REFERENCE, unsupportedProvider, @@ -138,15 +151,19 @@ describe("guided prompt completion from investigation records", () => { ...EMPTY_PROCESS_CAPTURE_EXAMPLE, manifest: { ...legacyManifest, executable_sha256 }, }; - const evidence = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: legacyCapture, - confidence: "observed", - authority: "controlled-replay", - environment: fixtureEnvironment, - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: legacyCapture, + confidence: "observed", + authority: "controlled-replay", + environment: fixtureEnvironment, + }, + ); expect(session.recordEvidence(evidence).ok).toBe(true); const completion = createPromptCompletionSource(session, session); @@ -159,36 +176,48 @@ describe("guided prompt completion from investigation records", () => { it("projects only validated typed identifiers from the evidence ledger", async () => { const session = createTestBinarySession(() => client([])); - const invalidCapture = createEvidence(undefined, PROCESS_PROVIDER, { - predicateType: "rea.process-capture", - operation: "capture_process_scenario", - parameters: {}, - result: {}, - confidence: "observed", - authority: "controlled-replay", - environment: fixtureEnvironment, - }); - const invalidInventory = createEvidence(undefined, fixtureProvider, { - operation: "fixture_inventory", - parameters: {}, - result: ARTIFACT_COMPARISON_EXAMPLE.right.normalized_result, - confidence: "observed", - authority: "shipped-artifact", - }); + const invalidCapture = createEvidence( + unknownTarget("not-observed"), + PROCESS_PROVIDER, + { + predicateType: "rea.process-capture", + operation: "capture_process_scenario", + parameters: {}, + result: {}, + confidence: "observed", + authority: "controlled-replay", + environment: fixtureEnvironment, + }, + ); + const invalidInventory = createEvidence( + unknownTarget("not-observed"), + fixtureProvider, + { + operation: "fixture_inventory", + parameters: {}, + result: ARTIFACT_COMPARISON_EXAMPLE.right.normalized_result, + confidence: "observed", + authority: "shipped-artifact", + }, + ); const inventoryInspection = createArtifactInspection( ARTIFACT_COMPARISON_EXAMPLE.left, ); const inventory = artifactInventoryResultSchema.parse( ARTIFACT_COMPARISON_EXAMPLE.left.normalized_result, ); - const inspectionEvidence = createEvidence(undefined, fixtureProvider, { - operation: "inspect_artifact", - parameters: {}, - result: inventoryInspection, - confidence: "observed", - authority: "shipped-artifact", - evidenceLinks: inventoryInspection.evidence_links, - }); + const inspectionEvidence = createEvidence( + unknownTarget("not-observed"), + fixtureProvider, + { + operation: "inspect_artifact", + parameters: {}, + result: inventoryInspection, + confidence: "observed", + authority: "shipped-artifact", + evidenceLinks: inventoryInspection.evidence_links, + }, + ); for (const evidence of [ ARTIFACT_COMPARISON_EXAMPLE.left, inspectionEvidence, @@ -342,13 +371,17 @@ describe("guided prompt completion from retained records", () => { it("deduplicates, case-folds, and returns deterministic live evidence IDs", async () => { const session = createTestBinarySession(() => client([])); for (let index = 149; index >= 0; index -= 1) { - const evidence = createEvidence(undefined, fixtureProvider, { - operation: `fixture-${String(index)}`, - parameters: { index }, - result: index, - confidence: "derived", - authority: "analyst-inference", - }); + const evidence = createEvidence( + unknownTarget("not-observed"), + fixtureProvider, + { + operation: `fixture-${String(index)}`, + parameters: { index }, + result: index, + confidence: "derived", + authority: "analyst-inference", + }, + ); expect(session.recordEvidence(evidence).ok).toBe(true); expect(session.recordEvidence(evidence).ok).toBe(true); } @@ -561,12 +594,12 @@ const createPagedInspectionEvidence = async ( if (target === null) throw new Error("fixture inventory has no subject"); const evidence = createEvidence( { - path: target.local_path, + path: fileSubjectDisplay(target).local_path, sha256: corruption === "carrier-subject" ? "a".repeat(64) - : target.digest.sha256, - format: target.format, + : fileIdentity(target).sha256, + format: fileIdentity(target).format, }, fixtureProvider, { diff --git a/tests/boundary/mcp/promptMcp.test.ts b/tests/boundary/mcp/promptMcp.test.ts index fda86a3cd4..6a4e9a4f8c 100644 --- a/tests/boundary/mcp/promptMcp.test.ts +++ b/tests/boundary/mcp/promptMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { closeVerifierResources, withVerifierCleanup, @@ -511,7 +512,7 @@ describe("guided prompt completion registry", () => { for (let index = 0; index < 150; index += 1) expect( session.recordEvidence( - createEvidence(undefined, fixtureProvider, { + createEvidence(unknownTarget("not-observed"), fixtureProvider, { operation: `fixture-${String(index)}`, parameters: { index }, result: index, diff --git a/tests/boundary/mcp/pseudocodeDeliveryMcp.test.ts b/tests/boundary/mcp/pseudocodeDeliveryMcp.test.ts index 20f7b6c1e6..3732b6d4bf 100644 --- a/tests/boundary/mcp/pseudocodeDeliveryMcp.test.ts +++ b/tests/boundary/mcp/pseudocodeDeliveryMcp.test.ts @@ -160,7 +160,7 @@ it.each([ if (typeof result.parent_evidence_id !== "string") throw new Error("Missing parent reference"); const parent = harness.session.evidenceById(result.parent_evidence_id); - if (parent === undefined || parent.subject === null) + if (parent === undefined || parent.subject.identity.kind !== "file") throw new Error("Missing retained artifact observation"); const locations = [ { kind: "artifact-path", path: parent.subject.local_path }, diff --git a/tests/boundary/mcp/reconstructionCoverageMcp.test.ts b/tests/boundary/mcp/reconstructionCoverageMcp.test.ts index 0a71feefce..30a91218a6 100644 --- a/tests/boundary/mcp/reconstructionCoverageMcp.test.ts +++ b/tests/boundary/mcp/reconstructionCoverageMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { ok as resultOk } from "../../../src/domain/result.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; @@ -71,7 +72,7 @@ it("uses the latest listed unknown revision when evaluating a boundary", async ( if (first === undefined || second === undefined) throw new Error("Missing fixture Evidence"); const unknownSource = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "unknown-source", name: "Unknown source", version: "1" }, { operation: "observe_unknown", @@ -178,7 +179,7 @@ describe("reconstruction coverage inline Evidence", () => { if (latest === undefined) throw new Error("Expected fixture verifier result"); const inference = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "weak-proof", name: "Weak proof fixture", version: "1" }, { operation: "infer", @@ -216,7 +217,7 @@ describe("reconstruction coverage inline Evidence", () => { await withCoverageMcp(async ({ client }) => { const coverage = currentFixtureCoverage(); const inference = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "tampered-proof", name: "Tampered proof fixture", version: "1" }, { operation: "infer", diff --git a/tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts b/tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts index fa5440c24d..5b60763918 100644 --- a/tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts +++ b/tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { reconstructionProofApplicabilityCases } from "../../fixtures/reconstructionProofApplicability.js"; import { reconstructionObligationLedgerSchema } from "../../../src/domain/reconstructionObligationLedgerSchemas.js"; import type { ReconstructionObligationManifest } from "../../../src/domain/reconstructionObligationLedgerSchemas.js"; @@ -15,6 +16,7 @@ import { import { createEvidence, evidenceSchema, + evidenceSubjectInput, } from "../../../src/domain/evidence.js"; import { PROCESS_PROVIDER } from "../../../src/domain/process/processEvidenceProvider.js"; import { @@ -94,7 +96,7 @@ describe("reconstruction obligation ledger residual graph input", () => { relationships: [], }); const mutation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.residual-unknown-mutation", @@ -140,7 +142,7 @@ describe("reconstruction obligation ledger residual graph input", () => { : [], }); const mutation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.residual-unknown-mutation", @@ -206,14 +208,18 @@ describe("reconstruction obligation ledger process provider admission", () => { "preserves process provider admission for %s", async (_, provider, admitted) => { const source = processEvidence(); - const record = createEvidence(undefined, provider, { - predicateType: source.predicate_type, - operation: source.operation, - parameters: source.parameters, - result: source.normalized_result, - confidence: source.confidence, - authority: source.authority, - }); + const record = createEvidence( + evidenceSubjectInput(source.subject), + provider, + { + predicateType: source.predicate_type, + operation: source.operation, + parameters: source.parameters, + result: source.normalized_result, + confidence: source.confidence, + authority: source.authority, + }, + ); await withLedgerClient(async (request) => { const response = await request(createEvidenceBundle([record])); expect(response.isError).not.toBe(true); @@ -276,7 +282,7 @@ describe("reconstruction obligation ledger MCP parity", () => { it("rejects noncanonical source bundles before ledger generation", async () => { const records = ["first", "second"].map((label) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", @@ -328,7 +334,7 @@ describe("reconstruction obligation ledger MCP parity", () => { it("distinguishes corrupt source bundles from missing caller-selected review references", async () => { const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", parameters: {}, result: {} }, ); diff --git a/tests/boundary/mcp/recordedCrashMcp.test.ts b/tests/boundary/mcp/recordedCrashMcp.test.ts index e2453cef72..7b86e187a5 100644 --- a/tests/boundary/mcp/recordedCrashMcp.test.ts +++ b/tests/boundary/mcp/recordedCrashMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -84,7 +85,7 @@ it("records inline recorded-core evidence with compact schemas and canonical pat ); const evidence = parseEvidence(parsed); expect(evidence.confidence).toBe("observed"); - expect(evidence.subject?.digest.sha256).toBe(value.artifact.sha256); + expect(fileIdentity(evidence.subject).sha256).toBe(value.artifact.sha256); expect(parsed.normalized_result).toEqual(value); expect(session.evidenceById(evidence.evidence_id)).toEqual(evidence); const relative = await client.callTool({ diff --git a/tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts b/tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts index 5986ff53ef..c980ba6733 100644 --- a/tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts +++ b/tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { afterAll, expect, it } from "vitest"; @@ -256,12 +257,12 @@ it("preserves validation for the referenced record's operation, predicate, and s const { client, session } = await connect(); for (const record of [ createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "inventory_artifact", parameters: {}, result: {} }, ), createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "analyze_javascript_application", diff --git a/tests/boundary/mcp/sameFunctionObservation.test.ts b/tests/boundary/mcp/sameFunctionObservation.test.ts index 3c1f5bf836..b6a82c0cfa 100644 --- a/tests/boundary/mcp/sameFunctionObservation.test.ts +++ b/tests/boundary/mcp/sameFunctionObservation.test.ts @@ -10,6 +10,7 @@ import { createEvidence, parseEvidence, type Evidence, + evidenceSubjectInput, } from "../../../src/domain/evidence.js"; import { functionDossierSchema } from "../../../src/domain/native/functionDossier.js"; import { functionComparisonResultSchema } from "../../../src/domain/functionComparisonSchemas.js"; @@ -66,16 +67,20 @@ const expectRejectedDimensionCitation = async ( dimensions: original.dimensions.map(altered), changes: original.changes.map(altered), }); - const invalid = createEvidence(undefined, comparison.provider, { - predicateType: comparison.predicate_type, - operation: comparison.operation, - parameters: comparison.parameters, - result, - confidence: comparison.confidence, - authority: comparison.authority, - limitations: comparison.limitations, - evidenceLinks: [main.evidence_id, another.evidence_id], - }); + const invalid = createEvidence( + evidenceSubjectInput(comparison.subject), + comparison.provider, + { + predicateType: comparison.predicate_type, + operation: comparison.operation, + parameters: comparison.parameters, + result, + confidence: comparison.confidence, + authority: comparison.authority, + limitations: comparison.limitations, + evidenceLinks: [main.evidence_id, another.evidence_id], + }, + ); const response = await client.callTool({ name: "find_changed_behavior", arguments: { comparisons: [invalid] }, @@ -149,19 +154,23 @@ it.each(["compact"] as const)( ]), }, }); - const contradictory = createEvidence(undefined, comparison.provider, { - predicateType: comparison.predicate_type, - operation: comparison.operation, - parameters: { - left_evidence_id: main.evidence_id, - right_evidence_id: another.evidence_id, + const contradictory = createEvidence( + evidenceSubjectInput(comparison.subject), + comparison.provider, + { + predicateType: comparison.predicate_type, + operation: comparison.operation, + parameters: { + left_evidence_id: main.evidence_id, + right_evidence_id: another.evidence_id, + }, + result: comparison.normalized_result, + confidence: comparison.confidence, + authority: comparison.authority, + limitations: comparison.limitations, + evidenceLinks: [main.evidence_id, another.evidence_id], }, - result: comparison.normalized_result, - confidence: comparison.confidence, - authority: comparison.authority, - limitations: comparison.limitations, - evidenceLinks: [main.evidence_id, another.evidence_id], - }); + ); const contradictoryBehavior = await client.callTool({ name: "find_changed_behavior", arguments: { comparisons: [contradictory] }, diff --git a/tests/boundary/mcp/serverUnknownsMcp.test.ts b/tests/boundary/mcp/serverUnknownsMcp.test.ts index 990dfafb58..08fcf2797b 100644 --- a/tests/boundary/mcp/serverUnknownsMcp.test.ts +++ b/tests/boundary/mcp/serverUnknownsMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; @@ -103,7 +104,7 @@ it("rejects divergent imported histories without suggesting an unchanged retry", const root = await createTestTempDirectory("rea-unknown-divergent-"); const provider = { id: "fixture", name: "Fixture", version: "1" }; const records = ["create", "left", "right"].map((operation) => - createEvidence(undefined, provider, { + createEvidence(unknownTarget("not-observed"), provider, { operation, parameters: {}, result: {}, @@ -263,7 +264,7 @@ it("records capture disagreement as a contradicted unknown", async () => { ], }); const captureEvidence = (capture: typeof left) => - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture", operation: "capture_process_scenario", parameters: {}, diff --git a/tests/boundary/mcp/sessionMcp.test.ts b/tests/boundary/mcp/sessionMcp.test.ts index b6f1176582..437e56804f 100644 --- a/tests/boundary/mcp/sessionMcp.test.ts +++ b/tests/boundary/mcp/sessionMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { ProviderCleanupError } from "../../../src/domain/providerCleanupError.js"; import { createEvidence } from "../../../src/domain/evidence.js"; import { ProcessCaptureResourceScope } from "../../../src/process/capture/ProcessCaptureLifecycle.js"; @@ -450,7 +451,7 @@ describe("snapshot receipt after MCP cleanup", () => { "rea-mcp-snapshot-process-cleanup-", ); const cleanupObservation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "health", parameters: {}, result: "cleanup facts" }, ); diff --git a/tests/boundary/mcp/sessionMcpHarness.ts b/tests/boundary/mcp/sessionMcpHarness.ts index 3d22454d08..e7c70ac6d7 100644 --- a/tests/boundary/mcp/sessionMcpHarness.ts +++ b/tests/boundary/mcp/sessionMcpHarness.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -162,7 +163,7 @@ export const snapshotAndRecordUnknown = async ( JSON.stringify( createEvidenceBundle([ createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "external_observation", parameters: {}, result: true }, ), diff --git a/tests/boundary/mcp/shutdown.test.ts b/tests/boundary/mcp/shutdown.test.ts index b2b7ff2e38..f5848cb4c7 100644 --- a/tests/boundary/mcp/shutdown.test.ts +++ b/tests/boundary/mcp/shutdown.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { EventEmitter } from "node:events"; import type { StdioServerHandle } from "@modelcontextprotocol/server/stdio"; import pino from "pino"; @@ -243,7 +244,7 @@ it("retries only failed cleanup owners after concurrent shutdown requests", asyn expect( session.recordEvidence( createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Shutdown fixture", diff --git a/tests/boundary/mcp/signalRecordingMcp.test.ts b/tests/boundary/mcp/signalRecordingMcp.test.ts index a7a52a724b..68618acf66 100644 --- a/tests/boundary/mcp/signalRecordingMcp.test.ts +++ b/tests/boundary/mcp/signalRecordingMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { createEvidence } from "../../../src/domain/evidence.js"; import { AnalysisCancelledError } from "../../../src/domain/analysisErrorCore.js"; @@ -66,7 +67,7 @@ it.each(["cancelled", "cleanup"])( decoders: "uart", }; const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Completed decoder fixture", version: "1" }, { operation: "decode_signal_recording", diff --git a/tests/boundary/mcp/sourcePublicationContext.test.ts b/tests/boundary/mcp/sourcePublicationContext.test.ts index f8a9c19e5d..b60a8a871e 100644 --- a/tests/boundary/mcp/sourcePublicationContext.test.ts +++ b/tests/boundary/mcp/sourcePublicationContext.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { canonicalOutputSchema, withCanonicalOutputSchema, @@ -35,7 +36,7 @@ it.each( async ({ mode, profile }) => { const id = { id: "fixture", name: "Fixture", version: "1" }; const original = createEvidence( - undefined, + unknownTarget("not-observed"), id, { operation: "health", @@ -174,7 +175,7 @@ it.each([false, true])( async (large) => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", @@ -283,7 +284,7 @@ it.each([false, true])( it("keeps a smaller sibling recovery when a later completed observation exceeds delivery", async () => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", diff --git a/tests/boundary/mcp/sourcePublicationRecovery.test.ts b/tests/boundary/mcp/sourcePublicationRecovery.test.ts index 8f7b63c6b4..e8ae8da73d 100644 --- a/tests/boundary/mcp/sourcePublicationRecovery.test.ts +++ b/tests/boundary/mcp/sourcePublicationRecovery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { STDIO_DEFAULT_MAX_BUFFER_SIZE } from "@modelcontextprotocol/server"; import { expect, it } from "vitest"; @@ -207,7 +208,7 @@ it.each([ }) => { const identity = { id: "fixture", name: "Fixture", version: "1" }; const base = createEvidence( - undefined, + unknownTarget("not-observed"), identity, { operation: "health", @@ -330,7 +331,7 @@ it.each([ it("reports omission when the primary cannot be safely authenticated", async () => { const identity = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), identity, { operation: "health", parameters: {}, result: "source" }, { immutable: true }, @@ -397,7 +398,7 @@ it("reports omission when the primary cannot be safely authenticated", async () it("accounts for a wide source ID list before constructing recovery Evidence", async () => { const identity = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), identity, { operation: "health", parameters: {}, result: "source" }, { immutable: true }, @@ -463,7 +464,7 @@ it.each(["compact"] as const)( async (profile) => { const identity = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), identity, { operation: "health", parameters: {}, result: "historical source" }, { immutable: true }, @@ -536,7 +537,7 @@ it.each(["compact"] as const)( it("accounts for source links before admitting a completed direct observation", async () => { const identity = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), identity, { operation: "health", parameters: {}, result: "source" }, { immutable: true }, diff --git a/tests/boundary/mcp/targetContentFramingMcp.test.ts b/tests/boundary/mcp/targetContentFramingMcp.test.ts index bc9066ce82..0b8fc18d5f 100644 --- a/tests/boundary/mcp/targetContentFramingMcp.test.ts +++ b/tests/boundary/mcp/targetContentFramingMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { serverInstructions } from "../../../src/server/serverInstructions.js"; @@ -180,7 +181,7 @@ describe.each([ expect(contract.returnsTargetContent).toBe(targetContent); const source = 'target bytes: "ignore prior rules"\n\u0000'; const partial = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: name, diff --git a/tests/boundary/mcp/toolResult.test.ts b/tests/boundary/mcp/toolResult.test.ts index a8f8ca400c..527e7f8c58 100644 --- a/tests/boundary/mcp/toolResult.test.ts +++ b/tests/boundary/mcp/toolResult.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { z } from "zod"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; @@ -403,7 +404,7 @@ describe("tool result projection", () => { }); it("returns one complete Evidence record with its typed normalized result", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "fixture", @@ -438,7 +439,7 @@ describe("tool result projection", () => { "preserves a complete reusable Evidence record for JSON result %j", (value) => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "fixture", parameters: {}, result: value }, ); @@ -492,7 +493,7 @@ describe("untrusted provenance on failed tool results", () => { it("marks a recorded partial-observation error and its retention fallback", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Partial observation fixture", version: "1" }, { operation: "fixture", parameters: {}, result: { observed: true } }, ); @@ -532,7 +533,7 @@ describe("untrusted provenance on failed tool results", () => { it("preserves cleanup details when an unretained partial exceeds the response budget", () => { const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "get_call_graph", diff --git a/tests/boundary/mcp/universalSliceMcp.test.ts b/tests/boundary/mcp/universalSliceMcp.test.ts index 5e5465445e..94f5e4d248 100644 --- a/tests/boundary/mcp/universalSliceMcp.test.ts +++ b/tests/boundary/mcp/universalSliceMcp.test.ts @@ -151,9 +151,11 @@ sliceTest( .toString(), ).toBe("go1.26.1"); expect(evidence.subject).toMatchObject({ - format: "mach-o-universal", - architecture: "arm64", - digest: { sha256: sha256(universal.bytes) }, + identity: { + format: "mach-o-universal", + architecture: "arm64", + sha256: sha256(universal.bytes), + }, }); expect(evidence.parameters).toEqual({ path, architecture: "arm64" }); // A retained report cannot claim a slice its own container or CPU contradicts. diff --git a/tests/boundary/mcp/wasmArtifactMcp.test.ts b/tests/boundary/mcp/wasmArtifactMcp.test.ts index 852b0959a6..d6e0c6b485 100644 --- a/tests/boundary/mcp/wasmArtifactMcp.test.ts +++ b/tests/boundary/mcp/wasmArtifactMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { withCanonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { advertisedMcpToolSchemas, @@ -658,7 +659,7 @@ it("checks WASM semantic identity while preserving rebound display paths", async { kind: "wasm", facet: "exports", offset: 0, limit: 1 }, ] as const; for (const target of [ - undefined, + unknownTarget("not-observed"), { path: value.artifact.path, sha256: "f".repeat(64), diff --git a/tests/boundary/mcp/webBundleViewsMcp.test.ts b/tests/boundary/mcp/webBundleViewsMcp.test.ts index 72ccc3314c..0ac56b3a00 100644 --- a/tests/boundary/mcp/webBundleViewsMcp.test.ts +++ b/tests/boundary/mcp/webBundleViewsMcp.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { afterAll, expect, it } from "vitest"; @@ -18,7 +19,7 @@ afterAll(() => schemaValidation.clear()); const makeParent = () => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-browser", name: "REA Browser", version: "6.8.0" }, { operation: "analyze_web_bundle", diff --git a/tests/boundary/mcp/workflowUnknownIdentityMcp.test.ts b/tests/boundary/mcp/workflowUnknownIdentityMcp.test.ts index 01b994d605..08eedbe282 100644 --- a/tests/boundary/mcp/workflowUnknownIdentityMcp.test.ts +++ b/tests/boundary/mcp/workflowUnknownIdentityMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import type { Client } from "@modelcontextprotocol/client"; import { expect, it } from "vitest"; @@ -28,14 +29,12 @@ const withClient = async ( const pathSource = () => { const template = FUNCTION_COMPARISON_EXAMPLE.left; - if (template.subject === null) - throw new Error("Call-path fixtures must be artifact-bound"); const dossier = functionDossierSchema.parse(template.normalized_result); return createEvidence( { path: `${template.subject.local_path}/workflow-unknown-path`, - sha256: template.subject.digest.sha256, - format: template.subject.format, + sha256: fileIdentity(template.subject).sha256, + format: fileIdentity(template.subject).format, }, template.provider, { @@ -64,13 +63,11 @@ const pathSource = () => { const incompleteRight = (suffix: string) => { const template = FUNCTION_COMPARISON_EXAMPLE.right; - if (template.subject === null) - throw new Error("Comparison fixtures must be artifact-bound"); return createEvidence( { path: `${template.subject.local_path}/${suffix}`, - sha256: template.subject.digest.sha256, - format: template.subject.format, + sha256: fileIdentity(template.subject).sha256, + format: fileIdentity(template.subject).format, }, template.provider, { diff --git a/tests/boundary/model/modelArtifact.test.ts b/tests/boundary/model/modelArtifact.test.ts index b17df28ef9..d3972232b6 100644 --- a/tests/boundary/model/modelArtifact.test.ts +++ b/tests/boundary/model/modelArtifact.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import { open, writeFile, symlink, truncate } from "node:fs/promises"; import { join } from "node:path"; @@ -1192,7 +1193,7 @@ it("retains GGUF declarations and metadata when storage overlap is refused", asy ...INVALID_FORMAT, }); const evidence = parseEvidence(result.error.partialObservation); - expect(evidence.subject).toBeNull(); + expect(evidence.subject.identity.kind).toBe("unknown"); expect(evidence.normalized_result).toMatchObject({ artifact: { header_sha256: null, @@ -1536,7 +1537,7 @@ it("retains explicit scoped identity through shared service and preserves caller onTestFinished(() => service.close()); const result = await service.inspect({ path, detail: "complete" }); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect( modelArtifactSchema.parse(result.value.normalized_result).artifact.sha256, ).toBeNull(); @@ -1546,7 +1547,7 @@ it("retains explicit scoped identity through shared service and preserves caller detail: "complete", }); if (!full.ok) throw full.error; - expect(full.value.subject?.digest.sha256).toBe(hash(fixture.bytes)); + expect(fileIdentity(full.value.subject).sha256).toBe(hash(fixture.bytes)); const controller = new AbortController(); const reason = new Error("selected caller stop"); controller.abort(reason); diff --git a/tests/boundary/model/modelArtifactPartialCancellation.test.ts b/tests/boundary/model/modelArtifactPartialCancellation.test.ts index 850c282193..0015779df0 100644 --- a/tests/boundary/model/modelArtifactPartialCancellation.test.ts +++ b/tests/boundary/model/modelArtifactPartialCancellation.test.ts @@ -89,7 +89,7 @@ it.each([undefined, 64])( expect(arrayBytesObserved).toBeLessThan(count); expect(result.error.cause).toBe(reason); const evidence = parseEvidence(result.error.partialObservation); - expect(evidence.subject).toBeNull(); + expect(evidence.subject.identity.kind).toBe("unknown"); expect(evidence.operation).toBe("inspect_model_artifact"); expect(evidence.normalized_result).toMatchObject({ kind: "model-artifact-partial", diff --git a/tests/boundary/model/modelArtifactViewIdentity.test.ts b/tests/boundary/model/modelArtifactViewIdentity.test.ts index 0c4d4070a5..dab43554a9 100644 --- a/tests/boundary/model/modelArtifactViewIdentity.test.ts +++ b/tests/boundary/model/modelArtifactViewIdentity.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -22,7 +23,6 @@ it("checks each model parent digest independently of cached declarations and dis }); if (!inspected.ok) throw inspected.error; const original = inspected.value; - if (original.subject === null) throw new Error("Missing full-file subject"); const report = freezeJsonSnapshot(original.normalized_result); const parent = (name: string, targetPath: string, digest: string) => createEvidence( @@ -36,7 +36,7 @@ it("checks each model parent digest independently of cached declarations and dis limitations: original.limitations, }, ); - const digest = original.subject.digest.sha256; + const digest = fileIdentity(original.subject).sha256; const valid = parent("valid", path, digest); const aliasPath = join(root, "other.gguf"); const rebound = parent("rebound-path", aliasPath, digest); diff --git a/tests/boundary/process/androidMappingMcp.test.ts b/tests/boundary/process/androidMappingMcp.test.ts index 3ea4a5a59c..61302b3243 100644 --- a/tests/boundary/process/androidMappingMcp.test.ts +++ b/tests/boundary/process/androidMappingMcp.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { canonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { Ajv2020 } from "ajv/dist/2020.js"; @@ -169,7 +170,7 @@ it("annotates class inspection with a caller-selected mapping and reuses one eng contract.outputSchema.parse(response.structuredContent), ); expect(evidence.parameters.mapping_path).toBe(path); - expect(evidence.subject?.digest.sha256).toBe(apkSha256); + expect(fileIdentity(evidence.subject).sha256).toBe(apkSha256); expect(evidence.limitations.join(" ")).toContain("pg_map_id"); const result = androidResultSchemas.inspect_android_class.parse( evidence.normalized_result, diff --git a/tests/boundary/process/jadxIntegration.test.ts b/tests/boundary/process/jadxIntegration.test.ts index 77fba3ada9..5b258acc50 100644 --- a/tests/boundary/process/jadxIntegration.test.ts +++ b/tests/boundary/process/jadxIntegration.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { SdkErrorCode } from "@modelcontextprotocol/client"; import { packagedJadxBridgeIdentity } from "../../support/packagedJadxBridge.js"; import { ArtifactResourceScope } from "../../../src/resources/ArtifactResourceScope.js"; @@ -100,8 +101,8 @@ it.each(["alias/../bin", ""])( path: apk, }); if (!second.ok) throw second.error; - expect(second.value.subject?.digest.sha256).toBe( - first.value.subject?.digest.sha256, + expect(fileIdentity(second.value.subject).sha256).toBe( + fileIdentity(first.value.subject).sha256, ); const secondStarts = (await readFile(logPath(directories[1]!), "utf8")) .trim() @@ -445,9 +446,11 @@ it("retire sessions when APK bytes, engine bytes or JVM options change", async ( Buffer.concat([await readFile(apk), Buffer.from("new artifact bytes")]), ); const changed = await inspect(); - expect(first.subject?.digest.sha256).toEqual(expect.any(String)); - expect(changed.subject?.digest.sha256).toEqual(expect.any(String)); - expect(changed.subject?.digest.sha256).not.toBe(first.subject?.digest.sha256); + expect(fileIdentity(first.subject).sha256).toEqual(expect.any(String)); + expect(fileIdentity(changed.subject).sha256).toEqual(expect.any(String)); + expect(fileIdentity(changed.subject).sha256).not.toBe( + fileIdentity(first.subject).sha256, + ); await verifyCleanup(launches.slice(0, 1)); await writeJadxJarInventory(jar, ["fixture/NewEngineMarker.class"]); await inspect(); diff --git a/tests/boundary/process/mcpVerifierResults.test.ts b/tests/boundary/process/mcpVerifierResults.test.ts index a249e08f80..5e65712dc1 100644 --- a/tests/boundary/process/mcpVerifierResults.test.ts +++ b/tests/boundary/process/mcpVerifierResults.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { ARTIFACT_COMPARISON_EXAMPLE } from "../../../src/contracts/artifactComparisonExample.js"; import { artifactInventoryResultSchema } from "../../../src/domain/artifactGraph.js"; import { digestCanonicalValue } from "../../../src/domain/canonicalDigest.js"; @@ -108,7 +109,7 @@ it("requires candidate capabilities in CLI provider output", async () => { const retainedBundle = (value = 7) => createEvidenceBundle([ createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", @@ -538,7 +539,7 @@ it("preserves raw extraction manifest extensions for separate Evidence authentic limitations: [], }; const evidenceFor = (result: unknown) => - createEvidence(undefined, inventoryEvidence.provider, { + createEvidence(unknownTarget("not-observed"), inventoryEvidence.provider, { operation: "extract_artifact", parameters: {}, result, diff --git a/tests/boundary/process/processCli.test.ts b/tests/boundary/process/processCli.test.ts index aa21f2285d..0f89a7cb46 100644 --- a/tests/boundary/process/processCli.test.ts +++ b/tests/boundary/process/processCli.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { access, readFile, readdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -421,7 +422,7 @@ describe("process CLI evidence validation", () => { await writeFile( invalidCapture, JSON.stringify( - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "rea.process-capture/other", operation: "capture_process_scenario", parameters: {}, @@ -432,7 +433,7 @@ describe("process CLI evidence validation", () => { await writeFile( unrelated, JSON.stringify( - createEvidence(undefined, PROCESS_PROVIDER, { + createEvidence(unknownTarget("not-observed"), PROCESS_PROVIDER, { predicateType: "unrelated/v1", operation: "other", parameters: {}, diff --git a/tests/boundary/providers/ghidra/ghidraFileFailure.test.ts b/tests/boundary/providers/ghidra/ghidraFileFailure.test.ts index 8b54289234..6a780abadc 100644 --- a/tests/boundary/providers/ghidra/ghidraFileFailure.test.ts +++ b/tests/boundary/providers/ghidra/ghidraFileFailure.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../../src/domain/targetIdentity.js"; import { open, writeFile, type FileHandle } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -72,7 +73,7 @@ const retainForeignFailure = async (path: string) => { const owner = new OwnedFileHandle(await open(path, "r")); const lease = AnalysisCleanupLease.forCloseOwner(owner, path); const partial = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "foreign", name: "foreign", version: null }, { operation: "inspect_artifact", diff --git a/tests/boundary/providers/kuna/kunaQueryErrors.test.ts b/tests/boundary/providers/kuna/kunaQueryErrors.test.ts index 57615a9f74..cc50457424 100644 --- a/tests/boundary/providers/kuna/kunaQueryErrors.test.ts +++ b/tests/boundary/providers/kuna/kunaQueryErrors.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../../src/domain/targetIdentity.js"; import { expect, it } from "vitest"; import { kunaQueryFailureForCaller } from "../../../../src/kuna/KunaQueryErrors.js"; import { @@ -19,7 +20,7 @@ const capturedOutput = { truncated: false, }; const partialObservation = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "kuna", name: "Kuna", version: null }, { operation: "kuna:strings", diff --git a/tests/boundary/providers/managed/managedDirectAnalysis.test.ts b/tests/boundary/providers/managed/managedDirectAnalysis.test.ts index a209d4721f..1cca56333c 100644 --- a/tests/boundary/providers/managed/managedDirectAnalysis.test.ts +++ b/tests/boundary/providers/managed/managedDirectAnalysis.test.ts @@ -26,7 +26,7 @@ describe("managed direct-analysis path boundary", () => { expect(evidence).toMatchObject({ operation: "inspect_managed_artifact", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, normalized_result: { classification: { status: "managed", runtime_family: "modern-dotnet" }, references: [expect.objectContaining({ name: "System.Runtime" })], @@ -41,7 +41,7 @@ describe("managed direct-analysis path boundary", () => { expect(memberEvidence).toMatchObject({ operation: "inspect_managed_members", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, normalized_result: { identity_scope: { token_identity: "build-local" }, methods: [expect.objectContaining({ token: expect.any(String) })], @@ -58,7 +58,7 @@ describe("managed direct-analysis path boundary", () => { expect(boundaryEvidence).toMatchObject({ operation: "inspect_managed_native_boundaries", provider: { id: "rea-dotnet-static" }, - subject: { local_path: path, format: "pe" }, + subject: { local_path: path, identity: { format: "pe" } }, normalized_result: { identity_scope: { token_identity: "build-local" }, pinvoke_imports: [], diff --git a/tests/boundary/providers/managed/managedMemberComparison.test.ts b/tests/boundary/providers/managed/managedMemberComparison.test.ts index f55b67754e..1f592bc566 100644 --- a/tests/boundary/providers/managed/managedMemberComparison.test.ts +++ b/tests/boundary/providers/managed/managedMemberComparison.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../../src/domain/targetIdentity.js"; import { chmod, rm, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -499,7 +500,7 @@ describe("managed member comparison subject identity", () => { }, ); const unavailableSubject = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "partial-fixture", name: "Partial fixture", @@ -827,7 +828,7 @@ describe("compare-managed-members source failures", () => { operation: "inspect_managed_members", subject: { local_path: leftPath, - digest: { + identity: { sha256: expect.stringMatching(/^[0-9a-f]{64}$/u), }, }, diff --git a/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts b/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts index 9a37e91787..c0aabe1765 100644 --- a/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts +++ b/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts @@ -42,7 +42,7 @@ describe("artifact archive inventory", () => { expect(cliEvidence).toMatchObject({ operation: "inventory_artifact", provider: { id: "rea-artifact-graph" }, - subject: { format: "apk" }, + subject: { identity: { format: "apk" } }, }); const inspectionEvidence = parseEvidence( await runProviderAnalysis(zipPath, "inspect_artifact", {}).then( diff --git a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts index 7b67b3855f..e815369e35 100644 --- a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts +++ b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts @@ -76,7 +76,7 @@ describe("artifact archive safety", () => { ), ).toMatchObject({ operation: "inventory_artifact", - subject: { format }, + subject: { identity: { kind: "file", format } }, }); }, ); diff --git a/tests/boundary/providers/native/artifactProvider.directAnalysis.test.ts b/tests/boundary/providers/native/artifactProvider.directAnalysis.test.ts index ac184b35d8..04188e3296 100644 --- a/tests/boundary/providers/native/artifactProvider.directAnalysis.test.ts +++ b/tests/boundary/providers/native/artifactProvider.directAnalysis.test.ts @@ -13,7 +13,10 @@ import { interfaceBuilderAnalysisSchema } from "../../../../src/domain/apple/int import { artifactInspectionResultSchema } from "../../../../src/domain/artifactInspection.js"; import { createAnalysisExecutionEvidence } from "../../../../src/domain/analysisObservation.js"; import { immutableJsonSnapshotMember } from "../../../../src/domain/immutableJson.js"; -import { parseEvidence } from "../../../../src/domain/evidence.js"; +import { + parseEvidence, + evidenceFileTarget, +} from "../../../../src/domain/evidence.js"; const { runProviderAnalysis } = createDirectAnalysis({}); @@ -54,7 +57,7 @@ it("runs static .app decoding without registering native analysis engines", asyn ); expect(result.documents).toEqual([]); expect(result.graph.target_sha256).toBe( - evidence.subject?.digest.sha256 ?? null, + evidenceFileTarget(evidence)?.sha256 ?? null, ); }); diff --git a/tests/boundary/sqlite/sqliteDatabaseDescriptorCleanup.test.ts b/tests/boundary/sqlite/sqliteDatabaseDescriptorCleanup.test.ts index b596bedaa7..91636524bd 100644 --- a/tests/boundary/sqlite/sqliteDatabaseDescriptorCleanup.test.ts +++ b/tests/boundary/sqlite/sqliteDatabaseDescriptorCleanup.test.ts @@ -464,8 +464,7 @@ nativeInspectionTest.each([ parameters: input, subject: { local_path: input.path, - format: "file", - digest: { sha256: databaseDigest }, + identity: { format: "file", sha256: databaseDigest }, }, normalized_result: { artifact: { diff --git a/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts b/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts index 45ccad4506..548be74082 100644 --- a/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts +++ b/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts @@ -471,7 +471,7 @@ it.each(["late-cancellation", "cleanup-failure", "cancelled cleanup-failure"])( confidence: "observed", subject: { local_path: database.path, - digest: { sha256: digestForTest(original) }, + identity: { sha256: digestForTest(original) }, }, parameters: { path: database.path, @@ -509,7 +509,7 @@ it.each(["late-cancellation", "cleanup-failure", "cancelled cleanup-failure"])( confidence: "observed", subject: { local_path: database.path, - digest: { sha256: digestForTest(original) }, + identity: { sha256: digestForTest(original) }, }, parameters: { path: database.path, diff --git a/tests/composition/analysis-sessions/binarySession.test.ts b/tests/composition/analysis-sessions/binarySession.test.ts index ea5dd1f586..81de1b40a6 100644 --- a/tests/composition/analysis-sessions/binarySession.test.ts +++ b/tests/composition/analysis-sessions/binarySession.test.ts @@ -1,3 +1,8 @@ +import { + fileSubjectTarget, + displayedEvidenceSubject, +} from "../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { awaitAcknowledgement } from "../../fixtures/lifecycleAcknowledgement.js"; import { createAnalysisExecution, @@ -665,17 +670,10 @@ describe("evidence metadata imports and snapshot cache", () => { const before = session.exportAnalysisSnapshot(); if (!before.ok) throw before.error; const existing = session.exportEvidenceBundle().records[0]; - if (existing === undefined || existing.subject === null) + if (existing === undefined) throw new Error("Expected artifact-bound Evidence"); const addition = createEvidence( - { - path: existing.subject.local_path, - sha256: existing.subject.digest.sha256, - format: existing.subject.format, - ...(existing.subject.architecture === null - ? {} - : { architecture: existing.subject.architecture }), - }, + fileSubjectTarget(existing.subject), { id: "fixture", name: "Fixture", version: "1" }, { predicateType: "rea.analysis", @@ -743,7 +741,10 @@ describe("Evidence display metadata refresh", () => { const activeEvidence = baseline.value.evidence_bundle.records.find( ({ operation }) => operation === "address_name", ); - if (activeEvidence === undefined || activeEvidence.subject === null) + if ( + activeEvidence === undefined || + activeEvidence.subject.identity.kind !== "file" + ) throw new Error("Expected artifact-bound Evidence"); const evidence = scope === "active" @@ -754,14 +755,14 @@ describe("Evidence display metadata refresh", () => { { operation: "health", parameters: {}, result: true }, ); expect(session.recordEvidence(evidence).ok).toBe(true); - if (evidence.subject === null) throw new Error("Expected a subject"); + if (evidence.subject.identity.kind !== "file") + throw new Error("Expected a subject"); const relocated = { ...evidence, - subject: { - ...evidence.subject, + subject: displayedEvidenceSubject(evidence.subject, { local_path: `${evidence.subject.local_path}.moved`, name: `${evidence.subject.name}.moved`, - }, + }), }; const changed = vi.fn(); const unsubscribe = session.onAnalysisSnapshotChanged(changed); @@ -1157,7 +1158,7 @@ describe("snapshot cache eligibility", () => { ...(live ? { cachePolicy: "live" as const } : {}), })); const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider.identity(), { operation: "health", @@ -1210,11 +1211,15 @@ describe("snapshot cache eligibility", () => { it("rejects invalid source Evidence on a non-replayable observation", async () => { const [target] = await createBinarySessionTargets(); const provider = createCacheProvider([]); - const source = createEvidence(undefined, provider.identity(), { - operation: "health", - parameters: {}, - result: "original", - }); + const source = createEvidence( + unknownTarget("not-observed"), + provider.identity(), + { + operation: "health", + parameters: {}, + result: "original", + }, + ); provider.createClient = () => ({ execute: async () => resultOk( diff --git a/tests/composition/analysis-sessions/investigationRecords.test.ts b/tests/composition/analysis-sessions/investigationRecords.test.ts index b8ab41fb21..0df14e9d6a 100644 --- a/tests/composition/analysis-sessions/investigationRecords.test.ts +++ b/tests/composition/analysis-sessions/investigationRecords.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { expect, it, onTestFinished } from "vitest"; import { BinarySession } from "../../../src/application/binary/BinarySession.js"; @@ -43,7 +44,7 @@ it("uses the composed record owner and preserves best-effort post-commit notific throw new Error("Synthetic async observer failure"); }); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "independent-app", parameters: {}, result: true }, ); diff --git a/tests/composition/analysis-sessions/managedApplicationGraph.test.ts b/tests/composition/analysis-sessions/managedApplicationGraph.test.ts index ddc2175080..fd48d0df18 100644 --- a/tests/composition/analysis-sessions/managedApplicationGraph.test.ts +++ b/tests/composition/analysis-sessions/managedApplicationGraph.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { describe, expect, it } from "vitest"; import { projectManagedApplicationGraphEvidence } from "../../../src/application/managed/ManagedApplicationGraphService.js"; @@ -317,7 +318,7 @@ it("preserves only a managed graph's matching subject in feature traces", () => ...query, }); if (!foreignTrace.ok) throw foreignTrace.error; - expect(foreignTrace.value.evidence.subject).toBeNull(); + expect(foreignTrace.value.evidence.subject.identity.kind).toBe("unknown"); const contradictory = createEvidence( { path: "/other.exe", sha256: "f".repeat(64), format: "pe" }, parsed.provider, @@ -351,6 +352,29 @@ it("preserves only a managed graph's matching subject in feature traces", () => }); }); +it("names the graph after a later file subject when the artifact subject is unknown", () => { + const { artifactEvidence, memberEvidence } = createManagedInteropEvidence(); + const unboundArtifact = createEvidence( + unknownTarget("not-observed"), + artifactEvidence.provider, + { + operation: artifactEvidence.operation, + parameters: artifactEvidence.parameters, + result: artifactEvidence.normalized_result, + rawResult: null, + limitations: artifactEvidence.limitations, + }, + ); + const projected = projectManagedApplicationGraphEvidence({ + managed_artifact: unboundArtifact, + managed_members: memberEvidence, + }); + if (!projected.ok) throw projected.error; + expect(parseEvidence(projected.value).subject).toEqual( + memberEvidence.subject, + ); +}); + describe("managed application graph request", () => { it("accepts any nonempty set of inline sources and rejects duplicates", () => { const evidence = MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members; @@ -522,25 +546,29 @@ it("normalizes MVID casing for node identity while preserving observed values", const uppercaseMvid = members.module.mvid?.toUpperCase(); if (uppercaseMvid === undefined || uppercaseMvid === null) throw new Error("Expected fixture module MVID"); - const uppercaseMembers = createEvidence(undefined, MANAGED_STATIC_PROVIDER, { - operation: "inspect_managed_members", - parameters: {}, - result: { - ...members, - module: { - ...members.module, - mvid: uppercaseMvid, - enc_id: null, - enc_base_id: null, - }, - identity_scope: { - ...members.identity_scope, - requires_mvid: uppercaseMvid, + const uppercaseMembers = createEvidence( + unknownTarget("not-observed"), + MANAGED_STATIC_PROVIDER, + { + operation: "inspect_managed_members", + parameters: {}, + result: { + ...members, + module: { + ...members.module, + mvid: uppercaseMvid, + enc_id: null, + enc_base_id: null, + }, + identity_scope: { + ...members.identity_scope, + requires_mvid: uppercaseMvid, + }, }, + rawResult: null, + limitations: members.limitations, }, - rawResult: null, - limitations: members.limitations, - }); + ); const baseline = projectManagedApplicationGraphEvidence({ managed_members: memberEvidence, managed_native_boundaries: boundaryEvidence, @@ -585,7 +613,7 @@ describe("managed application graph module identity consistency", () => { ); const conflictingMvid = "ffffffff-ffff-ffff-ffff-ffffffffffff"; const conflictingBoundaries = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_native_boundaries", @@ -625,7 +653,7 @@ describe("managed application graph module identity consistency", () => { if (members.module === null) throw new Error("Expected fixture module identity"); const conflictingMembers = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_members", @@ -663,7 +691,7 @@ describe("managed application graph token scope", () => { ); const wrongMvidValue = "ffffffff-ffff-ffff-ffff-ffffffffffff"; const wrongMvidEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_members", @@ -680,7 +708,7 @@ describe("managed application graph token scope", () => { }, ); const wrongArtifactEvidence = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_members", @@ -738,7 +766,7 @@ describe("managed application graph token scope", () => { ? { ...members.identity_scope, requires_mvid: null } : members.identity_scope; const inconsistentMembers = createEvidence( - undefined, + unknownTarget("not-observed"), MANAGED_STATIC_PROVIDER, { operation: "inspect_managed_members", @@ -770,25 +798,29 @@ describe("unknown managed application graph token scope", () => { const boundaries = managedNativeBoundaryInspectionSchema.parse( parseEvidence(boundaryEvidence).normalized_result, ); - const unknownMembers = createEvidence(undefined, MANAGED_STATIC_PROVIDER, { - operation: "inspect_managed_members", - parameters: {}, - result: { - ...members, - module: - members.module === null - ? null - : { - ...members.module, - mvid: null, - enc_id: null, - enc_base_id: null, - }, - identity_scope: { ...members.identity_scope, requires_mvid: null }, + const unknownMembers = createEvidence( + unknownTarget("not-observed"), + MANAGED_STATIC_PROVIDER, + { + operation: "inspect_managed_members", + parameters: {}, + result: { + ...members, + module: + members.module === null + ? null + : { + ...members.module, + mvid: null, + enc_id: null, + enc_base_id: null, + }, + identity_scope: { ...members.identity_scope, requires_mvid: null }, + }, + rawResult: null, + limitations: members.limitations, }, - rawResult: null, - limitations: members.limitations, - }); + ); const projected = projectManagedApplicationGraphEvidence({ managed_members: unknownMembers, diff --git a/tests/composition/analysis-sessions/nativeArchitectureIdentity.test.ts b/tests/composition/analysis-sessions/nativeArchitectureIdentity.test.ts index 30ed31a8b9..3f0046b69b 100644 --- a/tests/composition/analysis-sessions/nativeArchitectureIdentity.test.ts +++ b/tests/composition/analysis-sessions/nativeArchitectureIdentity.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../../fixtures/evidenceSubject.js"; import { expect, it } from "vitest"; import type { BinaryTarget } from "../../../src/domain/binaryTargetTypes.js"; import { createAnalysisProfile } from "../../../src/domain/analysisProfile.js"; @@ -121,9 +122,9 @@ it.each(cases)( JSON.parse(serializeAnalysisSnapshot(snapshot)), ); expect(restored.target.architecture).toBe(architecture); - expect(restored.evidence_bundle.records[0]?.subject?.architecture).toBe( - architecture, - ); + expect( + fileIdentity(restored.evidence_bundle.records[0]?.subject).architecture, + ).toBe(architecture); expect(restored.entries[0]?.execution.subject?.architecture).toBe( architecture, ); @@ -134,7 +135,10 @@ it.each(cases)( expect(() => parseEvidence({ ...evidence, - subject: { ...evidence.subject, architecture: "x86" }, + subject: { + ...evidence.subject, + identity: { ...evidence.subject.identity, architecture: "x86" }, + }, }), ).toThrow("semantic identifier"); const changed = createAnalysisProfile(provider, changedFacts); diff --git a/tests/composition/reverseEngineering.test.ts b/tests/composition/reverseEngineering.test.ts index f292808d42..b478a02f37 100644 --- a/tests/composition/reverseEngineering.test.ts +++ b/tests/composition/reverseEngineering.test.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import type { Stats } from "node:fs"; import { mkdtemp, rm, writeFile } from "node:fs/promises"; @@ -447,7 +448,7 @@ describe("Rizin command service", () => { if (!result.ok) return; const lookupPath = result.value.subject?.local_path; expect(isAbsolute(lookupPath ?? "")).toBe(true); - expect(result.value.subject?.digest.sha256).toBe( + expect(fileIdentity(result.value.subject).sha256).toBe( createHash("sha256").update("fixture").digest("hex"), ); expect(calls).toEqual([ @@ -541,7 +542,7 @@ describe("Rizin command service", () => { }); expect(result.ok).toBe(true); if (!result.ok) return; - expect(result.value.subject?.digest.sha256).toBe( + expect(fileIdentity(result.value.subject).sha256).toBe( createHash("sha256").update("before").digest("hex"), ); expect(result.value.raw_result).toMatchObject({ diff --git a/tests/composition/reverseEngineeringEdgeCases.test.ts b/tests/composition/reverseEngineeringEdgeCases.test.ts index 53b3bd189c..3811eff346 100644 --- a/tests/composition/reverseEngineeringEdgeCases.test.ts +++ b/tests/composition/reverseEngineeringEdgeCases.test.ts @@ -102,7 +102,7 @@ it("records pathless objdump architecture support as provider capability evidenc operation: "architectures", }); if (!result.ok) throw result.error; - expect(result.value.subject).toBeNull(); + expect(result.value.subject.identity.kind).toBe("unknown"); expect(result.value.parameters).not.toHaveProperty("path"); expect(result.value.parameters).not.toHaveProperty( "artifact_sha256_before", diff --git a/tests/composition/sourcePublicationOneShot.test.ts b/tests/composition/sourcePublicationOneShot.test.ts index fd68b597f6..ea8e05b9c1 100644 --- a/tests/composition/sourcePublicationOneShot.test.ts +++ b/tests/composition/sourcePublicationOneShot.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { expect, it, vi } from "vitest"; import { writeFile } from "node:fs/promises"; import { dirname, basename, join } from "node:path"; @@ -28,7 +29,7 @@ it.each(["inspect_macho", "inspect_managed_members"] as const)( const [target] = await createBinarySessionTargets(); const path = `${dirname(target)}/./${basename(target)}`; const provider = { id: "fixture", name: "Fixture", version: "1" }; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "large".repeat(20000), @@ -84,7 +85,7 @@ it.each(["inspect_macho", "inspect_managed_members"] as const)( it("delivers a preexisting completed record inline after one-shot cleanup", async () => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "large".repeat(20000) }, { immutable: true }, @@ -161,7 +162,7 @@ it("delivers a preexisting completed record inline after one-shot cleanup", asyn it("keeps caller spelling on a raw observation when a source ID is malformed", async () => { const provider = { id: "fixture", name: "Fixture", version: "1" }; - const base = createEvidence(undefined, provider, { + const base = createEvidence(unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "source", @@ -223,7 +224,7 @@ it.each([false, true])( async (closeFails) => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "large".repeat(20000) }, { immutable: true }, @@ -353,7 +354,7 @@ it.each([false, true])( it("reports an omitted completed one-shot result when authentication headroom is exhausted", async () => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "historical source" }, { immutable: true }, @@ -411,7 +412,7 @@ it.each([false, true])( async (closeFails) => { const provider = { id: "fixture", name: "Fixture", version: "1" }; const source = createEvidence( - undefined, + unknownTarget("not-observed"), provider, { operation: "health", parameters: {}, result: "history" }, { immutable: true }, diff --git a/tests/composition/webCaptureDeliveryRedaction.test.ts b/tests/composition/webCaptureDeliveryRedaction.test.ts index adf849ef59..8c43fabd13 100644 --- a/tests/composition/webCaptureDeliveryRedaction.test.ts +++ b/tests/composition/webCaptureDeliveryRedaction.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { writeFile, readFile } from "node:fs/promises"; import { join } from "node:path"; @@ -189,12 +190,12 @@ it.each([true, false])( const outputPath = join(root, "partial.json"); if (refused) await writeFile(outputPath, "existing caller file"); const provider = { id: "fixture", name: "Fixture", version: "1" }; - const source = createEvidence(undefined, provider, { + const source = createEvidence(unknownTarget("not-observed"), provider, { operation: "source_fixture", parameters: {}, result: { observed: 7 }, }); - const partial = createEvidence(undefined, provider, { + const partial = createEvidence(unknownTarget("not-observed"), provider, { operation: "derived_fixture", parameters: {}, result: { completed_sources: 1 }, diff --git a/tests/conformance/formats/mzPeAdmission.test.ts b/tests/conformance/formats/mzPeAdmission.test.ts index c81a68dbf8..7f86852a7a 100644 --- a/tests/conformance/formats/mzPeAdmission.test.ts +++ b/tests/conformance/formats/mzPeAdmission.test.ts @@ -166,7 +166,7 @@ it("preserves fuse inspection after a short DOS header with a confirmed PE signa const inspected = await service.inspect({ path }); expect(inspected).toMatchObject({ ok: true, - value: { subject: { architecture: "x86_64" } }, + value: { subject: { identity: { architecture: "x86_64" } } }, }); } finally { await service.close(); diff --git a/tests/conformance/providers/managed/managedNativeVerification.test.ts b/tests/conformance/providers/managed/managedNativeVerification.test.ts index ee8e9b475e..ed22191c99 100644 --- a/tests/conformance/providers/managed/managedNativeVerification.test.ts +++ b/tests/conformance/providers/managed/managedNativeVerification.test.ts @@ -1,3 +1,9 @@ +import { + fileIdentity, + fileSubjectTarget, + fileSubjectArchitecture, +} from "../../../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../../../src/domain/targetIdentity.js"; import { readManagedPeLayout } from "../../../../src/dotnet/ManagedPeReader.js"; import { machoRuntimeSymbolName } from "../../../../src/domain/native/machoSymbolName.js"; import { @@ -43,19 +49,14 @@ const nativeEvidenceWithExports = ( ) => { const input = exampleInput(); const native = input.native_observations[0]; - if (native === undefined || native.subject === null) - throw new Error("missing native example"); + if (native === undefined) throw new Error("missing native example"); const macho = inspectMachoSchema.parse(native.normalized_result); return createEvidence( subjectless - ? undefined + ? unknownTarget("not-observed") : { - path: path ?? native.subject.local_path, - sha256: native.subject.digest.sha256, - format: native.subject.format, - ...(native.subject.architecture === null - ? {} - : { architecture: native.subject.architecture }), + ...fileSubjectTarget(native.subject), + ...(path === undefined ? {} : { path }), }, native.provider, { @@ -139,18 +140,22 @@ const inputWithImportScope = (scope: string | null) => { ); return { ...input, - managed_boundaries: createEvidence(undefined, managed.provider, { - operation: managed.operation, - parameters: managed.parameters, - result: { - ...normalized, - pinvoke_imports: normalized.pinvoke_imports.map((item) => ({ - ...item, - import_scope_name: scope, - })), + managed_boundaries: createEvidence( + unknownTarget("not-observed"), + managed.provider, + { + operation: managed.operation, + parameters: managed.parameters, + result: { + ...normalized, + pinvoke_imports: normalized.pinvoke_imports.map((item) => ({ + ...item, + import_scope_name: scope, + })), + }, + rawResult: null, }, - rawResult: null, - }), + ), }; }; @@ -416,16 +421,13 @@ it("treats a Mach-O ABI-prefixed export as an exact declared import", () => { it("reports module mismatch as a contradiction within supplied Evidence", () => { const input = exampleInput(); const native = input.native_observations[0]; - if (native === undefined || native.subject === null) - throw new Error("missing native example"); + if (native === undefined) throw new Error("missing native example"); const mismatched = createEvidence( { path: "/examples/other.dll", - sha256: native.subject.digest.sha256, + sha256: fileIdentity(native.subject).sha256, format: "pe", - ...(native.subject.architecture === null - ? {} - : { architecture: native.subject.architecture }), + ...fileSubjectArchitecture(native.subject), }, native.provider, { @@ -650,19 +652,23 @@ it("retains a decorated module match when another decorated candidate has unknow const normalized = managedNativeBoundaryInspectionSchema.parse( parent.normalized_result, ); - const managed = createEvidence(undefined, parent.provider, { - operation: parent.operation, - parameters: parent.parameters, - result: { - ...normalized, - pinvoke_imports: normalized.pinvoke_imports.map((item) => ({ - ...item, - char_set: "unicode", - no_mangle: false, - })), + const managed = createEvidence( + unknownTarget("not-observed"), + parent.provider, + { + operation: parent.operation, + parameters: parent.parameters, + result: { + ...normalized, + pinvoke_imports: normalized.pinvoke_imports.map((item) => ({ + ...item, + char_set: "unicode", + no_mangle: false, + })), + }, + rawResult: null, }, - rawResult: null, - }); + ); const known = nativeFunctionEvidence( "/examples/nativehelper.dll", "pe", @@ -670,7 +676,7 @@ it("retains a decorated module match when another decorated candidate has unknow ); const subjectless = (name: string) => { const source = nativeFunctionEvidence("/examples/unknown.dll", "pe", name); - return createEvidence(undefined, source.provider, { + return createEvidence(unknownTarget("not-observed"), source.provider, { operation: source.operation, parameters: source.parameters, result: source.normalized_result, @@ -925,18 +931,22 @@ it("reports coverage unknown when the managed boundary inspection is unavailable return verifyManagedNativeVerificationSource( readFixtureSource({ ...input, - managed_boundaries: createEvidence(undefined, managed.provider, { - operation: managed.operation, - parameters: managed.parameters, - result: { - ...normalized, - ...(state === "unavailable" - ? { module_refs: [], pinvoke_imports: [] } - : {}), - coverage: { ...normalized.coverage, state }, + managed_boundaries: createEvidence( + unknownTarget("not-observed"), + managed.provider, + { + operation: managed.operation, + parameters: managed.parameters, + result: { + ...normalized, + ...(state === "unavailable" + ? { module_refs: [], pinvoke_imports: [] } + : {}), + coverage: { ...normalized.coverage, state }, + }, + rawResult: null, }, - rawResult: null, - }), + ), native_observations: nativeObservations, }), ); @@ -944,13 +954,7 @@ it("reports coverage unknown when the managed boundary inspection is unavailable const exhaustive = nativeEvidenceWithExports(["open_native"]); const macho = inspectMachoSchema.parse(exhaustive.normalized_result); const partialExports = createEvidence( - exhaustive.subject === null - ? undefined - : { - path: exhaustive.subject.local_path, - sha256: exhaustive.subject.digest.sha256, - format: exhaustive.subject.format, - }, + fileSubjectTarget(exhaustive.subject), exhaustive.provider, { operation: exhaustive.operation, @@ -1055,19 +1059,23 @@ it("does not treat a raw Mach-O ABI name as an exact underscored C identifier", const result = verifyManagedNativeVerificationSource( readFixtureSource({ ...input, - managed_boundaries: createEvidence(undefined, managed.provider, { - operation: managed.operation, - parameters: managed.parameters, - result: { - ...normalized, - pinvoke_imports: imports.map((item) => ({ - ...item, - import_name: "_open_native", - no_mangle: true, - })), + managed_boundaries: createEvidence( + unknownTarget("not-observed"), + managed.provider, + { + operation: managed.operation, + parameters: managed.parameters, + result: { + ...normalized, + pinvoke_imports: imports.map((item) => ({ + ...item, + import_name: "_open_native", + no_mangle: true, + })), + }, + rawResult: null, }, - rawResult: null, - }), + ), native_observations: [nativeEvidenceWithExports(["_open_native"])], }), ); diff --git a/tests/conformance/readiness/report/reconstructionReadinessExample.ts b/tests/conformance/readiness/report/reconstructionReadinessExample.ts index 4fa2063c6a..50ca0f6725 100644 --- a/tests/conformance/readiness/report/reconstructionReadinessExample.ts +++ b/tests/conformance/readiness/report/reconstructionReadinessExample.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../../../src/domain/targetIdentity.js"; import { createEvidence } from "../../../../src/domain/evidence.js"; import { createEvidenceBundle } from "../../../../src/domain/evidenceBundle.js"; import { READINESS_REQUIRED_CHECKS } from "./reconstructionReadinessJourneyFindings.js"; @@ -14,7 +15,7 @@ import { const HASH = "a".repeat(64); const sourceEvidence = (variant: string) => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "rea-readiness-fixture", name: "REA readiness fixture", diff --git a/tests/evaluation/model-evals/AgentEvaluationFixtures.ts b/tests/evaluation/model-evals/AgentEvaluationFixtures.ts index 590c105ff9..dfa6adb02e 100644 --- a/tests/evaluation/model-evals/AgentEvaluationFixtures.ts +++ b/tests/evaluation/model-evals/AgentEvaluationFixtures.ts @@ -486,7 +486,7 @@ const managedClaims = ( evidence.authority === source.authority && evidence.confidence === source.confidence && evidence.subject?.local_path === source.subject.path && - evidence.subject.digest.sha256 === source.subject.sha256, + evidence.subject.identity.sha256 === source.subject.sha256, ); if (artifacts.length !== 1) return undefined; const parsedArtifact = readManagedInspectionEvidence( diff --git a/tests/evaluation/model-evals/KnownAnswerEvaluation.ts b/tests/evaluation/model-evals/KnownAnswerEvaluation.ts index 38d86e2c6f..bf816b716f 100644 --- a/tests/evaluation/model-evals/KnownAnswerEvaluation.ts +++ b/tests/evaluation/model-evals/KnownAnswerEvaluation.ts @@ -408,7 +408,7 @@ const matchesSubject = ( ): boolean => evidence.subject?.local_path === expected.path && (expected.sha256 === undefined || - evidence.subject.digest.sha256 === expected.sha256); + evidence.subject.identity.sha256 === expected.sha256); const matchesParameters = ( evidence: Evidence, diff --git a/tests/evaluation/model-evals/knownAnswerEvaluation.test.ts b/tests/evaluation/model-evals/knownAnswerEvaluation.test.ts index 16a4d56448..de4c068ba1 100644 --- a/tests/evaluation/model-evals/knownAnswerEvaluation.test.ts +++ b/tests/evaluation/model-evals/knownAnswerEvaluation.test.ts @@ -1,3 +1,4 @@ +import { displayedEvidenceSubject } from "../../fixtures/evidenceSubject.js"; import { STDIO_DEFAULT_MAX_BUFFER_SIZE } from "@modelcontextprotocol/server"; import { describe, expect, it } from "vitest"; @@ -390,10 +391,9 @@ describe("managed member grounding", () => { ).toBe("failed"); const conflicting = { ...fixture.artifactEvidence, - subject: - fixture.memberEvidence.subject === null - ? null - : { ...fixture.memberEvidence.subject, local_path: "/other.dll" }, + subject: displayedEvidenceSubject(fixture.memberEvidence.subject, { + local_path: "/other.dll", + }), }; expect( fixture.grade([ @@ -749,10 +749,9 @@ describe("fixture identity and provenance binding", () => { const evidence = createObservation(); const conflicting = { ...evidence, - subject: - evidence.subject === null - ? null - : { ...evidence.subject, local_path: "/targets/other.asar" }, + subject: displayedEvidenceSubject(evidence.subject, { + local_path: "/targets/other.asar", + }), }; expect( assess( diff --git a/tests/fixtures/advertisedMcpTool.ts b/tests/fixtures/advertisedMcpTool.ts index f87ef5dcb5..2317b48beb 100644 --- a/tests/fixtures/advertisedMcpTool.ts +++ b/tests/fixtures/advertisedMcpTool.ts @@ -1,3 +1,4 @@ +import { fileIdentity } from "./evidenceSubject.js"; import { canonicalInputSchema, canonicalOutputSchema, @@ -95,7 +96,7 @@ export const assertRecordedMcpEvidence = ( ); const evidence = parseEvidence(parsed); expect(evidence.confidence).toBe(confidence); - expect(evidence.subject?.digest.sha256).toBe(expected.artifact.sha256); + expect(fileIdentity(evidence.subject).sha256).toBe(expected.artifact.sha256); expect(parsed.normalized_result).toEqual(expected); expect(session.evidenceById(evidence.evidence_id)).toEqual(evidence); return evidence; diff --git a/tests/fixtures/analysisView.ts b/tests/fixtures/analysisView.ts index 64b005f532..be5f524550 100644 --- a/tests/fixtures/analysisView.ts +++ b/tests/fixtures/analysisView.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import type { JsonValue } from "../../src/domain/jsonValue.js"; import { apiSurfaceHar, @@ -263,7 +264,7 @@ export const analysisViewCaptureEvidence = ( ): Evidence => createEvidence( capture.artifact.sha256 === null - ? undefined + ? unknownTarget("not-observed") : { path: capture.artifact.path, sha256: capture.artifact.sha256, diff --git a/tests/fixtures/artifactEvidence.ts b/tests/fixtures/artifactEvidence.ts index 9c4fe7ffb0..17457399a1 100644 --- a/tests/fixtures/artifactEvidence.ts +++ b/tests/fixtures/artifactEvidence.ts @@ -1,3 +1,4 @@ +import { fileSubjectDisplay, fileIdentity } from "./evidenceSubject.js"; import { artifactInventoryResultSchema, type ArtifactInventoryResult, @@ -19,8 +20,6 @@ export const historicalInventoryEvidence = ( const inventory = artifactInventoryResultSchema.parse( source.normalized_result, ); - if (source.subject === null) - throw new TypeError("Inventory has no artifact subject"); const occurrences = inventory.occurrences.map(alter); const graphSha256 = artifactGraphDigest({ nodes: inventory.nodes, @@ -30,7 +29,7 @@ export const historicalInventoryEvidence = ( }); return createEvidence( { - path: source.subject.local_path, + path: fileSubjectDisplay(source.subject).local_path, sha256: inventory.manifest.root_sha256, format: inventory.manifest.root_format, }, @@ -65,14 +64,12 @@ export const fragmentInventoryEvidence = ( evidence.normalized_result, ); const subject = evidence.subject; - if (subject === null) - throw new TypeError("Inventory has no artifact subject"); return Array.from({ length: count }, (_, index) => createEvidence( { - path: subject.local_path, - sha256: subject.digest.sha256, - format: subject.format, + path: fileSubjectDisplay(subject).local_path, + sha256: fileIdentity(subject).sha256, + format: fileIdentity(subject).format, }, evidence.provider, { diff --git a/tests/fixtures/evidenceSubject.ts b/tests/fixtures/evidenceSubject.ts new file mode 100644 index 0000000000..8d5c9eb99d --- /dev/null +++ b/tests/fixtures/evidenceSubject.ts @@ -0,0 +1,80 @@ +import { + evidenceSubject, + evidenceSubjectDisplay, + evidenceSubjectTarget, + type Evidence, + type EvidenceSubjectTarget, +} from "../../src/domain/evidence.js"; +import { unknownTarget } from "../../src/domain/targetIdentity.js"; + +type EvidenceSubject = Evidence["subject"]; + +/** Target identity members a test may change on an Evidence subject. */ +interface EvidenceSubjectChange { + readonly sha256?: string; + readonly format?: string; + readonly architecture?: string | null; +} + +/** + * Change an Evidence subject's target identity, so a test of a mismatched + * subject changes what readers see. The result is deliberately not + * validated: tests use it for refused parents. + */ +export const changedEvidenceSubject = ( + subject: EvidenceSubject, + change: EvidenceSubjectChange, +): EvidenceSubject => + ({ + ...subject, + identity: { ...subject.identity, ...change }, + }) as EvidenceSubject; + +/** Change a subject's display facts without validating the result. */ +export const displayedEvidenceSubject = ( + subject: EvidenceSubject, + display: { readonly name?: string; readonly local_path?: string }, +): EvidenceSubject => ({ ...subject, ...display }) as EvidenceSubject; + +/** The file identity of a subject a test expects to name a file. */ +export const fileIdentity = ( + subject: EvidenceSubject | undefined, +): Extract => { + if (subject?.identity.kind !== "file") + throw new Error("Expected an Evidence subject that names a file"); + return subject.identity; +}; + +/** The display facts of a subject a test expects to name a file. */ +export const fileSubjectDisplay = ( + subject: EvidenceSubject | undefined, +): { readonly name: string; readonly local_path: string } => { + const display = evidenceSubjectDisplay({ subject }); + if (display === undefined) + throw new Error("Expected an Evidence subject that names a file"); + return display; +}; + +/** A producer target for the file a subject names, without its display name. */ +export const fileSubjectTarget = ( + subject: EvidenceSubject | undefined, +): EvidenceSubjectTarget => { + const target = evidenceSubjectTarget(subject); + if (target === undefined) + throw new Error("Expected an Evidence subject that names a file"); + const { name: _name, ...withoutName } = target; + return withoutName; +}; + +/** The architecture member of the file target a subject names, when it has one. */ +export const fileSubjectArchitecture = ( + subject: EvidenceSubject | undefined, +): Pick => { + const { architecture } = fileSubjectTarget(subject); + return architecture === undefined ? {} : { architecture }; +}; + +/** A subject whose target identity was not observed. */ +export const UNKNOWN_EVIDENCE_SUBJECT: EvidenceSubject = evidenceSubject( + unknownTarget("not-observed"), +); diff --git a/tests/fixtures/flutterVerifierPreload.mjs b/tests/fixtures/flutterVerifierPreload.mjs index 11eb821afb..cdbf5ba681 100644 --- a/tests/fixtures/flutterVerifierPreload.mjs +++ b/tests/fixtures/flutterVerifierPreload.mjs @@ -7,7 +7,7 @@ export function result(operation,input) { const abi=input.abi ?? (process.env.REA_FLUTTER_PROBE === 'wrong' ? 'ghost' : 'x86_64'); return {target,abi,coverage:'complete',libapp:{coverage:'complete',sha256:'b'.repeat(64),bytes:100,snapshot_hash_sources:2,snapshot_hash:'hash',sections:['_kDartVmSnapshotData','_kDartVmSnapshotInstructions','_kDartIsolateSnapshotData','_kDartIsolateSnapshotInstructions'].map(name=>({name,offset:0,size:64,magic_valid:true,kind:3,header_length:48}))},string_pool:{coverage:'complete',package_uri_count_at_least:1,dart_uri_count_at_least:1}}; } -export function envelope(op,input){const resultValue=result(op,input);return {normalized_result:resultValue,subject:{local_path:input.path,digest:{sha256:identity.sha256}},limitations:[]};} +export function envelope(op,input){const resultValue=result(op,input);return {normalized_result:resultValue,subject:{local_path:input.path,identity:{kind:"file",sha256:identity.sha256}},limitations:[]};} `; const modelUrl = "data:text/javascript," + encodeURIComponent(model); const mocks = { diff --git a/tests/fixtures/reconstructionProofApplicability.ts b/tests/fixtures/reconstructionProofApplicability.ts index 353ca190c1..5883cd9952 100644 --- a/tests/fixtures/reconstructionProofApplicability.ts +++ b/tests/fixtures/reconstructionProofApplicability.ts @@ -1,5 +1,9 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { readyReviewedLedgerRequest } from "../../src/application/ReconstructionObligationLedger.fixture.js"; -import { createEvidence } from "../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSubjectInput, +} from "../../src/domain/evidence.js"; import { createEvidenceBundle } from "../../src/domain/evidenceBundle.js"; import { reconstructionObligationProofSchema } from "../../src/domain/reconstructionObligationProof.js"; @@ -12,14 +16,18 @@ const replaceProof = ( const original = input.evidence_bundle.records.find( (record) => record.predicate_type === "rea.reconstruction-proof", )!; - const replacement = createEvidence(undefined, original.provider, { - predicateType: original.predicate_type, - operation: original.operation, - parameters: original.parameters, - result: result, - confidence: original.confidence, - authority: original.authority, - }); + const replacement = createEvidence( + evidenceSubjectInput(original.subject), + original.provider, + { + predicateType: original.predicate_type, + operation: original.operation, + parameters: original.parameters, + result: result, + confidence: original.confidence, + authority: original.authority, + }, + ); input.evidence_bundle = createEvidenceBundle( input.evidence_bundle.records.map((record) => record.evidence_id === original.evidence_id ? replacement : record, @@ -244,7 +252,7 @@ export const reconstructionProofApplicabilityCases = () => if (specification.name === "passing fixture with stale failed proof") proof.owner_sha256 = "2".repeat(64); const failed = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "failed-fixture", name: "Fixture verifier", diff --git a/tests/fixtures/webScriptCapture.ts b/tests/fixtures/webScriptCapture.ts index 06682ef614..c3445e623f 100644 --- a/tests/fixtures/webScriptCapture.ts +++ b/tests/fixtures/webScriptCapture.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { createHash } from "node:crypto"; import { sanitizeBrowserUrl } from "../../src/domain/browserObservation.js"; @@ -129,7 +130,7 @@ export const scriptScenarioFixture = ( /** Complete Evidence envelope for authentication and file-boundary tests. */ export const scriptCaptureEvidenceFixture = () => createEvidence( - undefined, + unknownTarget("not-observed"), { id: "source-fixture", name: "Source fixture", version: "1" }, { operation: "capture_browser_scenario", diff --git a/tests/process-global/analysisEvidenceDelivery.test.ts b/tests/process-global/analysisEvidenceDelivery.test.ts index 5618d51a59..be8bb8bf08 100644 --- a/tests/process-global/analysisEvidenceDelivery.test.ts +++ b/tests/process-global/analysisEvidenceDelivery.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { readFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it, vi } from "vitest"; @@ -19,7 +20,7 @@ it("publishes CLI Evidence without re-authenticating the complete graph", async const root = await createTestTempDirectory("rea-cli-evidence-"); const destination = join(root, "bundle.json"); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "fixture", @@ -49,7 +50,7 @@ it("keeps the writer heap check for mutable source Evidence", async () => { const root = await createTestTempDirectory("rea-cli-mutable-evidence-"); const destination = join(root, "bundle.json"); const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "fixture", @@ -59,7 +60,7 @@ it("keeps the writer heap check for mutable source Evidence", async () => { { immutable: true }, ); const source = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "source-fixture", diff --git a/tests/process-global/bundleComparisonFailures.test.ts b/tests/process-global/bundleComparisonFailures.test.ts index a91995a93e..8423e4368c 100644 --- a/tests/process-global/bundleComparisonFailures.test.ts +++ b/tests/process-global/bundleComparisonFailures.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { readdir, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -222,7 +223,7 @@ it.each(unexpectedBundleFailures)( ); const { bundle } = await validBundleFile(directory); const existing = evidenceDomain.createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", diff --git a/tests/process-global/byteEntropyCleanupCli.test.ts b/tests/process-global/byteEntropyCleanupCli.test.ts index b271eaa63e..bfd4b97635 100644 --- a/tests/process-global/byteEntropyCleanupCli.test.ts +++ b/tests/process-global/byteEntropyCleanupCli.test.ts @@ -96,7 +96,7 @@ it.each([ partial_observation: { provider: { id: BYTE_ENTROPY_PROVIDER.id }, subject: { - digest: { + identity: { sha256: createHash("sha256").update(content).digest("hex"), }, }, diff --git a/tests/process-global/derivedOperationFailures.test.ts b/tests/process-global/derivedOperationFailures.test.ts index 51ba2f0c10..da043c2f4f 100644 --- a/tests/process-global/derivedOperationFailures.test.ts +++ b/tests/process-global/derivedOperationFailures.test.ts @@ -1,3 +1,5 @@ +import { fileSubjectTarget } from "../fixtures/evidenceSubject.js"; +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -9,7 +11,13 @@ import { ARTIFACT_COMPARISON_EXAMPLE } from "../../src/contracts/artifactCompari import { FUNCTION_COMPARISON_EXAMPLE } from "../../src/contracts/functionComparisonExample.js"; import { completeReconstructionCoverageData } from "../../src/domain/reconstructionCoverage.fixture.js"; import { reconstructionClosureResultSchema } from "../../src/domain/reconstructionCoverage.js"; -import { createEvidence } from "../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSubjectInput, +} from "../../src/domain/evidence.js"; +import { RetainedRegularFileCleanupFailure } from "../../src/process/RegularFileRead.js"; +import { OwnedFileHandle } from "../../src/filesystem/OwnedFileHandle.js"; +import { primaryAnalysisError } from "../../src/domain/analysisErrorBase.js"; import { functionComparisonResultSchema } from "../../src/domain/functionComparisonSchemas.js"; import { createServer } from "../../src/server/createServer.js"; import { createTestBinarySession } from "../fixtures/binarySession.js"; @@ -28,9 +36,6 @@ import { managedReconstructionImportResultSchema } from "../../src/domain/manage import { captureProcessScenarioFile } from "../../src/application/process/ProcessCli.js"; import { managedComparisonCommand } from "../fixtures/managedComparisonCommand.js"; -import { RetainedRegularFileCleanupFailure } from "../../src/process/RegularFileRead.js"; -import { OwnedFileHandle } from "../../src/filesystem/OwnedFileHandle.js"; -import { primaryAnalysisError } from "../../src/domain/analysisErrorBase.js"; import { buildManagedPeFixture } from "../../src/dotnet/ManagedPe.fixture.js"; import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js"; import { wasmArtifactFixture } from "../fixtures/wasm/artifact.js"; @@ -142,15 +147,10 @@ describe.each([ const invalidFunctionOperationEvidence = () => { const left = FUNCTION_COMPARISON_EXAMPLE.left; - if (left.subject === null) throw new Error("Expected a function subject"); return createEvidence( { + ...fileSubjectTarget(left.subject), path: "/tmp/wrong-function-operation", - sha256: left.subject.digest.sha256, - format: left.subject.format, - ...(left.subject.architecture === null - ? {} - : { architecture: left.subject.architecture }), }, left.provider, { @@ -169,15 +169,10 @@ const invalidFunctionOperationEvidence = () => { const malformedFunctionResultEvidence = () => { const left = FUNCTION_COMPARISON_EXAMPLE.left; - if (left.subject === null) throw new Error("Expected a function subject"); return createEvidence( { + ...fileSubjectTarget(left.subject), path: "/tmp/malformed-function-result", - sha256: left.subject.digest.sha256, - format: left.subject.format, - ...(left.subject.architecture === null - ? {} - : { architecture: left.subject.architecture }), }, left.provider, { @@ -320,35 +315,43 @@ describe("runtime reconciliation failure ownership through the public SDK", () = async ({ field, path, reason }) => { await withSdk(async ({ client, session }) => { const { evidence, result } = activeRuntimeFixture(); - const runtime = createEvidence(undefined, evidence.provider, { - operation: evidence.operation, - predicateType: evidence.predicate_type, - authority: evidence.authority, - confidence: evidence.confidence, - parameters: - field === "parameters" - ? { - ...evidence.parameters, - resolved_paths: { - ...(evidence.parameters.resolved_paths as object), - application_root: 3, + const runtime = createEvidence( + evidenceSubjectInput(evidence.subject), + evidence.provider, + { + operation: evidence.operation, + predicateType: evidence.predicate_type, + authority: evidence.authority, + confidence: evidence.confidence, + parameters: + field === "parameters" + ? { + ...evidence.parameters, + resolved_paths: { + ...(evidence.parameters.resolved_paths as object), + application_root: 3, + }, + } + : evidence.parameters, + result: + field === "parameters" + ? result + : { + ...result, + application: { + ...result.application, + application_path: + field === "payload" + ? 3 + : join( + process.cwd(), + "another-application", + "main.js", + ), + }, }, - } - : evidence.parameters, - result: - field === "parameters" - ? result - : { - ...result, - application: { - ...result.application, - application_path: - field === "payload" - ? 3 - : join(process.cwd(), "another-application", "main.js"), - }, - }, - }); + }, + ); const response = await client.callTool({ name: "reconcile_javascript_runtime", arguments: { @@ -561,11 +564,15 @@ describe.each(managedWorkflows)( it("rejects a malformed authenticated source payload as Evidence integrity", async () => { await withSdk(async ({ client, session }) => { - const source = createEvidence(undefined, workflow.source.provider, { - operation: workflow.source.operation, - parameters: {}, - result: { malformed: true }, - }); + const source = createEvidence( + unknownTarget("not-observed"), + workflow.source.provider, + { + operation: workflow.source.operation, + parameters: {}, + result: { malformed: true }, + }, + ); const response = await client.callTool({ name: workflow.name, arguments: { ...workflow.input, [workflow.sourceField]: source }, diff --git a/tests/process-global/evidenceBundleHeadroom.test.ts b/tests/process-global/evidenceBundleHeadroom.test.ts index e94853cee0..3fc63be833 100644 --- a/tests/process-global/evidenceBundleHeadroom.test.ts +++ b/tests/process-global/evidenceBundleHeadroom.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -44,7 +45,7 @@ describe("evidence bundle import headroom", () => { "bundle.json", ); const record = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "observe", diff --git a/tests/process-global/javascriptAnalysisCancellation.test.ts b/tests/process-global/javascriptAnalysisCancellation.test.ts index 538844fada..3acd89bf01 100644 --- a/tests/process-global/javascriptAnalysisCancellation.test.ts +++ b/tests/process-global/javascriptAnalysisCancellation.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -97,7 +98,7 @@ it.each([ ); }); const prior = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "prior_observation", diff --git a/tests/process-global/managedBundleReadGuards.test.ts b/tests/process-global/managedBundleReadGuards.test.ts index 4150254ab3..cba048975d 100644 --- a/tests/process-global/managedBundleReadGuards.test.ts +++ b/tests/process-global/managedBundleReadGuards.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { getHeapStatistics } from "node:v8"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { createServer } from "../../src/server/createServer.js"; @@ -9,6 +10,7 @@ import { createEvidence, isImmutableEvidence, parseEvidence, + evidenceSubjectInput, } from "../../src/domain/evidence.js"; import { createTestBinarySession } from "../fixtures/binarySession.js"; import { writeFile } from "node:fs/promises"; @@ -121,7 +123,7 @@ it("keeps the owning operation when native matching reloads a needed earlier bun const path = join(root, "parent.json"), empty = join(root, "empty.json"); const parent = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { operation: "list_procedures", parameters: {}, result: {} }, ); @@ -289,13 +291,17 @@ it("authenticates escaped payloads without serializing either complete bundle", const path = join(root, "parent.json"); const escaped = '\u0000\u0001\\"😀\ud800'.repeat(20000); const example = SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE.application; - const parent = createEvidence(undefined, example.provider, { - predicateType: example.predicate_type, - operation: example.operation, - parameters: example.parameters, - result: example.normalized_result, - rawResult: { escaped }, - }); + const parent = createEvidence( + evidenceSubjectInput(example.subject), + example.provider, + { + predicateType: example.predicate_type, + operation: example.operation, + parameters: example.parameters, + result: example.normalized_result, + rawResult: { escaped }, + }, + ); await writeFile( path, JSON.stringify(createImmutableEvidenceBundle([parent])), @@ -341,7 +347,11 @@ it("seals a fresh object-heavy Evidence tree without retaining a set of complete parameters: {}, result, }; - const complete = createEvidence(undefined, provider, observation); + const complete = createEvidence( + unknownTarget("not-observed"), + provider, + observation, + ); const add = Set.prototype.add; const guarded = vi.spyOn(Set.prototype, "add").mockImplementation(function ( this: Set, @@ -360,9 +370,14 @@ it("seals a fresh object-heavy Evidence tree without retaining a set of complete }); let sealed; try { - sealed = createEvidence(undefined, provider, observation, { - immutable: true, - }); + sealed = createEvidence( + unknownTarget("not-observed"), + provider, + observation, + { + immutable: true, + }, + ); } finally { guarded.mockRestore(); } diff --git a/tests/process-global/oneShotSourceClosure.test.ts b/tests/process-global/oneShotSourceClosure.test.ts index d13d0d1396..a2d8cceaa4 100644 --- a/tests/process-global/oneShotSourceClosure.test.ts +++ b/tests/process-global/oneShotSourceClosure.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { readdir, readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -65,11 +66,15 @@ type FinalClose = const fixture = async (dependencyText = "Synthetic dependency") => { const root = await createTestTempDirectory("rea-source-closure-"); - const dependency = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_dependency", - parameters: {}, - result: { source: dependencyText }, - }); + const dependency = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_dependency", + parameters: {}, + result: { source: dependencyText }, + }, + ); const left = nativeMatchingInventory( "1", [{ address: "0x10", value: "main" }], @@ -271,20 +276,28 @@ it("keeps the fault on the final close when another scope closes first", async ( it("keeps cancellation typed for a captured source with a data-sized link set", async () => { // Repeated links are valid Evidence, and only one distinct record backs them. - const ancestor = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_ancestor", - parameters: {}, - result: { source: "Synthetic ancestor" }, - }); - const wide = createEvidence(undefined, nativeMatchingProvider, { - operation: "fixture_dependency", - parameters: {}, - result: { source: "Synthetic wide dependency" }, - evidenceLinks: Array.from( - { length: DATA_SIZED_LINKS }, - () => ancestor.evidence_id, - ), - }); + const ancestor = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_ancestor", + parameters: {}, + result: { source: "Synthetic ancestor" }, + }, + ); + const wide = createEvidence( + unknownTarget("not-observed"), + nativeMatchingProvider, + { + operation: "fixture_dependency", + parameters: {}, + result: { source: "Synthetic wide dependency" }, + evidenceLinks: Array.from( + { length: DATA_SIZED_LINKS }, + () => ancestor.evidence_id, + ), + }, + ); const input = await fixture(); const left = nativeMatchingInventory( "1", diff --git a/tests/process-global/stableArtifactConsumers.test.ts b/tests/process-global/stableArtifactConsumers.test.ts index d2883c7a3d..690e07f70d 100644 --- a/tests/process-global/stableArtifactConsumers.test.ts +++ b/tests/process-global/stableArtifactConsumers.test.ts @@ -1,3 +1,4 @@ +import { unknownTarget } from "../../src/domain/targetIdentity.js"; import { PeLoadConfigProvider } from "../../src/native/pe/PeLoadConfigProvider.js"; import { createArtifactAnalysisResources } from "../../src/providers/artifactResourceFailure.js"; import { ReleaseExposureReader } from "../../src/artifacts/ReleaseExposureReader.js"; @@ -296,7 +297,7 @@ const expectIl2cppSource = ( expect(source.operation).toBe("observe_il2cpp_metadata_source"); expect(source.subject).toMatchObject({ local_path: path, - digest: { sha256 }, + identity: { sha256 }, }); expect(source.normalized_result).toEqual({ artifact: { path, sha256, bytes: bytes.length }, @@ -533,7 +534,7 @@ it.each([ if (result.ok) throw new Error("Expected finalization failure"); const evidence = parseEvidence(result.error.partialObservation); expect(evidence.operation).toBe("inspect_model_artifact"); - expect(evidence.subject).toBeNull(); + expect(evidence.subject.identity.kind).toBe("unknown"); expect(evidence.normalized_result).toMatchObject({ artifact: { path, sha256: null, read_scope: "header" }, tensors: [{ name: "weight" }, { name: "quant" }], @@ -879,7 +880,7 @@ it.each([ foreignPath, ); const foreignPartial = createEvidence( - undefined, + unknownTarget("not-observed"), { id: "foreign", name: "foreign owner", version: null }, { operation: "inspect_artifact", diff --git a/tests/support/analysis-efficiency/agent-trial.py b/tests/support/analysis-efficiency/agent-trial.py index 8308c95c93..dbd2e894af 100644 --- a/tests/support/analysis-efficiency/agent-trial.py +++ b/tests/support/analysis-efficiency/agent-trial.py @@ -126,7 +126,7 @@ def main(): 'Preserve observations, derivations, inferences, limitations, and real Evidence IDs. ' 'An Evidence value has evidence_id, normalized_result and limitations; ' 'non-Evidence session values have result. ' - 'The analyzed target digest is Evidence.subject.digest.sha256. ' + 'The analyzed target digest is Evidence.subject.identity.sha256. ' 'normalized_result.engine.artifact_sha256 identifies the analysis engine ' 'artifact and must never be substituted for the target digest. ' 'Prefer summary/focused views where appropriate. Do not invent successful facts ' diff --git a/tests/support/analysis-efficiency/android-jni.mjs b/tests/support/analysis-efficiency/android-jni.mjs index 3571bb2720..ccee3b6faa 100644 --- a/tests/support/analysis-efficiency/android-jni.mjs +++ b/tests/support/analysis-efficiency/android-jni.mjs @@ -597,7 +597,7 @@ async function qualifyRetainedRemoval(invoke) { detail: "complete", }); assert.equal(parent.operation, "inspect_android_jni_bindings"); - assert.equal(parent.subject.digest.sha256, targetSha); + assert.equal(parent.subject.identity.sha256, targetSha); assert.equal(parent.normalized_result.apk.path, ownedCopy); const report = parent.normalized_result; (values.variant === "conscrypt" ? checkConscrypt : checkFixture)( @@ -883,7 +883,7 @@ try { ? "inspect_analysis_view" : "inspect_android_jni_bindings", ); - assert.equal(evidence.subject.digest.sha256, targetSha); + assert.equal(evidence.subject.identity.sha256, targetSha); const parent = { id: values.detail === "summary" @@ -927,7 +927,7 @@ try { ); assert.ok(parent, "Complete source Evidence must remain exportable"); assert.equal(parent.operation, "inspect_android_jni_bindings"); - assert.equal(parent.subject.digest.sha256, targetSha); + assert.equal(parent.subject.identity.sha256, targetSha); if (report !== undefined) assert.deepEqual(parent.normalized_result, report); report = parent.normalized_result; diff --git a/tests/support/analysis-efficiency/android-mapping-retention.mjs b/tests/support/analysis-efficiency/android-mapping-retention.mjs index 813e6c5ca0..5438af332a 100644 --- a/tests/support/analysis-efficiency/android-mapping-retention.mjs +++ b/tests/support/analysis-efficiency/android-mapping-retention.mjs @@ -35,6 +35,7 @@ const INPUT_BYTES = 10 * 1024 * 1024; const paths = { parser: resolve(selectedRepo, "dist/domain/android/proguardMapping.js"), evidence: resolve(selectedRepo, "dist/domain/evidence.js"), + targetIdentity: resolve(selectedRepo, "dist/domain/targetIdentity.js"), ledger: resolve( selectedRepo, "dist/application/investigation/EvidenceLedger.js", @@ -51,6 +52,9 @@ for (const [name, path] of Object.entries(paths)) { const { parseProguardMapping, resolveProguardClass, resolveProguardMethod } = await import(pathToFileURL(paths.parser).href); const { createEvidence } = await import(pathToFileURL(paths.evidence).href); +const { unknownTarget } = await import( + pathToFileURL(paths.targetIdentity).href +); const { EvidenceLedger } = await import(pathToFileURL(paths.ledger).href); // This explicit UTF-16 byte roundtrip owns new string storage. Concatenation, @@ -159,7 +163,7 @@ function recordSelected(holder, detached, paddingBytes = INPUT_BYTES) { // Real production createEvidence -> immutable snapshot -> real ledger record. // There is no JSON stringify/parse inserted as an artificial detachment. const evidence = createEvidence( - undefined, + unknownTarget("not-observed"), PROVIDER, { operation: "string-retention-probe", diff --git a/tests/support/analysis-efficiency/android-mapping.mjs b/tests/support/analysis-efficiency/android-mapping.mjs index c094e59d1f..2d175b8195 100644 --- a/tests/support/analysis-efficiency/android-mapping.mjs +++ b/tests/support/analysis-efficiency/android-mapping.mjs @@ -132,7 +132,7 @@ try { ); const evidence = result.structuredContent; if (name === "export_evidence_bundle") return evidence; - assert.equal(evidence.subject.digest.sha256, targetSha); + assert.equal(evidence.subject.identity.sha256, targetSha); const projection = evidence.normalized_result; const normalized = values.detail === "summary" ? projection.summary : projection; @@ -300,7 +300,7 @@ try { ); assert.ok(parent, "Complete source Evidence must remain exportable"); assert.equal(parent.operation, expected.name); - assert.equal(parent.subject.digest.sha256, targetSha); + assert.equal(parent.subject.identity.sha256, targetSha); assert.equal( parent.parameters.mapping_path, expected.args.mapping_path, diff --git a/tests/support/analysis-efficiency/native-entry.mjs b/tests/support/analysis-efficiency/native-entry.mjs index caaf6a802f..4680d00b6e 100644 --- a/tests/support/analysis-efficiency/native-entry.mjs +++ b/tests/support/analysis-efficiency/native-entry.mjs @@ -189,7 +189,7 @@ export const measureNativeEntry = async ({ ? await retainedJqMain(call, ToolFailure) : {}; return { - artifact_sha256: info.subject?.digest.sha256, + artifact_sha256: info.subject?.identity.sha256, entry_address: address, containing_procedure: normalized(containing), procedure: n.procedure, diff --git a/tests/support/analysis-efficiency/review-model.py b/tests/support/analysis-efficiency/review-model.py index 782c320e16..2195ff1965 100644 --- a/tests/support/analysis-efficiency/review-model.py +++ b/tests/support/analysis-efficiency/review-model.py @@ -312,8 +312,8 @@ def main(): checks['pcap_cited_subjects_match_artifact'] = bool(cited) and all( isinstance(record, dict) and isinstance(record.get('subject'), dict) - and isinstance(record['subject'].get('digest'), dict) - and record['subject']['digest'].get('sha256') == reference['artifact_sha256'] + and isinstance(record['subject'].get('identity'), dict) + and record['subject']['identity'].get('sha256') == reference['artifact_sha256'] and record['subject'].get('local_path') == reference['capture']['target']['path'] for record in cited ) diff --git a/tests/support/analysis-efficiency/test_codex_context.py b/tests/support/analysis-efficiency/test_codex_context.py index 2ebc6fb2a2..3f9181b36d 100644 --- a/tests/support/analysis-efficiency/test_codex_context.py +++ b/tests/support/analysis-efficiency/test_codex_context.py @@ -81,7 +81,7 @@ class PcapGraderWorkflowTests(unittest.TestCase): 'retained_counts': {'http_request_uris': 3}} prefix = ['http://example.test/one', 'http://example.test/two'] coverage = {'status': 'page', 'examined': 2, 'total': 3, 'next_offset': 2, 'exhausted': False} - subject = {'digest': {'sha256': capture['target']['sha256']}, 'local_path': capture['target']['path']} + subject = {'identity': {'sha256': capture['target']['sha256']}, 'local_path': capture['target']['path']} summary = {'evidence_id': summary_id, 'operation': 'inspect_analysis_view', 'subject': copy.deepcopy(subject), 'evidence_links': [parent], 'limitations': ['source', 'view'], @@ -226,7 +226,7 @@ class PcapGraderWorkflowTests(unittest.TestCase): self.assertFalse(self.grade(answer, [receipt], reference, ['inspect_analysis_view'])['all_factual_checks_pass']) wrong_operation = copy.deepcopy(receipt);wrong_operation['operation'] = 'inspect_analysis_view' self.assertFalse(self.grade(answer, [wrong_operation], reference)['all_factual_checks_pass']) - for subject in [None, {'digest': {'sha256': 'e' * 64}, 'local_path': source['target']['path']}]: + for subject in [None, {'identity': {'sha256': 'e' * 64}, 'local_path': source['target']['path']}]: changed = copy.deepcopy(receipt);changed['subject'] = subject report = self.grade(answer, [changed], reference) self.assertTrue(report['factual_checks']['pcap_cited_capture']) @@ -252,8 +252,8 @@ class PcapGraderWorkflowTests(unittest.TestCase): def test_cited_receipt_subjects_must_identify_the_reference_capture(self): for index in [0, 1]: for subject in [None, [], 'artifact', {}, {'digest': None}, - {'digest': {'sha256': 'e' * 64}, 'local_path': '/fixture/http.pcapng'}, - {'digest': {'sha256': 'd' * 64}, 'local_path': '/fixture/other.pcapng'}]: + {'identity': {'sha256': 'e' * 64}, 'local_path': '/fixture/http.pcapng'}, + {'identity': {'sha256': 'd' * 64}, 'local_path': '/fixture/other.pcapng'}]: with self.subTest(index=index, subject=subject): answer, records, reference = self.fixture() records[index]['subject'] = subject