Skip to content

build: deny unwrap, expect, indexing, and unsafe code in production - #18

Merged
furedea merged 3 commits into
mainfrom
build/74-clippy
Nov 10, 2026
Merged

furedea merged 3 commits into
mainfrom
build/74-clippy

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs furedea/agent-config#74

概要

agent-config#74 段階 1B.template-rust の clippy 設定に,agent-harness と同じ deny 規則を入れ,unwrap_used,indexing_slicing,expect_used を追加する.

  • Cargo.toml: [lints.rust] unsafe_code = "forbid",dbg_macro / todo / unimplemented / unwrap_used / indexing_slicing / expect_used を deny(並びは agent-harness と同じ)
  • clippy.toml: allow-unwrap-in-tests,allow-expect-in-tests,allow-indexing-slicing-in-tests を true
  • src/main.rs: 何も検証しないテスト assert!(true) を,挨拶文を返す関数 greeting() の値を検証するテストに置き換えた

違反数

規則 有効化前 有効化後(本番コード)
unwrap_used 0 0
indexing_slicing 0 0
expect_used 0 0
dbg_macro / todo / unimplemented 0 0
unsafe_code 0 0

違反の修正

追加した規則による違反はなく,#[expect] や #[allow],その他の抑制も追加していない.

修正 設計上の理由
assert!(true) を greeting() のテストへ assert!(true) は何も検証せず,cargo clippy --all-targets が assertions_on_constants で失敗していた.テストできる単位(挨拶文)を関数にして,値を検証する

規則の対応表

規則 ID 元の場所 元の規則(原文) 判定 実装 例のテスト 元の文章
clippy::unwrap_used agents/skills/rust-style/references/errors.md:9 no unwrap/expect in production 既存 linter(clippy) Cargo.toml [lints.clippy],clippy.toml 後述の手動確認(本番 deny,テスト許可) 残して併記
clippy::expect_used 同上 同上 既存 linter(clippy) 同上 同上 残して併記
clippy::indexing_slicing agents/skills/rust-style/references/errors.md:15 avoid direct indexing 既存 linter(clippy) 同上 同上 残して併記
clippy::dbg_macro / todo / unimplemented agents/skills/rust-style/references/errors.md:17 no todo!/unimplemented!/debug panic! 既存 linter(clippy) Cargo.toml [lints.clippy] なし(agent-harness と同一設定) 残して併記
rust::unsafe_code (style skill に直接の行なし) agent-harness の設定と揃える 既存 linter(rustc) Cargo.toml [lints.rust] なし 残して併記

検証

nix develop 内で実行した.

  • cargo clippy --all-targets -- -D warnings: 通過
  • cargo clippy -- -D warnings(CI と同じ): 通過
  • cargo fmt --check: 通過
  • cargo test: 1 件通過

規則が効いていることを,一時的に src/main.rs へ unwrap() / expect() / 添字アクセスを本番とテストに書いて確認した(確認後に元へ戻した).

  • 本番コード:unwrap_used,expect_used,indexing_slicing が発火した.
  • #[cfg(test)] 内:この 3 規則は発火しなかった(unnecessary_literal_unwrap と useless_vec は別の規則).

🤖 Generated with Claude Code

Copy agent-harness's dbg_macro, todo, and unimplemented deny and
unsafe_code = "forbid". Add unwrap_used and expect_used (deny) and let
tests use them through clippy.toml. Production code has 0 violations.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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 ❌ Failed 2026-11-10T05:11:41.316653Z
We couldn’t complete this review. Comment @codex review to try again.
62f5cd4 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

I found no blocking issues and posted no inline comments.

  • Cargo.toml: unsafe_code = "forbid" under [lints.rust] and the deny entries under [lints.clippy] are correct. They take precedence over the all/pedantic groups because those groups use priority = -1.
  • clippy.toml: allow-unwrap-in-tests and allow-expect-in-tests are valid keys. The toolchain is new enough because the crate already requires edition 2024.
  • Tests: this PR only changes lint configuration, so no new tests are needed. The manual check described in the PR description is enough.

Findings: P0: 0, P1: 0, P2: 0, P3: 0.

furedea and others added 2 commits November 10, 2026 14:11
Match agent-harness: deny clippy::indexing_slicing and allow it in
tests through clippy.toml. Production code has 0 violations.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
assert!(true) checks nothing and fails clippy --all-targets
(assertions_on_constants). Move the greeting into a function and test
its value.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea-agent furedea-agent Bot changed the title build: deny unwrap, expect, and unsafe code in production build: deny unwrap, expect, indexing, and unsafe code in production Nov 10, 2026
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary: no blocking findings.

  • Cargo.toml: the deny rules (unsafe_code forbid; dbg_macro, todo, unimplemented, unwrap_used, expect_used, indexing_slicing) are set correctly. They are explicit lint levels, so they take precedence over the all/pedantic groups, which have priority -1.
  • clippy.toml: setting the allow-*-in-tests options keeps tests exempt from these rules, as intended.
  • src/main.rs: greeting() replaces the empty assert!(true) test with one that checks a real value. Behavior is unchanged.

P0/P1: 0. No inline comments.

🤖 Generated with Claude Code

@furedea
furedea merged commit 9f36eec into main Nov 10, 2026
16 of 18 checks passed
@furedea
furedea deleted the build/74-clippy branch November 10, 2026 05:55
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