Skip to content

feat(evidence)!: name the Evidence subject by its target identity (format revision 2) - #11416

Merged
morluto merged 15 commits into
mainfrom
feat/evidence-subject-target-identity
Nov 15, 2026
Merged

morluto merged 15 commits into
mainfrom
feat/evidence-subject-target-identity

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #11417 (remaining slices), #10510.

Slice 2a of the accepted target identity decision (docs/adr/evidence/target-identity.md). The Evidence subject now carries its target identity, subject.identity (kind: "file", sha256, format, architecture, selection), and the Evidence ID commits to that identity instead of the subject's digest, format and architecture. This is Evidence format revision 2: every record also carries evidence_format: 2, and revision 1 bundles, records and snapshots are refused with the recreate guidance. Breaking: every Evidence ID changes.

Problem and expected behavior

  • Two raw-binary (or DOL) observations of the same bytes at different entry points shared an Evidence subject identity, unless the operation happened to echo the entry point into parameters. The same was true for ESP flash images read at different flash offsets. The snapshot target already kept them apart, so the two identities disagreed.
  • A standalone Evidence record did not declare its format. Only bundles were refused as one format decision, so an earlier standalone record was either admitted or failed field by field.

Expected: one projection of an open target into its identity, used by Evidence and snapshot comparison. Two observations that differ only in their selection are different subjects. Every record names the format revision it was written in.

Change and scope

  • src/domain/targetIdentity.ts: fileTargetIdentitySchema and fileTargetSelectionSchema (the persisted forms), and binaryTargetIdentity / binaryTargetSelection, the single projection of a BinaryTarget (raw/DOL entry point, ESP flash offsets). snapshotMatchesTarget now compares against this projection instead of round-tripping through snapshotTarget.
  • src/domain/evidenceFormat.ts: EVIDENCE_FORMAT_REVISION = 2, with a revision note that names the subject change. admitEvidenceRecordFormat refuses a standalone record from another format with the same single decision as a bundle. admitEvidenceBundleFormat also checks each record a current bundle carries.
  • src/domain/evidence.ts:
    • The subject schema gains identity. The existing digest, format and architecture members stay, refined to agree with the identity, so current readers keep compiling. Later slices remove them (see the plan below).
    • A selection must fit the format: entry points for raw/DOL, flash offsets for ESP flash images.
    • evidenceSemanticContent commits subject.identity.
    • evidenceSubject(target) is the one builder of a persisted subject.
    • EvidenceSubjectTarget gains an optional selection, which evidenceSubjectTarget round-trips.
    • Rebinding compares identities through sameTargetIdentity. The local sameEvidenceSubjectTargetIdentity is deleted.
    • Accessors for the reader migration: evidenceTargetIdentity, evidenceFileTarget, evidenceSubjectDisplay.
    • Deleted: evidenceSubjectIdentity, and the pre-6.6 null-coverage diagnosis. Records without evidence_format are now refused before their ID is checked, so the diagnosis can no longer be reached.
  • BinarySessionExecution.bindExecutionTarget records the target's selection. Snapshot replay restores the selection from the matched target: the query ID already commits to it, and snapshot subjects do not persist it yet (slice 2d).
  • evidenceBundle.ts: when a refused bundle is a standalone record from an earlier format, the bundle-schema message (which carries the recreate guidance) is kept instead of an unexpected throw.
  • Regenerated: the two published analysis-view examples (source Evidence ID, parent digest and view digest), and the advertised schema summaries (the Evidence output schema is in every tool).
  • Docs: mcp-contracts.md describes revision 2 and subject.identity. The ESP, IL2CPP and process-capture guides no longer promise that earlier standalone records stay readable. The ledger example uses revision 2.
  • Not included (later slices, each green on its own):
    • (b) migrate the 85 source and 107 test files that read subject.digest|format|architecture|name|local_path to the accessors, family by family, behind a shrinking guard;
    • (c) url/process/session/unknown kinds, a non-null subject for the 50 subject-less sites, and removal of MISSING_EVIDENCE_SUBJECT_LIMITATION;
    • (d) persisted snapshot targets and execution subjects become the identity, plus universal-slice selection for universal Mach-O;
    • (e) drop the duplicated digest/format/architecture subject members and the bundle artifact manifest's copy.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/targetIdentity.ts (projection of a target into its identity) and src/domain/evidence.ts (subject builder and ID commitment); src/domain/evidenceFormat.ts owns the revision. Superseded and deleted: evidenceSubjectIdentity, sameEvidenceSubjectTargetIdentity, the null-coverage legacy diagnosis.
  • Contribution scope fit and linked maintainer decision: ADR docs/adr/evidence/target-identity.md, Accepted 2026-11-15 (docs(adr): accept the target identity decision #11340), slice 2.
  • CLI and MCP/tool-catalog contract: every Evidence output gains evidence_format and subject.identity; the advertised schema summaries are updated.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: every Evidence ID changes. Raw/DOL entry points and ESP flash offsets are now part of the subject identity. Revision 1 Evidence (bundles, records, snapshots) is refused with the recreate guidance.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: advertised schema summaries only.

Expected effects:

  • 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/domain/evidence.test.ts: two raw targets at different entry points get different Evidence IDs, and the identity carries the selection. A display-only rebind keeps the ID, and a different selection is not rebound. A forged identity (digest disagreement, or a selection that does not fit the format) is refused. A pre-revision record is refused with the recreate guidance.
    • src/domain/evidenceFormat.test.ts: an unmarked or revision 1 record is refused, both alone and inside a current bundle (evidence-record, evidence_format).
    • tests/boundary/cli/evidenceBundleCommands.test.ts: CLI and MCP import of a current bundle carrying a pre-revision record report evidence_integrity_mismatch with the recreate guidance (previously the null-coverage diagnosis).
    • nativeArchitectureIdentity.test.ts now tampers with both architecture members, so it still reaches the ID check. Fixtures in evidenceSubject.test.ts and three analysis-view tests build subjects with evidenceSubject. Two CLI tests use EVIDENCE_FORMAT_REVISION instead of a literal 1.
  • Base reproduction or other evidence: source-derived. On the base, evidenceSubjectIdentity omitted the entry point, so two raw targets that differed only in entry point and returned the same result had equal IDs.
  • Remaining proof gaps: no real-provider run. Universal Mach-O slices still share a subject until slice 2d.

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 check:fast: passed (typecheck, lint, architecture guards across 2813 files)

  • npx oxfmt --check .: passed

  • npm run docs:check: passed

  • npm run verify:advertised-schemas -- --update-summary: passed. Rust jsonschema engines are not installed locally ("not verified").

  • npm run test:focused --: 113 files selected for Evidence IDs, subject fixtures, format markers, snapshots and the published examples, in three batches. Final runs passed after fixing the published example digests and the null-coverage test.

  • npm run test:focused --: 172 further files that build subjects, bundles or snapshots, in four batches. All passed after the evidenceBundleFiles and nativeArchitectureIdentity fixes, which were rerun alone.

  • Review fixes (55eaa21), each regression shown failing on the unfixed code first:

    • The shared Evidence readers return the format refusal as a Result. All consumers map it to one integrity refusal with the recreate guidance.
    • Inventory roots and provider subjects that name the target's bytes carry its ESP selection.
    • Snapshot rows bind only Evidence whose identity, selection included, matches the header.
    • Entry-point selections use rawBinaryEntryPointSchema.
    • An unmarked object counts as an earlier record only when it has every member records have always carried, so malformed records still report schema issues.
    • Tests: 4 regression files, 76 passed. 72 sibling files (artifact, ESP, process, environment, snapshot) and the 113 targeted files passed.
  • briefs/local-gate.sh 11416 on 559077f passed (60 affected files, 1124 passed).

  • Review follow-up (3dc4323): recognizeEvidence replaces tryParseEvidence. A partial observation that names an evidence_id but fails authentication or the format check is now a refusal, not "no Evidence". The flutter, debugger and release-exposure recoveries use the authenticated owner. An earlier-format desktop capture.json is refused with the recreate guidance; that regression failed on the unfixed reader. 37 affected test files passed (606 tests). npm run check:fast, npx oxfmt --check . and the architecture guards passed.

  • Base fix (189081e), found while validating the stacked refactor(native): compare function snapshots by their Evidence target identity #11450:

    • The build_reconstruction_obligation_ledger and reconstruction coverage examples still named evidence_format: 1. They now use EVIDENCE_FORMAT_REVISION.
    • MCP delivery ranked the unretained recoveries to omit by a parsed-storage estimate clipped at the response budget. Once the revision 2 source record crossed the clip, it tied with the larger completed observation and was omitted first (sourcePublicationComposed.test.ts). Delivery now ranks by serialized size.
    • Both toolSchemaValidity.test.ts cases and the composed-publication test failed on 55eaa21 and pass now. 74 delivery/contract files passed (884 tests) and 56 example-bearing CLI/MCP boundary files passed (1492 tests). check:fast, oxfmt --check . and verify:advertised-schemas (summary unchanged) passed.

Carried from #11423 (collapsed into this PR, not breaking)

Slice 2b, first family. Analysis views (19 files in src/domain/analysisView/) read their parent's subject through evidenceFileTarget / evidenceSubjectTarget / evidenceSubjectDisplay instead of the duplicated digest/format/architecture members. A counted guard, evidence-subject-declaration-read (baseline in scripts/verify/baselines/, shrink-only), keeps new direct reads out. tests/fixtures/evidenceSubject.ts changedEvidenceSubject lets tests change a subject's declaration together with its identity. Validation: all 80 analysis-view test files passed (1746 tests).

Carried from #11450 and #11461 (collapsed into this PR, not breaking)

  • refactor(native): compare function snapshots by their Evidence target identity #11450, native function family: function snapshots carry target: FileTargetIdentity. build_call_path refuses functions from the same bytes opened at different selections, and compare_functions matches entries by address only within one target (sameTargetIdentity). Regressions in callPath.test.ts and functionComparison.test.ts failed on the unfixed readers.
  • refactor(artifacts): compare artifact and WASM summaries by their Evidence target identity #11461, artifact and WASM comparison family: summary-to-inventory authentication compares target identities and rebinds the alias with its selection. A flash-selected inventory summary under an alias path is no longer refused; that regression failed on the unfixed reader. WASM comparison, the analysis view artifact and the inventory root check read through the accessors.
  • Delivery ranking (review thread): unretained recoveries are ranked by errorTextWireBytes, the encoder's escaped UTF-8 measure.
  • Guard baseline evidence-subject-declaration-read: 12 files / 26 reads remain.

Carried from #11536 (slice 2c, collapsed into this PR, breaking)

  • Every Evidence subject is present: a file identity, or { kind: "unknown", reason } with null display facts. MISSING_EVIDENCE_SUBJECT_LIMITATION and subjectUnavailableReason are deleted; producer explanations are ordinary limitations. gdb, Rizin and Cutter use not-observed until their slice-3 session identities.
  • JavaScript callers that are not type-checked pass unknownTarget("not-observed"); follow-up [Design] Type-check the JavaScript verification scripts that import domain modules #11545 proposes type-checking them.
  • The managed application graph takes the first input subject that names a file.
  • Test guards that checked a subject for null now check its kind, or are removed where a file-only helper already requires it.
  • After the collapse: two boundary tests still matched subject.format from before slice 2e; they now match subject.identity.format (3e040c6). npm run test:focused -- tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts: 7 passed (the signature test failed before on macOS).

Compatibility, safety, and release

  • Breaking changes or migration steps: every Evidence ID changes, and every record carries evidence_format: 2 and subject.identity. Evidence bundles, standalone records and analysis snapshots written by earlier releases are refused as evidence_integrity_mismatch. Migration: recreate the observations with this release; re-exporting an earlier bundle does not update its format or identities. Stored Evidence is not migrated, because an Evidence ID is a content commitment (ADR decision 5).
  • Release hold (decided): releases are held from this PR until slice 2e lands ([Design] Finish the target identity ADR: reader migration, explicit subjects, snapshot identity, slice 3 identities #11417). Slices 2c and 2d change revision 2 IDs or shapes again without bumping evidence_format.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: identities are path-free. local_path and name remain display facts outside the ID.

BREAKING CHANGE: Evidence format revision 2. Evidence IDs commit to the subject's target identity (subject.identity, including the raw/DOL entry point or ESP flash offsets), and every record declares evidence_format: 2. Evidence bundles, records and analysis snapshots from earlier releases are refused; recreate the observations with this release.

BREAKING CHANGE (from #11497, folded into this PR): the Evidence subject no longer has digest, format or architecture; read subject.identity.sha256, subject.identity.format and subject.identity.architecture. A record that still carries them is refused.

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.

BREAKING CHANGE (from #11536, folded into this PR): every Evidence record has a subject. A record without a file target names subject.identity { "kind": "unknown", "reason": "derived-from-linked-evidence" | "not-observed" | "unsupported-subject" } with name and local_path null, instead of subject: null and the limitation "Artifact identity is unavailable for this observation.". Their Evidence IDs change.

BREAKING CHANGE (from stacked #11551, once folded into this PR): analysis snapshot files change shape: target is { kind, identity: { kind: "file", sha256, format, architecture, selection } } and entry execution.subject is the Evidence subject ({ identity, name, local_path }, never null). Snapshot binding-mismatch details report target.snapshot/target.selected in the same shape. Evidence IDs of universal Mach-O targets change because their subject identity now carries the selected slice (universal-slice: offset, size, cpu_type, cpu_subtype). Recreate saved snapshots and Evidence bundles of universal Mach-O targets.

…rmat revision 2)

The Evidence subject carries subject.identity (kind, sha256, format,
architecture, selection) and the Evidence ID commits to it, so raw/DOL
entry points and ESP flash offsets of the same bytes are different
subjects. Every record declares evidence_format: 2; revision 1 bundles,
standalone records and snapshots are refused with the recreate guidance.
binaryTargetIdentity is the one projection of an open target, used by
Evidence and snapshot comparison.

BREAKING CHANGE: Evidence format revision 2. Evidence IDs commit to the
subject's target identity (subject.identity, including the raw/DOL entry
point or ESP flash offsets), and every record declares evidence_format: 2.
Evidence bundles, records and analysis snapshots from earlier releases are
refused; recreate the observations with this release.
@chatgpt-codex-connector

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-15T19:34:32.392877Z
We couldn’t complete this review. Comment @codex review to try again.
559077f PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The reviewed follow-up appears safe to merge under the stated release hold.

Summary

Evidence revision 2 commits each record to subject.identity, including target selection. Records now declare evidence_format, and unknown subjects carry an explicit reason.

  • Evidence IDs now distinguish files opened with different selections.
  • Evidence readers now require format revision 2.
  • Evidence records without a file target now name why it is unknown.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  T[Selected target] --> I[Target identity and selection]
  I --> S[Evidence subject]
  U[Explicit unknown reason] --> S
  S --> H[Evidence ID]
  R[Record or bundle] --> F{Format revision 2?}
  F -->|No| X[Refuse with recreate guidance]
  F -->|Yes| A[Check shape and Evidence ID]
Loading

Reviews (11) · Last reviewed commit: "test(evidence): expect the Evidence subj..." · Reviewed by Greptile

Comment thread src/domain/evidence.ts Resolved
Comment thread src/domain/targetIdentity.ts Resolved
…entity accessors (#11423)

Analysis views compare their parent's file identity (evidenceFileTarget)
and take path and digest from evidenceSubjectTarget instead of reading
the subject's digest, format and architecture members, which duplicate
subject.identity until they are removed. A counted guard
(evidence-subject-declaration-read) keeps new direct reads out and
records the 20 remaining files.
…d target selections

- safeParseEvidence/safeParseImmutableEvidence return the format refusal as
  an expected failure; every consumer maps it to the one integrity refusal
  with the recreate guidance. An unmarked object is an earlier record only
  when it has every member records have always carried.
- ArtifactProvider inventory roots and provider subjects that name the
  target's own bytes carry the target's selection (ESP flash offsets).
- Snapshot rows bind only Evidence whose identity, selection included,
  matches the snapshot target.
- Entry-point selections use the raw-binary entry point form.
…ad of reading them as absent

- recognizeEvidence (evidenceValidation) replaces tryParseEvidence: input
  without an evidence_id is not Evidence (ok(undefined)); a record that names
  one but fails authentication or is from another format revision is an
  EvidenceIntegrityError carrying the recreate guidance, never undefined.
- Direct analysis retains that refusal as a secondary failure instead of
  silently skipping source capture; cleanup projection, source-closure
  annotation and the flutter, debugger and release-exposure recoveries use
  the same owner (the last three previously read the unauthenticated schema).
- A desktop capture.json from an earlier format is refused with the recreate
  guidance instead of "not desktop application capture Evidence".
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Follow-up on the 4/5 summary ("finish preserving older-format refusals in the remaining readers"), fixed in 3dc4323.

Root cause. tryParseEvidence owned the "is this partial observation Evidence?" decision and returned undefined for any record that named an evidence_id but failed authentication or the format check, so its callers could not tell "not Evidence" from "Evidence we refuse". Three sibling readers (flutterCommands, reverseEngineeringCommands, ReleaseExposureService) bypassed it with the unauthenticated evidenceSchema.safeParse. One persisted reader, DesktopApplicationState (capture.json), mapped an earlier-format record to "not desktop application capture Evidence".

Fix at the owner. recognizeEvidence in evidenceValidation.ts replaces tryParseEvidence and returns Result<Evidence | undefined, EvidenceIntegrityError>. Input without evidence_id gives ok(undefined). A record with one that fails authentication or the revision check gives the integrity refusal, which carries RECREATE_EVIDENCE_GUIDANCE through the shared integrityFailure mapping.

  • DirectAnalysis: retains the refusal as a secondary failure instead of silently skipping source capture.
  • DirectAnalysisCleanup, AnalysisEvidenceSources: the failure that carries the record is projected unchanged. The existing undeliveredSourceClosure.test.ts contract still holds: an unauthenticated record selects no sources.
  • flutterCommands, reverseEngineeringCommands, ReleaseExposureService: now use the authenticated owner. On refusal the original error stands.
  • DesktopApplicationState: an earlier-format capture.json gets the recreate refusal.

Readers checked that already refuse explicitly: readEvidence/readImmutableEvidence (functionDossierEvidence, staticRuntimeCorrelation, changedBehavior, managed inspection/native verification, JavaScriptApplicationEvidenceGraph, NativeMatchingSources, NativeMatchingBundleSources, ArtifactComparisonEvidence, StaticObservedEndpointComparisonService, artifactInventoryEvidence), plus AnalysisViewService, evidenceFileSource, environmentSource, javascriptRuntimeReconciliationInputValidation, ProcessCli/ProcessEvidence, WasmInterfaceComparisonService (input error with the refusal message), EvidenceBundleFiles/evidenceBundle (bundle and carried records), and AnalysisSnapshotFiles.

In-process only, no change: ToolResultDelivery (the partial falls back to the error result), sourcePublicationRecovery (reports primary-authentication-failed), and the EvidenceLedger record paths, whose inputs are already-parsed Evidence. Bundle import admits the format first.

Validation. New tests: recognizeEvidence with an unmarked record, a revision-1 record, a tampered record, a non-Evidence object and undefined (evidenceFormat.test.ts). An earlier-format desktop capture is refused with the guidance; this test failed on the unfixed reader. 37 affected test files pass (606 tests). check:fast, oxfmt --check . and the architecture guards pass.

@greptileai review

… omissions by serialized size

- The obligation ledger and reconstruction coverage examples named
  evidence_format 1, which revision 2 refuses; they now use
  EVIDENCE_FORMAT_REVISION.
- MCP delivery chose which unretained recovery to omit by a parsed-storage
  lower bound clipped at the response budget. Once revision 2 subjects made
  the source record's estimate cross the budget, both candidates tied at the
  clip and the smaller source was omitted ahead of the larger completed
  observation. Candidates are now ranked by serialized size, which is what
  the budget counts.
… identity (#11450)

Function snapshots carry the subject's file target identity instead of the
duplicated subject declaration. Call paths and function comparisons compare
targets through sameTargetIdentity, so the same bytes opened at a different
raw entry point or ESP flash offset no longer count as one coordinate space:
build_call_path refuses the mix, and compare_functions no longer matches
entries by address across selections. Structural candidates and native
function matching read the architecture and digest through
evidenceFileTarget.

Refs #11417
Comment thread src/server/ToolResultDelivery.ts Resolved
…dence target identity (#11461)

Artifact comparison authenticates a summary against its retained inventory
through sameTargetIdentity and rebinds the alias with the whole target,
selection included, so a flash-selected inventory summary taken under an
alias path is no longer refused. WASM comparison, the analysis view
artifact projection and the inventory root check read the digest, format
and display path through the Evidence identity accessors.

Refs #11417
…-target-identity

# Conflicts:
#	src/application/desktop/DesktopApplicationState.test.ts
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — latest head d3711de (main merged; delivery ranking now uses the encoder's errorTextWireBytes per the resolved thread).

…rs in JS, managed, ledger and bundle readers (#11470)

JavaScript application graphs, runtime reconciliation, managed inspection
and native verification sources, the record summary filter, the ledger's
residual-unknown target and bundle scope selection read the subject digest,
format and display path through evidenceFileTarget and
evidenceSubjectDisplay. No comparison changes: each reader matches one
record's facts against its own payload or a caller filter.

Refs #11417
# Conflicts:
#	src/artifacts/ArtifactHash.ts
#	src/artifacts/DotnetBundleArtifactReader.ts
#	src/artifacts/MachOSliceArtifactReader.ts
#	src/artifacts/NodeSeaArtifactReader.ts
#	src/artifacts/PyInstallerArtifactReader.ts
#	src/artifacts/deno/DenoVirtualFs.ts
#	src/artifacts/extraction/ArtifactExtraction.ts
#	src/artifacts/pyinstaller/PyInstallerPyzStore.ts
#	src/resources/StableRootArtifact.ts
…ntity (#11497)

* refactor(evidence)!: name the Evidence subject only by its target identity

The subject keeps `identity` and the display facts `name` and `local_path`.
The duplicated `digest`, `format` and `architecture` members are removed; the
format-owned declaration now validates the identity itself. Readers the type
checker found move to the owner accessors; untyped reads in verify scripts,
the efficiency harness and test matchers move to `subject.identity`. The
`evidence-subject-declaration-read` text guard and its baseline are deleted.

Fixes #11473
Refs #11417

BREAKING CHANGE: the Evidence subject no longer has `digest`, `format` or
`architecture`; read `subject.identity.sha256`, `subject.identity.format` and
`subject.identity.architecture`. A record that still carries them is refused.

* test(evidence): give the Flutter verifier fixture the identity subject and check the DOL declaration without the ID
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — latest head b548afe: #11497 (the Evidence subject keeps only identity, name and local_path; the duplicated digest/format/architecture members and the text guard are removed) was folded in, after main was merged at be1abec.

Comment thread src/domain/evidenceSubject.test.ts Resolved
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — latest head 0b136c9 (fixes the subject fixture finding).

…-target-identity

# Conflicts:
#	src/application/DirectAnalysisCleanup.ts
#	src/artifacts/InesArtifactReader.ts
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

…ity (#11536)

* feat(evidence)!: give every Evidence record an explicit subject identity

A producer that cannot name a file passes an `unknown` target identity
with a closed reason (derived-from-linked-evidence, not-observed,
unsupported-subject) instead of no subject. The subject is non-null;
unknown subjects have no display facts. The generic missing-subject
limitation and `subjectUnavailableReason` are removed; producer-specific
explanations are ordinary limitations. Comparison identity requires the
derived unknown, and null-subject consumers ask the owner accessors.

Refs #11417

BREAKING CHANGE: every Evidence record has a subject. A record without a
file target names `subject.identity` `{ "kind": "unknown", "reason": … }`
with `name` and `local_path` null, instead of `subject: null` and the
limitation "Artifact identity is unavailable for this observation.".
Their Evidence IDs change.

* fix(evidence): name explicit unknown subjects in JavaScript callers and keep a managed graph's file subject

The verification scripts are not type-checked, so five createEvidence
callers still passed undefined (or a missing first target) after the subject
became required. They now pass unknownTarget("not-observed").

A managed application graph chose the first present input subject. Every
subject is now present, so an unknown artifact subject hid a file subject on
the member or boundary Evidence. The graph now takes the first input subject
that names a file.

* test(evidence): assert the subject kind instead of a presence the type now guarantees

Every Evidence record has a subject after this change, so test guards and
assertions that checked it for null always passed. Each now checks that the
fixture subject names a file, or is removed where a later fileIdentity,
fileSubjectTarget or fileSubjectDisplay call already requires that. Non-null
assertions on Evidence subjects are removed; analysis-view inputs, whose
subject is optional, keep an undefined check.
Two boundary tests still matched subject.format, which slice 2e moved into
subject.identity. toMatchObject is not type-checked against the Evidence
shape, so they failed only when run (the signature test on macOS).
@morluto
morluto merged commit 1f24b3f into main Nov 15, 2026
8 of 12 checks passed
@morluto
morluto deleted the feat/evidence-subject-target-identity branch November 15, 2026 22:28
morluto added a commit that referenced this pull request Nov 16, 2026
…mp command records (#11613)

Since #11416 every Evidence record has a subject; one without a file
target names identity {kind: unknown, reason: not-observed} with null name
and local_path. Four tests that #11416's run did not select still expected
subject: null and fail on main: the keyless bundle resource CLI, provider
composition and acceptance tests, and the objdump command identity test.
morluto added a commit that referenced this pull request Nov 16, 2026
… kernel config tests (#11650)

#11551 made a snapshot entry's subject the Evidence subject schema and
#11416 moved the subject's format under identity. Two tests that merged
alongside them still asserted the old shapes and fail on main:

- evidenceSubject.test.ts parsed the snapshot subject with the retired
  {format, architecture, path, sha256} projection and expected it to strip
  extra fields. It now asserts the snapshot subject is the Evidence subject
  schema, whose admission and strictness the rest of the test covers.
- KernelBuildConfigService.test.ts matched subject.format; it now matches
  subject.identity.format.
Plastic-time added a commit to Plastic-time/rea that referenced this pull request Nov 16, 2026
- Move PeRichHeaderPort to src/ports/binaryDiagnostics (morluto#11208). The
  provider now implements it, like the other PE providers.
- Import the artifact toolkit from src/resources, BinaryContainer from
  src/domain/binaryContainer and readPeHeaders from src/domain/pe.
- List PeRichHeaderProvider among native's entry files.
- Map failures with projectPeBinaryFailure, as PeImportsProvider and
  PeLoadConfigProvider do. The new guards forbid a hand-built
  resource-constraint refusal and an inline error message; the shared
  PE projection already owns both, so the provider adds neither. The
  structural allowance's recovery now carries its ceiling (morluto#11651).
- Tests: the Evidence subject names its target identity (morluto#11416), and
  readPeHeaders now throws a malformed ParseFailureError (morluto#11550).
- Re-record the advertised schema summary: the output hash now matches
  inspect_pe_imports after Evidence format revision 2.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 22, 2026
…command owner

Main now requires every verifier to allocate its root through
VerifierFixture, validate tools against the canonical output schemas, and
refuse a host without its fixture toolchain before allocating. The Xtensa
lane now does all three: readelf is declared as the xtensa lane's toolchain
(REA_XTENSA_READELF still selects it), its commands run through the shared
owner with SIGINT/SIGTERM interruption, and a failed run retains its
workspace.

Main also removed the -vN suffix from runtime-selected profile values, so
the Xtensa profile records language_selection provider-pinned/configured
and lane elf32-le-exec-windowed-generic. The .xtensa.info refusal test now
uses an ET_EXEC header so it reaches the ABI check rather than the e_type
refusal.

Main also names the Evidence subject and snapshot target by their
identity (morluto#11416), so the lane reads subject.identity and
target.identity.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 22, 2026
…#11416 moved it

Evidence subjects and snapshot targets now carry their digest under
identity, as the rest of the RISC-V verifier reads it.
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
morluto added a commit that referenced this pull request Nov 24, 2026
…ce (#8464)

* fix(ghidra)!: load ESP-IDF flash code in Ghidra's default address space

ESP-IDF's linker script reserves the addresses of .flash.text with the
NOBITS section .flash_rodata_dummy. Ghidra 12.1.4's ELF loader gives the
default address space to the later section, so .flash.text lands in an
overlay that its DWARF import, call-frame processing and default-space
references do not reach. Flash functions lose their DWARF signatures,
locals and no-return flags, each gets a one-byte shadow function in the
reservation, and pseudocode runs past calls such as esp_restart().

The ELF reader now records allocated ranges that an executable section
shares with another section, through one section-table visitor that the
RISC-V ISA reader also uses. When a NOBITS section starts with one
executable section and covers it, the RISC-V lanes commit both sections
to the analysis profile. ReaGhidraPrepareElfLoad.java then gives the code
the default address space before auto-analysis and keeps the reservation
as an uninitialized overlay; bytes, file offsets, symbols, functions and
entry points are kept. The session reports the outcome, and any memory
map that differs from the committed plan is refused. Images without such
an overlap keep their analysis profiles byte for byte.

BREAKING CHANGE: RISC-V images with this layout, such as ESP-IDF
ESP32-C6, H2 and H21 builds, report flash code at its ELF address
(0x42...) instead of .flash.text:0x42..., and their analysis profiles
change. RISC-V images with any other section overlap that involves
executable code are now refused with the overlapping sections named.
These include ESP-IDF v5.5.2 ESP32-C5 and C61 builds, whose second
reservation, .ext_ram.dummy, also covers .flash.text. See
docs/ghidra-riscv.md.

* fix(ghidra): bound the overlap sweep and check the load preparation

Domain:
- Find section overlaps with one sort and sweep that stops at the second
  overlap involving executable code, and read the ISA and the overlap in
  one section-table pass.
- Record the two sections that cause a refusal as witnesses. The Ghidra
  lane owns the refusal text and names them with their ranges.

Ghidra lane:
- Check the preparation report before the first lazily started analysis
  call, as for the calling-convention report.
- The pre-analysis script removes the code's overlay entry points, checks
  that no symbol or reference remains in the old overlay range, and reports
  the counts of the result. Its report echoes the blocks it left, which the
  client compares with the committed sections. A failed move refuses and
  rethrows. Reservation labels mark no entry points.
- Session limitations no longer state a planned move after a canonical
  outcome.

Verification:
- The ESP fixture defines ESP-IDF's absolute text bounds and the
  reservation's label. The lane checks their addresses, the entry points,
  file-offset uniqueness and snapshot replay, a reservation-first build,
  a pre-analysis refusal through analyzeHeadless and a truncated
  double-float section table.
- Boundary tests cover the refusal witnesses, a 10,000-section table and
  an ELF64 table.

* fix(ghidra): retarget references into the moved ESP-IDF flash code

The move takes the references from the code's range but not the
references into it. Besides the entry points, Ghidra 12.1.4's loader
records one data reference from the .flash.text section header to the
code, which the new post-condition refused in the RISC-V lane. Retarget
plain memory references and entry points into the old range to the moved
code; any other kind stays behind and is refused.

Removing the reservation block keeps the references into its range, so
the pinned symbols' entry points need no re-add.

* fix(ghidra): move labels past the ESP-IDF flash code's end with it

Ghidra 12.1.4 places a section-relative symbol at the section's end, such
as ESP-IDF's _etext, in the code's overlay space one byte past the block.
The move covers the block only, so the label stayed in the overlay and
ended up in the reservation. Everything in the code's overlay space now
follows the code: references are retargeted, labels outside the block are
created again in the default space, and the post-condition checks the
whole space. The script refuses when another block shares that space.

The ESP fixture defines _etext, and the lane checks its address.

* fix(ghidra): check prepared blocks by coordinates and address spaces

The client compared the pre-script's echoed block names with the ELF
section names, although section names are display only: an unnamed
section's empty name never matches the name Ghidra gives its block, so
that preparation was refused. It also accepted any reported address
spaces. The check now compares addresses, sizes and the code's file
offset, and requires moved code to go from an overlay into the
program's default space while its reservation leaves it, and canonical
code to stay there. An unnamed section is labelled by its index.

The docs and the pre-script now state that a failure during the move
may be refused without its reason, and that an entry mark on a
reservation label stays at its default-space address. The docs give
the llvm-objcopy route for the refused C5 and C61 builds. The lane
checks that no other block maps any of the code's file bytes, and the
overlap tests add the C5 and C61 section shape.

* fix(ghidra): bound the sections the overlap check keeps

The overlap check kept one record per allocated, non-empty section, and
only the file size limited their number. NOBITS headers take no file
bytes, so a crafted 1 GB ELF32 table holds about 27 million of them.
The check now keeps at most 65,280 (SHN_LORESERVE, from which ELF
counts sections through section zero) and reports the overlap as
unavailable beyond that, which the RISC-V lanes refuse as they refuse
a table that cannot be read.

* fix(ghidra): check RISC-V handshake reports before any analysis call

A RISC-V session that committed neither a calling-convention policy nor
a load preparation started its bridge lazily on the first query other
than `health`. An `elf_load_preparation` or calling-convention report
that the profile did not commit was then never checked, and the query
returned its result. Every RISC-V session now starts through the
checked handshake, so such a report closes the session before any
analysis call, whatever the first query is. A double-float session that
reports a preparation, and one that reports a calling-convention
policy, are now tested with `list_procedures`; both fail without the
fix.

Admission, profile parameters and profile digests do not change. If
Ghidra exits during the first query of a double-float session, the
error now tells the caller to reopen the session, as other checked
sessions do.

* fix(ghidra): skip analysis after a refused ELF load preparation

A refused memory map only wrote the refusal, so headless Ghidra still
ran seeds, auto-analysis and post-script analysis on a program that REA
then discarded. The preparation now turns off headless auto-analysis when
it refuses; later pre-scripts and the bridge still run, so the session
reports the reason.

The swap also renamed the reservation's overlay space to the section's
raw name, so a reservation named like another address space, such as
the RISC-V default space ram, or containing characters Ghidra rejects,
failed after the move. The space now takes the name Ghidra's memory map
derives for an overlay block: ':' and whitespace become '_', and a name
in use gains .1, .2 and so on.

verify:ghidra:riscv drops -noanalysis from the refusal run and checks
that Ghidra analyzed nothing, and a seventh fixture names the
reservation ram and checks that it moves into the overlay space ram.1.

* test(ghidra): read the load preparation report before Ghidra's log suffix

* test(ghidra): pin unchanged RISC-V profiles at main's revisions

main's byte-search (#8840), data-type (#8602) and reference revisions change every
Ghidra profile. With those revisions reversed, the old pins hold.

* fix(ghidra): name the moved RISC-V guide in load-layout diagnostics

The overlap refusal, the load-layout limitation and the bridge comments
named docs/ghidra-riscv.md, which main moved to docs/providers/.

* test(ghidra): check load-preparation facts instead of sentences

The refusal, report-check and handshake tests compared whole messages.
They now check the sections, coordinates, spaces and counts each message
must state, and the handshake compares the session's limitations with
ghidraRiscvLoadPreparationLimitations. Rewording the messages passes;
dropping a count fails.

* fix(ghidra): give the ESP-IDF load preparation unused temporary names

The preparation created its temporary blocks as <name>.rea, so a disjoint
section already named that refused an otherwise admitted image. It now
takes the first unused <name>.rea[.N]. verify:ghidra:riscv gains an
esp-edge-names fixture with such a section.

* fix(ghidra): keep both final block names free during the ESP-IDF swap

The code's temporary block could take the removed reservation's name,
such as a reservation named <code>.rea, and the reservation's rename
back then collided. The picker now skips both final names.
verify:ghidra:riscv's esp-edge-names fixture names its reservation
.flash.text.rea beside a disjoint .flash.text.rea.1.

* test(ghidra): repin the overlap-free RISC-V digests for main's #8340

main's #8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. With the revision reverted in place, the old
pins hold (79 of 79).

* test(ghidra): repin unchanged RISC-V digests for main's value-flow budgets

main's #9706 adds native_value_flow_projection to the shared analysis
semantics, which changes the profiles of images without a section overlap.
With that one revision removed, the previous pins hold (79 of 79).

* fix(ghidra): inspect RISC-V PIE section overlaps and refuse an unverified PIE reservation

Main admits RISC-V PIE, but this lane requires a section-overlap read
that the resolver made only for ET_EXEC, so every PIE was refused. A PIE's
section addresses are fixed offsets from its load base, so overlaps do not
depend on the base: read them for ET_DYN too. The NOBITS reservation
preparation is verified for ET_EXEC only, so a PIE that needs it is
refused. Main's producer identity now digests the bridge sources, so the
test that compared profile digests with main's is replaced by checking
that images without an overlap commit no load preparation.

* fix(ghidra): find an ESP-IDF reservation that Ghidra 12.2 marks executable

Ghidra 12.2 gives each section block the permissions of the first PT_LOAD
that contains its address, so a NOBITS reservation that shares the code's
addresses comes out executable and the preparation refused every ESP-IDF
image. Tell the reservation from the code by its missing bytes alone; the
displaced reservation is still made non-executable. The PIE refusal test
now uses the ELF64 lane, which admits PIE.

* fix(verify): read the ESP-IDF fixtures' identity where main's #11416 moved it

Evidence subjects and snapshot targets now carry their digest under
identity, as the rest of the RISC-V verifier reads it.

* docs(ghidra): describe the ESP-IDF load layout as verified on Ghidra 12.2

The real RISC-V lane now passes on Ghidra 12.2, whose ELF loader still puts
the code in an overlay when its reservation follows it. Name 12.2 where the
lane exercised that behaviour, and note that 12.2 can mark the reservation
executable. Measurements of Ghidra APIs the lane did not re-check keep
their 12.1.4 attribution.

* docs(domain): align RISC-V section-overlap JSDoc with ET_DYN inspection

---------

Co-authored-by: morluto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant