Skip to content

fix(evidence): derive default authority from subject binding - #10321

Merged
morluto merged 16 commits into
morluto:mainfrom
2SinceJuly:fix/10294-evidence-authority
Nov 18, 2026
Merged

morluto merged 16 commits into
morluto:mainfrom
2SinceJuly:fix/10294-evidence-authority

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

evidenceEnvelopeForAdmission defaulted a missing authority to
shipped-artifact for every observation. A subject that names no identified
target therefore claimed authority over an artifact it cannot name, and the live
GDB, Rizin and Cutter observation sites inherited that label, so those records
could never satisfy a live-observation contract: docs/reconstruction-coverage.md
accepts only controlled-replay or external-service Evidence for it.

Fixes #10294

Problem and expected behavior

  • The default was shipped-artifact, the strongest available authority,
    independent of what the subject actually names.
  • src/gdb, src/rizin and src/cutter declared authority zero times, so
    every live debugger command/startup observation was labeled as a statement
    about a shipped artifact.
  • Consequence: verifierHasComparableEvidence never qualifies a verifier result
    that cites only live-session Evidence, even though the session observed the
    behavior the contract describes.

Expected: the default follows what the record can actually support, and
live-session observations describe the replay they performed.

Change and scope

  • src/domain/evidence.ts: the default authority is derived from the subject
    identity — analyst-inference when it is unknown, shipped-artifact when it
    names a target. An explicit authority still wins in both cases.
  • Declared authority: "controlled-replay" at the six GDB observation sites
    (startup, console, retained process-exit, protocol failure, timeout,
    cancellation) and on the Rizin command observation.
  • Declared authority: "external-service" on the Cutter command observation:
    the bridge drives an already-running GUI whose document state REA neither owns
    nor resets, so it claims no controlled replay. live-observation still accepts
    it; controlled-replay-only contracts and bundle replay scenarios no longer
    include it.

Not included: no change to the coverage contract table, and no re-labeling of
stored Evidence. Existing records keep the authority they were written with;
evidence_id covers authority, so already-persisted records are unaffected
byte-for-byte.

This branch was rebased onto the Evidence target-identity revision (#11416,
#11568). That revision removed subjectUnavailableReason and made every
record name a target identity, so the earlier subject === null test no longer
distinguished anything; the derivation now keys on subject.identity.kind.

It was then merged with main again at 6c4e2bba9 to pick up #11686, which
repairs the Stryker command-handler selector after #11680 moved the CLI
commands onto registerCliCommand.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/evidence.ts owns the
    envelope default; the debugger adapters own their own observation label.
  • Contribution scope fit and linked maintainer decision: not applicable — an
    ordinary fix inside existing boundaries, no new provider or target authority.
  • CLI and MCP/tool-catalog contract: unchanged shape; authority values in
    output change for records whose subject names no target and for debugger
    observations.
  • Provider, bridge, target-format, or platform compatibility: GDB/Rizin Evidence
    is now labeled controlled-replay and Cutter external-service, instead of
    inheriting shipped-artifact.
  • Evidence, artifact, provenance, or reconstruction contract: this is the fix —
    records naming no target no longer claim shipment authority, and live-session
    records can now back live-observation.
  • Target selection, authority, upstream behavior, and cleanup details: no
    target interaction added; the debugger sites already ran.
  • Generated metadata, package, or installation impact: none.

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.

The debugger sites are existing behavior; this change only relabels their
Evidence.

Evidence and regression coverage

  • Tests added or updated:
    • src/domain/evidence.test.ts: a new case pins the default for a target-naming
      subject, an unknown subject, and the explicit-authority override in both
      directions.
    • tests/boundary/providers/CutterBridgeService.test.ts: a confirmed Cutter
      command observation reports external-service and not controlled-replay.
    • tests/boundary/providers/GdbSessionManagerCoverage.test.ts: the retained
      process-exit observation reports controlled-replay.
  • Base reproduction or other evidence: source-derived. On origin/main,
    grep -n "?? \"shipped-artifact\"" src/domain/evidence.ts finds the default and
    grep -rn authority src/gdb src/rizin src/cutter returns no matches.
  • User-visible CLI/MCP output: authority fields in debugger Evidence and in
    Evidence whose subject names no target now report their real source.
  • Remaining proof gaps: no live GDB/Rizin/Cutter session was run; the debugger
    sites are covered by the existing boundary tests, which exercise the retention
    paths and now assert the label on two of them.

Validation performed

All of the following were re-run on the merged head 0be5ef06f:

  • npm run check:fast — typecheck, lint and architecture guards passed.
  • npm run test:local -- src/domain/evidence.test.ts — 47 passed.
  • npm run test:focused -- tests/boundary/providers/CutterBridgeService.test.ts tests/boundary/providers/GdbSessionManagerCoverage.test.ts — 237 passed.
  • node scripts/prepare-reverse-tools-mutation.mjs — exits 0.
  • npm run test:focused -- tests/boundary/providers/RizinDebugSessionManagers.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part1.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part2.test.ts — 32 passed (run on the pre-merge head c0c1e6db8; the merge did not touch Rizin).
  • npm run test:local -- src/application/ReconstructionObligationLedger.authority.test.ts src/application/ReconstructionObligationCandidates.test.ts src/domain/reconstructionCoverageEvidence.test.ts — 64 passed (pre-merge head).
  • npm run test:local -- src/application/WorkflowEvidence.test.ts src/application/desktop/DesktopApplicationCapture.test.ts src/application/investigation/EvidenceLedger.test.ts src/application/binary/BinarySessionBundleResources.test.ts — 81 passed, 13 skipped (pre-merge head).
  • Not run: the full suite. The rebased branch touches evidence admission, which
    many suites read; I ran the obligation, workflow, desktop-capture, ledger and
    bundle-resource consumers plus the three provider boundaries.

Two boundary tests, tests/boundary/mcp/decompileAllCaveats.test.ts and
tests/boundary/mcp/environmentServeMcp.test.ts, fail on this branch. They fail
identically on a clean origin/main checkout at 6c4e2bba9, and main's own CI
is red at several of the SHAs since f14e9a1d2, so they reflect upstream work in
flight rather than this diff. Neither test reads Evidence authority.

Compatibility, safety, and release

  • Breaking changes or migration steps: persisted Evidence keeps its identity and
    authority; only newly created records use the derived default. Consumers that
    filtered on shipped-artifact for an unknown subject or debugger records will
    see the corrected label.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no real debugger
    session was run (see remaining proof gaps).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none — the change is a
    provenance label, not an authority grant.

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.

evidenceEnvelopeForAdmission defaulted a missing authority to shipped-artifact
for every observation, including ones with no artifact subject and ones
produced by a live debugger session. An unbound record therefore claimed
authority over an artifact it cannot name, and live GDB, Rizin and Cutter
observations could never qualify a live-observation contract because that
contract accepts only controlled-replay or external-service Evidence.

Default to analyst-inference when no subject is bound and keep
shipped-artifact when one is, so the default matches what the record can
actually support. Declare controlled-replay at the eight live debugger
observation sites (GDB 6, Rizin 1, Cutter 1) so those records describe the
controlled replay they performed and satisfy the documented contract.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-18T02:32:16.527970Z 5b19e81 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 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge within its stated scope.

Summary

This PR derives default Evidence authority from the named subject and gives debugger and ADB observations explicit source labels.

  • Evidence authority now follows the subject or the named source.
  • ADB observations now name the device as an external service.
  • GDB and Rizin records describe a replay, while Cutter names an external service.

The latest changes only adjust formatting. No new issues or security problems were found. The base still contains the old default, so this fix has not been superseded there.

Reviews (17) · Last reviewed commit: "style(adb): apply oxfmt formatting to th..." · Reviewed by Greptile

Comment thread src/domain/evidence.ts Resolved

@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: 50e4e928ad

ℹ️ 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
The GDB command process-exit branch was the only unbound retention path that
named no authority, so this branch's new default derived it as
analyst-inference. That label cannot support the live-observation contract,
and every sibling path (timeout, cancellation, protocol failure, startup)
already states controlled-replay.

The authority and the unavailable-subject reason now live beside the
provider identity so the retention paths read them from one place instead
of repeating the literals and drifting apart.

@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: 5a915f4dbe

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

@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: 2bf721d828

ℹ️ 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/cutter/CutterBridgeService.ts Resolved
The bridge drives the documented already-running Cutter GUI, whose
document state REA neither owns nor resets, so its command
observations claim no controlled replay. Label them external-service
like the comparable IDA and Frida bridge evidence: live-observation
obligations still accept it, while controlled-replay-only verifier
contracts and bundle replay scenarios no longer include these
observations.
@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.

evidenceEnvelopeForAdmission defaulted a missing authority to shipped-artifact
for every observation, including ones whose subject names no target.
An unknown subject therefore claimed authority over an artifact it cannot
name, and live GDB, Rizin and Cutter observations inherited that label, so
those records could never satisfy a live-observation contract that accepts
only controlled-replay or external-service Evidence.

Default to analyst-inference when the subject identity is unknown and keep
shipped-artifact when it names a target. Declare the authority the live
debugger paths actually performed: controlled-replay for GDB and Rizin, and
external-service for Cutter, whose document state REA neither owns nor
resets. Rebased onto the Evidence target-identity revision; the earlier
subjectUnavailableReason field no longer exists.
@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.

@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Status on the red lanes: both are upstream, not this branch.

Test shard (10/12) and Portable tests fail on two cases in tests/boundary/process/processCaptureProgress.test.ts — "forwards live capture progress only when the MCP client supplies a token" and "reports timeout and cancellation cleanup through MCP progress". I checked the same two cases against current main (run 43811744697, commit ab1616306) and they fail there identically, so the lane is red before this branch is applied.

This PR does not touch that path: the diff is 8 files, all in src/domain/evidence.ts and its test, plus the Cutter/GDB/Rizin provider identity plumbing. The processCaptureProgress test and the code it exercises are untouched. CI required fails only because it aggregates the shard result.

State otherwise: MERGEABLE/CLEAN, 8 files +106/−1, and every other lane passes on 0be5ef06fe. The behavioral summary from the last round still holds — the default authority now follows subject binding instead of assuming shipped-artifact, and the boundary tests cover both the bound and unbound cases.

Two things you could weigh in on:

  1. Whether to merge with the shard red on an upstream failure, or wait for that test to be fixed on main and rebase.
  2. The known follow-up I have not included here: subjectless live providers (AdbDeviceAnalysisService and the other live observers) still land on analyst-inference unless AnalysisObservation gains an authority field each provider declares. That is a separate change spanning four providers and their regression tests, so I kept this PR to the evidence default. If you would rather that land first, say so and I will send it as its own PR against this branch.

main moved the GDB observation sites onto createGdbSessionEvidence, which
left the explicit authority up to each caller. Pass GDB_OBSERVATION_AUTHORITY
in the helper so every session observation keeps the controlled-replay label
without repeating it at nine call sites.
@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.

@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 230db70fb and pushed f1f54fcc6; the branch is mergeable again.

The conflict was in src/gdb/GdbSessionManager.ts: #11568/#11652 moved every session observation onto createGdbSessionEvidence, which took over envelope creation but left authority unset at each call site. Rather than repeat GDB_OBSERVATION_AUTHORITY nine times, this push passes it once inside the helper, so the explicit label in the PR description still holds and the call sites stay unchanged.

Validation actually run on the merged tree:

  • npm run check:fast — passed (typecheck, lint, architecture guards over 2819 files).
  • npm run test:local -- src/domain/evidence.test.ts — 47 tests passed.
  • npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts — 211 tests passed.

Not run: the full check:pr gate. Also note main itself currently has four failing test shards (1/12, 2/12, 7/12, 10/12) on 230db70fb, so a red shard here may be inherited rather than caused by this branch.

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

The admission default now derives authority from the subject, so a subjectless ADB observation fell to analyst-inference. A device is a service REA attaches to rather than drives, so the observation supports external-service and must stay eligible for live-observation contracts.

Carry an explicit authority through AnalysisObservation so a producer that knows its own authority can name it, and set it for every ADB operation.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Handled the three open review threads on the current head (b65b6e5a3).

Two were already fixed on the branch. The GDB process-exit retention and the Cutter bridge reply both go through paths that now pass an explicit authority (GdbSessionManager.ts via createGdbSessionEvidence, CutterBridgeService.ts with external-service), so they no longer inherit the subject-derived default. Replied on each thread and resolved them.

The ADB one was real, and I fixed it rather than dismissing it. AdbDeviceAnalysisService.execute produces subjectless observations, so the new subject-derived default labelled device, logcat, package and process replies analyst-inference. A device is a service REA attaches to and does not own or reset — the observation supports external-service, which the live-observation contract already accepts alongside controlled-replay.

  • src/domain/analysisObservation.ts — AnalysisObservation can now carry an authority, forwarded into the Evidence input, so a producer that knows what its observation supports can name it instead of relying on the subject.
  • src/domain/evidence.ts — export EvidenceAuthority, which AnalysisObservation needs.
  • src/application/adb/AdbDeviceAnalysisService.ts — default every ADB observation to external-service, never overriding one the provider set.
  • src/application/adb/AdbDeviceAnalysisService.test.ts — the composition test now asserts the authority.

Validation, actually run:

  • npm run check:fast — typecheck, lint and the architecture guards pass (2816 source files).
  • src/application/adb/AdbDeviceAnalysisService.test.ts 16 passed, src/domain/evidence.test.ts 47 passed.
  • Reversed it: dropping the ADB change makes the new assertion fail with expected 'analyst-inference' to be 'external-service', so the regression test is not vacuous.

Not run: the full test suite, and no real adb device was attached — the provider is the existing fixture port.

The admission default derives authority from the subject, and a subjectless
observation falls to analyst-inference. createAnalysisExecution never carried
an authority field, so every observation the ADB adapter built through it was
committed at the subject-derived default instead of the service's.

Name the authority once in the domain model, stamp it on every successful
execution at the adapter boundary, and route the cleanup-failure and
cancellation-retention sites through one helper. Open the execution options
field so other providers can name their own authority.

Verified: a push whose device digest does not match now retains its receipt at
external-service; removing the stamp fails that assertion. check:fast passes.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

The greptile finding on the retained ADB observations is fixed in fae7b4a5d; thread resolved.

What changed: the authority is now stamped once at the provider's execute boundary and both retained-observation paths go through one helper, instead of only the success return naming it. CreateAnalysisExecutionOptions now carries authority, so the adapter no longer has to drop it.

Verified with a reverse-check: the push digest-mismatch test asserts external-service on the retained receipt and fails when the stamp is removed. npm run check:fast passes.

Not covered here: cancellation-retained partials in pull / package-pull / activity-start / bugreport still use their bare shapes and therefore the subject-derived default. That needs the four producer shapes and their projections updated, which I would rather land separately than fold into this fix.

@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: fae7b4a5d7

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/adb/AdbProvider.ts Resolved
Resolves the AdbProvider.execute conflict: main extracted the retained-cleanup
retry into #retryPendingCleanup, which already covers both the provider-owned
resources and the pending output directory that this branch retried inline.
Keep the branch's observedExecution wrapper so device observations still
carry external-service authority.
The verificationFailed branch built its retained receipt with createEvidence
directly, so the admission default derived the authority from a subjectless
target and labelled an observed push as analyst-inference. Pass the device
authority through the same way the neighbouring digest-mismatch partial does,
so the receipt can still support live-observation verification.
The previous commit wrapped two expressions that oxfmt keeps on one line, so
npm run format:check failed on Static checks.
@morluto
morluto merged commit b99e773 into morluto:main Nov 18, 2026
55 checks passed
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction bug Something isn't working labels Nov 22, 2026
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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Evidence without an artifact subject claims shipped-artifact authority, so live sessions cannot qualify live-observation contracts

2 participants