Skip to content

feat(providers): retain native selection provenance in Evidence - #9668

Merged
vincentkoc merged 67 commits into
morluto:mainfrom
2SinceJuly:feat/9137-session-provider-provenance
Nov 26, 2026
Merged

vincentkoc merged 67 commits into
morluto:mainfrom
2SinceJuly:feat/9137-session-provider-provenance

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Native analysis Evidence now records why Hopper, Ghidra, IDA, or Kuna was selected: the request/environment/automatic source, evaluated candidates, availability, target support, and rejection codes. This follows the first implementation scope in #9133 and the provenance request in #9137; both parent issues are already closed.

Behavior and scope

  • Capture selection from the exact native dispatch, including noncacheable results. Match stable provider identity and analysis profile; leave unknown versions unknown.
  • Retain historical selection, including its absence, through snapshot replay and bundle import. A later active provider does not rewrite the source's provenance.
  • Keep selection outside the top-level Evidence semantic ID. Reconcile supplied metadata for duplicate native observations through the ledger's existing admission and snapshot ownership.
  • Derived views retain links to their native sources. Android, browser, managed, artifact, capture, generic records, and nested Evidence payloads are not relabeled.
  • Add the optional provider_selection contract, schema summaries, and CLI reference. No new tool, provider, target execution, installation, or mutation authority.

Example native metadata: provider_selection.selection_source = "request", with Ghidra marked selected, available, supported, and with no rejection codes. Derived summaries and older unannotated records omit this field.

Validation

  • Exact candidate: ff01a11498c42ff10c36ad66c0c4108065e4004d.
  • Full-candidate P2 review and scoped reviews of the corrective changes completed; all reported findings are addressed. Main e99d0b2d86431c3b20b662c3d706fb5c932079a5 is integrated, with the independent schema-input/output conflict separately reviewed.
  • The full source suite, static checks, docs, build, and advertised-schema client/engine validation passed on this head. All 246 changed files pass the pinned formatter.
  • Real Ghidra 12.2 validation passed, covering fresh/partial/analyzed projects, exported native records, historical absence, derived links, replay, and active-selection import. That job checked generated merge 7a3de8dd74994e6dad5954b4006105e9e27a846d, containing this PR head.
  • Complete CI run and current required-check status.
  • Regression coverage includes native dispatch, name resolution, shared limitations, historical replay/absence, metadata-copy headroom, and completed mutation recovery or explicit omission.
  • Local dependency-backed tests and local real-provider execution were not run; the runtime evidence above is from hosted CI.

Author readiness

Human owner: @2SinceJuly

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

…idence

The registry records how a deep provider became selected and why every other candidate was rejected, and binary_session exposes those facts for the active route. Evidence already carried provider identity, but nothing recorded which candidates the session evaluated, so a retained record could not explain why this engine produced the observation or what the alternatives were.

Attach provider_selection to Evidence admitted by the session: the selection source and, for each evaluated candidate, its identity and version, selection state, availability and target-support outcome, and the stable rejection codes. The field is optional and excluded from semantic identity, following caller_input_path, so each admitted record stays attributable to the exact provider instance without changing observation identity, evidence IDs or replay.

Copy only stable selection facts. Candidate diagnostics, remediation prose and target content stay in the session status projection instead of being repeated in every record.
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T16:39:49.654886Z
We couldn’t complete this review. Comment @codex review to try again.
ff01a11 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46318fde74

ℹ️ 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".

Comment thread src/domain/evidence.ts Resolved
Comment thread src/application/binary/BinarySession.ts Resolved
oxfmt --check rejected the three-line expect() call; the formatter's
single-line layout is the canonical one, so Static checks failed only
on formatting.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Merged origin/main (a8aa55f3b) and fixed the one remaining Static checks failure (182a5c47e): oxfmt wanted the provider-selection assertion on a single line.

Verified locally after the merge: node scripts/check-doc-facts.mjs passes (the docs/readme/README_bg.md drift came from the pre-merge base), oxfmt --check is clean, and src/domain/evidence.test.ts passes (42 tests).

Note: origin/main at e9b6c87c1 still fails to compile — src/cli/adbCommands.ts redeclares const packageName (TS2451). I patched it only locally to build and restored it; this branch does not touch it. #9677/#9678 fix that upstream.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 182a5c47e6

ℹ️ 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".

`recordEvidence` ran `withEvidenceProviderSelection` before handing the record
to the ledger. That helper parses to seal the rebound envelope, so a tampered or
otherwise invalid record threw a `ZodError` from the attribution step and never
reached `EvidenceLedger.record`, which is where the declared `Result` is
produced. `tests/boundary/mcp/processEvidenceIdentityMcp.test.ts:454` asserts
`session.recordEvidence(tampered).ok === false` and fails on the throw.

Authenticate the input first and return the ledger's own rejection for a value
it would refuse anyway; attribution then only ever sees a record its reader
accepts.
Import replaces a same-ID record's presentation metadata, and
provider_selection is part of that metadata. When runDirectAnalysis imports
the provider's own bundle, the copy it rebuilds carries no selection, so the
import erased the attribution the session had stamped and the caller kept an
unattributed record instead. Attribute at both merge sites, where the session
already authenticates everything it admits.

A refreshed route after a failed switch can bind a different selection than
the one the earlier binding held, so re-derive it there as the initial open
does; spreading the previous binding kept the stale value.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d001fc0d5b

ℹ️ 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".

recordEvidence and the two bundle import paths seal Evidence through
withEvidenceProviderSelection before handing it to the ledger. A sealed
value skips the ledger's ordinary-JSON and heap-headroom admission, so a
session with no authentication allowance accepted a mutable record and a
large record was copied and traversed before the guard ran.

Hold the caller's own value to that admission first, then attribute. The
import paths also refuse with a Result instead of falling through to an
unattributed import when admission fails.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6570fe022a

ℹ️ 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".

recordEvidence now admits the caller's value before attributing it, but a
record returned by evidenceForAnalysis has already been through that
admission and is sealed. Running the ordinary-JSON walk and the
heap-headroom check over it again repeats the work the ledger itself
skips for a sealed value.

Ask the ledger first: a value it holds is the admission it made, so the
check costs one lookup. Only a value the ledger has not seen pays for the
full walk.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b0a708b5f

ℹ️ 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".

@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Merged origin/main in 73f9fa8. The failing checks on the previous head were main-side fallout, not this branch: Documentation reported desktop-build-witness.html: missing rendered anchor ./desktop-application-tasks.html#readers, and Source tests / Portable tests compared against stale src/domain/desktop/appTaskReaders.test.ts and environmentBuildCli.test.ts expectations. #9763 ("fix(ci): restore main workflows and captured-state replay") repaired all of them on main, so the failing assertions now describe the fixed state.

CI has not re-run on this head yet.

Import re-stamps session provenance onto the Evidence it records, but callers kept the pre-import copy, so retained selection attribution and cache metadata were dropped from what analysis reported. Read the recorded record back after a successful import, and leave an already-retained record as the ledger attributed it instead of re-deriving attribution from the caller's copy.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5989df5ac

ℹ️ 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 record

The merge with main brought in the unchanged-record path, where an import whose only change is display metadata now replaces the ledger's record. Re-attributing that incoming value put the session's provider selection on the caller's copy, so the import reported a record that differed from what the caller sent. Attribution now applies only to records the ledger does not already hold.

The snapshot cache test now asserts the session's attribution explicitly instead of byte equality with the un-attributed source.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fac647f1f5

ℹ️ 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".

…ed one

The previous change skipped attribution for a record the ledger already held, which left the imported copy's own selection — missing or from another session — in place. Import replaces a same-ID record's presentation metadata, and provider_selection is part of it, so the session's attribution wins over the caller's copy while the caller's other display metadata is kept untouched.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a47748ac17

ℹ️ 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".

Address the open review findings on session provider provenance:

- importAnalysisSnapshot merged the re-attributed bundle into the ledger but
  staged the snapshot's own bundle, so AnalysisSnapshotCache rebuilt replay
  bindings from records the merge had replaced. Hand the merged bundle back
  to the stage so replays bind to the attributed evidence.
- recordResult recorded an attributed record and then serialized the
  caller's copy, so successful MCP responses omitted provider_selection
  while the ledger and exports carried it. Read the recorded Evidence back
  before delivery, as the direct analysis path already does.
- recordUnknown and updateUnknown synthesized unknown-mutation Evidence
  without the active session's provider selection, so those exported
  records were unattributed. Thread the binding's selection through to
  unknownMutationEvidence, which is where the record is produced.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eeca98bb2b

ℹ️ 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".

…cord

recordEvidenceWithUnknown synthesizes its own rea.residual-unknown-mutation record, so the selection the session threads into recordUnknown and updateUnknown never reached it. The atomic comparison workflows therefore exported one record without provider_selection, contradicting the guarantee that every admitted record carries the recording session's selection. Thread the active binding through the atomic method as well; analyst-authored mutation records still keep analyst-inference authority and gain only the session selection.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 679fbe2cbe

ℹ️ 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".

Comment thread src/domain/evidence.ts Resolved
@vincentkoc

Copy link
Copy Markdown
Collaborator

The parent scope in #9133 is native-provider provenance. I’m narrowing the repair to fresh native observations; imports retain their history, and derived or artifact results keep their source links without being relabelled. This removes the broad writer changes behind several review findings.

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

Comment thread src/domain/evidence.ts Resolved
@vincentkoc vincentkoc changed the title feat(providers): retain provider selection provenance with session evidence feat(providers): retain native selection provenance in Evidence Nov 26, 2026
@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.

Comment thread src/application/binary/BinarySession.ts Resolved
@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.

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

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

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

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

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

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

@vincentkoc
vincentkoc merged commit 2bb086c into morluto:main Nov 26, 2026
55 of 56 checks passed
@vincentkoc

Copy link
Copy Markdown
Collaborator

Thanks @2SinceJuly! Landed in 2bb086c. The native-only implementation, recovery cases, full CI, and real Ghidra validation are complete.

reynold-hu added a commit to reynold-hu/rea that referenced this pull request Nov 27, 2026
…n re-merge

Main's morluto#9668 added the optional provider_selection provenance field to
the shared Evidence envelope, so every tool's output compact schema
changed; this branch's summary predates the re-merge to 0f5ab1e and
went stale. The tool's own output (normalized_result) is unchanged:
the compact schema gains only the optional provider_selection property,
pruned to a bare object by the compact budget.

Signed-off-by: Reynold Hu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants