Repository navigation
fix(abi): pin the coprocessor kind tags on the Rust side and tie them in CI - #521
Conversation
… in CI Coprocessor.Foreign maps each CoprocessorKind to a u8 tag (0 to 15). The Rust enum had no discriminants, so those tags matched it only by declaration order. Reordering or inserting a Rust variant would have moved the Rust side silently. - The Rust enum is now `#[repr(u8)]` with explicit discriminants 0 to 15. Nothing in Rust casts the kind today, so behaviour is unchanged (`cargo check --locked --lib` and `cargo fmt --check` pass). - scripts/ci/check-coprocessor-tags.sh compares the two lists as Name=tag pairs. It fails on any difference, on a Rust variant with no explicit discriminant, or when either list is empty. Tested on the tree (16 kinds agree) and on two broken copies: a swapped Idris tag and a bare Rust variant. Both fail with an ::error. The Idris2 ABI workflow runs it on every event, and on pushes to main that touch types.rs. - The header of Coprocessor/Foreign.idr said "Phase 0 declares the Math kind only". It declares sixteen kinds, and the header now says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3
Same tests as before: the tree passes (16 kinds), and the swapped-tag and bare-variant copies both fail with exit 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab2126355a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex (P2): the Rust regex stopped at the first digits, so `Math = 0x10` (Rust tag 16) read as Math=0 and the check reported agreement. The Idris side had the same gap. The script now requires every Rust variant line to read `Name = <decimal>` (trailing comma optional) and every coprocessorKindToU8 clause to read `coprocessorKindToU8 Name = <decimal>`. Any other shape (hex, underscores, an expression, a trailing comment) fails with an ::error that names the line. Tested: the tree passes, as does a copy without the last variant's comma. Each of these fails with exit 1: a swapped Idris tag, a bare Rust variant, `Math = 0x10` in Rust, and `= 0x10` in Idris. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
…4e9w-coproc-tags # Conflicts: # .github/workflows/idris2-abi-ci.yml
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|



Summary
This follows up on #512 (and the #511 batch).
Coprocessor.Foreignmaps eachCoprocessorKindto a u8 tag from 0 to 15. The Rust enum insrc/rust/coprocessor/types.rshad no discriminants. The tags therefore matched Rust only by declaration order, and reordering or inserting a Rust variant would have shifted the Rust side without any error.Changes
CoprocessorKind: now#[repr(u8)]with explicit discriminants 0 to 15. Nothing in Rust casts the kind today, so behaviour does not change.scripts/ci/check-coprocessor-tags.sh: compares the Rust and Idris lists asName=tagpairs. It fails on any difference, on a Rust variant with no explicit discriminant, or when either list is empty.idris2-abi-ci.yml: runs that check on every event. On pushes tomain, it also runs whentypes.rsor the script changes.Coprocessor/Foreign.idr:RSR Quality Checklist
Required
cargo fmt --all -- --checkpasses.cargo check --locked --libpasses. Clippy and actionlint were not run in this session; CI runs both.unsafeblocks without// SAFETY:comments.envfiles includedAs Applicable
Testing
bash scripts/ci/check-coprocessor-tags.shon the tree printscoprocessor tags agree: 16 kindsand exits 0.Gapchanged to 13: the script prints::error … disagrees, shows the diffrust Gap=14/idris Gap=13, and exits 1.Gapleft without a discriminant: the script prints::error … variants without an explicit discriminantand exits 1.Generated by Claude Code