Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
perf(ghidra): omit redundant raw results (#5355)
gensokyo-dev58d6043303e7
diff --git a/docs/mcp-contracts.md b/docs/mcp-contracts.mdindex 9e0159d9e..ce6612b40 100644--- a/docs/mcp-contracts.md+++ b/docs/mcp-contracts.md@@ -22,6 +22,14 @@ directly to `compare_functions`, and `inspect_artifact` Evidence to`compare_artifacts`. Use `get_evidence_bundle` when the task needs broaderretained session history or an explicit bundle for transfer.+Ghidra inventories and function replies use `raw_result: null` when their facts+are already preserved in `normalized_result`, limitations, locations and+relationship coverage. Distinct overview details, measured load-image+observations, file-offset selection roles and database types supplemented with+derived metadata keep their upstream representation. Read function results from+`normalized_result`; older retained Evidence keeps its original representation+and identity.+Artifact inventories declare `coverage.scope` (`root` or `container-entries`)and `coverage.status` (`complete` or `unknown`) independently of diagnosticwording. Comparison requires matching scopes, complete graph members and completediff --git a/experiments/analysis-efficiency/README.md b/experiments/analysis-efficiency/README.mdindex 3d9b728aa..27667bac9 100644--- a/experiments/analysis-efficiency/README.md+++ b/experiments/analysis-efficiency/README.md@@ -5,6 +5,11 @@ reconciles the earlier audit queue and measures immutable historical-capturevalidation reuse on public compact and large qlogs, including first-view costs,small-input limits and unchanged Evidence delivery.+The [Ghidra Evidence projection checkpoint](ghidra-evidence-projection.md)+measures removal of redundant raw copies on real `true` and jq workflows,+with complete provenance, unchanged response budgets, native CLI/MCP checks+and explicit cold-analysis variance.+For Hopper literal string queries, see the [decoded-record checkpoint](hopper-string-records.md).It measures record reuse through real Linux CLI/MCP workflows, preservingnative recognition gaps, guard-stopped attempts and negative whole-task costs.diff --git a/experiments/analysis-efficiency/ghidra-evidence-projection.json b/experiments/analysis-efficiency/ghidra-evidence-projection.jsonnew file mode 100644index 000000000..edb99d43a--- /dev/null+++ b/experiments/analysis-efficiency/ghidra-evidence-projection.json@@ -0,0 +1,719 @@+{+ "issue": 5337,+ "initial_base_revision": "4e716b06078d725a53234503cbefbb340731e809",+ "integration_base_revision": "3fca2e0ca6e54ba700c286d9a85a9600dee6a19d",+ "environment": {+ "platform": "Linux x86_64",+ "node": "24.18.0",+ "npm": "11.16.0",+ "mcp_sdk": "2.3.1",+ "ghidra": "12.1.4",+ "java": "Eclipse Adoptium 21.0.12.1+1-LTS",+ "configured_java_heap": "768M",+ "configured_active_processors": 1,+ "query_cpu_quota_percent": 100,+ "query_cpu_affinity": [15],+ "query_hard_memory_bytes": 4294967296,+ "query_early_stop_bytes": 3221225472,+ "query_task_limit": 192,+ "swap_bytes": 0,+ "os_caches": "warm and unflushed; fresh servers, homes and Java analysis",+ "initial_startup_and_rpc_deadline_ms": 300000,+ "integrated_startup_and_rpc_deadline_ms": 600000,+ "product_default_deadlines_changed": false+ },+ "method": {+ "task": "Full observed procedure inventory, overview/load image and first internal non-thunk function facts; repeat inventory/pseudocode, export Evidence and close.",+ "calls": 15,+ "catalog_discoveries": 1,+ "fact_comparison_excludes_only": ["evidence_id", "raw_result"],+ "bytes": "Node JSON.stringify UTF-8 of complete SDK catalog, tool name/argument objects and reply envelopes; initialization, wire framing and model rendering unmeasured.",+ "actual_model_usage": null,+ "tokenizer_estimates": null,+ "memory": "Kernel cgroup family peak including file cache at payload exit; post-GC retained heap unmeasured.",+ "counter_scope": "Verified payload exit while the observer remains alive; final whole-scope counters after removal unavailable.",+ "latency_claim": "No whole-task latency, CPU or peak-memory improvement established.",+ "candidate_control_overhead": "Baseline fact-file parsing/comparison is included on the candidate side; its isolated cost is unmeasured."+ },+ "runtime_tables": {+ "baseline": {+ "files": 1841,+ "sha256_sorted_path_tab_digest_lines": "549bb479ed41e9c55505c169e726552b632f0e5341e63194380b8d0ded344658",+ "revision": "4e716b06078d725a53234503cbefbb340731e809"+ },+ "candidate": {+ "files": 1841,+ "sha256_sorted_path_tab_digest_lines": "0ebceab15311cc5ccdcfb92a0891022fc37736f2e7d01e2c1d22e88920df1ca8",+ "base_revision": "4e716b06078d725a53234503cbefbb340731e809",+ "source_diff_sha256": "7c460367e77daf2fad507800f1346dcd9e74553999fb049232b33b27684c8f49"+ },+ "integrated-baseline": {+ "files": 1847,+ "sha256_sorted_path_tab_digest_lines": "0d1672378dd3989663f7ef9ead3a91f56283dd06868f4574cae4d062dc83b041",+ "base_revision": "3fca2e0ca6e54ba700c286d9a85a9600dee6a19d"+ },+ "integrated-candidate": {+ "files": 1847,+ "sha256_sorted_path_tab_digest_lines": "d4348d25b4b18e371ac63375accd8f14e72197588934f66b8ab2bb7049ddb7d3",+ "base_revision": "3fca2e0ca6e54ba700c286d9a85a9600dee6a19d",+ "source_diff_sha256": "7c460367e77daf2fad507800f1346dcd9e74553999fb049232b33b27684c8f49",+ "driver_sha256": "b0463f8da110dcbae45769045a690dc5accf74791fa53f5086a60e8383f074de"+ }+ },+ "driver_versions": {+ "earlier": "b5bf4b378102de16f871c5f13e7302cbdcecbe0a14cc90b30ab80031920aaa06",+ "integrated": "b0463f8da110dcbae45769045a690dc5accf74791fa53f5086a60e8383f074de"+ },+ "completed_tasks": [+ {+ "name": "baseline-true-4",+ "expected_projection": "duplicate",+ "artifact_sha256": "c79bf44242829108e323378531f4ac839513ca1fba45efd6583643526e1e9fd2",+ "artifact_bytes": 35664,+ "procedure_count": 231,+ "selected_procedure": "0x102000",+ "facts_sha256": "5b826454c00709fb26777e3b6663aa69ce879f51597c54d6ec3021fc1984eb74",+ "call_count": 15,+ "catalog": {+ "elapsed_ms": 1132.755321,+ "bytes": 3255374,+ "sha256": "8a646b95cc5607ee57e5a3c0ef480b77e4cec7e5168498e72f511a8af40daf61"+ },+ "rpc_argument_bytes": 908,+ "rpc_reply_bytes": 473344,+ "catalog_arguments_replies_bytes": 3729626,+ "normalized_value_bytes_once_per_selected_reply": 94357,+ "raw_value_bytes_once_per_selected_reply": 90839,+ "bundle_bytes": 177922,+ "phases": {+ "open_binary": {+ "elapsed_ms": 913.6441110000001,+ "reply_bytes": 499+ },+ "list_documents": {+ "elapsed_ms": 27770.679519,+ "reply_bytes": 6029+ },+ "list_procedures": {+ "elapsed_ms": 156.53601400000116,+ "reply_bytes": 125181+ },+ "binary_overview": {+ "elapsed_ms": 101.32018699999753,+ "reply_bytes": 17387+ },+ "inspect_native_load_image": {+ "elapsed_ms": 265.31070799999725,+ "reply_bytes": 101123+ },+ "procedure_info": {+ "elapsed_ms": 80.39036699999997,+ "reply_bytes": 7643+ },+ "procedure_pseudo_code": {+ "elapsed_ms": 81.57453700000042,+ "reply_bytes": 6549+ },+ "procedure_assembly": {+ "elapsed_ms": 53.14257799999905,+ "reply_bytes": 6715+ },+ "procedure_callers": {+ "elapsed_ms": 22.954539999998815,+ "reply_bytes": 6709+ },+ "procedure_callees": {+ "elapsed_ms": 8.837930000001506,+ "reply_bytes": 6753+ },+ "analyze_function": {+ "elapsed_ms": 294.8276279999991,+ "reply_bytes": 56545+ },+ "warm-inventory": {+ "elapsed_ms": 49.338327999998,+ "reply_bytes": 125181+ },+ "warm-pseudocode": {+ "elapsed_ms": 16.670878999997512,+ "reply_bytes": 6549+ },+ "export_evidence_bundle": {+ "elapsed_ms": 51.058947999998054,+ "reply_bytes": 312+ },+ "close_binary": {+ "elapsed_ms": 494.6449689999936,+ "reply_bytes": 169+ }+ },+ "scope_seconds": 34.369,+ "payload_cpu_seconds": 33.150037,+ "payload_family_peak_bytes": 993923072,+ "payload_cleanup_verified": true,+ "zero_limit_events_at_payload_exit": true,+ "final_whole_scope_counters_verified": false+ },+ {+ "name": "candidate-true-1",+ "expected_projection": "compact",+ "artifact_sha256": "c79bf44242829108e323378531f4ac839513ca1fba45efd6583643526e1e9fd2",+ "artifact_bytes": 35664,+ "procedure_count": 231,+ "selected_procedure": "0x102000",+ "facts_sha256": "5b826454c00709fb26777e3b6663aa69ce879f51597c54d6ec3021fc1984eb74",+ "call_count": 15,+ "catalog": {+ "elapsed_ms": 1208.093488,+ "bytes": 3255374,+ "sha256": "8a646b95cc5607ee57e5a3c0ef480b77e4cec7e5168498e72f511a8af40daf61"+ },+ "rpc_argument_bytes": 909,+ "rpc_reply_bytes": 326642,+ "catalog_arguments_replies_bytes": 3582925,+ "normalized_value_bytes_once_per_selected_reply": 94357,+ "raw_value_bytes_once_per_selected_reply": 22114,+ "bundle_bytes": 137135,+ "phases": {+ "open_binary": {+ "elapsed_ms": 941.0834749999995,+ "reply_bytes": 499+ },+ "list_documents": {+ "elapsed_ms": 27897.447016,+ "reply_bytes": 5981+ },+ "list_procedures": {+ "elapsed_ms": 136.00869700000112,+ "reply_bytes": 65589+ },+ "binary_overview": {+ "elapsed_ms": 124.65224699999817,+ "reply_bytes": 17387+ },+ "inspect_native_load_image": {+ "elapsed_ms": 249.8859930000035,+ "reply_bytes": 101123+ },+ "procedure_info": {+ "elapsed_ms": 95.36772800000472,+ "reply_bytes": 6671+ },+ "procedure_pseudo_code": {+ "elapsed_ms": 84.8552570000029,+ "reply_bytes": 6355+ },+ "procedure_assembly": {+ "elapsed_ms": 97.34392800000205,+ "reply_bytes": 6305+ },+ "procedure_callers": {+ "elapsed_ms": 8.018889999999374,+ "reply_bytes": 6177+ },+ "procedure_callees": {+ "elapsed_ms": 6.999988999996276,+ "reply_bytes": 6199+ },+ "analyze_function": {+ "elapsed_ms": 271.9528430000064,+ "reply_bytes": 31929+ },+ "warm-inventory": {+ "elapsed_ms": 30.13376900000003,+ "reply_bytes": 65589+ },+ "warm-pseudocode": {+ "elapsed_ms": 7.71154899999965,+ "reply_bytes": 6355+ },+ "export_evidence_bundle": {+ "elapsed_ms": 71.93626799999765,+ "reply_bytes": 314+ },+ "close_binary": {+ "elapsed_ms": 620.6287440000015,+ "reply_bytes": 169+ }+ },+ "scope_seconds": 34.901,+ "payload_cpu_seconds": 33.834228,+ "payload_family_peak_bytes": 1025228800,+ "payload_cleanup_verified": true,+ "zero_limit_events_at_payload_exit": true,+ "final_whole_scope_counters_verified": false+ },+ {+ "name": "baseline-jq-1",+ "expected_projection": "duplicate",+ "artifact_sha256": "b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f",+ "artifact_bytes": 2267912,+ "procedure_count": 2276,+ "selected_procedure": "0x401000",+ "facts_sha256": "f7b95167c93f2b9129b5a4332590ef6bbb9d7b646d554ba4c396db1055ef0d24",+ "call_count": 15,+ "catalog": {+ "elapsed_ms": 2761.8931860000002,+ "bytes": 3255374,+ "sha256": "8a646b95cc5607ee57e5a3c0ef480b77e4cec7e5168498e72f511a8af40daf61"+ },+ "rpc_argument_bytes": 965,+ "rpc_reply_bytes": 2372592,+ "catalog_arguments_replies_bytes": 5628931,+ "normalized_value_bytes_once_per_selected_reply": 536023,+ "raw_value_bytes_once_per_selected_reply": 533635,+ "bundle_bytes": 609212,+ "phases": {+ "open_binary": {+ "elapsed_ms": 1856.9621389999993,+ "reply_bytes": 617+ },+ "list_documents": {+ "elapsed_ms": 290349.418768,+ "reply_bytes": 6167+ },+ "list_procedures": {+ "elapsed_ms": 624.2473109999555,+ "reply_bytes": 1092959+ },+ "binary_overview": {+ "elapsed_ms": 214.38793299999088,+ "reply_bytes": 15727+ },+ "inspect_native_load_image": {+ "elapsed_ms": 432.1906869999948,+ "reply_bytes": 75633+ },+ "procedure_info": {+ "elapsed_ms": 106.62601700000232,+ "reply_bytes": 7813+ },+ "procedure_pseudo_code": {+ "elapsed_ms": 165.65909500000998,+ "reply_bytes": 6869+ },+ "procedure_assembly": {+ "elapsed_ms": 98.534897000005,+ "reply_bytes": 6855+ },+ "procedure_callers": {+ "elapsed_ms": 23.43981900002109,+ "reply_bytes": 6891+ },+ "procedure_callees": {+ "elapsed_ms": 9.403080000018235,+ "reply_bytes": 7479+ },+ "analyze_function": {+ "elapsed_ms": 327.3197410000139,+ "reply_bytes": 45277+ },+ "warm-inventory": {+ "elapsed_ms": 396.67419799999334,+ "reply_bytes": 1092959+ },+ "warm-pseudocode": {+ "elapsed_ms": 6.517379999975674,+ "reply_bytes": 6869+ },+ "export_evidence_bundle": {+ "elapsed_ms": 56.13109899999108,+ "reply_bytes": 308+ },+ "close_binary": {+ "elapsed_ms": 550.6349530000007,+ "reply_bytes": 169+ }+ },+ "scope_seconds": 304.543,+ "payload_cpu_seconds": 294.743485,+ "payload_family_peak_bytes": 1159921664,+ "payload_cleanup_verified": true,+ "zero_limit_events_at_payload_exit": true,+ "final_whole_scope_counters_verified": false+ },+ {+ "name": "integrated-baseline-jq",+ "expected_projection": "duplicate",+ "artifact_sha256": "b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f",+ "artifact_bytes": 2267912,+ "procedure_count": 2279,+ "selected_procedure": "0x401000",+ "facts_sha256": "87722aab25011f1b047eb2bf8302cdbc5a4256c1b7f17d7bd68404a7d191e070",+ "call_count": 15,+ "catalog": {+ "elapsed_ms": 1411.786849,+ "bytes": 3263492,+ "sha256": "c754f774156866d70be754e050335d0e4d3a7a6cbb156746cf1f7b5ffa42b26b"+ },+ "rpc_argument_bytes": 974,+ "rpc_reply_bytes": 2375466,+ "catalog_arguments_replies_bytes": 5639932,+ "normalized_value_bytes_once_per_selected_reply": 536689,+ "raw_value_bytes_once_per_selected_reply": 534301,+ "bundle_bytes": 609878,+ "phases": {+ "open_binary": {+ "elapsed_ms": 983.5489280000002,+ "reply_bytes": 617+ },+ "list_documents": {+ "elapsed_ms": 270159.690556,+ "reply_bytes": 6167+ },+ "list_procedures": {+ "elapsed_ms": 717.9032449999941,+ "reply_bytes": 1094387+ },+ "binary_overview": {+ "elapsed_ms": 203.3595150000183,+ "reply_bytes": 15727+ },+ "inspect_native_load_image": {+ "elapsed_ms": 362.37314199999673,+ "reply_bytes": 75633+ },+ "procedure_info": {+ "elapsed_ms": 92.72515800001565,+ "reply_bytes": 7813+ },+ "procedure_pseudo_code": {+ "elapsed_ms": 85.43632900004741,+ "reply_bytes": 6869+ },+ "procedure_assembly": {+ "elapsed_ms": 78.87645799998427,+ "reply_bytes": 6855+ },+ "procedure_callers": {+ "elapsed_ms": 32.66119900002377,+ "reply_bytes": 6891+ },+ "procedure_callees": {+ "elapsed_ms": 8.895469999988563,+ "reply_bytes": 7479+ },+ "analyze_function": {+ "elapsed_ms": 343.2701520000119,+ "reply_bytes": 45277+ },+ "warm-inventory": {+ "elapsed_ms": 338.9290720000281,+ "reply_bytes": 1094387+ },+ "warm-pseudocode": {+ "elapsed_ms": 9.391289999999572,+ "reply_bytes": 6869+ },+ "export_evidence_bundle": {+ "elapsed_ms": 82.86341799999354,+ "reply_bytes": 326+ },+ "close_binary": {+ "elapsed_ms": 679.7842850000015,+ "reply_bytes": 169+ }+ },+ "scope_seconds": 279.699,+ "payload_cpu_seconds": 277.696079,+ "payload_family_peak_bytes": 1111494656,+ "payload_cleanup_verified": true,+ "zero_limit_events_at_payload_exit": true,+ "final_whole_scope_counters_verified": false+ },+ {+ "name": "integrated-candidate-jq",+ "expected_projection": "compact",+ "artifact_sha256": "b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f",+ "artifact_bytes": 2267912,+ "procedure_count": 2279,+ "selected_procedure": "0x401000",+ "facts_sha256": "87722aab25011f1b047eb2bf8302cdbc5a4256c1b7f17d7bd68404a7d191e070",+ "call_count": 15,+ "catalog": {+ "elapsed_ms": 1213.2912340000003,+ "bytes": 3263492,+ "sha256": "c754f774156866d70be754e050335d0e4d3a7a6cbb156746cf1f7b5ffa42b26b"+ },+ "rpc_argument_bytes": 975,+ "rpc_reply_bytes": 1264884,+ "catalog_arguments_replies_bytes": 4529351,+ "normalized_value_bytes_once_per_selected_reply": 536689,+ "raw_value_bytes_once_per_selected_reply": 16143,+ "bundle_bytes": 345626,+ "phases": {+ "open_binary": {+ "elapsed_ms": 927.8219500000005,+ "reply_bytes": 617+ },+ "list_documents": {+ "elapsed_ms": 391135.781249,+ "reply_bytes": 6119+ },+ "list_procedures": {+ "elapsed_ms": 646.0353969999705,+ "reply_bytes": 550261+ },+ "binary_overview": {+ "elapsed_ms": 198.11136500001885,+ "reply_bytes": 15727+ },+ "inspect_native_load_image": {+ "elapsed_ms": 456.49483100004727,+ "reply_bytes": 75633+ },+ "procedure_info": {+ "elapsed_ms": 99.12928700004704,+ "reply_bytes": 6825+ },+ "procedure_pseudo_code": {+ "elapsed_ms": 114.82446700002765,+ "reply_bytes": 6584+ },+ "procedure_assembly": {+ "elapsed_ms": 80.73368800000753,+ "reply_bytes": 6444+ },+ "procedure_callers": {+ "elapsed_ms": 10.588890000013635,+ "reply_bytes": 6337+ },+ "procedure_callees": {+ "elapsed_ms": 19.5354899999802,+ "reply_bytes": 6631+ },+ "analyze_function": {+ "elapsed_ms": 352.812751999998,+ "reply_bytes": 26364+ },+ "warm-inventory": {+ "elapsed_ms": 197.59054599999217,+ "reply_bytes": 550261+ },+ "warm-pseudocode": {+ "elapsed_ms": 8.122649999975692,+ "reply_bytes": 6584+ },+ "export_evidence_bundle": {+ "elapsed_ms": 61.80356899998151,+ "reply_bytes": 328+ },+ "close_binary": {+ "elapsed_ms": 614.0456879999838,+ "reply_bytes": 169+ }+ },+ "scope_seconds": 399.097,+ "payload_cpu_seconds": 352.659548,+ "payload_family_peak_bytes": 1088741376,+ "payload_cleanup_verified": true,+ "zero_limit_events_at_payload_exit": true,+ "final_whole_scope_counters_verified": false+ }+ ],+ "incomplete_attempts": [+ {+ "name": "baseline-true-1",+ "reason": "Harness selected subject.sha256 instead of subject.digest.sha256.",+ "reported_status": "failed",+ "payload_exit_code": 1,+ "scope_seconds": 41.401,+ "payload_cpu_seconds": 39.027824,+ "payload_family_peak_bytes": 1132675072,+ "observed_procedures": null,+ "payload_cleanup_verified": true,+ "resource_events_at_payload_exit": {+ "memory.events": {+ "low": 0,+ "high": 0,+ "max": 0,+ "oom": 0,+ "oom_kill": 0,+ "oom_group_kill": 0+ },+ "pids.events": {+ "max": 0+ }+ },+ "is_completed_performance_sample": false+ },+ {+ "name": "baseline-true-2",+ "reason": "Harness assumed the composed overview provider was Ghidra rather than rea-workflow.",+ "reported_status": "failed",+ "payload_exit_code": 1,+ "scope_seconds": 37.538,+ "payload_cpu_seconds": 36.599406,+ "payload_family_peak_bytes": 1001476096,+ "observed_procedures": 231,+ "payload_cleanup_verified": true,+ "resource_events_at_payload_exit": {+ "memory.events": {+ "low": 0,+ "high": 0,+ "max": 0,+ "oom": 0,+ "oom_kill": 0,+ "oom_group_kill": 0+ },+ "pids.events": {+ "max": 0+ }+ },+ "is_completed_performance_sample": false+ },+ {+ "name": "baseline-true-3",+ "reason": "Facts and cleanup completed, but the harness incorrectly read a status property from the boolean finalizer and exited 1.",+ "reported_status": "passed",+ "payload_exit_code": 1,+ "scope_seconds": 35.796,+ "payload_cpu_seconds": 34.736678,+ "payload_family_peak_bytes": 1001455616,+ "observed_procedures": 231,+ "payload_cleanup_verified": true,+ "resource_events_at_payload_exit": {+ "memory.events": {+ "low": 0,+ "high": 0,+ "max": 0,+ "oom": 0,+ "oom_kill": 0,+ "oom_group_kill": 0+ },+ "pids.events": {+ "max": 0+ }+ },+ "is_completed_performance_sample": false+ },+ {+ "name": "candidate-jq-1",+ "reason": "SDK five-minute first-query deadline expired while awaiting list_documents; cleanup completed.",+ "reported_status": "failed",+ "payload_exit_code": 1,+ "scope_seconds": 316.605,+ "payload_cpu_seconds": 293.28205,+ "payload_family_peak_bytes": 1065631744,+ "observed_procedures": null,+ "payload_cleanup_verified": true,+ "resource_events_at_payload_exit": {+ "memory.events": {+ "low": 0,+ "high": 0,+ "max": 0,+ "oom": 0,+ "oom_kill": 0,+ "oom_group_kill": 0+ },+ "pids.events": {+ "max": 0+ }+ },+ "is_completed_performance_sample": false+ },+ {+ "name": "integrated-baseline-jq-control",+ "reason": "Unmodified-main repeat differs by three observed procedure rows; strict comparison rejected it before export. Cause unestablished.",+ "reported_status": "failed",+ "payload_exit_code": 1,+ "scope_seconds": 276.557,+ "payload_cpu_seconds": 274.502165,+ "payload_family_peak_bytes": 1200726016,+ "observed_procedures": 2276,+ "payload_cleanup_verified": true,+ "resource_events_at_payload_exit": {+ "memory.events": {+ "low": 0,+ "high": 0,+ "max": 0,+ "oom": 0,+ "oom_kill": 0,+ "oom_group_kill": 0+ },+ "pids.events": {+ "max": 0+ }+ },+ "is_completed_performance_sample": false+ }+ ],+ "capacity_control": {+ "baseline_revision": "3fca2e0ca6e54ba700c286d9a85a9600dee6a19d",+ "records": 30000,+ "baseline": "regression fails with resource_constraint for list_procedures at the unchanged 10485760-byte stdio budget",+ "candidate": "all 30000 records delivered exactly; raw_result null",+ "real_provider": false,+ "production_boundary": "GhidraProvider -> BinarySession -> public MCP"+ },+ "executed_validation": [+ {+ "check": "npm run check",+ "base": "4e716b060",+ "result": "6 tasks and architecture guards passed"+ },+ {+ "check": "npm run check",+ "base": "3fca2e0ca",+ "result": "6 tasks and architecture guards passed; before adding the capacity regression"+ },+ {+ "check": "Focused Ghidra inventory/function/provider and four MCP files",+ "base": "4e716b060",+ "result": "246 assertions passed across 7 files"+ },+ {+ "check": "Capacity regression alone",+ "base": "3fca2e0ca",+ "result": "candidate passes; unchanged production baseline fails with resource_constraint; six other tests filtered out"+ },+ {+ "check": "Existing real Ghidra large-result helper through a private stdio harness",+ "result": "passed",+ "successful_calls": 15,+ "expected_rejections": 4,+ "runtime_empty_after_provider_close": true,+ "scope": "oversized lookup/read/annotation/dossier retention and recovery, complete CLI readback, unchanged source bytes"+ },+ {+ "check": "node scripts/verify-real-ghidra-address-context.mjs",+ "result": "passed with real Ghidra/CLI/MCP and verified empty descendant set",+ "scope": "PIE load identity, file-offset decompilation/roles, address round trips, failure guidance/recovery, unchanged source and complete cleanup",+ "fixture_sha256": "093f8ba3aef80f3d7c0e8f22557e9a8af29505e286835578282b8e32ff804a02"+ },+ {+ "check": "Final focused Ghidra source and MCP regression selection",+ "base": "3fca2e0ca",+ "result": "247 assertions across 7 files passed"+ },+ {+ "check": "npm run docs:check",+ "result": "generated metadata/documentation checks and 5 README conformance assertions passed"+ }+ ],+ "unmodified_main_control": {+ "same_target_digest_and_analysis_profile": true,+ "expected_procedures": 2279,+ "observed_procedures": 2276,+ "missing_relative_to_first_run": ["0x4f9930", "0x5260b0", "0x529640"],+ "cause": "unestablished; no engine/default-analysis repair included",+ "interpretation": "The matched pair is an observation, not a guarantee of cross-session procedure discovery or a latency distribution."+ },+ "limitations": [+ "No actual model-token or tokenizer measurement.",+ "Single completed pairs, not latency distributions.",+ "Unmodified-main procedure-inventory repeat failed the strict oracle; retained as an incomplete control.",+ "First three successful query receipts used the earlier driver; archived warm results were rechecked when explicit repeat assertions were added.",+ "Real Windows/macOS Ghidra, other engine versions and real NativeAOT overlays remain unqualified.",+ "Initial cached baseline build had an unverified payload-exit cleanup observation; a later systemd inspection found its scope inactive. It is not a query measurement."+ ],+ "resource_stopped_validation": [+ {+ "check": "Final focused regression selection, first attempt",+ "abort": "host_available_memory_early_stop",+ "peak_family_bytes_sampled": 837332992,+ "outcome": "guard-stopped without final test results; not counted as passing",+ "retry_budget": "4 GiB hard/3 GiB early, based on the earlier focused run peak of about 1.3 GiB"+ }+ ]+}diff --git a/experiments/analysis-efficiency/ghidra-evidence-projection.md b/experiments/analysis-efficiency/ghidra-evidence-projection.mdnew file mode 100644index 000000000..7f23fedd4--- /dev/null+++ b/experiments/analysis-efficiency/ghidra-evidence-projection.md@@ -0,0 +1,165 @@+# Ghidra Evidence projection++Continues [#5337](https://github.com/morluto/rea/issues/5337). The bridge+adapter supplied a complete `rawResult` for every successful operation, even+when strict parsing preserved the same value in `normalized_result`. Function+observation envelopes repeated their value and already-projected qualifications.+The generic Evidence contract already permits `raw_result: null` in this case.++## Owning change++The Ghidra inventory and function parsers now declare whether they retain an+independent upstream representation. Execution consumes those parsed facts and+named metadata, replacing the positional helper argument that required every+caller to supply another complete report. CLI and MCP use the same projection.++Ordinary inventories and function observations omit the redundant copy.+Limitations, relationship coverage and locations remain canonical Evidence+fields. The following representations remain available:++- The overview's upstream segment permissions, sections and provenance.+- Load-image observations before local attestation and enrichment.+- File-offset selection roles, which generic locations alone do not express.+- The database type reply before adding a locally derived NativeAOT overlay.++No tool, schema, query default, provider protocol, cache, target execution or+annotation authority is added. Existing source Evidence is not rewritten.+New records have the identities appropriate to their new representation;+artifact and procedure identities remain unchanged. Consumers should read+function results from `normalized_result`, rather than `raw_result.value`.++## Real inputs and completed question++Both ELF x86-64 targets are read without executing them:++| Target | Bytes | SHA-256 | Provenance |+| ---------------- | --------: | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |+| `true` | 35,664 | `c79bf44242829108e323378531f4ac839513ca1fba45efd6583643526e1e9fd2` | Installed Debian coreutils 9.1-1; package metadata is a local observation. |+| `jq-linux-amd64` | 2,267,912 | `b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f` | [Official jq 1.8.2 asset](https://github.com/jqlang/jq/releases/tag/jq-1.8.2); matches both the corpus and the release API's asset digest/size. |++Each fresh production stdio MCP session discovers the complete catalog, opens+the target, reads documents and the complete observed procedure inventory,+selects the first internal non-thunk procedure, reads overview/load image and+six function operations, repeats inventory/pseudocode, exports Evidence and+closes. This is one catalog discovery and 15 RPCs, including cleanup.+It qualifies this inventory/function-read question, rather than application+feature reconstruction or complete native-code discovery.++The live named SDK contracts validate replies. Each selected record binds to+the original target digest and Ghidra profile. The candidate's complete selected+fact vector equals the baseline after excluding only `evidence_id` and+`raw_result`: subject, parameters, normalized facts, provider/profile, authority,+limitations, relationships, locations and Evidence links remain equal. Exported+records match returned Evidence, repeated facts agree, and target hashes remain+unchanged. This is representation equivalence, not an independent qualification+of every Ghidra interpretation.++## Measurements and limits++Linux x86-64, Node 24.18.0/npm 11.16.0, MCP SDK 2.3.1, Ghidra 12.1.4 and+Eclipse Adoptium 21.0.12.1+1-LTS. Sessions and Java analysis are fresh; OS caches+are warm and unflushed. Configured Java heap is 768 MiB with one active processor.+The whole process family uses one logical CPU, 4 GiB hard/3 GiB early-stop memory,+no swap and 192 tasks. No completed query task has an OOM/limit event or cleanup+failure at verified payload exit. Final whole-scope counters after scope removal+remain unavailable. Post-GC retained heap is unmeasured.++The small pair uses main `4e716b06078d725a53234503cbefbb340731e809` and its+candidate. Main advanced during the experiment; the large pair uses+`3fca2e0ca6e54ba700c286d9a85a9600dee6a19d` on both sides. Existing timing+samples keep their original runtime fingerprints. The [curated receipt](ghidra-evidence-projection.json)+retains individual observations and incomplete attempts; raw data stays outside Git.++| Recording / metric | Before | After |+| ----------------------------------------------- | ---------: | ---------: |+| `true`: observed procedures | 231 | 231 |+| `true`: all RPC result bytes | 473,344 | 326,642 |+| `true`: catalog + request arguments + results | 3,729,626 | 3,582,925 |+| `true`: complete scope wall | 34.369 s | 34.901 s |+| `true`: payload-family CPU | 33.150 s | 33.834 s |+| `true`: kernel family peak including file cache | 947.9 MiB | 977.7 MiB |+| `jq`: observed procedures | 2,279 | 2,279 |+| `jq`: all RPC result bytes | 2,375,466 | 1,264,884 |+| `jq`: catalog + request arguments + results | 5,639,932 | 4,529,351 |+| `jq`: complete scope wall | 279.699 s | 399.097 s |+| `jq`: payload-family CPU | 277.696 s | 352.660 s |+| `jq`: kernel family peak including file cache | 1060.0 MiB | 1038.3 MiB |++RPC result bytes include the SDK's text and structured representations. Request+objects and the complete catalog are included in the combined byte count;+initialization, wire framing and model rendering are unmeasured. Actual model+tokens and tokenizer estimates are unmeasured. The observed byte reduction+does not establish a token saving or better agent investigation outcome.++The large result envelopes shrink by 46.8%; combined serialization shrinks by+19.7%, with unchanged catalog and call count. Small combined serialization+shrinks by 3.9%. These are single pairs, not distributions. No whole-task latency,+CPU or peak-memory improvement is established. The large candidate's first+`list_documents` costs 391.136 s versus 270.160 s before; this phase includes+startup, analysis wait and client work, not isolated engine time. Changed+projection code executes after the bridge returns its observation, but the+cause of the preparation-time variation is unestablished. One warm inventory+read costs 338.93 → 197.59 ms; this is not a general latency qualification.++A subsequent unchanged-main repeat with the same target/profile returned 2,276+procedures instead of 2,279, omitting `0x4f9930`, `0x5260b0` and `0x529640`+relative to its earlier inventory. The strict oracle rejected that control+before export. Its cause is unestablished; it is retained as an incomplete+attempt, not added to performance averages or treated as a projection defect.++## Verification scope++The production-boundary capacity regression supplies 30,000 valid simulated+Ghidra procedure rows through `GhidraProvider`, `BinarySession` and MCP. On+unchanged production main it fails with `resource_constraint` at the existing+10 MiB response budget. The candidate delivers every row exactly, without a+budget increase or truncation. This qualifies response admission, not a real+30,000-function Ghidra analysis or a universal maximum procedure count.++Source/parser tests cover strict rejection, sidecars, distinct file-offset+mapping roles, overview details, NativeAOT enrichment and unchanged observations.+Executed checks and real-provider verification are recorded in the receipt.+NativeAOT overlay tests use producer fixtures; real Windows/macOS and other+engine versions remain unqualified here.++The existing real large-result helper passed through a private stdio harness:+oversized lookup/read/annotation/dossier replies retained complete Evidence,+subsequent queries recovered, complete CLI readback matched the original bytes+with `raw_result: null`, and generated target bytes remained unchanged.+The public `verify-real-ghidra-address-context.mjs` also passed with real+Ghidra/CLI/MCP, including file-offset selection, address round trips, recovery,+unchanged source and verified cleanup. These capacity/address fixtures use a+separate 6 GiB family cap; they are correctness checks, not latency pairs.++Three early `true` harness attempts used an incorrect subject-digest selector,+assumed the composed overview's provider was Ghidra, or misread the existing+finalizer's boolean result. The last completed its facts but exited nonzero;+none is a completed performance sample. A first `jq` candidate hit the SDK's+five-minute deadline while awaiting readiness, then cleaned up successfully.+The final driver's startup/RPC deadlines are ten minutes on both sides; product+defaults are unchanged. Earlier successful warm facts were rechecked from their+archived production replies when explicit warm-result assertions were added.++## Reproduce++Build and retain separate baseline/candidate runtimes. Use the same absolute+target path and caller-supplied Ghidra/JDK for both:++```sh+python3 experiments/analysis-efficiency/resource-run.py --observe-payload-exit -- \+ node experiments/analysis-efficiency/ghidra-evidence-projection.mjs \+ --runtime /absolute/baseline --target /absolute/application \+ --ghidra /absolute/ghidra --java /absolute/jdk \+ --expect duplicate --output /absolute/new-before++python3 experiments/analysis-efficiency/resource-run.py --observe-payload-exit -- \+ node experiments/analysis-efficiency/ghidra-evidence-projection.mjs \+ --runtime /absolute/candidate --target /absolute/application \+ --ghidra /absolute/ghidra --java /absolute/jdk \+ --expect compact --control /absolute/new-before/facts.json \+ --output /absolute/new-after+```++The candidate's independent baseline comparison is included in harness costs;+its isolated verification overhead is unmeasured. Static checks use a separate+8 GiB memory cap. All heavy operations run serially.diff --git a/experiments/analysis-efficiency/ghidra-evidence-projection.mjs b/experiments/analysis-efficiency/ghidra-evidence-projection.mjsnew file mode 100644index 000000000..3686f11d7--- /dev/null+++ b/experiments/analysis-efficiency/ghidra-evidence-projection.mjs@@ -0,0 +1,216 @@+/** Real Ghidra inventory/function Evidence; raw inputs and receipts stay outside Git. */+import assert from "node:assert/strict";+import { createHash } from "node:crypto";+import { createWriteStream } from "node:fs";+import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join, resolve } from "node:path";+import { finished } from "node:stream/promises";+import { parseArgs } from "node:util";+import { Client } from "@modelcontextprotocol/client";+import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";+import { createRetainedQueryCaller } from "./retained-query-calls.mjs";+import { finalizeRetainedQueryReceipt } from "./retained-query-finalization.mjs";++const { values } = parseArgs({+ options: Object.fromEntries(+ ["runtime", "target", "output", "ghidra", "java", "expect", "control"].map(+ (name) => [name, { type: "string" }],+ ),+ ),+});+for (const name of ["runtime", "target", "output", "ghidra", "java"])+ assert.ok(values[name] && values[name] === resolve(values[name]), name);+assert.ok(["duplicate", "compact"].includes(values.expect));+const hash = (value) => createHash("sha256").update(value).digest("hex");+const output = values.output;+await mkdir(output, { mode: 0o700 });+const bytes = await readFile(values.target);+const home = await mkdtemp(join(tmpdir(), "rea-ghidra-evidence-"));+const client = new Client({ name: "ghidra-evidence-projection", version: "1" });+const transport = new StdioClientTransport({+ command: process.execPath,+ args: [join(values.runtime, "scripts/rea.mjs"), "mcp"],+ env: {+ HOME: home,+ PATH: process.env.PATH,+ NODE_OPTIONS: "--max-old-space-size=2048",+ GHIDRA_INSTALL_DIR: values.ghidra,+ JAVA_HOME: values.java,+ GHIDRA_HEADLESS_MAXMEM: "768M",+ JAVA_TOOL_OPTIONS: "-XX:ActiveProcessorCount=1",+ REA_GHIDRA_STARTUP_TIMEOUT_MS: "600000",+ REA_LOG_LEVEL: "silent",+ },+ stderr: "pipe",+});+const serverLog = createWriteStream(join(output, "server.log"));+const serverLogFinished = finished(serverLog);+serverLogFinished.catch(() => {});+transport.stderr?.pipe(serverLog);+const report = {+ artifact: { path: values.target, bytes: bytes.length, sha256: hash(bytes) },+ expected_projection: values.expect,+ calls: [],+};+const transcript = [];+const evidence = [];+const call = createRetainedQueryCaller(client, (receipt, event) => {+ report.calls.push(receipt);+ transcript.push(event);+});+const result = async (name, input, phase = name) => {+ const reply = await call(name, input, phase);+ assert.notEqual(reply.isError, true, JSON.stringify(reply));+ assert.ok(reply.structuredContent);+ return reply.structuredContent;+};+const inspect = async (name, input, phase = name) => {+ const value = await result(name, input, phase);+ assert.equal(value.subject.digest.sha256, report.artifact.sha256);+ assert.equal(+ value.provider.id,+ name === "binary_overview" ? "rea-workflow" : "ghidra",+ );+ assert.equal(+ value.provider.version,+ name === "binary_overview" ? "1" : "12.1.4",+ );+ assert.ok(value.analysis_profile);+ evidence.push({ phase, value });+ return value;+};+const started = performance.now();+let opened = false;+try {+ await client.connect(transport);+ const discovery = performance.now();+ const catalog = await client.listTools();+ assert.equal(catalog.nextCursor, undefined);+ report.catalog = {+ elapsed_ms: performance.now() - discovery,+ bytes: Buffer.byteLength(JSON.stringify(catalog)),+ sha256: hash(JSON.stringify(catalog)),+ };+ await writeFile(join(output, "catalog.json"), JSON.stringify(catalog));+ const definitions = new Map(catalog.tools.map((tool) => [tool.name, tool]));+ const original = client.callTool.bind(client);+ client.callTool = (input, options) =>+ original(input, {+ ...options,+ timeout: 600000,+ toolDefinition: definitions.get(input.name),+ });+ await result("open_binary", { path: values.target, provider_id: "ghidra" });+ opened = true;+ const documents = await inspect("list_documents", {});+ assert.equal(documents.normalized_result.length, 1);+ const procedures = await inspect("list_procedures", {});+ assert.ok(procedures.normalized_result.length > 0);+ const selected = procedures.normalized_result.find(+ (row) => row.procedure.external === false && row.procedure.thunk === false,+ );+ assert.ok(selected);+ report.procedure = selected.address;+ report.procedure_count = procedures.normalized_result.length;+ await inspect("binary_overview", {});+ await inspect("inspect_native_load_image", {});+ for (const name of [+ "procedure_info",+ "procedure_pseudo_code",+ "procedure_assembly",+ "procedure_callers",+ "procedure_callees",+ "analyze_function",+ ])+ await inspect(name, { procedure: selected.address });+ const warmInventory = await inspect("list_procedures", {}, "warm-inventory");+ assert.deepEqual(+ warmInventory.normalized_result,+ procedures.normalized_result,+ );+ const warmPseudocode = await inspect(+ "procedure_pseudo_code",+ { procedure: selected.address },+ "warm-pseudocode",+ );+ assert.deepEqual(+ warmPseudocode.normalized_result,+ evidence.find(({ phase }) => phase === "procedure_pseudo_code").value+ .normalized_result,+ );+ for (const { phase, value } of evidence) {+ if (phase === "binary_overview") {+ assert.equal(value.raw_result, null);+ continue;+ }+ const distinct = phase === "inspect_native_load_image";+ if (values.expect === "compact" && !distinct)+ assert.equal(value.raw_result, null, phase);+ else assert.notEqual(value.raw_result, null, phase);+ if (values.expect === "duplicate" && !distinct) {+ const raw = value.raw_result;+ const wrapped =+ raw !== null &&+ !Array.isArray(raw) &&+ Object.hasOwn(raw, "value") &&+ Object.hasOwn(raw, "limitations");+ assert.deepEqual(+ wrapped ? raw.value : raw,+ value.normalized_result,+ phase,+ );+ }+ }+ const facts = evidence.map(({ phase, value }) => {+ const { evidence_id: _id, raw_result: _raw, ...facts } = value;+ return { phase, facts };+ });+ report.facts_sha256 = hash(JSON.stringify(facts));+ await writeFile(join(output, "facts.json"), JSON.stringify(facts));+ if (values.control)+ assert.deepEqual(facts, JSON.parse(await readFile(values.control, "utf8")));+ const path = join(output, "evidence.json");+ await result("export_evidence_bundle", { path });+ const bundle = JSON.parse(await readFile(path, "utf8"));+ for (const { value } of evidence)+ assert.deepEqual(+ bundle.records.find((record) => record.evidence_id === value.evidence_id),+ value,+ );+ assert.equal(hash(await readFile(values.target)), report.artifact.sha256);+ report.status = "passed";+} catch (cause) {+ report.status = "failed";+ report.failure = String(cause?.stack ?? cause);+ process.exitCode = 1;+} finally {+ if (opened) {+ try {+ await result("close_binary", {});+ } catch (cause) {+ report.status = "failed";+ report.close_failure = String(cause?.stack ?? cause);+ }+ }+ report.elapsed_before_cleanup_ms = performance.now() - started;+ try {+ await writeFile(+ join(output, "transcript.json"),+ JSON.stringify(transcript),+ );+ } catch (cause) {+ report.status = "failed";+ report.transcript_failure = String(cause);+ }+ const finalized = await finalizeRetainedQueryReceipt({+ report,+ client,+ transport,+ account: home,+ serverLog,+ serverLogFinished,+ output,+ });+ if (report.status !== "passed" || !finalized) process.exitCode = 1;+}diff --git a/scripts/lib/real-ghidra-large-results.mjs b/scripts/lib/real-ghidra-large-results.mjsindex fa1c5115f..6890bd4a2 100644--- a/scripts/lib/real-ghidra-large-results.mjs+++ b/scripts/lib/real-ghidra-large-results.mjs@@ -167,26 +167,18 @@ export async function verifyGhidraLargeResults({assert.equal(read.returned_bytes, length);assert.equal(read.complete, true);assert.equal(read.bytes_hex, expected.toString("hex"));- assert.equal(readRecord.raw_result.bytes_hex, read.bytes_hex);+ assert.equal(readRecord.raw_result, null);const annotationRecord = retained(annotationId);const annotation = annotationRecord.normalized_result;assert.equal(annotation.annotations.name, "rea_frame_probe");assert.equal(annotation.annotations.comment, comment);assert.equal(annotation.annotations.inline_comment, comment);- assert.equal(annotationRecord.raw_result.annotations.comment, comment);- assert.equal(- annotationRecord.raw_result.annotations.inline_comment,- comment,- );+ assert.equal(annotationRecord.raw_result, null);const dossierRecord = retained(dossierId);const dossier = dossierRecord.normalized_result;assert.equal(dossier.procedure.name, "rea_frame_probe");assert.ok(dossier.comments.some(({ text }) => text === comment));- assert.ok(- dossierRecord.raw_result.value.comments.some(- ({ text }) => text === comment,- ),- );+ assert.equal(dossierRecord.raw_result, null);const { stdout } = await exec(process.execPath,[@@ -202,7 +194,9 @@ export async function verifyGhidraLargeResults({],{ env, timeout: 240000, maxBuffer: 72 * 1024 * 1024 },);- assert.deepEqual(JSON.parse(stdout).normalized_result, read);+ const cliRead = JSON.parse(stdout);+ assert.deepEqual(cliRead.normalized_result, read);+ assert.equal(cliRead.raw_result, null);assert.deepEqual(await readFile(path), bytes);await call("close_binary");await call("open_binary", { path: target.path, provider_id: "ghidra" });diff --git a/scripts/verify-real-ghidra-function.mjs b/scripts/verify-real-ghidra-function.mjsindex 8acfeb102..dbf4e77b7 100644--- a/scripts/verify-real-ghidra-function.mjs+++ b/scripts/verify-real-ghidra-function.mjs@@ -49,7 +49,7 @@ async function inventoryCall(client, operation, parameters) {);const parsed = parseGhidraInventoryResult(operation, called.value);if (!parsed.ok) throw parsed.error;- return parsed.value;+ return parsed.value.value;}export async function verifyDebugFunctionOperations(diff --git a/scripts/verify-real-ghidra-inventory.mjs b/scripts/verify-real-ghidra-inventory.mjsindex e8c240789..d5e033a99 100644--- a/scripts/verify-real-ghidra-inventory.mjs+++ b/scripts/verify-real-ghidra-inventory.mjs@@ -16,7 +16,7 @@ export async function call(client, operation, parameters) {);const parsed = parseGhidraInventoryResult(operation, called.value);if (!parsed.ok) throw parsed.error;- return parsed.value;+ return parsed.value.value;}export async function allItems(client, operation, parameters) {diff --git a/scripts/verify-real-ghidra-windows.mjs b/scripts/verify-real-ghidra-windows.mjsindex fa297fd71..ca64f3804 100644--- a/scripts/verify-real-ghidra-windows.mjs+++ b/scripts/verify-real-ghidra-windows.mjs@@ -378,7 +378,7 @@ async function inventory(operation, parameters) {const result = parseGhidraInventoryResult(operation, called.value);if (!result.ok) throw result.error;observed.add(operation);- return result.value;+ return result.value.value;}async function functionOperation(operation, parameters) {diff --git a/src/ghidra/GhidraFunctionValues.test.ts b/src/ghidra/GhidraFunctionValues.test.tsindex 71c8ddb50..6ee0d39fc 100644--- a/src/ghidra/GhidraFunctionValues.test.ts+++ b/src/ghidra/GhidraFunctionValues.test.ts@@ -193,7 +193,7 @@ describe("Ghidra relationship metadata validation", () => {it("preserves file-offset resolution in Evidence locations and rejects inexact offsets", () => {const selection = {file_offset: 0x210,- mapped_address: "0x140001010",+ mapped_address: "0x140001014",procedure_address: "0x140001010",};const wire = { value: "return 42;", limitations: [], selection };@@ -204,9 +204,10 @@ describe("Ghidra relationship metadata validation", () => {if (!parsed.ok) throw parsed.error;expect(parsed.value.locations).toEqual([{ kind: "file-offset", offset: 0x210 },- { kind: "address", address: "0x140001010" },+ { kind: "address", address: "0x140001014" },{ kind: "address", address: "0x140001010" },]);+ expect(parsed.value.rawResult).toEqual(wire);expect(parseGhidraFunctionResult("procedure_pseudo_code", {...wire,diff --git a/src/ghidra/GhidraFunctionValues.ts b/src/ghidra/GhidraFunctionValues.tsindex c8890aae8..8de099c08 100644--- a/src/ghidra/GhidraFunctionValues.ts+++ b/src/ghidra/GhidraFunctionValues.ts@@ -437,6 +437,7 @@ const functionObservationEnvelope = z.strictObject({export interface ParsedGhidraFunctionResult {readonly value: JsonValue;+ readonly rawResult?: JsonValue;readonly limitations: readonly string[];readonly locations?: readonly EvidenceLocation[];readonly relationshipCoverage?: RelationshipCoverage;@@ -488,6 +489,8 @@ export const parseGhidraFunctionResult = (...(observation.selection === undefined? {}: {+ // Generic locations retain coordinates but not their mapping roles.+ rawResult: value,locations: [{kind: "file-offset" as const,diff --git a/src/ghidra/GhidraInventoryValues.test.ts b/src/ghidra/GhidraInventoryValues.test.tsindex b66fed3ca..5f70c8870 100644--- a/src/ghidra/GhidraInventoryValues.test.ts+++ b/src/ghidra/GhidraInventoryValues.test.ts@@ -53,7 +53,41 @@ describe("provider-owned overview boundary", () => {parseGhidraInventoryResult("read_binary_inventory_summary", overview),).toEqual({ok: true,- value: { ...overview, segment_count: 0 },+ value: { value: { ...overview, segment_count: 0 }, rawResult: overview },+ });+ });++ it("keeps the independent segment permissions and provenance behind an overview", () => {+ const reported = {+ ...overview,+ segments: [+ {+ name: ".text",+ start: "0x1000",+ end: "0x100f",+ readable: true,+ writable: false,+ executable: true,+ permissions: { available: true, source: "ghidra-memory-block" },+ provenance: "ghidra-memory-block",+ address_space: "ram",+ image_base: "0x1000",+ initialized: true,+ overlay: false,+ sections: [],+ },+ ],+ };+ const parsed = parseGhidraInventoryResult(+ "read_binary_inventory_summary",+ reported,+ );+ if (!parsed.ok) throw parsed.error;+ expect(parsed.value.rawResult).toEqual(reported);+ expect(parsed.value.value).toMatchObject({+ procedure_count: 0,+ string_count: 0,+ segments: [{ name: ".text", start: "0x1000", end: "0x100f" }],});});diff --git a/src/ghidra/GhidraInventoryValues.ts b/src/ghidra/GhidraInventoryValues.tsindex 1d8fff19e..36ddeb515 100644--- a/src/ghidra/GhidraInventoryValues.ts+++ b/src/ghidra/GhidraInventoryValues.ts@@ -357,28 +357,47 @@ const resultSchemas = {set_addresses_names: z.record(z.string(), z.boolean()),} satisfies Readonly<Record<GhidraInventoryOperation, z.ZodType>>;-/** Validate exact Java-bridge output before creating Evidence. */+/** The format owner retains raw output only when projection omits reported facts. */+export interface ParsedGhidraInventoryResult<Value = JsonValue> {+ readonly value: Value;+ readonly rawResult?: JsonValue;+}++/** Validate exact Java-bridge output and own its Evidence representation. */export function parseGhidraInventoryResult(operation: "inspect_native_load_image",value: JsonValue,-): Result<NativeLoadImageObservation, AnalysisOutputError>;+): Result<+ ParsedGhidraInventoryResult<NativeLoadImageObservation>,+ AnalysisOutputError+>;export function parseGhidraInventoryResult(operation: GhidraInventoryOperation,value: JsonValue,-): Result<JsonValue, AnalysisOutputError>;+): Result<ParsedGhidraInventoryResult, AnalysisOutputError>;export function parseGhidraInventoryResult(operation: GhidraInventoryOperation,value: JsonValue,-): Result<JsonValue | NativeLoadImageObservation, AnalysisOutputError> {+): Result<+ ParsedGhidraInventoryResult<JsonValue | NativeLoadImageObservation>,+ AnalysisOutputError+> {if (operation === "inspect_native_load_image") {const parsed = resultSchemas.inspect_native_load_image.safeParse(value);return parsed.success- ? ok(parsed.data)+ ? ok({ value: parsed.data, rawResult: value }): err(inventoryOutputFailure(operation, parsed.error));}const parsed = resultSchemas[operation].safeParse(value);return parsed.success- ? ok(jsonValueSchema.parse(parsed.data))+ ? ok({+ value: jsonValueSchema.parse(parsed.data),+ // The overview omits detailed segment permissions, sections and provenance.+ // Load-image observations above undergo separate local attestation.+ ...(operation === "read_binary_inventory_summary"+ ? { rawResult: value }+ : {}),+ }): err(inventoryOutputFailure(operation, parsed.error));}diff --git a/src/ghidra/GhidraProvider.behavior.test.ts b/src/ghidra/GhidraProvider.behavior.test.tsindex 49aee30f3..b56f18022 100644--- a/src/ghidra/GhidraProvider.behavior.test.ts+++ b/src/ghidra/GhidraProvider.behavior.test.ts@@ -1142,7 +1142,7 @@ describe("Ghidra client projection", () => {},analysisProfile: resolved.value.profile,result: [{ address: "0x1000", value: "fixture_main" }],- rawResult: [{ procedure: { external: false, thunk: false } }],+ rawResult: null,},});expect(startCount).toBe(0);@@ -1181,10 +1181,7 @@ describe("Ghidra result projection", () => {if (!execution.ok) throw execution.error;expect(execution.value.result).toBe("void main() {}");expect(execution.value.limitations).toContain(limitation);- expect(execution.value.rawResult).toEqual({- value: "void main() {}",- limitations: [limitation],- });+ expect(execution.value.rawResult).toBeNull();await client.close();});@@ -1672,6 +1669,7 @@ it("returns read-only NativeAOT metadata inline and drills down by derived Methoexpect(detail).toMatchObject({ok: true,value: {+ rawResult: unavailableNativeAotDatabaseType("0x140002280"),result: {status: "unavailable",source: "analysis-database",diff --git a/src/ghidra/GhidraProviderClient.ts b/src/ghidra/GhidraProviderClient.tsindex f6e6b8f16..5427b5d8f 100644--- a/src/ghidra/GhidraProviderClient.ts+++ b/src/ghidra/GhidraProviderClient.ts@@ -120,6 +120,13 @@ export type GhidraProviderClientFactory = (type GhidraProviderClientInstance = ReturnType<GhidraProviderClientFactory>;+interface GhidraExecutionMetadata {+ readonly rawResult?: JsonValue;+ readonly limitations?: readonly string[];+ readonly locations?: readonly EvidenceLocation[];+ readonly relationshipCoverage?: RelationshipCoverage;+}+/** Build one AnalysisClient for an admitted Ghidra target and profile. */export const createGhidraProviderClient = (input: {readonly config: AppConfig;@@ -499,19 +506,14 @@ export const createGhidraProviderClient = (input: {const projectExecution = (operation: AnalysisOperation,normalized: JsonValue,- rawResult: JsonValue,- observationLimitations: readonly string[] = [],- locations: readonly EvidenceLocation[] = [],- relationshipCoverage?: RelationshipCoverage,+ observation: GhidraExecutionMetadata = {},) => {return createAnalysisExecution(normalized, committedProfile.provider, {- rawResult,- locations,+ ...observation,analysisProfile: committedProfile,- ...(relationshipCoverage === undefined ? {} : { relationshipCoverage }),limitations: [...limitationsFor(operation),- ...observationLimitations,+ ...(observation.limitations ?? []),...sessionLimitations(),],});@@ -531,12 +533,14 @@ export const createGhidraProviderClient = (input: {);const parsed = parseGhidraInventoryResult(operation, called.value);if (!parsed.ok) return parsed;- return ok(projectExecution(operation, parsed.value, called.value));+ const { value, ...observation } = parsed.value;+ return ok(projectExecution(operation, value, observation));};const loadImageExecution = async (raw: JsonValue, signal?: AbortSignal) => {const operation = "inspect_native_load_image";const measured = parseGhidraInventoryResult(operation, raw);if (!measured.ok) return measured;+ const { value: observed, ...observation } = measured.value;let derived: NativeAotPeResult | undefined;if (target.format === "pe") {if (nativeAotOwner === undefined)@@ -549,7 +553,7 @@ export const createGhidraProviderClient = (input: {}),);const result = await nativeAotOwner.derive(- measured.value.image_base,+ observed.image_base,operation,signal,raw,@@ -560,7 +564,7 @@ export const createGhidraProviderClient = (input: {const attested = await attestGhidraNativeLoadImage({target,operation,- measured: measured.value,+ measured: observed,client,mapSessionError: (failure) =>projectSessionError(@@ -577,7 +581,7 @@ export const createGhidraProviderClient = (input: {projectExecution(operation,jsonValueSchema.parse(attested.value),- raw,+ observation,),): attested;@@ -662,22 +666,11 @@ export const createGhidraProviderClient = (input: {);if (operation === "inspect_native_load_image")return loadImageExecution(called.value, options?.signal);- let normalized: JsonValue;- let observationLimitations: readonly string[] = [];- let observationLocations: readonly EvidenceLocation[] = [];- let relationshipCoverage: RelationshipCoverage | undefined;- if (isGhidraFunctionOperation(operation)) {- const result = parseGhidraFunctionResult(operation, called.value);- if (!result.ok) return result;- normalized = result.value.value;- observationLimitations = result.value.limitations;- observationLocations = result.value.locations ?? [];- relationshipCoverage = result.value.relationshipCoverage;- } else {- const result = parseGhidraInventoryResult(operation, called.value);- if (!result.ok) return result;- normalized = result.value;- }+ const result = isGhidraFunctionOperation(operation)+ ? parseGhidraFunctionResult(operation, called.value)+ : parseGhidraInventoryResult(operation, called.value);+ if (!result.ok) return result;+ let { value: normalized, ...observation } = result.value;if (operation === "inspect_native_data_type" &&normalized !== null &&@@ -712,23 +705,17 @@ export const createGhidraProviderClient = (input: {if (!derived.ok) return derived;}const metadata = nativeAotOwner?.readTypeDetail(address);- if (metadata !== undefined)+ if (metadata !== undefined) {+ // Preserve the database reply independently of the derived overlay.+ observation = { ...observation, rawResult: called.value };normalized = jsonValueSchema.parse({...normalized,metadata_recovery: metadata,});+ }}}- return ok(- projectExecution(- operation,- normalized,- called.value,- observationLimitations,- observationLocations,- relationshipCoverage,- ),- );+ return ok(projectExecution(operation, normalized, observation));},executeIfReady: async (operation, parameters, options) => {if (operation !== "list_documents" && operation !== "list_procedures")diff --git a/tests/boundary/mcp/ghidraEvidenceMcp.test.ts b/tests/boundary/mcp/ghidraEvidenceMcp.test.tsindex bb8ed8ce7..c249a8b82 100644--- a/tests/boundary/mcp/ghidraEvidenceMcp.test.ts+++ b/tests/boundary/mcp/ghidraEvidenceMcp.test.ts@@ -182,10 +182,7 @@ it("retains terminal-call qualifications across function views and snapshot replreply.structuredContent,);expect(evidence.normalized_result, name).toEqual(value);- expect(evidence.raw_result, name).toEqual({- value,- limitations: [limitation],- });+ expect(evidence.raw_result, name).toBeNull();expect(evidence.limitations, name).toContain(limitation);expect(evidence.analysis_profile?.parameters).toMatchObject({function_boundary_observations:@@ -240,7 +237,7 @@ it("retains handler-region limitations on incoming and outgoing reference Evidenreply.structuredContent,);expect(evidence.normalized_result).toMatchObject({ direction });- expect(evidence.raw_result).toMatchObject({ limitations: [limitation] });+ expect(evidence.raw_result).toBeNull();expect(evidence.limitations).toContain(limitation);const replay = await harness.session.execute("procedure_references",diff --git a/tests/boundary/mcp/ghidraInventoryMcp.test.ts b/tests/boundary/mcp/ghidraInventoryMcp.test.tsindex b269087ac..130088cc6 100644--- a/tests/boundary/mcp/ghidraInventoryMcp.test.ts+++ b/tests/boundary/mcp/ghidraInventoryMcp.test.ts@@ -25,6 +25,35 @@ import { createServer } from "../../../src/server/createServer.js";import { waitForExit } from "../../support/process/processFixture.js";import { GhidraSessionError } from "../../../src/ghidra/GhidraSessionError.js";+it("delivers a complete Ghidra inventory within the existing MCP response budget", async () => {+ const items = Array.from({ length: 30_000 }, (_, index) => ({+ address: `0x${(0x1000 + index).toString(16)}`,+ value: `procedure_${String(index).padStart(6, "0")}`,+ procedure: { external: false, thunk: false, thunk_target: null },+ }));+ const harness = await connectGhidraMcp(+ "inventory-response-budget",+ (operation) => {+ if (operation !== "list_procedures")+ throw new Error(`Unexpected operation: ${operation}`);+ return Promise.resolve(ok(items));+ },+ );+ try {+ const reply = await harness.mcp.callTool({+ name: "list_procedures",+ arguments: {},+ });+ if (reply.isError) throw new Error(JSON.stringify(reply));+ const evidence = sessionEvidence(harness.session, reply.structuredContent);+ expect(evidence.raw_result).toBeNull();+ expect(evidence.normalized_result).toEqual(items);+ expect(harness.calls).toEqual(["list_procedures"]);+ } finally {+ await harness.close();+ }+});+it("retains byte-search coverage and rejects malformed pages before creating Evidence", async () => {const page = {matches: [@@ -245,6 +274,7 @@ it("searches bytes through MCP and the socket bridge with pagination and skipped});expect(first.isError, JSON.stringify(first)).not.toBe(true);const firstEvidence = sessionEvidence(session, first.structuredContent);+ expect(firstEvidence.raw_result).toBeNull();expect(firstEvidence.normalized_result).toMatchObject({matches: [{