[PR #7250] [MERGED] fix(analysis): retain source evidence through directory exports #7747

Closed
opened 2026-11-03 13:40:05 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/6090-bulk-export-verification


📝 Commits (4)

  • f50763f fix(analysis): retain provider sources through directory workflows
  • 7245400 test(analysis): verify directory export capacity and resume
  • 066899f docs(analysis): link export verification outside the docs site
  • 1ef2aed fix(analysis): preserve sources for plain analysis ports

📊 Changes

15 files changed (+887 additions, -66 deletions)

View changed files

📝 docs/verification/native-decompile-directory-2026-10-23.md (+4 -0)
➕ experiments/analysis-efficiency/decompile-directory.md (+149 -0)
➕ experiments/analysis-efficiency/decompile-directory.mjs (+328 -0)
📝 src/application/DirectAnalysis.ts (+13 -2)
📝 src/application/FunctionAnalysisEvidence.test.ts (+14 -1)
📝 src/application/FunctionAnalysisEvidence.ts (+34 -24)
📝 src/application/WorkflowEvidence.test.ts (+42 -0)
📝 src/application/WorkflowEvidence.ts (+41 -25)
📝 src/application/binary/BinarySession.ts (+9 -5)
📝 src/application/investigation/EvidenceLedger.ts (+5 -0)
➕ src/application/investigation/recordEvidenceSources.test.ts (+32 -0)
📝 src/application/investigation/recordEvidenceSources.ts (+43 -1)
📝 src/server/registerEnhancedTools.ts (+13 -2)
📝 tests/boundary/mcp/analyzeFunctionDetail.test.ts (+77 -6)
📝 tests/composition/analysis-sessions/binarySession.test.ts (+83 -0)

📄 Description

Summary

Fixes #6090. Directory export already shipped in #6170; this follow-up fixes a provenance gap when composing it with existing Ghidra projects and verifies large exports/resume.

Problem and expected behavior

A project with saved seed/analyzer reports exported function files successfully, but its Evidence bundle lost those historical sources. Source retention was incorrectly conditional on snapshot eligibility, workflows ignored producer source IDs, and the function adapter manually copied observation fields without links.

Change and scope

Retain authenticated source facts independently of replay eligibility, deduplicate source IDs in composed workflows, and use the shared observation-to-Evidence constructor for function dossiers, including late-cancelled completion. Calls without source records skip recording work. Plain helpers return authenticated immutable source records alongside success or failure. Both adapters explicitly commit them before link delivery, preserve earlier cancellation/producer errors if recording fails, and refuse source-bearing replies without a retention owner. Source collection borrows records without constructing/hashing an intermediate bundle. CLI/MCP share the same application owners; public schemas and caller inputs stay compatible.

Scope decision: not applicable; ordinary correction to existing static analysis, with no new target execution, injection, mutation or authority. Existing exports still write only the selected output directory; original projects are copied/read-only. No package, installer or generated-output changes. The verification driver reuses the existing cleanup/receipt owner.

Evidence and regression coverage

  • Final local gate: 144 tests passed across nine files, build, typecheck/lint, docs (9 cases) and full formatting passed. Against unmodified main source, the three affected source suites reproduce 7 failures / 70 passes.
  • Real Linux Ghidra 12.1.4 / JDK21 MCP: historical baseline fails its missing-source oracle; fixed export retains one historical record and links it. All 652 inventory entries and sampled pseudocode match fresh import. Project/target content stays unchanged; complete bundle authenticates.
  • Real CLI address filter selects one function / excludes 651, reports unavailable DWARF layout explicitly, then resumes in another process without changing file hash/mtime; historical link stays stable.
  • Plain ls before/after: 541 written, 111 external, no failures, identical complete address/name/status/body/pseudocode facts; all prior files survive cross-session and verified resume. Wall 51.41 / 50.94 s, CPU 78.98 / 79.89 s, sampled family peak 0.943 / 1.201 GiB, whole-wire estimates 57,082 / 57,072 tokens. No general speed/memory reduction is claimed.
  • Baseline large run: 14,338 functions, 14,194 files, 143 external, one explicitly recorded five-second deadline at 0x387f00; later functions continue. Full task 506.39 s / 459.82 CPU s / 1.502 GiB, roughly 12-KiB replies and 57,322 estimated whole-wire tokens. The first fixed full comparison at 724540047 matched every comparison fact plus the independent fresh-import oracle: 571.70 s / 496.92 CPU s / 1.585 GiB / 57,324 estimated wire tokens. Review-final 1ef2aed0c full comparison passed, again matching all 14,338 comparison records and fresh-import inventory/sample pseudocode: 494.03 s / 445.63 CPU s / 1.584 GiB / 57,338 estimated wire tokens. Outcomes remain 14,194 written / 143 external / 1 recorded deadline; source/project content unchanged and cleanup succeeds. Variability across sequential shared-host runs is reported, not interpreted as a general speed or memory improvement.

All real runs use 2-CPU affinity and an 8-GiB sampled family guard; no OOM/resource stop or cleanup failure. Token estimates use cl100k_base over complete JSON-RPC messages, including discovery; actual model billing/host projection is unmeasured. Real Windows/macOS filesystems, other providers, native DWARF layout, and directory-CLI standalone source-bundle persistence remain unverified. An additional integrated CLI function --snapshot check preserves both its complete dossier and linked historical record after process exit.

Protocol, revisions, resource method, preparation exclusions and reproduction: verification.

Review regressions additionally cover real-SDK fixed ports for both function and directory tools, source payload omission, missing-retainer refusal, and successful-retry verification. Actual review-final historical-project workflow passed (68.87 s / 83.69 CPU s / 0.920 GiB / 57,223 estimated wire tokens): one retained source, all 652 records/sample pseudocode and all export comparison facts match, source content unchanged. Local VitePress build passed after correcting the site-to-repository verification link.

Baseline control: both unmodified main f02df45a4 and review-final feature 1ef2aed0c reproduce the same two Kuna doctor installation-identity cleanup failures (case names and assertions match). Final-head CI 40349220706 passed source/static/build/docs, reverse-tools quality, Linux package and shard 7. Shard 4 failed four ADB MCP cases; all four and the same underlying adb-version refusal also occur in main CI 40349559391, which contains no PR changes. Both exact main and PR merge trees pass those four cases when run alone locally. Remaining cancelled shard logs contain no additional failure reports; cancelled coverage remains unverified. The earlier Kuna baseline is separately recorded above. Greptile review passed and both actionable threads are resolved. Author readiness remains unchecked under the explicitly authorized bypass.

Latest-main integration: main a5ad16428 + final PR 1ef2aed0c builds and passes 289 tests across 11 files, including both changed Ghidra parser suites, plus typecheck/lint. Actual integrated CLI function returns nonempty pseudocode and its selected historical source; the saved analysis snapshot retains both complete Evidence records and resolves the source link offline.

Post-merge verification on actual commit 5508b2aff: 107 core/registry/source tests passed, typecheck/lint and runtime build passed. Actual Ghidra CLI function analysis returns a nonempty dossier; its selected snapshot retains the complete function and historical source after process exit. Offline bundle authentication and every source link resolve.

Author readiness

Human owner: @gensokyo-dev

  • 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.

Merged with the user-authorized bypass of the unchecked readiness gate and demonstrated main CI failures. No human-review attestation is made; cancelled CI coverage is stated above.


🔄 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/7250 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `feat/6090-bulk-export-verification` --- ### 📝 Commits (4) - [`f50763f`](https://github.com/morluto/rea/commit/f50763fd21527bdf3bab944633617b9df61dded4) fix(analysis): retain provider sources through directory workflows - [`7245400`](https://github.com/morluto/rea/commit/72454004772f826440c5e21002f4dd52b4ad43c0) test(analysis): verify directory export capacity and resume - [`066899f`](https://github.com/morluto/rea/commit/066899f97d37067f70e313eec0b66fe715d03009) docs(analysis): link export verification outside the docs site - [`1ef2aed`](https://github.com/morluto/rea/commit/1ef2aed0c23c5593a64e04f515df3ad2e2cb38b0) fix(analysis): preserve sources for plain analysis ports ### 📊 Changes **15 files changed** (+887 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `docs/verification/native-decompile-directory-2026-10-23.md` (+4 -0) ➕ `experiments/analysis-efficiency/decompile-directory.md` (+149 -0) ➕ `experiments/analysis-efficiency/decompile-directory.mjs` (+328 -0) 📝 `src/application/DirectAnalysis.ts` (+13 -2) 📝 `src/application/FunctionAnalysisEvidence.test.ts` (+14 -1) 📝 `src/application/FunctionAnalysisEvidence.ts` (+34 -24) 📝 `src/application/WorkflowEvidence.test.ts` (+42 -0) 📝 `src/application/WorkflowEvidence.ts` (+41 -25) 📝 `src/application/binary/BinarySession.ts` (+9 -5) 📝 `src/application/investigation/EvidenceLedger.ts` (+5 -0) ➕ `src/application/investigation/recordEvidenceSources.test.ts` (+32 -0) 📝 `src/application/investigation/recordEvidenceSources.ts` (+43 -1) 📝 `src/server/registerEnhancedTools.ts` (+13 -2) 📝 `tests/boundary/mcp/analyzeFunctionDetail.test.ts` (+77 -6) 📝 `tests/composition/analysis-sessions/binarySession.test.ts` (+83 -0) </details> ### 📄 Description ## Summary Fixes #6090. Directory export already shipped in #6170; this follow-up fixes a provenance gap when composing it with existing Ghidra projects and verifies large exports/resume. ## Problem and expected behavior A project with saved seed/analyzer reports exported function files successfully, but its Evidence bundle lost those historical sources. Source retention was incorrectly conditional on snapshot eligibility, workflows ignored producer source IDs, and the function adapter manually copied observation fields without links. ## Change and scope Retain authenticated source facts independently of replay eligibility, deduplicate source IDs in composed workflows, and use the shared observation-to-Evidence constructor for function dossiers, including late-cancelled completion. Calls without source records skip recording work. Plain helpers return authenticated immutable source records alongside success or failure. Both adapters explicitly commit them before link delivery, preserve earlier cancellation/producer errors if recording fails, and refuse source-bearing replies without a retention owner. Source collection borrows records without constructing/hashing an intermediate bundle. CLI/MCP share the same application owners; public schemas and caller inputs stay compatible. Scope decision: not applicable; ordinary correction to existing static analysis, with no new target execution, injection, mutation or authority. Existing exports still write only the selected output directory; original projects are copied/read-only. No package, installer or generated-output changes. The verification driver reuses the existing cleanup/receipt owner. ## Evidence and regression coverage - Final local gate: **144 tests passed across nine files**, build, typecheck/lint, docs (9 cases) and full formatting passed. Against unmodified main source, the three affected source suites reproduce **7 failures / 70 passes**. - Real Linux Ghidra 12.1.4 / JDK21 MCP: historical baseline fails its missing-source oracle; fixed export retains one historical record and links it. All 652 inventory entries and sampled pseudocode match fresh import. Project/target content stays unchanged; complete bundle authenticates. - Real CLI address filter selects one function / excludes 651, reports unavailable DWARF layout explicitly, then resumes in another process without changing file hash/mtime; historical link stays stable. - Plain ls before/after: 541 written, 111 external, no failures, identical complete address/name/status/body/pseudocode facts; all prior files survive cross-session and verified resume. Wall **51.41 / 50.94 s**, CPU **78.98 / 79.89 s**, sampled family peak **0.943 / 1.201 GiB**, whole-wire estimates **57,082 / 57,072 tokens**. No general speed/memory reduction is claimed. - Baseline large run: **14,338 functions**, 14,194 files, 143 external, one explicitly recorded five-second deadline at `0x387f00`; later functions continue. Full task **506.39 s / 459.82 CPU s / 1.502 GiB**, roughly 12-KiB replies and 57,322 estimated whole-wire tokens. The first fixed full comparison at `724540047` matched every comparison fact plus the independent fresh-import oracle: **571.70 s / 496.92 CPU s / 1.585 GiB / 57,324 estimated wire tokens**. **Review-final `1ef2aed0c` full comparison passed**, again matching all 14,338 comparison records and fresh-import inventory/sample pseudocode: **494.03 s / 445.63 CPU s / 1.584 GiB / 57,338 estimated wire tokens**. Outcomes remain 14,194 written / 143 external / 1 recorded deadline; source/project content unchanged and cleanup succeeds. Variability across sequential shared-host runs is reported, not interpreted as a general speed or memory improvement. All real runs use 2-CPU affinity and an 8-GiB sampled family guard; no OOM/resource stop or cleanup failure. Token estimates use cl100k_base over complete JSON-RPC messages, including discovery; actual model billing/host projection is unmeasured. Real Windows/macOS filesystems, other providers, native DWARF layout, and directory-CLI standalone source-bundle persistence remain unverified. An additional integrated CLI `function --snapshot` check preserves both its complete dossier and linked historical record after process exit. Protocol, revisions, resource method, preparation exclusions and reproduction: [verification](https://github.com/morluto/rea/blob/1ef2aed0c23c5593a64e04f515df3ad2e2cb38b0/experiments/analysis-efficiency/decompile-directory.md). Review regressions additionally cover real-SDK fixed ports for both function and directory tools, source payload omission, missing-retainer refusal, and successful-retry verification. Actual review-final historical-project workflow passed (68.87 s / 83.69 CPU s / 0.920 GiB / 57,223 estimated wire tokens): one retained source, all 652 records/sample pseudocode and all export comparison facts match, source content unchanged. Local VitePress build passed after correcting the site-to-repository verification link. Baseline control: both unmodified main `f02df45a4` and review-final feature `1ef2aed0c` reproduce the same two Kuna doctor installation-identity cleanup failures (case names and assertions match). Final-head CI [40349220706](https://github.com/morluto/rea/actions/runs/40349220706) passed source/static/build/docs, reverse-tools quality, Linux package and shard 7. Shard 4 failed four ADB MCP cases; all four and the same underlying adb-version refusal also occur in [main CI 40349559391](https://github.com/morluto/rea/actions/runs/40349559391), which contains no PR changes. Both exact main and PR merge trees pass those four cases when run alone locally. Remaining cancelled shard logs contain no additional failure reports; cancelled coverage remains unverified. The earlier Kuna baseline is separately recorded above. Greptile review passed and both actionable threads are resolved. Author readiness remains unchecked under the explicitly authorized bypass. Latest-main integration: main `a5ad16428` + final PR `1ef2aed0c` builds and passes **289 tests across 11 files**, including both changed Ghidra parser suites, plus typecheck/lint. Actual integrated CLI `function` returns nonempty pseudocode and its selected historical source; the saved analysis snapshot retains both complete Evidence records and resolves the source link offline. Post-merge verification on actual commit `5508b2aff`: **107 core/registry/source tests passed**, typecheck/lint and runtime build passed. Actual Ghidra CLI function analysis returns a nonempty dossier; its selected snapshot retains the complete function and historical source after process exit. Offline bundle authentication and every source link resolve. ## Author readiness Human owner: @gensokyo-dev - [ ] 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. Merged with the user-authorized bypass of the unchecked readiness gate and demonstrated main CI failures. No human-review attestation is made; cancelled CI coverage is stated above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:40:05 +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#7747
No description provided.