Skip to content

fix(domain): attribute noncanonical bundle errors to the violated section - #7358

Closed
zzrs-xxxr wants to merge 2 commits into
morluto:mainfrom
zzrs-xxxr:fix/evidence-bundle-canonical-reason
Closed

zzrs-xxxr wants to merge 2 commits into
morluto:mainfrom
zzrs-xxxr:fix/evidence-bundle-canonical-reason

Conversation

@zzrs-xxxr

@zzrs-xxxr zzrs-xxxr commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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 [Bug] Record-order validation incorrectly reports noncanonical manifests #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.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-27T01:18:29.586442Z
We couldn’t complete this review. Comment @codex review to try again.
7795a54 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

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.

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found.

Summary

The PR makes bundle errors name the section that differs from the canonical form.

  • Invalid evidence bundles now name record-order failures accurately.

Reviews (2) · Last reviewed commit: "test(evidence): align canonical diagnost..." · Reviewed by Greptile

Comment thread src/domain/evidenceBundle.ts Resolved
Comment thread src/domain/evidenceBundle.test.ts Resolved
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the PR's 3 changed test files on Node 22.23.4, 24.22.1 and 26.12.1. All 57 tests passed on each version. With src/domain/evidenceBundle.ts swapped back to the merge base, 3 tests failed on each version, one per file.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head a73c373 pass: 3 files, 57 tests pass: 3 files, 57 tests pass: 3 files, 57 tests
Red run (head, with src/domain/evidenceBundle.ts from merge base d109a39) fail: 3 files, 3 tests failed, 54 passed fail: 3 files, 3 tests failed, 54 passed fail: 3 files, 3 tests failed, 54 passed

Each file's new check fails without the fix and passes with it. In the Node 24.22.1 log, the three failures are:

  • tags valid-shaped bundles that fail canonical ordering
  • rejects noncanonical source bundles before ledger generation
  • reports non-canonical authenticated bundles as caller input

CI on a73c373:

  • CI and PR title are waiting for a maintainer to approve them (action_required).
  • Greptile Review passed.
  • Validate author declaration has one successful and one cancelled check run.
  • PR readiness has one successful and one cancelled run, and its commit status is success.

The head is 928 commits behind main b81da90. GitHub says the PR is mergeable, and its merge state is blocked.

Not run

  • A real evidence bundle whose records are out of canonical order.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: a73c373 / d109a39 (merge base with main)
  • Red run: a73c373 with src/domain/evidenceBundle.ts from d109a39
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/domain/evidenceBundle.test.ts tests/boundary/cli/reconstructionObligationLedgerCli.test.ts tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
Any canonical-form mismatch reported "Evidence bundle manifests are not
canonical", so a bundle whose records were out of order, or whose
unknowns differed, blamed unchanged manifests. The error now names the
top-level sections that differ from canonical form, for example
"Evidence bundle sections are not canonical: records".

Fixes #7330

Based on #7358 by zzrs-xxxr, which split records from manifests; this
reports every differing section instead, so unknowns or several
sections are attributed correctly.

Co-Authored-By: zzrs-xxxr <[email protected]>
Co-Authored-By: gensokyo-dev <[email protected]>
gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
Any canonical-form mismatch reported "Evidence bundle manifests are not
canonical", so a bundle whose records were out of order, or whose
unknowns differed, blamed unchanged manifests. The error now names the
top-level sections that differ from canonical form, for example
"Evidence bundle sections are not canonical: records".

Fixes #7330

Based on #7358 by zzrs-xxxr, which split records from manifests; this
reports every differing section instead, so unknowns or several
sections are attributed correctly.

Co-Authored-By: zzrs-xxxr <[email protected]>
Co-Authored-By: gensokyo-dev <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
Any canonical-form mismatch reported "Evidence bundle manifests are not
canonical", so a bundle whose records were out of order, or whose
unknowns differed, blamed unchanged manifests. The error now names the
top-level sections that differ from canonical form, for example
"Evidence bundle sections are not canonical: records".

Fixes #7330

Based on #7358 by zzrs-xxxr, which split records from manifests; this
reports every differing section instead, so unknowns or several
sections are attributed correctly.

Co-Authored-By: zzrs-xxxr <[email protected]>
Co-Authored-By: gensokyo-dev <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you. #10499 reimplemented this fix and credits this PR (see the PR table), so I'm closing it as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Record-order validation incorrectly reports noncanonical manifests

4 participants