Skip to content

Migrate commit validator to Rust#48

Draft
sebastien-boulle wants to merge 22 commits into
masterfrom
feat/rust-migration
Draft

Migrate commit validator to Rust#48
sebastien-boulle wants to merge 22 commits into
masterfrom
feat/rust-migration

Conversation

@sebastien-boulle

Copy link
Copy Markdown
Contributor

Summary

Migrates the commit-message validator from bash to a single Rust binary (commit-message-validator), as designed in docs/superpowers/specs/2026-07-03-rust-migration-design.md.

Behavior-compatible port: identical validation rules and exit codes (Structure=1 … Revert=10), same env var names (COMMIT_VALIDATOR_*, GLOBAL_*) with empty/unset → off/default, same defaults (header 100, body 100, jira types feat fix). The .bats suites were ported to Rust as the golden reference.

Architecture

  • Pure library core (no I/O): config, error, patterns, parser (state machine), validate (rules), preprocess.
  • Thin clap CLI (main.rs) with two subcommands:
    • commit-message-validator message <FILE> — commit-msg hook (replaces check_message.sh)
    • commit-message-validator range <REV_RANGE> — CI / pre-push (replaces check.sh)
  • Git accessed via subprocess (keeps the binary tiny and musl-static-friendly).
  • Flags unified with env fallback (flag wins, then env, then default).

Distribution

  • CI (.github/workflows/ci.yml): fmt + clippy -D warnings + test + cargo llvm-cov (hard-fails < 90%; currently 97.82%).
  • Release (.github/workflows/release.yml): on v* tags, builds static binaries for {x86_64,aarch64}-{unknown-linux-musl,apple-darwin} and attaches them to the release.
  • Composite Action (action.yml): downloads the matching prebuilt binary and runs range.
  • pre-commit / pre-push: hooks/commit-message-validator shim downloads/caches the binary.
  • Old bash scripts and .bats tests removed; README updated.

Testing

74 tests (unit + assert_cmd CLI integration against temp git repos). Built strictly TDD; each commit is atomic and independently green.

Review process

Built via subagent-driven development: a fresh implementer + spec/quality reviewer per task, plus a final whole-branch review. The final review confirmed behavioral equivalence with the bash original (and noted it even fixes two latent bash bugs: cross-commit global state leakage in ranges, and NO_REVERT_SHA1 aborting the whole range). Two cross-cutting bugs it found were fixed in b2e3616 (preprocess trailing-newline rejection of normal commit-msg files; download shim defaulting to a nonexistent master release).

Known follow-ups (draft — not blocking review, flagging for decision)

  • Cut a v2.x release with the Rust binary assets before switching consumers over — the pre-commit/pre-push/Action integrations need published assets to work end-to-end (CI validates the code meanwhile). The shim now defaults to releases/latest.
  • Checksum/signature verification of the downloaded binary (Action + shims) is not yet implemented — currently relies on TLS. Suggest publishing + verifying SHA256SUMS.
  • Behavior note: the message path now honors ambient env vars (bash check_message.sh explicitly unset them). Intentional per the unified flag/env design; called out in case local-shell env should be ignored for local commits.
  • Minor: README still has older per-integration option lists that partially duplicate the new unified options table.

See docs/superpowers/plans/2026-07-03-rust-migration.md for the full implementation plan.

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