perf(evidence): stop copying normalized results into raw_result (#1402)
createAnalysisExecution defaulted an omitted rawResult to a second complete copy of the result. Every caller that had no distinct provider representation therefore doubled its Evidence: decode_interface_builder, inspect_keyed_archive, inspect_asset_catalog, trace_dylib_resolution, inspect_native_dispatch_metadata, observe_native_calls, observe_native_ui/capture_native_ui_scenario (including screenshots), and small Ghidra/IDA lifecycle records. Sibling operations of the same providers already recorded null. An omitted rawResult now records null. Normalized results are unchanged. MCP responses repeat Evidence in text and structured content, so each response and its share of the 10 MiB transport budget shrink by the same half; e.g. trace_dylib_resolution on a real app bundle drops from 3,217,119 to 1,612,524 bytes per representation. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6875d4a64c
commit
499e2f54ef
@@ -0,0 +1,22 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { createAnalysisExecution } from "./AnalysisProvider.js";
|
||||
|
||||
const PROVIDER = { id: "fixture", name: "Fixture", version: "1" };
|
||||
|
||||
it("records no raw result unless the provider supplies a distinct one", () => {
|
||||
const result = { entries: [{ value: "normalized" }] };
|
||||
|
||||
expect(createAnalysisExecution(result, PROVIDER)).toMatchObject({
|
||||
result,
|
||||
rawResult: null,
|
||||
});
|
||||
expect(
|
||||
createAnalysisExecution(result, PROVIDER, {
|
||||
rawResult: { stdout: "raw" },
|
||||
}).rawResult,
|
||||
).toEqual({ stdout: "raw" });
|
||||
expect(
|
||||
createAnalysisExecution(result, PROVIDER, { rawResult: null }).rawResult,
|
||||
).toBeNull();
|
||||
});
|
||||
@@ -41,7 +41,13 @@ export interface AnalysisExecution {
|
||||
readonly subject: EvidenceSubjectTarget | null;
|
||||
}
|
||||
|
||||
/** Build a validated atomic provider observation at an adapter boundary. */
|
||||
/**
|
||||
* Build a validated atomic provider observation at an adapter boundary.
|
||||
*
|
||||
* Pass `rawResult` only for a provider representation distinct from
|
||||
* `result`. Omitting it records `null` rather than a second complete copy of
|
||||
* the normalized result in every Evidence record and tool response.
|
||||
*/
|
||||
export const createAnalysisExecution = (
|
||||
result: unknown,
|
||||
provider: ProviderIdentity,
|
||||
@@ -56,7 +62,7 @@ export const createAnalysisExecution = (
|
||||
result: jsonValueSchema.parse(result),
|
||||
rawResult:
|
||||
options.rawResult === undefined
|
||||
? jsonValueSchema.parse(result)
|
||||
? null
|
||||
: jsonValueSchema.parse(options.rawResult),
|
||||
provider,
|
||||
...(options.analysisProfile === undefined
|
||||
|
||||
Reference in New Issue
Block a user