Skip to content

F-028: refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)]#28

Merged
Sephyi merged 1 commit intodevelopmentfrom
audit/f-028-forbid-unsafe-main-refactor
Apr 30, 2026
Merged

F-028: refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)]#28
Sephyi merged 1 commit intodevelopmentfrom
audit/f-028-forbid-unsafe-main-refactor

Conversation

@Sephyi
Copy link
Copy Markdown
Owner

@Sephyi Sephyi commented Apr 22, 2026

Summary

refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)].

Audit context

Closes audit entry F-028 from #3.

Verification

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-targets

Note: one pre-existing test porcelain_exits_within_timeout_with_no_staged_changes is a known macOS cold-start flake that reproduces on unmodified development — unrelated to this change.

The `src/main.rs` binary re-declared `mod app; mod cli; mod config; …`,
which built a second module tree alongside `src/lib.rs`. That second tree
did not inherit the `#![forbid(unsafe_code)]` attribute from `lib.rs`,
leaving the binary half of the crate silently unprotected.

Shrink `main.rs` to a thin entry point that imports from the library
crate (`use commitbee::{App, Cli, error};`) and add
`#![forbid(unsafe_code)]` at its top so both compilation units enforce
the lint. `lib.rs` already declared every module publicly, so no other
file needed updating.

Closes audit entry F-028 from #3.
Copilot AI review requested due to automatic review settings April 22, 2026 19:51
@Sephyi Sephyi added the audit Codebase audit cleanup (issue #3) label Apr 22, 2026
@Sephyi Sephyi self-assigned this Apr 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the CLI binary crate to rely on the library crate (lib.rs) for module structure, and closes the audit gap where #![forbid(unsafe_code)] was enforced in the library but not in the binary crate.

Changes:

  • Add #![forbid(unsafe_code)] to src/main.rs.
  • Remove binary-local mod ... declarations and import App, Cli, and error from the commitbee library crate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sephyi Sephyi merged commit 7ead21f into development Apr 30, 2026
11 of 13 checks passed
@Sephyi Sephyi deleted the audit/f-028-forbid-unsafe-main-refactor branch April 30, 2026 16:16
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

audit Codebase audit cleanup (issue #3)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants