[PR #1402] [MERGED] perf(evidence): stop copying normalized results into raw_result #2858

Closed
opened 2026-10-17 21:11:06 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1402
Author: @kaoru0822-kitauji
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: perf/evidence-raw-result-no-copy


📝 Commits (1)

  • 1456f79 perf(evidence): stop copying normalized results into raw_result

📊 Changes

5 files changed (+38 additions, -5 deletions)

View changed files

📝 docs/mcp-contracts.md (+3 -1)
➕ src/application/AnalysisProvider.test.ts (+22 -0)
📝 src/application/AnalysisProvider.ts (+8 -2)
📝 tests/boundary/cli/dylibResolutionCli.test.ts (+3 -0)
📝 tests/composition/directAnalysisCleanup.test.ts (+2 -2)

📄 Description

Problem

createAnalysisExecution filled an omitted rawResult with a second complete copy of the result:

rawResult: options.rawResult === undefined ? jsonValueSchema.parse(result) : …

Every adapter call site that has no distinct provider representation therefore recorded the whole normalized_result twice in its Evidence (raw_result byte-identical to normalized_result). MCP results repeat Evidence in both text and structured content, so these responses carried four copies of the result. The duplicate also counted twice against the 10 MiB transport budget, and twice in the context of every agent that reads the result.

Affected call sites (all omitted rawResult):

Provider Operations
rea-artifact-graph decode_interface_builder, inspect_keyed_archive, inspect_asset_catalog, trace_dylib_resolution
native macOS inspect_native_dispatch_metadata, observe_native_calls, observe_native_ui / capture_native_ui_scenario (whose results include base64 screenshots)
Ghidra / IDA the open/started and health records (small)

Sibling operations of the same providers (inspect_artifact, extract_artifact, managed static analysis) already pass rawResult: null. Providers with a real upstream representation (Hopper, Ghidra calls, IDA, JADX, EVMole, Wakaru, inspect_plist provenance, …) pass it explicitly and are unchanged.

Change

An omitted rawResult now records null. The JSDoc and docs/mcp-contracts.md state the meaning: raw_result holds a provider representation distinct from the result, and is null when there is none. normalized_result, limitations, locations and subjects are unchanged. Evidence IDs of the affected operations change because the record changed.

Measurements (real MCP stdio client, pinned SDK, open_binary then the tool)

Tool Target main text / structured bytes This PR
trace_dylib_resolution Stash.app 3,217,119 1,612,524
trace_dylib_resolution Anki.app 1,093,111 550,918
decode_interface_builder KeepingYouAwake.app 3,831,653 1,917,473
decode_interface_builder Stash.app 2,814,104 1,414,774
inspect_asset_catalog Stash.app 1,120,144 560,945

Each figure is one representation. The MCP response carries it twice. normalized_result was compared byte for byte and is identical before and after on every target.

Tests

  • New src/application/AnalysisProvider.test.ts: an omitted raw result records null, and explicit raw results (including an explicit null) are preserved.
  • tests/boundary/cli/dylibResolutionCli.test.ts asserts raw_result: null on the real CLI path.
  • tests/composition/directAnalysisCleanup.test.ts pinned the old copy in its partial-observation expectations. It now expects null; the retained normalized_result assertion is unchanged.
  • Both new assertions fail with main's default and pass here.

Verification:

  • Full vitest run: 6200 passed. The remaining failures fail identically on unmodified main on this Mac: ibtool-compiled NIB tests (Command Line Tools only), hdiutil verify refusal, and three Node-discovery path tests. The MCP catalog tests needed the generated .cache catalog and pass once it is generated.
  • npm run check:fast, npm run docs:check

Not verified: real Ghidra and IDA (their only affected records are the small open/health ones), and real observe_native_ui capture (needs Accessibility permission). Refs #723, #1065 (T4: response repetition). This removes a duplicate inside Evidence; it does not change the text/structured repetition tracked there.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1402 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `perf/evidence-raw-result-no-copy` --- ### 📝 Commits (1) - [`1456f79`](https://github.com/morluto/rea/commit/1456f79bb14ed086bdf3df1e4d99f23d0563072d) perf(evidence): stop copying normalized results into raw_result ### 📊 Changes **5 files changed** (+38 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/mcp-contracts.md` (+3 -1) ➕ `src/application/AnalysisProvider.test.ts` (+22 -0) 📝 `src/application/AnalysisProvider.ts` (+8 -2) 📝 `tests/boundary/cli/dylibResolutionCli.test.ts` (+3 -0) 📝 `tests/composition/directAnalysisCleanup.test.ts` (+2 -2) </details> ### 📄 Description ## Problem `createAnalysisExecution` filled an omitted `rawResult` with a second complete copy of the result: ```ts rawResult: options.rawResult === undefined ? jsonValueSchema.parse(result) : … ``` Every adapter call site that has no distinct provider representation therefore recorded **the whole `normalized_result` twice** in its Evidence (`raw_result` byte-identical to `normalized_result`). MCP results repeat Evidence in both text and structured content, so these responses carried four copies of the result. The duplicate also counted twice against the 10 MiB transport budget, and twice in the context of every agent that reads the result. Affected call sites (all omitted `rawResult`): | Provider | Operations | | --- | --- | | `rea-artifact-graph` | `decode_interface_builder`, `inspect_keyed_archive`, `inspect_asset_catalog`, `trace_dylib_resolution` | | native macOS | `inspect_native_dispatch_metadata`, `observe_native_calls`, `observe_native_ui` / `capture_native_ui_scenario` (whose results include base64 screenshots) | | Ghidra / IDA | the open/started and health records (small) | Sibling operations of the same providers (`inspect_artifact`, `extract_artifact`, managed static analysis) already pass `rawResult: null`. Providers with a real upstream representation (Hopper, Ghidra calls, IDA, JADX, EVMole, Wakaru, `inspect_plist` provenance, …) pass it explicitly and are unchanged. ## Change An omitted `rawResult` now records `null`. The JSDoc and `docs/mcp-contracts.md` state the meaning: `raw_result` holds a provider representation distinct from the result, and is `null` when there is none. `normalized_result`, limitations, locations and subjects are unchanged. Evidence IDs of the affected operations change because the record changed. ## Measurements (real MCP stdio client, pinned SDK, `open_binary` then the tool) | Tool | Target | `main` text / structured bytes | This PR | | --- | --- | ---: | ---: | | `trace_dylib_resolution` | Stash.app | 3,217,119 | 1,612,524 | | `trace_dylib_resolution` | Anki.app | 1,093,111 | 550,918 | | `decode_interface_builder` | KeepingYouAwake.app | 3,831,653 | 1,917,473 | | `decode_interface_builder` | Stash.app | 2,814,104 | 1,414,774 | | `inspect_asset_catalog` | Stash.app | 1,120,144 | 560,945 | Each figure is one representation. The MCP response carries it twice. `normalized_result` was compared byte for byte and is identical before and after on every target. ## Tests - New `src/application/AnalysisProvider.test.ts`: an omitted raw result records `null`, and explicit raw results (including an explicit `null`) are preserved. - `tests/boundary/cli/dylibResolutionCli.test.ts` asserts `raw_result: null` on the real CLI path. - `tests/composition/directAnalysisCleanup.test.ts` pinned the old copy in its partial-observation expectations. It now expects `null`; the retained `normalized_result` assertion is unchanged. - Both new assertions fail with `main`'s default and pass here. Verification: - Full `vitest run`: 6200 passed. The remaining failures fail identically on unmodified `main` on this Mac: ibtool-compiled NIB tests (Command Line Tools only), `hdiutil verify` refusal, and three Node-discovery path tests. The MCP catalog tests needed the generated `.cache` catalog and pass once it is generated. - `npm run check:fast`, `npm run docs:check` Not verified: real Ghidra and IDA (their only affected records are the small open/health ones), and real `observe_native_ui` capture (needs Accessibility permission). Refs #723, #1065 (T4: response repetition). This removes a duplicate inside Evidence; it does not change the text/structured repetition tracked there. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:06 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2858
No description provided.