Skip to content

feat(evidence): read selected complete records without the whole bundle - #8528

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
feat/8307-evidence-record-selection
Nov 1, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
feat/8307-evidence-record-selection

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

What broke: after discovering a record by exact ID, there was no way to read just that record. detail: "complete" with filters is rejected, and inspect_analysis_view refuses parents without a view (annotations, pseudocode sources, native traces, view records). The only route was the whole canonical bundle, which overflows MCP on real sessions, or a file export.
Fix: get_evidence_bundle / rea inspect-evidence-bundle gain detail: "records". It returns a page of the matching complete records with unchanged IDs, plus missing_evidence_links for their direct links, labelled historical and not importable.
Risk: additive. complete and summary output is unchanged. complete + filters is still rejected (the message now also names records), and offset/limit are rejected outside records.

Summary

Fixes #8307 (proposal: #8307 (comment)).

One general, operation-agnostic contract instead of per-operation views. An agent that discovered an Evidence ID can fetch that exact record, or a bounded page of exactly filtered records, and learn which of its direct sources this session does not retain. It doesn't need to transfer the bundle.

Problem and expected behavior

Before, on aa48d494e, in a real stdio MCP session after analyzing Discord's app.asar (detail: summary):

  • get_evidence_bundle {} returned resource_constraint, response_bytes_at_least: 10511827.
  • inspect_analysis_view on a discovered inspect_analysis_view record returned unsupported_target.
  • get_evidence_bundle {detail:"records", …} returned invalid_request.

The issue's boundary requirements are to preserve the exact Evidence ID, subject digest, provider/profile, readback and historical semantics. A selection must not silently become an authenticated complete bundle or drop closure, and must not present an old annotation as live state.

Change and scope

  • src/domain/evidenceRecordSummary.ts (one owner of filter semantics): matchingEvidenceRecords now serves both summarizeEvidenceBundle and the new selectEvidenceRecords, so summary and records can't drift.
    • Records are paged in canonical bundle (Evidence ID) order, with offset/limit defaulting to 0/8.
    • Each returned record is the retained Evidence itself.
    • missing_evidence_links covers direct links of the returned records only, without traversal.
    • Two fixed limitations state that the records are historical, not live state, and that a selection is not an importable bundle.
  • InspectEvidenceBundle.ts (shared by the MCP session tool and the CLI file command) dispatches records and rejects offset/limit for other details.
  • Contracts: detail gains records, plus optional top-level offset/limit documented "records only". The output union gains evidenceRecordSelectionSchema, and one sentence is added to the description.
  • Overflow guidance: an oversized record page advises a smaller limit or one evidence_id (MCP_TRANSPORT_EVIDENCE_RECORDS). Whole-bundle overflow guidance now also points at record reads.
  • Docs: mcp-contracts.md, plus the wasm and route-inventory docs that previously told readers to fetch the complete bundle for one record, and the skill guidance.
  • Not included: residual-unknown selection (list_unknowns already pages it), multi-ID batch filters, link traversal, and annotation replay ([Feature] Ghidra: export analyst names and comments from a session and re-apply them when the target is reopened #6405). Complementary to fix(mcp): qualify retained Evidence view guidance #8377, which is guidance-only; overlapping description text will be merged when either lands.

Contract and boundary impact

  • Semantic owner and earliest changed stage: evidenceRecordSummary.ts filter matching, consumed by summary, records, the MCP get_evidence_bundle handler and CLI inspect-evidence-bundle. The duplicate inline filter loop was removed.

  • Contribution scope fit and linked maintainer decision: read-only selection of already retained Evidence. Proposal posted on [Design] Retrieve selected historical annotation Evidence without transferring the whole bundle #8307. No new authority.

  • CLI and MCP/tool-catalog contract: additive detail value and two optional fields. Output union superset.

  • Provider, bridge, target-format, or platform compatibility: none; no provider is consulted.

  • Evidence, artifact, provenance, or reconstruction contract: records are returned unchanged (same IDs). The selection carries explicit closure (missing_evidence_links), coverage (matching_records, total_retained_records, next_offset) and historical/non-bundle limitations.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none committed; docs:check and metadata:check pass.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/mcp/evidenceRecordSelectionMcp.test.ts (new; production MCP registration, full and compact output profiles). It uses synthetic annotation, pseudocode-source and trace records shaped like the issue's observations; no provider runs. It covers:
      • exact-ID selection returning the retained record itself, authenticated under its ID;
      • Ajv validation against the advertised input and output schemas;
      • two-page paging in canonical order across two targets, plus target filters and empty or past-end selections;
      • missing_evidence_links reported only for selected records and cleared once the source is retained;
      • identical selection after export and import into a fresh session;
      • complete + filters, summary + limit, complete + offset, default-detail limit and limit: 0 all rejected;
      • oversized-page guidance, with an exact selection still fitting.
    • tests/boundary/cli/analysisViewCli.test.ts: inspect-evidence-bundle with detail: "records" on a portable bundle file returns the same complete record.
  • Base reproduction:
    • the real-session run below, against a build without this change;
    • the new boundary file run unchanged without this change: 5/6 fail (records detail rejected, no selection result). The contract-separation test passes on both, because those combinations were already rejected; it guards that they stay rejected.
  • Remaining proof gaps:
    • No real Ghidra/Kuna annotation or trace was produced on this host, because no provider is installed. The selection is operation-agnostic and its records are synthetic.
    • No autonomous-agent study; token counts are byte/4 estimates.

Before/after on a real session (Discord app.asar, macOS arm64, Node 24.22.1, stdio rea mcp)

Step without this change this PR
get_evidence_bundle {} resource_constraint ≥ 10,511,827 B same, and the advice now names detail: records
inspect_analysis_view on a retained view record unsupported_target unsupported_target (unchanged)
get_evidence_bundle {detail:"records", filters:{evidence_id}}, a view record invalid_request 13,784 B text (~3.4k est. tokens), 1 ms, the complete record
same, for the 10.5 MB application parent invalid_request resource_constraint with "Request fewer records … a smaller limit or an exact evidence_id … A single record larger than one response needs export."

Validation performed

  • npm run test:focused on evidenceRecordSelectionMcp, analysisViewCli, largeToolResult, analysisViewMcp, fridaMcp, javascriptSourceSelection and process-global/bundleComparisonFailures: 7 files, 115/115 passed.
  • npm run test:changed: 444 files, 7377 passed, 22 skipped, and 1 failure, src/inspector/JavaScriptRuntimeScope.cancellation.test.ts ("stops Inspector target authorization after the current stat settles"). That test also fails identically on a branch without this change on this macOS host. It is unrelated to this diff, which touches no Inspector code.
  • npm run check:fast, npm run format:check, npm run docs:check, npm run metadata:check: passed.
  • Real-session before/after above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Existing complete/summary requests are unchanged; only the complete + filters error message now also names records.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 only; no provider.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: returns only records the caller's session or selected bundle already holds; no new paths or processes.

Author readiness

Human owner: @kaoru0822-kitauji

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

🤖 Generated with Claude Code

get_evidence_bundle could discover a record by exact ID, but reading it
required the complete canonical bundle: complete + filters was rejected,
and inspect_analysis_view refuses parents without a view, such as
annotations, pseudocode sources and native traces.

- Add detail: records, a page (offset, limit; default 0, 8) of the
  complete matching records in canonical bundle order. Records keep their
  original IDs, subjects, providers and readback; missing_evidence_links
  names direct links of the returned records that are not retained.
- The selection is labelled as historical and not an importable bundle;
  complete keeps returning the canonical bundle, and offset/limit
  require detail: records.
- Filters keep one owner shared by summary and records delivery, for the
  MCP session and the CLI's inspect-evidence-bundle.
- An oversized record page now advises a smaller limit or one
  evidence_id; whole-bundle overflow guidance mentions record reads.

Fixes #8307

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added enhancement New feature or request track:feature Feature/enhancement automation track labels Nov 1, 2026
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T14:51:38.368453Z 4f48d83 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 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

Adds detail: "records" to read selected complete Evidence records through MCP and CLI without transferring the whole bundle.

  • Callers can read selected complete Evidence records without loading the whole bundle.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  MCP["MCP get_evidence_bundle"] --> Shared["inspectEvidenceBundle"]
  CLI["CLI inspect-evidence-bundle"] --> Read["Read and validate local bundle"]
  Read --> Shared
  Shared --> Complete["complete: canonical bundle"]
  Shared --> Summary["summary: matching record metadata"]
  Shared --> Records["records: matching complete records"]
  Records --> Page["Page in Evidence ID order"]
  Page --> Result["Original records, missing direct links, and limitations"]
Loading

Reviews (2) · Last reviewed commit: "test(evidence): compare record-selection..." · Reviewed by Greptile

Assert the record-selection limitations and oversized-page guidance
against their owning constants, and check the reported limit facts
separately, instead of pinning explanatory phrases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit eb39a07 into main Nov 1, 2026
53 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the feat/8307-evidence-record-selection branch November 1, 2026 16:57
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
…le (morluto#8528)

* feat(evidence): read selected complete records without the whole bundle

get_evidence_bundle could discover a record by exact ID, but reading it
required the complete canonical bundle: complete + filters was rejected,
and inspect_analysis_view refuses parents without a view, such as
annotations, pseudocode sources and native traces.

- Add detail: records, a page (offset, limit; default 0, 8) of the
  complete matching records in canonical bundle order. Records keep their
  original IDs, subjects, providers and readback; missing_evidence_links
  names direct links of the returned records that are not retained.
- The selection is labelled as historical and not an importable bundle;
  complete keeps returning the canonical bundle, and offset/limit
  require detail: records.
- Filters keep one owner shared by summary and records delivery, for the
  MCP session and the CLI's inspect-evidence-bundle.
- An oversized record page now advises a smaller limit or one
  evidence_id; whole-bundle overflow guidance mentions record reads.

Fixes morluto#8307

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(evidence): compare record-selection guidance with its owners

Assert the record-selection limitations and oversized-page guidance
against their owning constants, and check the reported limit facts
separately, instead of pinning explanatory phrases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 23, 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 enhancement New feature or request track:feature Feature/enhancement automation track

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design] Retrieve selected historical annotation Evidence without transferring the whole bundle

2 participants