From 1bb2fa23de310bf334281b17eb0f5636888a1422 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:50:50 +0800 Subject: [PATCH] test(apple): match plist provenance to the selected workflow --- scripts/verify/apple/native-provenance.mjs | 67 +++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/scripts/verify/apple/native-provenance.mjs b/scripts/verify/apple/native-provenance.mjs index a0cf192a7e..63ae2183b0 100644 --- a/scripts/verify/apple/native-provenance.mjs +++ b/scripts/verify/apple/native-provenance.mjs @@ -6,6 +6,7 @@ import { toolContract } from "../../../dist/contracts/toolContracts.js"; import { artifactCliEvidence, withArtifactMcp, + withBundleResourcesMcp, } from "../../lib/artifact-e2e.mjs"; /** Inspect the compiled bundle with real native utilities through both adapters. */ @@ -16,15 +17,79 @@ export async function verifyNativeProvenance(app, executable) { const operations = [ ["inspect_macho", []], ["inspect_signature", []], - ["inspect_plist", []], ["list_architectures", []], ["demangle_swift", symbols], ]; const observations = []; + const resourcePlistCli = toolContract("inspect_plist").outputSchema.parse( + await artifactCliEvidence("inspect-plist", app), + ); + assert.equal(resourcePlistCli.subject, null); + assert.equal(resourcePlistCli.raw_result, null); + await withBundleResourcesMcp(app, async (client) => { + const response = await client.callTool({ + name: "inspect_plist", + arguments: {}, + }); + assert.notEqual(response.isError, true, JSON.stringify(response)); + const mcp = toolContract("inspect_plist").outputSchema.parse( + response.structuredContent, + ); + assert.equal(mcp.subject, null); + assert.equal(mcp.raw_result, null); + assert.deepEqual(mcp.normalized_result, resourcePlistCli.normalized_result); + assert.deepEqual( + JSON.parse(response.content.find((item) => item.type === "text").text), + response.structuredContent, + ); + await client.ping(); + observations.push({ + operation: "inspect_plist_resource_root", + commands: resourcePlistCli.normalized_result.provenance.length, + cli_bytes: Buffer.byteLength(JSON.stringify(resourcePlistCli)), + mcp_bytes: Buffer.byteLength(JSON.stringify(response)), + }); + }); + + const binaryPlistCli = toolContract("inspect_plist").outputSchema.parse( + await artifactCliEvidence("inspect-plist", executable), + ); + assert.equal(binaryPlistCli.subject?.digest.sha256, sha256); + assert.equal(binaryPlistCli.raw_result, null); + assert.equal(binaryPlistCli.normalized_result.resource_root, undefined); await withArtifactMcp(app, async (client) => { const definitions = new Map( (await client.listTools()).tools.map((tool) => [tool.name, tool]), ); + const plistResponse = await client.callTool( + { name: "inspect_plist", arguments: {} }, + { toolDefinition: definitions.get("inspect_plist") }, + ); + assert.notEqual(plistResponse.isError, true, JSON.stringify(plistResponse)); + const binaryPlistMcp = toolContract("inspect_plist").outputSchema.parse( + plistResponse.structuredContent, + ); + assert.equal(binaryPlistMcp.subject?.digest.sha256, sha256); + assert.equal(binaryPlistMcp.raw_result, null); + assert.equal(binaryPlistMcp.normalized_result.resource_root, undefined); + assert.deepEqual( + binaryPlistMcp.normalized_result, + binaryPlistCli.normalized_result, + ); + assert.deepEqual( + JSON.parse( + plistResponse.content.find((item) => item.type === "text").text, + ), + plistResponse.structuredContent, + ); + await client.ping(); + observations.push({ + operation: "inspect_plist_binary_bound", + commands: binaryPlistCli.normalized_result.provenance.length, + cli_bytes: Buffer.byteLength(JSON.stringify(binaryPlistCli)), + mcp_bytes: Buffer.byteLength(JSON.stringify(plistResponse)), + }); + for (const [operation, arguments_] of operations) { const cli = toolContract(operation).outputSchema.parse( await artifactCliEvidence(