Skip to content

refactor(native): parse native inventory results once at the operation port - #10880

Merged
morluto merged 1 commit into
mainfrom
refactor/native-operation-fact-port
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/native-operation-fact-port

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

First implementation step of the accepted ADR docs/adr/native/typed-operation-facts.md (#10866): named provider-neutral contracts for the five native inventory operations and one port-level executeFact that runs an operation through any AnalysisOperationPort and parses its result once. Readers migrate in the stacked PRs that follow. Plan W13 step 1 follow-up.

Problem and expected behavior

  • Four readers (EnhancedLiteralTracing, NativeDispatchMetadataInspection, functionInventory, nativeInventoryView) re-parse AnalysisExecution.result with their own schemas and failure policies.
  • Expected: one named contract per operation with an exact fact type, one parse and one failure policy (AnalysisOutputError with field diagnostics and the observed execution as partial Evidence), and Evidence keeping the provider's source value.

Change and scope

  • src/domain/native/nativeOperationFacts.ts: NativeOperationFactContract<Operation, Fact> and the contracts listNamesFact, listProceduresFact, searchProceduresFact, listStringsFact, searchStringsFact, built from nativeInventoryRowsSchemas (lenient rows: unknown fields dropped from the fact).
  • src/application/AnalysisOperationFacts.ts: executeFact(port, contract, parameters, options) returns { execution, fact }. It calls the given port's own execute, so wrapping ports (WorkflowEvidence, admission, managed wrappers) observe the call unchanged; the execution's result stays the source value.
  • ADR: names the module that owns executeFact.

Not included: reader migrations (stacked: nativeInventoryView, functionInventory, NativeDispatchMetadataInspection, EnhancedLiteralTracing), and a guard against new local re-parses, which lands with the last reader. Hopper's and Ghidra's reply checks are intentionally kept (ADR decision 6).

Contribution scope: not applicable (internal refactor within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the domain contracts own the fact schema; executeFact owns the parse and failure policy at the application port. No consumer changes in this PR.
  • Contribution scope fit and linked maintainer decision: ADR docs(adr): accept parsing native operation facts once at the operation port #10866 (accepted).
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged; the failure path retains the observed execution as partial Evidence with the source value.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/application/AnalysisOperationFacts.test.ts: each contract parses once through the port's execute, drops an unknown row field from the fact while the execution keeps it; a malformed row is refused with contract_issues ([0, "address"], expected string, received number) and the observed execution as partial Evidence; a port failure is returned unchanged.
  • Base reproduction or other evidence: source-derived (reader schemas listed in the ADR).
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: no consumer uses executeFact yet; the reader PRs carry the workflow coverage.

For evidence-bearing changes:

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

Validation performed

  • npm run test:local -- src/application/AnalysisOperationFacts.test.ts — 7 passed
  • npm run check:fast — passed
  • npx knip --include exports,types,files — no findings
  • npx oxfmt on changed files; pre-commit and pre-push hooks passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: not applicable.

Author readiness

Human owner:

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

Before merge

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T08:51:33.640958Z 5e5f9f4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge; no blocking issues were found.

Summary

Adds five named native inventory contracts and executeFact, which returns typed rows while keeping the provider’s source value.

  • Native inventory results have five named fact contracts.
  • Native inventory calls can return a typed fact with their execution.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Caller] --> B[executeFact]
  B --> C[Supplied port.execute]
  C --> D{Port succeeds?}
  D -->|No| E[Return original failure]
  D -->|Yes| F[Parse result with named contract]
  F --> G{Rows match?}
  G -->|Yes| H[Return original execution and typed fact]
  G -->|No| I[AnalysisOutputError with partial Evidence]
Loading

Reviews (2) · Last reviewed commit: "refactor(native): parse native inventory..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/native-operation-fact-port branch from 0615298 to 5e5f9f4 Compare November 15, 2026 08:49
@morluto
morluto merged commit 66d1527 into main Nov 15, 2026
12 checks passed
@morluto
morluto deleted the refactor/native-operation-fact-port branch November 15, 2026 08:59
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 22, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant