Skip to content

feat(abi-verify): teach the converter Zig reserved words (standards#9…#33

Closed
hyperpolymath wants to merge 1 commit into
mainfrom
feat/zig-reserved-word-converter
Closed

feat(abi-verify): teach the converter Zig reserved words (standards#9…#33
hyperpolymath wants to merge 1 commit into
mainfrom
feat/zig-reserved-word-converter

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

…2 follow-up)

Phase 2's spot-check across the boj-server cartridge corpus found that when an Idris2 variant snake_cases to a Zig reserved word, the cartridge renames the Zig identifier to avoid the collision (e.g. Error → err in airtable-mcp, postgresql-mcp). The verifier raised this as variant-missing-in-zig + variant-extra-in-zig — a false-positive class that masked real findings.

Changes

  • manifest_schema.rs:
    • ZIG_RESERVED — Zig 0.15.x reserved-word list (50 keywords)
    • is_zig_reserved(word) — predicate
    • zig_reserved_workaround(word) — cartridge convention table (error → err is the verified case; generic <name>_ fallback for future cartridges that pick a different rename)
    • zig_variant_candidates(idris_name) — returns the snake_case form, plus the workaround when the snake_case is reserved
  • verify.rs:
    • enum-variant lookup tries every candidate; first match wins
    • manifest_keys records every candidate so the accept-by-omission check doesn't flag a Zig variant the manifest legitimately covers
    • transition-table resolution uses candidates symmetrically (so Error → SomeState in the manifest matches err → some_state in the Zig switch)
    • finding messages now name every candidate tried, not just the snake_case form

Verified

  • 43 lib tests green (was 39; +4 new in manifest_schema::tests)
  • airtable-mcp was DRIFT (Error→err false-positive), is now CLEAN
  • postgresql-mcp now passes the reserved-word check; remaining drift is a separate naming-convention issue (BeginTransaction → begin_tx, abbreviation, not reserved-word — out of scope for this PR)
  • ssg-mcp, k9iser-mcp unchanged (still clean)
  • 007-mcp still DRIFT (ToolRisk missing in Zig — that's a real cartridge defect, not a verifier defect, will be fixed separately)

Note on type

type is a Zig primitive (alongside bool, u32, etc.), not a reserved keyword — it's a legal identifier in enum contexts. Explicit test pinning this so a future reader doesn't add it to the reserved list by mistake.

Refs hyperpolymath/standards#92
Refs hyperpolymath/standards#89

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

…2 follow-up)

Phase 2's spot-check across the boj-server cartridge corpus found that
when an Idris2 variant snake_cases to a Zig reserved word, the cartridge
renames the Zig identifier to avoid the collision (e.g. `Error → err`
in airtable-mcp, postgresql-mcp). The verifier raised this as
`variant-missing-in-zig` + `variant-extra-in-zig` — a false-positive
class that masked real findings.

## Changes

- `manifest_schema.rs`:
  - `ZIG_RESERVED` — Zig 0.15.x reserved-word list (50 keywords)
  - `is_zig_reserved(word)` — predicate
  - `zig_reserved_workaround(word)` — cartridge convention table
    (`error → err` is the verified case; generic `<name>_` fallback
    for future cartridges that pick a different rename)
  - `zig_variant_candidates(idris_name)` — returns the snake_case form,
    plus the workaround when the snake_case is reserved
- `verify.rs`:
  - enum-variant lookup tries every candidate; first match wins
  - `manifest_keys` records every candidate so the accept-by-omission
    check doesn't flag a Zig variant the manifest legitimately covers
  - transition-table resolution uses candidates symmetrically (so
    `Error → SomeState` in the manifest matches `err → some_state`
    in the Zig switch)
  - finding messages now name every candidate tried, not just the
    snake_case form

## Verified

- 43 lib tests green (was 39; +4 new in `manifest_schema::tests`)
- `airtable-mcp` was DRIFT (Error→err false-positive), is now CLEAN
- `postgresql-mcp` now passes the reserved-word check; remaining drift
  is a separate naming-convention issue (`BeginTransaction → begin_tx`,
  abbreviation, not reserved-word — out of scope for this PR)
- `ssg-mcp`, `k9iser-mcp` unchanged (still clean)
- `007-mcp` still DRIFT (`ToolRisk` missing in Zig — that's a real
  cartridge defect, not a verifier defect, will be fixed separately)

## Note on `type`

`type` is a Zig **primitive** (alongside `bool`, `u32`, etc.), not a
reserved keyword — it's a legal identifier in enum contexts. Explicit
test pinning this so a future reader doesn't add it to the reserved
list by mistake.

Refs hyperpolymath/standards#92
Refs hyperpolymath/standards#89

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

Closing as superseded. Branch tip (feat(abi-verify): teach the converter Zig reserved words (standards#92 follow-up)) was already merged via #15. Re-diff vs current main shows merging this branch would delete ~1867 lines of subsequently-merged work.

@hyperpolymath hyperpolymath deleted the feat/zig-reserved-word-converter branch May 21, 2026 07:02
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