Skip to content

fix(native): preserve compact reference provenance - #1438

Merged
morluto merged 3 commits into
morluto:mainfrom
JosephDemarest:codex/compact-reference-provenance-ntfs
Oct 10, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
JosephDemarest:codex/compact-reference-provenance-ntfs

Conversation

@JosephDemarest

Copy link
Copy Markdown
Contributor

Summary

Preserve Ghidra's reference origin, primary status, and DATA/READ/WRITE classification in compact instruction and call-target results. This is the compact-reference increment of #1245; the broader incoming-xref contract remains open.

Problem and expected behavior

An indexed store can have multiple analyzer-generated DATA references, including a non-primary reference. The compact representation previously dropped the primary flag, reference origin and access flags even though the full procedure-reference representation retained most of these facts. Consumers could not distinguish those references from literal accesses without another query.

Compact results now preserve the observed provider facts. primary is not proof of literal addressing or runtime access, and unknown metadata stays unknown.

Change and scope

  • Reuse the Ghidra referenceKind producer and add the actual source address and Reference.getSource() origin.
  • Extend the shared instruction/call-target reference schema with optional, nullable source_address, data, read, write, primary, provenance and source, preserving legacy omission and explicit nulls.
  • Extend the source-owned x86/x64 PE fixtures and real-provider verifiers with literal DATA/READ/WRITE, indexed non-primary analyzer references, direct calls, unresolved indirect calls, returns and outside-memory controls.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra bridge reference serialization; shared native schemas validate the additive fields.
  • CLI and MCP/tool-catalog contract: both existing operations expose the same additive metadata; no new tools or inputs.
  • Provider, bridge, target-format, or platform compatibility: Ghidra emits its observed facts; older captures/providers may omit the new fields.
  • Evidence, artifact, provenance, or reconstruction contract: evidence preserves the fields and distinguishes reference-manager provenance from provider reference origin. No runtime-access inference is added.
  • Process execution, authorization, cleanup, or containment impact: none; existing read-only execution and cleanup controls are retained and exercised.
  • Generated metadata, package, or installation impact: generated metadata checks pass; no package version, installation or native-addon source changes.

Evidence and regression coverage

  • Tests cover full metadata, legacy omission, explicit nulls, malformed present fields, and MCP evidence projection for both operations.
  • New schema-preservation tests failed on the base implementation and pass with this change.
  • Executed CLI output for the x86 indexed store includes these two references (excerpt):
[
  { "type": "DATA", "data": true, "read": false, "write": false, "primary": true, "source": "analysis", "provenance": "ghidra-reference-manager" },
  { "type": "DATA", "data": true, "read": false, "write": false, "primary": false, "source": "analysis", "provenance": "ghidra-reference-manager" }
]

The indexed store's analyzer targets are DATA references; separate literal controls prove READ and WRITE preservation. Compact references match full procedure-reference edges, and direct-call target references match the corresponding instruction references.

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

Validation performed

Executed on Windows 11, with Node 24.18.0, npm 11.16.0, Ghidra 12.1.4 and Temurin JDK 21.0.11:

  • npm run build:cached — passed.
  • npm run test:focused -- src/ghidra/GhidraFunctionValues.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/application/native/NativeValueTrace.test.ts tests/boundary/mcp/ghidraCompactReferencesMcp.test.ts tests/boundary/mcp/ghidraRoutingMcp.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/contractPresentation.test.ts — 72 tests passed across seven files. The ignored addon was temporarily absent for the existing missing-addon control, then restored.
  • npm run check — passed, including architecture guards; lint reported 494 warnings and zero errors.
  • npm run docs:check — passed.
  • node scripts/verify-test-discovery.mjs — 705 test files discovered exactly once.
  • LSP diagnostics — no errors in the changed TypeScript files.
  • node scripts/verify-real-ghidra-windows.mjs --x86 and node scripts/verify-real-ghidra-windows.mjs — real Ghidra x86/x64 passed all 25 read-only operations, compact/full reference assertions and complete cleanup.
  • node scripts/verify-packaged-ghidra-windows.mjs . build/fixtures/rea-ghidra-windows-x86.exe <progress-file> — source-built public CLI and real stdio MCP passed, including six CLI/MCP comparisons, 29 unique MCP operations, unchanged fixture digest, preserved collision controls and zero residual runtimes.
  • Commit and push hooks — passed without bypasses.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; omitted and null metadata remain valid without fabricated defaults.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra on Windows x86/x64 PE fixtures; CLI/MCP parity on the x86 fixture. Hopper and Linux/macOS engine runs were not performed.
  • Package or release metadata impact: none. The real Windows runs used the matching official published 6.3.0 native addon; no addon rebuild or tarball installation was tested.
  • Security, privacy, process, or containment review: source-owned fixtures are inspected statically; existing NTFS admission, protected DACL and Job Object controls passed. No new execution or mutation authority.
  • Remaining proof gaps: full deterministic suite is left to CI; this does not complete all of feat(native): preserve access kind and inference provenance in compact xrefs #1245.

Review checklist

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Independent maintenance integration is now on this existing PR as edb4c63adf9c3082c0efef65b6e060ec1203e09d (normal merge of main 4e3d3354, preserving the contributor commit/history).

Resolved the Windows fixture-generator conflict by retaining both sets of controls. Actual generation proves x86/x64 EXE bytes (1,536 each) are identical to the original PR, and x86/x64 DLL bytes (1,024 each) are identical to main. Production target classification verifies all four PE architectures, application/shared-library roles, managed=false, input SHA-256 and unchanged bytes. DLL verification now explicitly omits the EXE-layout-specific compact-reference proof (null), while keeping its existing exported-caller/return controls; applying the new EXE offsets to DLL export data would otherwise fail after integration.

Validation on the integrated source, pinned Linux Node 24.18.0 and the documented two-CPU/process-family guard:

  • 73 exact provider/value-trace/MCP/schema/presentation tests pass. The ignored catalog was freshly generated through the SDK; the two catalog-consuming suites were rerun after their initial missing-artifact setup failure.
  • Full serial compile/typecheck, lint, unchanged duplication gate, complete generated-document checks and formatting pass.
  • Actual compiled public CLI and production SDK stdio MCP analyze a source-owned 74-byte JavaScript target with identical Evidence, text/structured parity, unchanged source digest and successful ping. The actual advertised native output schemas retain the new metadata fields. This verifies public adapter/catalog integration; it is not a real Ghidra-reference claim.

The bridge/reference-schema change and the EXE bytes remain as reviewed in the original PR. Your actual Windows Ghidra/CLI/MCP proof remains attributed contributor evidence. No local Ghidra installation or Windows channel is available here, and no Ghidra/JDK was installed. Please repeat one source-owned x86 or x64 EXE compact-reference probe on this integrated head with the existing matching toolchain, report the head/settings/unchanged input hash/cleanup, and keep DLL-specific proof distinct. A full Obsidian/Notion or additional provider matrix is unnecessary for this increment.

Waiting for fresh CI/review on this exact head; no reviewers requested. The broader #1245 scope remains open.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

The current integration head is now 30473dbcacd9dd404b8ecb65aa487caf57ab0682, a normal merge of main 9defed97 preserving the original contributor history. Fresh CI is run 38035498870; only this current head was approved.

The previous CI's Linux shard and Windows lane failures came from main #1480's archive-case tests, not the compact-reference producer. I reproduced the failing control at cbcba290 and independently ran the 16 corrected controls at 9defed97. Main b12d0c63 already restores exact-spelling logical archive coverage and observes the actual destination filesystem before expecting extraction success or a named collision with rollback. Those fixes are now included here; no failed check was dismissed or merely retried.

On this current integration, 89 provider/native-value/compact-reference/SDK-schema/archive controls plus seven JADX cleanup controls pass. Full serial compile/typecheck, lint, unchanged duplication gate, complete generated-document checks and changed-file formatting pass. The newly compiled public CLI and SDK stdio MCP small-target proof also passes, retaining native metadata fields, unchanged source hash, text/structured parity, Evidence consistency and ping. This remains public adapter/catalog verification, not independent real Ghidra evidence.

The earlier request for one actual Windows Ghidra tiny-EXE recheck applies to this current head. Bridge/reference source and the previously byte-verified EXE controls remain unchanged; another provider/application matrix is unnecessary. Waiting for the fresh current-head CI and that attributed real-provider result before merge. Broader #1245 remains open.

@morluto
morluto merged commit 24d9337 into morluto:main Oct 10, 2026
19 checks passed
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
@morluto

morluto commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thanks @JosephDemarest for preserving compact-reference provenance through native analysis! Squash merged. Welcome to REA, and thank you for your first PR to the repo.

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants