Skip to content

fix(abi-verify): tolerate non-canonical Zig switch arm false shorthand#36

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/abi-verify-tolerate-false-arm
May 20, 2026
Merged

fix(abi-verify): tolerate non-canonical Zig switch arm false shorthand#36
hyperpolymath merged 1 commit into
mainfrom
fix/abi-verify-tolerate-false-arm

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

abi-verify's Zig FFI parser bombed on 5 cartridges' isValidTransition switch arms because their terminal-state arm body is the literal false (no outgoing transitions allowed) rather than the canonical to == .<v> chunk form:

fn isValidTransition(from: BspState, to: BspState) bool {
    return switch (from) {
        ...
        .exited => false,   // <-- parser bombed here
    };
}

The Zig is well-formed and the semantics ("empty allowed-set") are clear; the verifier just didn't accept the shorthand.

parse_arm_targets now detects this form (body trimmed of trailing ,/; and whitespace equals false) and returns the empty vec — equivalent to the "this state has no allowed outgoing transitions" manifest semantics, which is exactly what the cartridges intend.

End-to-end verified against the 5 cartridges named in the issue (after a fresh cargo build --release):

bsp-mcp → parses cleanly; surfaces real drift on BspCapability
container-mcp → abi-verify OK
dap-mcp → parses cleanly; surfaces real drift on StepGranularity
lsp-mcp → parses cleanly; surfaces real drift on CompletionKind
vault-mcp → parses cleanly; surfaces real drift on IdentityType

All 5 now produce either exit 0 (clean) or a real drift diagnosis, which is precisely the acceptance criterion in iseriser#19. The post-parse drift findings are separate per-cartridge issues — not verifier defects — and out of scope for this PR.

44 lib tests + 9 integration tests pass.

Refs hyperpolymath/standards#92 (Phase 2 allowlist expansion). Refs #19.

Summary

Changes

RSR Quality Checklist

Required

  • Tests pass (just test or equivalent)
  • Code is formatted (just fmt or equivalent)
  • Linter is clean (no new warnings or errors)
  • No banned language patterns (no TypeScript, no npm/bun, no Go/Python)
  • No unsafe blocks without // SAFETY: comments
  • No banned functions (believe_me, unsafeCoerce, Obj.magic, Admitted, sorry)
  • SPDX license headers present on all new/modified source files
  • No secrets, credentials, or .env files included

As Applicable

  • .machine_readable/STATE.a2ml updated (if project state changed)
  • .machine_readable/ECOSYSTEM.a2ml updated (if integrations changed)
  • .machine_readable/META.a2ml updated (if architectural decisions changed)
  • Documentation updated for user-facing changes
  • TOPOLOGY.md updated (if architecture changed)
  • CHANGELOG or release notes updated
  • New dependencies reviewed for license compatibility (PMPL-1.0-or-later / MPL-2.0)
  • ABI/FFI changes validated (src/interface/abi/ and src/interface/ffi/ consistent)

Testing

Screenshots

`abi-verify`'s Zig FFI parser bombed on 5 cartridges' `isValidTransition`
switch arms because their terminal-state arm body is the literal
`false` (no outgoing transitions allowed) rather than the canonical
`to == .<v>` chunk form:

    fn isValidTransition(from: BspState, to: BspState) bool {
        return switch (from) {
            ...
            .exited => false,   // <-- parser bombed here
        };
    }

The Zig is well-formed and the semantics ("empty allowed-set") are
clear; the verifier just didn't accept the shorthand.

`parse_arm_targets` now detects this form (body trimmed of trailing
`,`/`;` and whitespace equals `false`) and returns the empty vec —
equivalent to the "this state has no allowed outgoing transitions"
manifest semantics, which is exactly what the cartridges intend.

End-to-end verified against the 5 cartridges named in the issue
(after a fresh `cargo build --release`):

  bsp-mcp        → parses cleanly; surfaces real drift on BspCapability
  container-mcp  → abi-verify OK
  dap-mcp        → parses cleanly; surfaces real drift on StepGranularity
  lsp-mcp        → parses cleanly; surfaces real drift on CompletionKind
  vault-mcp      → parses cleanly; surfaces real drift on IdentityType

All 5 now produce either exit 0 (clean) or a real drift diagnosis,
which is precisely the acceptance criterion in iseriser#19. The
post-parse drift findings are separate per-cartridge issues — not
verifier defects — and out of scope for this PR.

44 lib tests + 9 integration tests pass.

Refs hyperpolymath/standards#92 (Phase 2 allowlist expansion).
Refs #19.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit 6b4a2a8 into main May 20, 2026
14 of 16 checks passed
@hyperpolymath hyperpolymath deleted the fix/abi-verify-tolerate-false-arm branch May 20, 2026 21:44
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