Skip to content

fix(abi): pin the coprocessor kind tags on the Rust side and tie them in CI - #521

Merged
hyperpolymath merged 4 commits into
mainfrom
claude/new-session-th4e9w-coproc-tags
Nov 17, 2026
Merged

hyperpolymath merged 4 commits into
mainfrom
claude/new-session-th4e9w-coproc-tags

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

This follows up on #512 (and the #511 batch). Coprocessor.Foreign maps each CoprocessorKind to a u8 tag from 0 to 15. The Rust enum in src/rust/coprocessor/types.rs had 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

  • Rust CoprocessorKind: now #[repr(u8)] with explicit discriminants 0 to 15. Nothing in Rust casts the kind today, so behaviour does not change.
  • New scripts/ci/check-coprocessor-tags.sh: compares the Rust and Idris lists as Name=tag pairs. 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 to main, it also runs when types.rs or the script changes.
  • Coprocessor/Foreign.idr:
    • The header said "Phase 0 declares the Math kind only". It now says the module declares all sixteen kinds.
    • The tag doc comment no longer says Rust has no discriminants.

RSR Quality Checklist

Required

  • Tests pass: the check passes on the tree and fails on both broken copies (see Testing).
  • Code is formatted: cargo fmt --all -- --check passes.
  • Linter is clean: cargo check --locked --lib passes. Clippy and actionlint were not run in this session; CI runs both.
  • No banned language patterns
  • No unsafe blocks without // SAFETY: comments
  • No banned functions
  • SPDX license headers present on all new files
  • No secrets, credentials, or .env files included

As Applicable

  • ABI/FFI changes validated: the Rust and Idris tags agree, and the check enforces it.

Testing

  • bash scripts/ci/check-coprocessor-tags.sh on the tree prints coprocessor tags agree: 16 kinds and exits 0.
  • Copy with the Idris tag for Gap changed to 13: the script prints ::error … disagrees, shows the diff rust Gap=14 / idris Gap=13, and exits 1.
  • Copy with the Rust variant Gap left without a discriminant: the script prints ::error … variants without an explicit discriminant and exits 1.

Generated by Claude Code

… 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
Repository owner deleted a comment from coderabbitai Bot Nov 17, 2026
@hyperpolymath
hyperpolymath marked this pull request as ready for review November 17, 2026 00:51
@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 17, 2026 00:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T00:58:44.605293Z 566bd98 New commits
🔒 Security Review ❌ Failed 2026-11-17T00:57:12.063428Z
We couldn’t complete this review. Comment @codex security review to try again.
566bd98 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 253a532a-cb23-4dff-b455-ac204c1e5a87
Commits

Reviewing files that changed from the base of the PR and between d70fc7b and 566bd98.

Files selected for processing: 4

  • .github/workflows/idris2-abi-ci.yml
  • scripts/ci/check-coprocessor-tags.sh
  • src/abi/Coprocessor/Foreign.idr
  • src/rust/coprocessor/types.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/ci/check-coprocessor-tags.sh Resolved
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
@chatgpt-codex-connector

Copy link
Copy Markdown

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
@chatgpt-codex-connector

Copy link
Copy Markdown

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.

@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit db175ce into main Nov 17, 2026
78 checks passed
@hyperpolymath
hyperpolymath deleted the claude/new-session-th4e9w-coproc-tags branch November 17, 2026 01:10
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.

3 participants