[PR #7358] fix(domain): attribute noncanonical bundle errors to the violated section #7830

Open
opened 2026-11-05 01:47:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7358
Author: @zzrs-xxxr
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: fix/evidence-bundle-canonical-reason


📝 Commits (2)

  • 7795a54 fix(domain): attribute noncanonical bundle errors to the violated section
  • a73c373 test(evidence): align canonical diagnostics across boundaries

📊 Changes

4 files changed (+51 additions, -10 deletions)

View changed files

📝 src/domain/evidenceBundle.test.ts (+24 -0)
📝 src/domain/evidenceBundle.ts (+25 -8)
📝 tests/boundary/cli/reconstructionObligationLedgerCli.test.ts (+1 -1)
📝 tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts (+1 -1)

📄 Description

Summary

evidence-import correctly rejects a bundle whose records are out of canonical order, but the diagnostic blames the manifests (reproduced in #7330). This violates the AGENTS.md requirement to preserve meaningful failure reasons. Fixes #7330.

Problem and expected behavior

Smallest trigger: import a bundle identical to an accepted canonical bundle except that records are reversed. Violated invariant: the failure reason must identify the constraint that actually failed. Observed: Evidence bundle manifests are not canonical even though every manifest section is byte-identical. Expected: continue rejecting under the same authenticated canonical-form contract, but describe the violated record-order constraint accurately; a genuinely inconsistent manifest keeps a manifest diagnostic.

Change and scope

authenticateBundle compares the parsed bundle against the canonical projection; on mismatch it now attributes the violation to the section that actually differs:

  • Only records differ → Evidence bundle records are not in canonical order
  • Any manifest section differs → the existing Evidence bundle manifests are not canonical

The error class gains an optional section parameter defaulting to "manifests", so external behaviour is unchanged for every pre-existing construction site. The fix stays at the producing boundary (src/domain/evidenceBundle.ts) where the canonical comparison already knows both objects; no downstream reinterpretation was added. Acceptance, rejection, classification, and retryability are intentionally unchanged. Contribution scope: not applicable (ordinary diagnostic fix within existing boundaries, no new provider or capability).

Contract and boundary impact

  • Semantic owner and earliest changed stage: evidenceBundle domain authentication (canonical-form check); consumers are the CLI/MCP integrity error projections which forward the message verbatim. No superseded paths removed.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no schema or tool-catalog change; one error message string becomes more specific for the record-order case.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: bundle validation semantics unchanged; only the failure reason wording is attributed more accurately.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: The existing record-order classification test also asserts the records diagnostic; an inconsistent-manifest control retains the manifest diagnostic. CLI and MCP ledger boundary tests assert the corrected record-order reason.
  • Base reproduction or other evidence: executed production-boundary check (via tsx against the source modules) on the affected base: canonical bundle parses; reversed-records bundle is rejected with the record-order message only after the fix — on the base it fails with the manifest message; a genuinely inconsistent provider manifest keeps the manifest message; a bundle violating both still reports the manifest diagnostic. Matches the restoration criteria in #7330.
  • User-visible CLI/MCP output (if applicable): The rebuilt CLI and MCP boundary suites on macOS assert the exact record-order reason through their public error projections.
  • Remaining proof gaps: The original Windows checkout could not collect Vitest on its baseline. The focused suites below passed on macOS; the complete suite was not run.

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

  • npx tsx behaviour script against src/domain/evidenceBundle.ts — canonical parses; reversed records → "Evidence bundle records are not in canonical order"; bad manifest → "Evidence bundle manifests are not canonical"; both violated → manifest message.

  • npx prettier --check src/domain/evidenceBundle.ts src/domain/evidenceBundle.test.ts — all matched files use Prettier code style.

  • npx tsc --noEmit — reports only pre-existing Playwright-typing errors unrelated to this change; no new errors in touched files.

  • npx vitest run src/domain/evidenceBundle.test.ts — did not execute: suite fails at collection on the unmodified baseline in this Windows checkout (environment limitation; CI runs the suite).

  • npm run test:local -- src/domain/evidenceBundle.test.ts — 9 passed on macOS, Node 24.22.1.

  • npm run test:focused -- tests/boundary/cli/reconstructionObligationLedgerCli.test.ts tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts — 48 passed on macOS.

  • npm run check:fast — passed on macOS.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. The rejection behaviour, error class, kind, and retryability are unchanged; only the message becomes more specific for one violation class.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (domain validation only, no provider involved).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new interaction surface; diagnostics carry no caller data beyond the fixed message.

Author readiness

Human owner: @zzrs-xxxr

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

🔄 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/7358 **Author:** [@zzrs-xxxr](https://github.com/zzrs-xxxr) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/evidence-bundle-canonical-reason` --- ### 📝 Commits (2) - [`7795a54`](https://github.com/morluto/rea/commit/7795a540762a16eb323c40dcb25ac37c9fb1aeb5) fix(domain): attribute noncanonical bundle errors to the violated section - [`a73c373`](https://github.com/morluto/rea/commit/a73c373c4864424e204e7a175f2208a07e5fb56f) test(evidence): align canonical diagnostics across boundaries ### 📊 Changes **4 files changed** (+51 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/evidenceBundle.test.ts` (+24 -0) 📝 `src/domain/evidenceBundle.ts` (+25 -8) 📝 `tests/boundary/cli/reconstructionObligationLedgerCli.test.ts` (+1 -1) 📝 `tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts` (+1 -1) </details> ### 📄 Description ## Summary `evidence-import` correctly rejects a bundle whose `records` are out of canonical order, but the diagnostic blames the manifests (reproduced in #7330). This violates the `AGENTS.md` requirement to preserve meaningful failure reasons. Fixes #7330. ## Problem and expected behavior Smallest trigger: import a bundle identical to an accepted canonical bundle except that `records` are reversed. Violated invariant: the failure reason must identify the constraint that actually failed. Observed: `Evidence bundle manifests are not canonical` even though every manifest section is byte-identical. Expected: continue rejecting under the same authenticated canonical-form contract, but describe the violated record-order constraint accurately; a genuinely inconsistent manifest keeps a manifest diagnostic. ## Change and scope `authenticateBundle` compares the parsed bundle against the canonical projection; on mismatch it now attributes the violation to the section that actually differs: - Only `records` differ → `Evidence bundle records are not in canonical order` - Any manifest section differs → the existing `Evidence bundle manifests are not canonical` The error class gains an optional `section` parameter defaulting to `"manifests"`, so external behaviour is unchanged for every pre-existing construction site. The fix stays at the producing boundary (`src/domain/evidenceBundle.ts`) where the canonical comparison already knows both objects; no downstream reinterpretation was added. Acceptance, rejection, classification, and retryability are intentionally unchanged. Contribution scope: not applicable (ordinary diagnostic fix within existing boundaries, no new provider or capability). ## Contract and boundary impact - Semantic owner and earliest changed stage: `evidenceBundle` domain authentication (canonical-form check); consumers are the CLI/MCP integrity error projections which forward the message verbatim. No superseded paths removed. - Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: no schema or tool-catalog change; one error message string becomes more specific for the record-order case. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: bundle validation semantics unchanged; only the failure reason wording is attributed more accurately. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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: The existing record-order classification test also asserts the records diagnostic; an inconsistent-manifest control retains the manifest diagnostic. CLI and MCP ledger boundary tests assert the corrected record-order reason. - Base reproduction or other evidence: executed production-boundary check (via `tsx` against the source modules) on the affected base: canonical bundle parses; reversed-records bundle is rejected with the record-order message **only after the fix** — on the base it fails with the manifest message; a genuinely inconsistent provider manifest keeps the manifest message; a bundle violating both still reports the manifest diagnostic. Matches the restoration criteria in #7330. - User-visible CLI/MCP output (if applicable): The rebuilt CLI and MCP boundary suites on macOS assert the exact record-order reason through their public error projections. - Remaining proof gaps: The original Windows checkout could not collect Vitest on its baseline. The focused suites below passed on macOS; the complete suite was not run. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx tsx` behaviour script against `src/domain/evidenceBundle.ts` — canonical parses; reversed records → "Evidence bundle records are not in canonical order"; bad manifest → "Evidence bundle manifests are not canonical"; both violated → manifest message. - `npx prettier --check src/domain/evidenceBundle.ts src/domain/evidenceBundle.test.ts` — all matched files use Prettier code style. - `npx tsc --noEmit` — reports only pre-existing Playwright-typing errors unrelated to this change; no new errors in touched files. - `npx vitest run src/domain/evidenceBundle.test.ts` — did not execute: suite fails at collection on the unmodified baseline in this Windows checkout (environment limitation; CI runs the suite). - `npm run test:local -- src/domain/evidenceBundle.test.ts` — 9 passed on macOS, Node 24.22.1. - `npm run test:focused -- tests/boundary/cli/reconstructionObligationLedgerCli.test.ts tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts` — 48 passed on macOS. - `npm run check:fast` — passed on macOS. ## Compatibility, safety, and release - Breaking changes or migration steps: none. The rejection behaviour, error class, kind, and retryability are unchanged; only the message becomes more specific for one violation class. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (domain validation only, no provider involved). - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new interaction surface; diagnostics carry no caller data beyond the fixed message. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @zzrs-xxxr - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7830
No description provided.