customanchor: surface structured verification failures - #160
Closed
darioAnongba wants to merge 1 commit into
Closed
Conversation
Add a typed CustomAnchorVerificationError that carries a CustomAnchorVerificationIssue so plan-verification failures are machine-branchable by scope, code, and origin via errors.As. Wire the request, input-proof, asset-identity, amount, anchor-output, and commitment failure sites, and add result helpers (OK/Errors/Warnings).
This was referenced Jul 13, 2026
Collaborator
Author
|
Closing: not needed for SwapDK to be correct and complete. Build/Commit already return an error and a nil plan on any verification failure, so a caller cannot sign or publish an unverified transfer — this only added a machine-branchable classification of the failure, which is diagnostics polish (and it duplicated the existing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Structured custom-anchor verification failures
Closes #159. Follow-up to #158 addressing sub-issue #144.
The custom-anchor builder's verification result already reports the success path as structured
CheckscarryingScope,Origin(SDK-local / backend-trusted / host), and a stableCode. Its failure path did not: every failure inBuildreturned an opaquefmt.Errorfstring plus anilplan, and theCustomAnchorVerificationIssuetype — withSeverity,Scope,Origin,Code, and input/output locators — was never constructed in production. Callers could not branch on failure class, so #144's core promise ("return structured failure information callers can use to decide whether signing is safe") was unmet on the failure path.What this changes
CustomAnchorVerificationError, a typed error that carries aCustomAnchorVerificationIssueand unwraps to its cause. Any verification failure is now machine-branchable viaerrors.Aseven whenBuildreturns anilplan:OK(),Errors(),Warnings(), and anaddCustomAnchorIssuehelper (the failure/warning counterpart toaddCustomAnchorCheck) for the paths that can carry warnings.VerifyProof), asset-identity, amount conservation, anchor output, commitment, and duplicate-input.Tests
custom_anchor_verification_test.gocovers the result helpers,errors.As/Unwrapbehaviour, and a table-driven pass asserting each failure class returns a*CustomAnchorVerificationErrorwith the expectedScope/Code/Origin/Severityand input locator.go build,go vet ./..., andgo test ./...pass;gofmtclean.Not in this PR (tracked in #159)
The passive-asset and loss-policy sites, the compact-proof-path input branch, and the capability gate (which already returns its own structured
UnsupportedCustomAnchorCapabilityError). Returning a partial plan carryingWarning-severity issues (rather than only failing hard) is also left for a follow-up once the remaining sites are converted.