[PR #6907] [MERGED] perf(native): query retained export table facts #7439

Closed
opened 2026-11-01 21:47:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6907
Author: @gensokyo-dev
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @gensokyo-dev

Base: main ← Head: perf/6900-native-export-views


📝 Commits (5)

  • fd23b89 perf(native): query retained export table facts
  • 5e9a17b docs(perf): record native export task comparisons
  • c7a90b7 fix(native): preserve omitted export projection fields
  • 14113d1 docs(perf): refresh final export view qualification
  • dfacdbe test(native): verify sparse export view digests

📊 Changes

20 files changed (+3871 additions, -51 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/references/evidence-workflows.md (+11 -0)
📝 docs/binary-diagnostics.md (+44 -3)
➕ experiments/analysis-efficiency/native-export-costs.py (+115 -0)
➕ experiments/analysis-efficiency/native-export-oracle.py (+48 -0)
➕ experiments/analysis-efficiency/native-export-views.json (+2404 -0)
➕ experiments/analysis-efficiency/native-export-views.md (+167 -0)
➕ experiments/analysis-efficiency/native-export-views.mjs (+224 -0)
📝 src/application/binaryDiagnostics/NativeExportsService.ts (+1 -2)
📝 src/cli/analysisViewCommands.ts (+1 -1)
📝 src/cli/binaryDiagnosticsCommands.ts (+13 -6)
📝 src/contracts/analysisViewToolContracts.ts (+1 -1)
📝 src/contracts/native/binaryDiagnosticsToolContracts.ts (+13 -4)
📝 src/domain/analysisView/analysisView.ts (+27 -0)
➕ src/domain/analysisView/nativeExportsView.ts (+251 -0)
📝 src/domain/native/nativeExports.ts (+44 -33)
➕ src/native/exports/NativeExportsView.test.ts (+263 -0)
📝 src/server/createServer.ts (+1 -0)
📝 src/server/registerNativeExportsTool.ts (+30 -1)
➕ tests/acceptance/applications/nativeExportsViews.test.ts (+168 -0)
📝 tests/boundary/mcp/binaryDiagnosticsMcp.test.ts (+45 -0)

📄 Description

Summary

Fixes #6900. Native export questions can request a summary and select retained PE/ELF export facts by exact names, original indices, fields and pages. Complete output remains the default and the complete parent Evidence stays accessible.

Problem and expected behavior

libLLVM has 44,459 exports: asking for two names previously delivered the whole table, exceeding the default 10 MiB MCP budget. The new summary plus retained pages succeeds at that budget, preserves every matching version/alias and distinguishes page coverage from incomplete source coverage.

Change and scope

One domain projector serves CLI and MCP. It validates an exact immutable retained report once with a weak lifetime; it does not cache filesystem results. Unfiltered pages slice existing order; filtered queries scan retained rows. Source count validation belongs to the report contract. Projection schemas preserve omitted fields rather than filling historical source defaults; a failing regression and actual MCP checks cover this. Scope decision: not applicable; this extends static file inspection within existing authority.

Contract and boundary impact

  • Semantic owner: native export contracts and shared analysis-view projector; adapters only deliver Evidence.

  • CLI/catalog: additive detail: summary and native-exports exports/issues views; CLI summary requires --evidence_output.

  • Compatibility: existing PE/ELF parsing and complete defaults remain; source indices identify rows within their complete parent, including ordinal-only and forwarded PE exports.

  • Evidence/provenance: stable complete parent ID, exact name encoding facts, source coverage, partial/unknown explanations and complete bundle access.

  • Authority/cleanup: static reads, existing session retention and CLI Evidence writes; no target execution or new provider authority.

  • Generated metadata: contracts and authored skill reference updated; ignored catalogs/packaged skills regenerated and checked locally, not committed.

  • Read existing files or captured data.

  • Launch or attach to a process. Validation launches CLI/MCP helper processes only.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration. Explicit Evidence output files only.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

Independent GNU readelf plus directly mapped ELF version bytes verified real LLVM/libc answers, full counts and unchanged artifact bytes. Three alternating complete/selected task pairs per artifact had identical answers, parent IDs and complete source report digests. Reproduction, full ranges and receipts.

Completed task median Complete → selected
LLVM wall / family CPU / peak MiB 97.516 → 37.094 s / 88.030 → 32.645 s / 1833.8 → 1142.6
LLVM reply bytes / token estimate 28,986,227 → 19,695 / 4,355,448 → 57,346
libc wall / family CPU / peak MiB 18.848 → 18.858 s / 17.260 → 17.476 s / 993.1 → 928.6
libc reply bytes / token estimate 1,653,415 → 25,952 / 289,912 → 58,253

Token estimates include all 220 input tool definitions, arguments and text replies once (cl100k_base); no actual model ran. LLVM comparison used 64 MiB for both lanes; separate default 10 MiB probes observed baseline refusal and selected success. Fresh servers, OS caches unflushed, 100% aggregate CPU quota, 3 GiB early stop/4 GiB hard/no swap. All twelve tasks passed with verified payload cleanup and no resource stops/OOM. No parser speedup or universal latency improvement is claimed; libc pays extra calls with no established latency gain. Real PE performance is unmeasured.

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/native/exports/NativeExportsView.test.ts src/native/exports/NativeExportParser.test.ts tests/acceptance/applications/nativeExportsViews.test.ts tests/boundary/mcp/binaryDiagnosticsMcp.test.ts — 48 passed, including actual CLI/stdio transport, advertised schema validation, exact sparse columns and recomputed returned view digests.
  • npm run check — passed, repeated after adding measurement reports.
  • Documentation generation and npm run docs:check — passed, repeated after reporting changes; nine README conformance tests passed.
  • npm run verify:test-discovery — all 2,180 tests discovered exactly once.
  • Real LLVM CLI summary → complete Evidence bundle → offline selected view — passed, all 44,459 exports retained.
  • Twelve real stdio task comparisons and two 10 MiB boundary probes — outcomes above; measured implementation c7a90b742a29328e5b0069c6f8a34381e0c11e57, baseline main f713087132021d235682f908a1c0f3bc6ab8762d. Later reporting commit changes no production code.

Initial CI run 40015745440: static/build/docs and selected real-format qualifications passed. All eight shard logs were inspected, including cancelled jobs: 11 source + 46 built failures were actually observed. Controls against that exact main base and current implementation reproduced all 57 with identical case identities and full failure messages, normalizing only the two checkout paths (including their shared dependency realpath). The broader selection executed 11 source cases (11 failed) and 52 built cases (48 failed, four passed) on both; extra selected cases are not claimed as CI observations. The report preserves scope and receipt references. Later CI runs are evaluated separately.

Compatibility, safety, and release

Additive API, no migration or dependency changes. PE/ELF fixture coverage includes aliases, ordinal-only/forwarded exports, versions, encoding, partial/unsupported empty pages, malformed imports and historical omissions. Real Linux ELF workflows qualified; no real Hopper/Ghidra/IDA or Windows/PE performance qualification. No target execution, byte mutation or installation changes.

Author readiness

Human owner: requesting user; GitHub identity not separately asserted.

The requesting user explicitly authorized continuing to ready/merge and waiving per-PR human confirmation in this maintenance session. The declarations below remain unchecked because this record does not attest that a human reviewed the final diff.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/6907 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `perf/6900-native-export-views` --- ### 📝 Commits (5) - [`fd23b89`](https://github.com/morluto/rea/commit/fd23b89b0b1727b483050025e7af344145c1fd91) perf(native): query retained export table facts - [`5e9a17b`](https://github.com/morluto/rea/commit/5e9a17bea7a6bc5931df60256eef61010a9c67e1) docs(perf): record native export task comparisons - [`c7a90b7`](https://github.com/morluto/rea/commit/c7a90b742a29328e5b0069c6f8a34381e0c11e57) fix(native): preserve omitted export projection fields - [`14113d1`](https://github.com/morluto/rea/commit/14113d13df7f20eae0f5f438b66619182e70d218) docs(perf): refresh final export view qualification - [`dfacdbe`](https://github.com/morluto/rea/commit/dfacdbe2ffc6868e4b6cbbceca9836e122c949f5) test(native): verify sparse export view digests ### 📊 Changes **20 files changed** (+3871 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/references/evidence-workflows.md` (+11 -0) 📝 `docs/binary-diagnostics.md` (+44 -3) ➕ `experiments/analysis-efficiency/native-export-costs.py` (+115 -0) ➕ `experiments/analysis-efficiency/native-export-oracle.py` (+48 -0) ➕ `experiments/analysis-efficiency/native-export-views.json` (+2404 -0) ➕ `experiments/analysis-efficiency/native-export-views.md` (+167 -0) ➕ `experiments/analysis-efficiency/native-export-views.mjs` (+224 -0) 📝 `src/application/binaryDiagnostics/NativeExportsService.ts` (+1 -2) 📝 `src/cli/analysisViewCommands.ts` (+1 -1) 📝 `src/cli/binaryDiagnosticsCommands.ts` (+13 -6) 📝 `src/contracts/analysisViewToolContracts.ts` (+1 -1) 📝 `src/contracts/native/binaryDiagnosticsToolContracts.ts` (+13 -4) 📝 `src/domain/analysisView/analysisView.ts` (+27 -0) ➕ `src/domain/analysisView/nativeExportsView.ts` (+251 -0) 📝 `src/domain/native/nativeExports.ts` (+44 -33) ➕ `src/native/exports/NativeExportsView.test.ts` (+263 -0) 📝 `src/server/createServer.ts` (+1 -0) 📝 `src/server/registerNativeExportsTool.ts` (+30 -1) ➕ `tests/acceptance/applications/nativeExportsViews.test.ts` (+168 -0) 📝 `tests/boundary/mcp/binaryDiagnosticsMcp.test.ts` (+45 -0) </details> ### 📄 Description ## Summary Fixes #6900. Native export questions can request a summary and select retained PE/ELF export facts by exact names, original indices, fields and pages. Complete output remains the default and the complete parent Evidence stays accessible. ## Problem and expected behavior libLLVM has 44,459 exports: asking for two names previously delivered the whole table, exceeding the default 10 MiB MCP budget. The new summary plus retained pages succeeds at that budget, preserves every matching version/alias and distinguishes page coverage from incomplete source coverage. ## Change and scope One domain projector serves CLI and MCP. It validates an exact immutable retained report once with a weak lifetime; it does not cache filesystem results. Unfiltered pages slice existing order; filtered queries scan retained rows. Source count validation belongs to the report contract. Projection schemas preserve omitted fields rather than filling historical source defaults; a failing regression and actual MCP checks cover this. Scope decision: not applicable; this extends static file inspection within existing authority. ## Contract and boundary impact - Semantic owner: native export contracts and shared analysis-view projector; adapters only deliver Evidence. - CLI/catalog: additive `detail: summary` and `native-exports` exports/issues views; CLI summary requires `--evidence_output`. - Compatibility: existing PE/ELF parsing and complete defaults remain; source indices identify rows within their complete parent, including ordinal-only and forwarded PE exports. - Evidence/provenance: stable complete parent ID, exact name encoding facts, source coverage, partial/unknown explanations and complete bundle access. - Authority/cleanup: static reads, existing session retention and CLI Evidence writes; no target execution or new provider authority. - Generated metadata: contracts and authored skill reference updated; ignored catalogs/packaged skills regenerated and checked locally, not committed. - [x] Read existing files or captured data. - [x] Launch or attach to a process. Validation launches CLI/MCP helper processes only. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. Explicit Evidence output files only. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage Independent GNU readelf plus directly mapped ELF version bytes verified real LLVM/libc answers, full counts and unchanged artifact bytes. Three alternating complete/selected task pairs per artifact had identical answers, parent IDs and complete source report digests. [Reproduction, full ranges and receipts](https://github.com/morluto/rea/blob/perf/6900-native-export-views/experiments/analysis-efficiency/native-export-views.md). | Completed task median | Complete → selected | | --- | --- | | LLVM wall / family CPU / peak MiB | 97.516 → 37.094 s / 88.030 → 32.645 s / 1833.8 → 1142.6 | | LLVM reply bytes / token estimate | 28,986,227 → 19,695 / 4,355,448 → 57,346 | | libc wall / family CPU / peak MiB | 18.848 → 18.858 s / 17.260 → 17.476 s / 993.1 → 928.6 | | libc reply bytes / token estimate | 1,653,415 → 25,952 / 289,912 → 58,253 | Token estimates include all 220 input tool definitions, arguments and text replies once (`cl100k_base`); no actual model ran. LLVM comparison used 64 MiB for both lanes; separate default 10 MiB probes observed baseline refusal and selected success. Fresh servers, OS caches unflushed, 100% aggregate CPU quota, 3 GiB early stop/4 GiB hard/no swap. All twelve tasks passed with verified payload cleanup and no resource stops/OOM. No parser speedup or universal latency improvement is claimed; libc pays extra calls with no established latency gain. Real PE performance is unmeasured. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- src/native/exports/NativeExportsView.test.ts src/native/exports/NativeExportParser.test.ts tests/acceptance/applications/nativeExportsViews.test.ts tests/boundary/mcp/binaryDiagnosticsMcp.test.ts` — 48 passed, including actual CLI/stdio transport, advertised schema validation, exact sparse columns and recomputed returned view digests. - `npm run check` — passed, repeated after adding measurement reports. - Documentation generation and `npm run docs:check` — passed, repeated after reporting changes; nine README conformance tests passed. - `npm run verify:test-discovery` — all 2,180 tests discovered exactly once. - Real LLVM CLI summary → complete Evidence bundle → offline selected view — passed, all 44,459 exports retained. - Twelve real stdio task comparisons and two 10 MiB boundary probes — outcomes above; measured implementation `c7a90b742a29328e5b0069c6f8a34381e0c11e57`, baseline main `f713087132021d235682f908a1c0f3bc6ab8762d`. Later reporting commit changes no production code. Initial [CI run 40015745440](https://github.com/morluto/rea/actions/runs/40015745440): static/build/docs and selected real-format qualifications passed. All eight shard logs were inspected, including cancelled jobs: 11 source + 46 built failures were actually observed. Controls against that exact main base and current implementation reproduced all 57 with identical case identities and full failure messages, normalizing only the two checkout paths (including their shared dependency realpath). The broader selection executed 11 source cases (11 failed) and 52 built cases (48 failed, four passed) on both; extra selected cases are not claimed as CI observations. The [report](https://github.com/morluto/rea/blob/perf/6900-native-export-views/experiments/analysis-efficiency/native-export-views.md#initial-ci-attribution) preserves scope and receipt references. Later CI runs are evaluated separately. ## Compatibility, safety, and release Additive API, no migration or dependency changes. PE/ELF fixture coverage includes aliases, ordinal-only/forwarded exports, versions, encoding, partial/unsupported empty pages, malformed imports and historical omissions. Real Linux ELF workflows qualified; no real Hopper/Ghidra/IDA or Windows/PE performance qualification. No target execution, byte mutation or installation changes. ## Author readiness Human owner: requesting user; GitHub identity not separately asserted. The requesting user explicitly authorized continuing to ready/merge and waiving per-PR human confirmation in this maintenance session. The declarations below remain unchecked because this record does not attest that a human reviewed the final diff. - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:52 +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#7439
No description provided.