diff --git a/src/resources/ArtifactFileOperation.ts b/src/resources/ArtifactFileOperation.ts index d43b7244e3..7463441995 100644 --- a/src/resources/ArtifactFileOperation.ts +++ b/src/resources/ArtifactFileOperation.ts @@ -248,8 +248,9 @@ export const assertArtifactReadActive = ( /** * Project a failure raised by a domain byte parser over artifact bytes onto the * reader's reasons: the caller's cancellation (`signal.reason`) becomes - * `cancelled`, parser failure kinds stay distinct, and a decode budget is - * bounded by `limitBoundary`. Every other cause passes through unchanged. + * `cancelled`, parser failure kinds and limit facts survive, and + * `limitBoundary` describes what a decode budget constrains. Every other cause + * passes through unchanged. */ export const artifactParseFailure = ( cause: unknown, @@ -266,6 +267,7 @@ export const artifactParseFailure = ( const boundary = limitBoundary?.(failure.limit); return new ArtifactReaderFailure("limit", cause.message, { cause, + parserLimit: failure.limit, ...(boundary === undefined ? {} : { boundary }), }); } diff --git a/tests/boundary/mcp/nodeSeaMcp.test.ts b/tests/boundary/mcp/nodeSeaMcp.test.ts index 09ad4dde13..276497cae6 100644 --- a/tests/boundary/mcp/nodeSeaMcp.test.ts +++ b/tests/boundary/mcp/nodeSeaMcp.test.ts @@ -7,6 +7,7 @@ import { nodeSeaPe, buildNodeSeaBlob, } from "../../../src/artifacts/nodeSea/NodeSea.fixture.js"; +import { peResourceFixture } from "../../../src/domain/pe/peResources.fixture.js"; import { parseEvidence } from "../../../src/domain/evidence.js"; import { artifactExtractionResultSchema } from "../../../src/domain/artifactGraph.js"; import { toolContract } from "../../../src/contracts/toolContracts.js"; @@ -173,3 +174,47 @@ it.each(["compact"] as const)( } }, ); + +it("reports the PE parser budget when Node SEA inventory exhausts it", async () => { + const root = await createTestTempDirectory("rea-sea-pe-budget-"); + const path = join(root, "application.exe"); + // Long sibling resource names expand into both source text and hex metadata. + const longName = "a".repeat(16 * 1024); + const { bytes } = peResourceFixture( + true, + [ + { + type: 10, + name: "NODE_SEA_BLOB", + language: 1033, + payload: buildNodeSeaBlob(), + }, + ...Array.from({ length: 96 }, (_, index) => ({ + type: 11, + name: longName + String(index), + language: 1033, + payload: Buffer.from("inert"), + })), + ], + 4 * 1024 * 1024, + ); + await writeFile(path, bytes); + const { call } = await connectLocalToolsMcp(); + const opened = await call("open_binary", { path }); + expect(opened.isError, JSON.stringify(opened)).not.toBe(true); + const reply = await call("inspect_artifact", {}); + expect(parseMcpToolError(reply).error).toMatchObject({ + code: "truncated", + retryable: false, + details: { + operation: "inspect_artifact", + reason: "limit", + boundary: "memory", + truncated: true, + reported_limits: { + boundary: "pe_resource_metadata_bytes", + maximum: 8 * 1024 * 1024, + }, + }, + }); +});