Skip to content

feat(verify): human-readable error messages + grouped tw-verify output (refs #126 — source-line resolution defers to #129)#159

Merged
hyperpolymath merged 3 commits into
mainfrom
feat/human-readable-errors
Jun 3, 2026
Merged

feat(verify): human-readable error messages + grouped tw-verify output (refs #126 — source-line resolution defers to #129)#159
hyperpolymath merged 3 commits into
mainfrom
feat/human-readable-errors

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Summary

Closes the prose-readability slice of #126: reword all #[error(...)] templates and replace tw-verify's {:?} debug-dump with a grouped, location-anchored bulleted list.

Changes

lib.rs — error message rewording (Display-only; no API breaks)

Pattern: L<n> (<aspect>): <subject is X but should be Y>.

Variant Old (excerpt) New (excerpt)
LinearUsedMultiple "Level 10 violation: function 0, param 0 — Linear (own) param loaded 5 times on some path" "L10 (linearity): function #0 parameter #0 is a Linear (own) resource but is used 5 times on some control-flow path; Linear resources must be consumed exactly once (possible duplication)"
ExclBorrowAliased "Level 7 violation: function 0, param 0 — ExclBorrow (mut) param aliased (2 simultaneous references)" "L7 (aliasing): function #0 parameter #0 is an ExclBorrow (&mut) reference but 2 simultaneous borrows occur on some control-flow path; at most one is permitted"
ModuleNotIsolated "Level 13 violation: {reason}" "L13 (module isolation): {reason}"
LinearImportCalledMultiple "Level 10 boundary violation: caller fn 7 calls import 'consume' 2 time(s)…" "L10 (linearity, cross-module): caller function #7 calls Linear import 'consume' 2 times on some control-flow path; Linear imports must be called at most once on every path"
MissingDependentRegions "Level 2 violation: typedwasm.access-sites section emitted without companion typedwasm.regions section (MissingDependentCarrier)" "L2 (region binding): typedwasm.access-sites section is present but the companion typedwasm.regions section is missing — access-site (region, field) keys have nothing to resolve against"

Same treatment for LinearNotUsed, LinearDroppedOnSomePath, LinearImportDroppedOnSomePath, CapabilitiesError::*, AccessSiteError::*.

VerifyError Vec-wrappers: replaced raw {:?} debug with a display_first_then_ellipsis helper that renders as "3 L7/L10/L13 ownership violation(s) — <first error's full Display>; … and 2 more".

bin/tw-verify.rs — grouped output

Replaces the previous flat {:?} / {e} printouts with grouping:

  • OwnershipErrors are bucketed by func_idx (with (module-scope) bucket for L13). Per bucket, errors are sorted by param_idx and printed as - <message>.
  • CrossErrors are bucketed by caller_func_idx.
  • L2 / L15 errors get an explicit FAIL <pass> ({n} violation(s)) header + bulleted list.

Sample output (before / after) — see commit message for details.

Out of scope

Source-line resolution ("at .twasm line N") defers to #129 (source maps). The verifier still has only wasm-level indices today; the #0 parameter / #N function notation makes that boundary explicit in the prose.

Test plan

  • cargo test -p typed-wasm-verify — 65 lib tests pass (62 baseline + 3 new Display tests)
  • cargo test -p typed-wasm-verify --all-features — 80 lib + 10 cross-compat + 5 cross-compat-real all green
  • cargo clippy -p typed-wasm-verify --all-features --tests — no new warnings (the pre-existing collapsible-match at verify.rs:323 remains; not mine)
  • No test compared raw error strings (all use matches! on variants), so rewording is backwards-compatible for the test suite

Refs #126. Source-line resolution defers to #129.

🤖 Generated with Claude Code

…t (refs #126)

Rewords every `#[error(...)]` template in OwnershipError / CrossError /
VerifyError / CapabilitiesError / AccessSiteError for plain-language
readability. All structural fields (func_idx, param_idx, count, …) are
preserved — this is a Display-only change, no API breaks.

Pattern: "L<n> (<aspect>): <what is wrong with what, and what should it
be>". Examples:

  before: "Level 10 violation: function 0, param 0 — Linear (own) param
           dropped on all paths (must be consumed exactly once)"
  after:  "L10 (linearity): function #0 parameter #0 is a Linear (own)
           resource but is never used; Linear resources must be consumed
           exactly once on every path"

VerifyError's Vec-wrapper variants previously rendered as raw `{:?}` debug
dumps. Now they render as "{count} L7/L10/L13 ownership violation(s) —
{first}; … and N more" via a small `display_first_then_ellipsis` helper,
so a single-line log is still informative.

`tw-verify` binary: replace the raw `{e}`/`{:?}` print with grouped output.
OwnershipError variants are sorted into per-function buckets (with a
`(module-scope)` bucket for L13 ModuleNotIsolated), and CrossError
variants are sorted by caller. Each location prints as a bulleted
sub-list under a "in function #N:" header. Output is now scannable
top-to-bottom by location rather than a flat debug blob.

Source-line resolution ("at .twasm line N") is the natural next step
but defers to #129 (source maps): wasm-level indices are still all the
verifier has today.

3 new Display unit tests cover OwnershipError, CrossError, and the
VerifyError vector-summary path.

Refs #126. Source-line resolution defers to #129.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🔍 Hypatia Security Scan

Findings: 94 issues detected

Severity Count
🔴 Critical 1
🟠 High 7
🟡 Medium 86

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Action perpolymath/standards/.github/workflows/governance-reusable.yml@main\n needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in c5-regenerate.yml",
    "type": "missing_timeout_minutes",
    "file": "c5-regenerate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in cargo-audit.yml",
    "type": "missing_timeout_minutes",
    "file": "cargo-audit.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath hyperpolymath marked this pull request as ready for review June 3, 2026 06:28
@hyperpolymath hyperpolymath enabled auto-merge (squash) June 3, 2026 06:28
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🔍 Hypatia Security Scan

Findings: 110 issues detected

Severity Count
🔴 Critical 1
🟠 High 7
🟡 Medium 102

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in c5-regenerate.yml",
    "type": "missing_timeout_minutes",
    "file": "c5-regenerate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in cargo-audit.yml",
    "type": "missing_timeout_minutes",
    "file": "cargo-audit.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in e2e.yml",
    "type": "missing_timeout_minutes",
    "file": "e2e.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath hyperpolymath disabled auto-merge June 3, 2026 23:33
@hyperpolymath hyperpolymath merged commit 045c070 into main Jun 3, 2026
18 of 27 checks passed
@hyperpolymath hyperpolymath deleted the feat/human-readable-errors branch June 3, 2026 23:36
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🔍 Hypatia Security Scan

Findings: 110 issues detected

Severity Count
🔴 Critical 1
🟠 High 7
🟡 Medium 102

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in c5-regenerate.yml",
    "type": "missing_timeout_minutes",
    "file": "c5-regenerate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in cargo-audit.yml",
    "type": "missing_timeout_minutes",
    "file": "cargo-audit.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in e2e.yml",
    "type": "missing_timeout_minutes",
    "file": "e2e.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant