[PR #2051] [CLOSED] fix(evidence): report a single record selected as a bundle as invalid input #4991

Closed
opened 2026-10-31 00:57:47 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2051
Author: @kaoru0822-kitauji
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-2050


📝 Commits (2)

  • 31bb737 fix(evidence): report a single record selected as a bundle as invalid input
  • 6c5aa93 fix(evidence): authenticate a single record before classifying it as not-bundle

📊 Changes

7 files changed (+84 additions, -9 deletions)

View changed files

📝 src/application/EvidenceBundleFiles.ts (+13 -0)
📝 src/domain/analysisErrorPresentation.ts (+4 -0)
📝 src/domain/analysisErrorProjection.ts (+3 -0)
📝 src/domain/evidenceBundle.ts (+21 -3)
📝 src/domain/evidenceErrors.ts (+11 -1)
📝 tests/boundary/filesystem/evidenceBundleFiles.test.ts (+24 -4)
📝 tests/boundary/mcp/bundleComparisonMcp.test.ts (+8 -1)

📄 Description

Fixes #2050

Problem

Reading a caller-selected Evidence bundle that holds one intact Evidence record, such as one command's --json result, failed as an integrity mismatch:

$ rea inspect-macho /bin/ls --json > record.json
$ rea evidence-import record.json --json
{"code":"evidence_integrity_mismatch","category":"integrity_mismatch","retryable":false, …}

The record authenticates; the caller chose the wrong kind of file, as the message itself explains. #1256 already reports the other caller-selection failures for Evidence files (missing, not-file, exists) as invalid input and keeps unparseable content as an integrity mismatch. An intact record is a selection error, not damaged content.

Change

  • readBundle (EvidenceBundleFiles.ts) is the boundary every affected workflow uses: evidence-import, evidence-export, compare, inspect-analysis-view, and MCP import_evidence_bundle / compare_bundles. It now classifies a schema failure whose input is one valid Evidence record as EvidenceFileError("read", "not-bundle"), carrying the resolved path and the record's evidence_id.
  • The error is projected as invalid_request / invalid_input, like the other file-selection reasons, with details.path and details.evidence_id.
  • The record-detection and guidance text moved into evidenceBundle.ts (singleEvidenceRecordId, singleEvidenceRecordMessage). The file-error presentation and the in-memory ledger import now share one message instead of each building its own.
  • Malformed, schema-mismatched or tampered bundles remain evidence_integrity_mismatch.

Contract impact: a new EvidenceFileError reason and an additive details.evidence_id. Error details is a generic record in the advertised schema, so no generated catalog changes.

Validation

  • tests/boundary/mcp/bundleComparisonMcp.test.ts (public MCP compare_bundles workflow) and tests/boundary/filesystem/evidenceBundleFiles.test.ts now assert the new classification. Both fail on the base commit and pass with this change.
  • Manual CLI check: rea evidence-import record.json returns invalid_request / invalid_input with the unchanged guidance message.
  • npm run lint passes.
  • npm test: 9,063 passed, 13 failed. The 13 failures predate this change:
    • 12 in nibNativeHierarchy, interfaceBuilderBundle, javascriptRuntimeObservation, javascriptRuntimeTargetLocations and nativeDmgArtifactReader are environmental on this host (macOS, Command Line Tools only). They fail identically without this change.
    • cliOptionAliases ("register only single-character short flags") reports two undescribed trace-web-module-imports options and fails identically on the base commit.

No provider is involved.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2051 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-2050` --- ### 📝 Commits (2) - [`31bb737`](https://github.com/morluto/rea/commit/31bb73768cd483492cb30a6edd139b0bb26806ef) fix(evidence): report a single record selected as a bundle as invalid input - [`6c5aa93`](https://github.com/morluto/rea/commit/6c5aa93140f406ded2baf8a11aaea4a2aa5b82d2) fix(evidence): authenticate a single record before classifying it as not-bundle ### 📊 Changes **7 files changed** (+84 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/application/EvidenceBundleFiles.ts` (+13 -0) 📝 `src/domain/analysisErrorPresentation.ts` (+4 -0) 📝 `src/domain/analysisErrorProjection.ts` (+3 -0) 📝 `src/domain/evidenceBundle.ts` (+21 -3) 📝 `src/domain/evidenceErrors.ts` (+11 -1) 📝 `tests/boundary/filesystem/evidenceBundleFiles.test.ts` (+24 -4) 📝 `tests/boundary/mcp/bundleComparisonMcp.test.ts` (+8 -1) </details> ### 📄 Description Fixes #2050 ## Problem Reading a caller-selected Evidence bundle that holds one intact Evidence record, such as one command's `--json` result, failed as an integrity mismatch: ``` $ rea inspect-macho /bin/ls --json > record.json $ rea evidence-import record.json --json {"code":"evidence_integrity_mismatch","category":"integrity_mismatch","retryable":false, …} ``` The record authenticates; the caller chose the wrong kind of file, as the message itself explains. #1256 already reports the other caller-selection failures for Evidence files (`missing`, `not-file`, `exists`) as invalid input and keeps unparseable content as an integrity mismatch. An intact record is a selection error, not damaged content. ## Change - `readBundle` (`EvidenceBundleFiles.ts`) is the boundary every affected workflow uses: `evidence-import`, `evidence-export`, `compare`, `inspect-analysis-view`, and MCP `import_evidence_bundle` / `compare_bundles`. It now classifies a schema failure whose input is one valid Evidence record as `EvidenceFileError("read", "not-bundle")`, carrying the resolved path and the record's `evidence_id`. - The error is projected as `invalid_request` / `invalid_input`, like the other file-selection reasons, with `details.path` and `details.evidence_id`. - The record-detection and guidance text moved into `evidenceBundle.ts` (`singleEvidenceRecordId`, `singleEvidenceRecordMessage`). The file-error presentation and the in-memory ledger import now share one message instead of each building its own. - Malformed, schema-mismatched or tampered bundles remain `evidence_integrity_mismatch`. Contract impact: a new `EvidenceFileError` reason and an additive `details.evidence_id`. Error `details` is a generic record in the advertised schema, so no generated catalog changes. ## Validation - `tests/boundary/mcp/bundleComparisonMcp.test.ts` (public MCP `compare_bundles` workflow) and `tests/boundary/filesystem/evidenceBundleFiles.test.ts` now assert the new classification. Both fail on the base commit and pass with this change. - Manual CLI check: `rea evidence-import record.json` returns `invalid_request` / `invalid_input` with the unchanged guidance message. - `npm run lint` passes. - `npm test`: 9,063 passed, 13 failed. The 13 failures predate this change: - 12 in `nibNativeHierarchy`, `interfaceBuilderBundle`, `javascriptRuntimeObservation`, `javascriptRuntimeTargetLocations` and `nativeDmgArtifactReader` are environmental on this host (macOS, Command Line Tools only). They fail identically without this change. - `cliOptionAliases` ("register only single-character short flags") reports two undescribed `trace-web-module-imports` options and fails identically on the base commit. No provider is involved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:47 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4991
No description provided.