Repository navigation
feat(analysis)!: default function MCP output to retained summaries - #5660
gensokyo-dev merged 39 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no new actionable issue was found, and the previous verification failure is fixed. Summary
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["MCP analyze_function"] --> B["Separate detail from provider input"]
B --> C["Produce complete dossier Evidence"]
C --> D{"detail"}
D -->|complete| E["Return complete Evidence"]
D -->|summary| F["Retain complete Evidence"]
F --> G["Return summary with parent_evidence_id"]
G --> H["inspect_analysis_view"]
H --> I["Page retained dossier facets"]
J["CLI function --detail summary"] --> K["Save complete Evidence bundle"]
K --> L["Read bundle as evidence-file"]
L --> H
Reviews (5) · Last reviewed commit: "test(evidence): pin validator member ord..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50c019d224
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Keeps BinarySession from marking every Ghidra operation unavailable after one procedure's decompile reaches the limit, and names the MCP tool-call deadline in the remediation.
…puts Address the five automated review findings on morluto#5660. P1: `detail` lived in the shared enhancedInputSchemas.analyze_function, so inspect_native_api composed `{procedure, detail: "summary"}` and the strict Ghidra analyze_function schema rejected it. Delivery detail is now owned by the analyze_function MCP tool contract; the handler separates it before any provider call, and executeFunctionAnalysisEvidence parses the provider input only. The MCP regression test validates provider input exactly as the production Ghidra client does and exercises inspect_native_api. P2: the analyze_function summary Evidence now carries the parent's relationship_coverage like native facet views, so partial or unknown caller/callee discovery is not reported as complete. P2: the summary reports the dossier's declared facet_availability, nulls the counts of facets the provider declared unavailable, and lists each reason in unknowns, so Kuna's empty references, comments and basic blocks are not mistaken for observed absence. P2: inspect-analysis-view evidence-file sources accept the Evidence bundle that --evidence_output writes, selecting a record with source.evidence_id when the bundle holds several; the CLI test reads the saved bundle back through that route. Tests that assert the complete dossier over public analyze_function now pass detail complete, and the oversized-dossier test asserts the summary view it previously expected to be unsupported. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edbfea04b3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
17171dc to
2234564
Compare
…puts Address the five automated review findings on morluto#5660. P1: `detail` lived in the shared enhancedInputSchemas.analyze_function, so inspect_native_api composed `{procedure, detail: "summary"}` and the strict Ghidra analyze_function schema rejected it. Delivery detail is now owned by the analyze_function MCP tool contract; the handler separates it before any provider call, and executeFunctionAnalysisEvidence parses the provider input only. The MCP regression test validates provider input exactly as the production Ghidra client does and exercises inspect_native_api. P2: the analyze_function summary Evidence now carries the parent's relationship_coverage like native facet views, so partial or unknown caller/callee discovery is not reported as complete. P2: the summary reports the dossier's declared facet_availability, nulls the counts of facets the provider declared unavailable, and lists each reason in unknowns, so Kuna's empty references, comments and basic blocks are not mistaken for observed absence. P2: inspect-analysis-view evidence-file sources accept the Evidence bundle that --evidence_output writes, selecting a record with source.evidence_id when the bundle holds several; the CLI test reads the saved bundle back through that route. Tests that assert the complete dossier over public analyze_function now pass detail complete, and the oversized-dossier test asserts the summary view it previously expected to be unsupported. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2234564c8f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…d sessions Adds REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS to the derived Codex/Kimi tool deadline and forwards it through setup. Marks a remote failure that settles after caller cancellation so the timeout projection no longer promises session reuse.
CassieFox23
left a comment
There was a problem hiding this comment.
TL;DR: The new summary default breaks the real-provider check scripts. They call analyze_function over MCP. This PR changes none of them. All 148 tests in the changed files pass on Node 22, 24 and 26. I could not reproduce the Codex memory concern about evidence bundles.
Tested head 2234564 (main was 335c042 when I checked; none of main's 8 newer commits touch a file in this PR).
| Check | Node 22 | Node 24 | Node 26 |
|---|---|---|---|
10 changed or added test files, test:focused |
148 passed | 148 passed | 148 passed |
| Greptile P1 replay (check scripts on the new default) | reproduced | reproduced | reproduced |
| Codex P1 replay (bundle parse memory) | not run | not reproduced | not run |
Greptile P1: reproduced
I called analyze_function with no detail through the PR's own in-memory MCP test setup (a fake provider, not real Ghidra). Then I ran the checks the scripts run.
- The Evidence
operationisinspect_analysis_view.native-value-e2e.mjsline 216 assertsanalyze_function, so that check fails. - The
normalized_resulthas no top-levelprocedure. Line 201 ofverify-real-hopper.mjscallsrequireFunctionDossier, and it throws"expected object, received undefined". - With
detail: "complete", both checks pass.
The PR changes no file under scripts/. Its validation list does not name verify:hopper or verify:ghidra. MCP callers I found: verify-real-hopper.mjs, real-hopper-semantic.mjs, native-value-e2e.mjs and ghidra-reference-snapshot-e2e.mjs. The scripts that use rea function are not hit, because the CLI default stays complete. 26 script files mention analyze_function with callTool or functionCall. I did not read all of them, so the full count is unknown.
Codex P1: not reproduced
This is a bounded probe plus code reading, not a proof. The code does more work on a bundle than on one record. It schema-parses the whole bundle. It parses each record again, and it compares two full JSON.stringify results. I wrote the same payload as a valid bundle and as a single record, and capped the heap with --max-old-space-size (Node 24 only).
- Small-object payloads (150k and 250k rows, 512 MB heap): both ran fine, up to a guard estimate of 230 MB.
- One long two-byte string (12M to 63M characters, 256 MB heap): both ran fine at all nine sizes.
- At 64.5M characters, the single record aborted once with out of memory. On rerun, both it and the bundle were refused by the headroom guard. At 66M characters both aborted the same way. That looks like a read-time limit shared by both paths. I did not check which step died.
I found no size where the bundle died and the single record survived.
Also open (read in the code, not run)
nativeFunctionView.tslines 186-190: the fivevalue_flow_*counts use?? 0, so an unavailable value flow reads as zero.- Lines 16-25 of
docs/mcp-contracts.mdstill sayanalyze_functionEvidence goes straight intocompare_functions. The new default has a different operation, andcompare_functionsrejects it.
Not run
npm run verify:hopperandnpm run verify:ghidra. Hopper was not found on PATH, and no changed test needed Ghidra.- The heap probe on Node 22 and 26, other payload shapes and a real exported bundle.
check:fast,docs:check, the full suite, and the PR's own real-target measurements.
Thanks, CryptoJones, for the clear write-up and for adding tests with the change.
Commands
git -C ~/code/rea-mirror/rea.git archive 2234564c8 | tar -x -C /tmp/b6-c/5660/src
npm ci && npm run prepare && npm run build:cached && npm run test:prepare # Node 24, all exit 0
npm run test:focused -- src/application/analysisView/AnalysisViewService.test.ts \
src/application/analysisView/evidenceFileSource.test.ts \
src/domain/analysisView/analysisView.test.ts \
tests/boundary/cli/analyzeFunctionDetail.test.ts \
tests/boundary/mcp/analysisViewMcp.test.ts \
tests/boundary/mcp/analyzeFunctionDetail.test.ts \
tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts \
tests/boundary/mcp/ghidraEvidenceMcp.test.ts \
tests/boundary/mcp/inlineEvidenceCompositionMcp.test.ts \
tests/boundary/mcp/investigationAnalysisMcp.test.ts
# exit 0 on Node 22.23.1, 24.18.0, 26.11.1; 10 files, 148 tests each
node --max-old-space-size=256 run.mjs payload.json # run.mjs only calls readEvidenceFileSource(path)The Greptile probe was one throwaway test file in the extracted tree, run with test:focused on all three Node versions (exit 0 each, output identical). The heap probe ran under systemd-run --user --scope -p MemoryMax=8G.
Test setup
🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊
analyze_function was the one analysis tool never wired into REA's detail: summary|complete convention, so it always returned the complete native dossier inline (0.2-10 MB, dominated by value-flow and references). Agents on tool-result-capped harnesses never reached the pseudocode. Add `detail` to analyze_function, defaulting to summary: return a compact dossier (procedure identity, pseudocode size, facet counts, value-flow availability) and retain the complete dossier Evidence in the session. Page pseudocode, references, assembly and value-flow through normalized_result.parent_evidence_id with inspect_analysis_view, which already projects every native facet. detail: complete returns the full dossier inline as before. Delivery detail never reaches the provider or Evidence identity. BREAKING CHANGE: analyze_function now defaults to the compact summary view instead of the complete dossier inline. Pass detail: "complete" for the previous behavior. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
Wire `rea function` into the shared CLI detail-delivery convention (--detail, --evidence_output) so the CLI and MCP adapters offer the same summary | complete choice for analyze_function. Summary delivery writes the complete dossier Evidence to a bundle and returns the compact summary view; it fails before analysis when --evidence_output is missing, so no provider work is wasted. The CLI default stays complete because a one-shot command has no in-process Evidence retention. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…eview FlatlineRoundtable cross-model review (6 lanes) converged on the summary projection's availability semantics being underspecified. Document that facet_availability is authoritative over raw pseudocode length, that code_units are UTF-16 (the unit inspect_analysis_view pages by), and that value_flow.truncated is meaningful only when value-flow is available. Parenthesize the nullish-coalescing/comparison for clarity. No behavior change; declined claims (value-flow "truncated collapse", unresolved_calls dead code) were schema-impossible or already correct. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
Close the roundtable's top convergent finding: the summary path had only domain-projection coverage, not the server/CLI wiring where the breaking behavior lives. MCP server (registerEnhancedTools): the default delivers a retained summary whose complete parent is recorded for paging; delivery detail is stripped before the provider request; detail: complete returns the full dossier inline; a registration without retention rejects a summary request before any provider work. CLI (rea function): the default returns the complete dossier; --detail summary without --evidence_output fails before analysis; with the bundle sink it returns the compact summary and writes the complete Evidence bundle. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…puts Address the five automated review findings on morluto#5660. P1: `detail` lived in the shared enhancedInputSchemas.analyze_function, so inspect_native_api composed `{procedure, detail: "summary"}` and the strict Ghidra analyze_function schema rejected it. Delivery detail is now owned by the analyze_function MCP tool contract; the handler separates it before any provider call, and executeFunctionAnalysisEvidence parses the provider input only. The MCP regression test validates provider input exactly as the production Ghidra client does and exercises inspect_native_api. P2: the analyze_function summary Evidence now carries the parent's relationship_coverage like native facet views, so partial or unknown caller/callee discovery is not reported as complete. P2: the summary reports the dossier's declared facet_availability, nulls the counts of facets the provider declared unavailable, and lists each reason in unknowns, so Kuna's empty references, comments and basic blocks are not mistaken for observed absence. P2: inspect-analysis-view evidence-file sources accept the Evidence bundle that --evidence_output writes, selecting a record with source.evidence_id when the bundle holds several; the CLI test reads the saved bundle back through that route. Tests that assert the complete dossier over public analyze_function now pass detail complete, and the oversized-dossier test asserts the summary view it previously expected to be unsupported. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
The analyze_function summary coerced an omitted unresolved_calls record to a count of 0 while the native facet view reports the same dossier as "not recorded", and it carried no counts at all for the pageable swift_string_literals facets. Count optional records as null when the dossier omits them, name them in unknowns, and add nullable counts for both Swift literal facets. The summary Evidence envelope also dropped the function address: createAnalysisViewEvidence now derives one function-view predicate for both the address location and relationship coverage. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…ider checks The real-provider check scripts call analyze_function over MCP and then consume the complete dossier: requireFunctionDossier, functionDossierSchema, .procedure/.pseudocode reads, operation assertions, compare_functions inputs and the oversized-dossier rejection path. The summary default broke them. Every such call site now passes detail: "complete". Provider-direct callers are unchanged because detail is an MCP contract field; the admission-error sites stay unchanged because provider failures return before the summary branch. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
summarizeDossier coerced the five value_flow_* counts to zero when native_value_flow was null (IDA, Kuna) or declared unavailable (Ghidra), so the summary reported empty collections while value_flow.available said otherwise. The counts are now null unless value flow is available, with the reason already named in unknowns. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…lized size The evidence-file headroom reserved two parsed copies, calibrated for one record, and charged strings at two bytes per character. Bundle authentication additionally holds the schema-parsed bundle, the re-parsed records and two JSON.stringify results, which expand control characters and lone surrogates sixfold: a bundle whose raw_result is a million NUL characters estimated at 2 MB parsed but needed 12 MB of serialized text. The budget now has a parsed term and a serialized term per file shape, owned by EvidenceAuthenticationHeadroom and shared by the analysis-view reader and the bundle importer, which had no guard. Two transient peaks the budget did not name are removed at their producers: the canonical digest hashes a large leaf directly instead of concatenating it into its buffer, and the JSON validator walks containers by cursor so a wide array no longer queues one entry per member. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
… in docs and prompts The MCP guide, the version-comparison and crash-triage prompt contracts, the authored skill and the Kuna, IDA and function-matching docs still told agents to pass analyze_function replies straight to compare_functions or build_call_path. Under the summary default those consumers reject the reply. They now name the retained-evidence reference for compare_functions, the observations fields of match_native_functions, and detail: "complete" for build_call_path, which accepts only inline dossiers. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…ation yielding Independent review of the cursor validator found the interrupted-validation fixture relied on the old last-first walk: its over-deep head was reached before the first cooperative yield. The padding now precedes the deep element so the walk yields first, which is the invariant the test guards. A new case pins first-defect-in-member-order reporting, skipped non-enumerable keys no longer count toward the yield cadence, and the import-headroom test loads the reader through a fresh module graph so it holds under the services project's shared workers. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb
…nce/5662-decompile-timeout-20261023
…nce/5662-decompile-timeout-20261023
…nce/5660-function-summary-20261023
…nce/5662-decompile-timeout-20261023
…nce/5660-function-summary-20261023
…nce/5660-function-summary-20261023
|
CI attribution for published head CI run 40042416832 completed with 13 successful jobs, 5 failures, 7 cancellations and 16 skips. I inspected the raw logs of all 12 failed/cancelled jobs, including the portable aggregation and required-check failure. All 1,015 visible assertion markers match retained main/exact-base controls; no unclassified assertion remains. Cancelled shards do not establish unexecuted coverage. The newly observed case, The remaining controls were recorded during #5662: shared source/built error-algebra assertions, exact-base JavaScript cases, Windows native cases, and the intermittent Kuna startup case. The Kuna control proves independent main failure, without claiming identical cancellation diagnostics. The full feature static gate, selected public CLI/MCP/SDK checks and real Linux Ghidra/CLI evidence described in the PR body passed. Per the maintainer's authorization, established baseline CI failures may be bypassed; this is not a claim that the whole suite passed or that cancelled checks executed. |
|
Final integration verification: the conflict-free candidate on main |
|
Correction to the earlier CI attribution: matching the failing test name was insufficient for the module-isolation check. Although main already had an SDK cancellation mock in a shared project, #5660 added another offender, The follow-up in #6206 moves both module-mock tests into the existing isolated The revised native view guidance also left a stale introductory-text assertion in the oversized discovery test. Its metadata filters, schema checks and retained paging now execute successfully; all 22 MCP view cases pass after removing that unrelated prose precheck. These corrections change test ownership and verification, while preserving the merged runtime summary behavior. The #6206 verification report records the controls and limitations. |
| import { toolRegistrationOptions } from "./toolRegistrationOptions.js"; | ||
| import { executeFunctionAnalysisEvidence } from "../application/FunctionAnalysisEvidence.js"; | ||
| import type { WithAdmittedAnalysis } from "./analysisAdmission.js"; | ||
| import type { EvidenceLookup } from "../application/EvidenceInputResolver.js"; |
There was a problem hiding this comment.
**sha256
| import type { EvidenceLookup } from "../application/EvidenceInputResolver.js"; | |
| import type { EvidenceLookup } from "../application/EvidenceInputResolver.js"; |
**
There was a problem hiding this comment.
Two weeks late ;)
Refs #5032.
MCP
analyze_functionalways returned the full native dossier, so large reference/value-flow results could consume the response budget before the requested code was useful. It now defaults todetail: "summary": function identity, availability, facet counts, limitations and a retained parent Evidence ID.inspect_analysis_viewpages that parent;detail: "complete"preserves the previous inline dossier. This default is a breaking MCP change. Delivery detail stays outside provider inputs and parent Evidence identity.CLI
rea functionstill defaults to complete output. Explicit summary delivery requires--evidence_output /absolute/path/dossier.json, writes an exclusive complete Evidence bundle and returns the summary. The saved bundle can be paged through anevidence-filesource and selectedevidence_idafter the provider closes. For example, select the returned parent ID with a nativepseudocodeview (offset: 0,limit: 4096). Summary delivery requires retention and an artifact-bound parent.The existing summary/view pipeline owns projection and provenance. Function addresses and relationship coverage survive; omitted or unavailable counts remain
null. Bundle import and file projection share authentication rather than parallel parsers. Ambiguous-bundle guidance keeps complete IDs within a 2 KiB encoded preview, with explicit omissions. Canonical hashing avoids copying large emitted strings while preserving its byte stream.Measured equivalent real Linux Ghidra MCP task (small-function pseudocode plus large-function availability/counts/20 assembly rows, then warm repeats and a matched complete-small read): selected facts match exactly, target digests stay unchanged and cleanup completes.
The 97.66% token reduction includes all catalog/argument/SDK-result projections and extra page calls. These are
tokenxestimates, not model usage; client rendering and prompts are unmeasured. Whole timings include counting and evidence writes; measured MCP phases total 217.33 → 127.54 s. One pair, baseline first, shared host, unflushed OS caches: no universal speed claim. The warm small task is about 6.7 ms slower despite a smaller answer. An earlier 240-second baseline timeout is retained separately and excluded from completed comparisons.Validation:
npm run check, 139 focused contract/CLI/progress/snapshot/path tests, 15 actual SDK/schema checks anddocs:checkpassed after integrating maina062529b. Initial stale generated-catalog and CLI harness-envelope failures are recorded in the report.Verification report pins source/artifact/harness identities, cold/warm phases, limits and incomplete controls.
Scope: existing read-only native analysis and caller-selected Evidence file output; no new provider, target execution/injection, executable mutation, attached-GUI authority or installation behavior.
Author readiness
Human owner: @CryptoJones
Before merge
type(scope): outcome.🤖 Generated with Claude Code
https://claude.ai/code/session_01AoJZDPcrgmMsCqLG4LfiFb