Skip to content

feat(lint): Bundle l (順位 129/131/132) — rule⑩ + diff metadata strip#159

Merged
aloekun merged 1 commit into
masterfrom
bundle-l
May 17, 2026
Merged

feat(lint): Bundle l (順位 129/131/132) — rule⑩ + diff metadata strip#159
aloekun merged 1 commit into
masterfrom
bundle-l

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 17, 2026

Summary

  • let _ = write_* swallowed error 検出 custom lint rule (rule⑩、no-write-result-discard) を .claude/custom-lint-rules.toml に追加 (順位 129)
  • cli-push-runner lint-screen stage に git diff metadata 行 (similarity index NN% / index <hex> / file mode / rename) の前処理 strip を追加し、mistral:7b magic-number FP を構造的に解消 (順位 132、順位 130 を supersede)
  • write_skip_report_logged の error path に regression test 3 件を追加し silent drop への回帰を機械検出 (順位 131)
  • 既存 codebase の 5 件の let _ = write_* violations を if let Err(e) = ... { log_*(...) } 形式に置換 (cli-pr-monitor poll.rs ×3 + cli-merge-pipeline feedback.rs ×2)、rule⑩ の clean baseline を確立
  • hooks-post-tool-linter に rule⑩ 検証 test を 8 件追加 (positive ×3 / negative ×4 / dogfood scan ×1)、todo-summary.md / todo8.md から 4 entries を整理

Context

Why: PR #155-#156 の lint-screen self-dogfood で 2 つの構造的問題が観測された:

  1. write_skip_report の Result を let _ = で silent drop していた anti-pattern (BLOCKING 指摘で fix 済だが、再発防止層なし)
  2. mistral:7b が similarity index 100%100% を magic-number として FP 検出 (file rename 含む PR で必ず出現するため Frequency Medium)

Trigger: PR #155 post-merge-feedback (順位 129/131) + PR #156 post-merge-feedback (順位 132)。順位 130 (PR #155 由来) は順位 132 と root cause 同一のため本 PR で supersede + 削除。

Scope decision: 順位 129 は本来「rule 追加のみ」(Adoption Risk None) を想定していたが、現実の codebase に 5 件の既存違反 (poll.rs ×3 / feedback.rs ×2) があり、completeness criteria (deployed_src_rust_passes_no_write_result_discard_rule で baseline 0 件強制) を満たすため fix を同 PR に bundle。silent failure を log 化することで観測可能性も同時に回復するため、scope expansion が justified。write_pending_marker_logged helper の抽出は fn run の 50 行ガイドライン超過回避が motivation で、lint_screen.rs の write_skip_report_logged と同 pattern。

Validation

  • cargo test 全 workspace pass (主要: hooks-post-tool-linter 119 pass / cli-push-runner 43 pass / cli-pr-monitor 170 pass / cli-merge-pipeline 89 pass)
  • pnpm build:all 成功 (cli-push-runner / cli-merge-pipeline / check-ci-coderabbit / cli-finding-classifier の release ビルド + .claude/ deploy)
  • cargo clippy --all-targets -- -D warnings clean (変更 3 crates: cli-push-runner / hooks-post-tool-linter / cli-pr-monitor)
  • pnpm push pre-push-review: verdict=all("approved")、1 iteration / 8m 4s で convergence (takt fix 起動なし)
  • Diff stats: 9 files, +473 / -154 (net ~320 lines、CLAUDE.md 250-800 lines/PR guideline 内)

References

Summary by CodeRabbit

リリースノート

  • テスト

    • I/O 書込操作のエラー処理に関する包括的なテストを追加し、コード品質を向上させました。
  • 改善

    • ファイル書込の失敗をログに記録するようにしました。これまでサイレントに失敗していた処理について、エラー情報がより可視化されるようになります。
    • カスタムリントルールを強化し、不適切なエラー処理パターンの検出精度を向上させました。
  • ドキュメント

    • 参照更新時の確認手順を改善しました。

Review Change Stack

… diff metadata strip + silent failure baseline cleanup

Bundle l 3 サブ変更を bundled で land (順位 129 + 131 + 132、todo-summary.md table 4 行整理含む)。
共通テーマ: cli-push-runner lint-screen stage の堅牢化 + I/O write 関数の silent failure 構造的防止。

順位 132 (Tier 1 / S): cli-push-runner/src/stages/lint_screen.rs に strip_diff_metadata_lines
前処理関数を追加し、similarity index NN% / index <hex> / file mode / rename 系の
diff metadata 行を LLM 入力前に決定論的に除去。PR #155-#156 で 5 観測された mistral:7b の
magic-number FP を構造的に解消。unit test 7 件 (各 metadata 系列 + content 保持 + substring 誤検出回避)。
順位 130 (prompt 改修 or 前処理 filter のいずれか) を本実装で前処理 filter に確定して supersede、
table から 130 行も削除。

順位 129 (Tier 1 / S): .claude/custom-lint-rules.toml に rule⑩ (no-write-result-discard、
pattern let\s+_\s*=\s+write_\w+\(、extensions=["rs"]、severity=error) を追加。
hooks-post-tool-linter に 8 件 unit test を追加 (positive x3 / negative x4 / dogfood x1)。
dogfood test (deployed_src_rust_passes_no_write_result_discard_rule) は src/**/*.rs を再帰走査して
clean baseline を強制。本 PR の completeness criteria に合わせて既存違反 5 件を fix:
  - cli-pr-monitor/src/stages/poll.rs: 3 箇所の let _ = write_state(...) を
    if let Err(e) = ... { log_info(...) } に置換 (非 fatal 進行 + 観測可能性回復)
  - cli-merge-pipeline/src/feedback.rs: FailedMarkerGuard::drop 内の write_failed_marker と
    feedback::run の write_pending_marker を log 化、後者は write_pending_marker_logged helper
    に抽出して fn run の 50 行ガイドライン超過を回避 (lint_screen.rs の write_skip_report_logged と同 pattern)

順位 131 (Tier 2 / M): write_skip_report_logged の error path regression test を 3 件追加。
parent が regular file な path に書込を試みて create_dir_all 失敗を確定的に誘発する方式 (Unix/Windows
両方で reliable、追加 dep 不要)。write_skip_report の Err 返却 + write_skip_report_logged の
no-panic + writable path success の 3 段で seal、将来 refactor での silent drop 回帰を機械検出。

副次: src/cli-push-runner/Cargo.toml に tempfile dev-dep を追加 (順位 131 test 用)、
todo8.md から 129/130/131/132 detail entry を削除 (Cross-File Reference Lifecycle 整合)。

検証: cargo test 全 workspace pass / pnpm build:all 成功 / 変更 crate 3 つ
(cli-push-runner / hooks-post-tool-linter / cli-pr-monitor) で cargo clippy --all-targets -- -D warnings clean。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af126182-8d38-44ff-af51-9f5817afa9ed

📥 Commits

Reviewing files that changed from the base of the PR and between c378816 and 788d7c9.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .claude/custom-lint-rules.toml
  • docs/todo-summary.md
  • docs/todo8.md
  • src/cli-merge-pipeline/src/feedback.rs
  • src/cli-pr-monitor/src/stages/poll.rs
  • src/cli-push-runner/Cargo.toml
  • src/cli-push-runner/src/stages/lint_screen.rs
  • src/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (2)
  • docs/todo-summary.md
  • docs/todo8.md

📝 Walkthrough

Walkthrough

Rust コードで I/O 書き込み関数の Result を無視する let _ = write_* パターンを禁止するカスタムリントルール「no-write-result-discard」を定義し、既存実装での Result 無視を除去して stderr ログ出力に統一、加えて git diff metadata 行除去処理の実装とテスト検証を追加。

Changes

Write 関数 Result 無視検出と改善

Layer / File(s) Summary
カスタムリントルール定義と検証テスト
.claude/custom-lint-rules.toml, src/hooks-post-tool-linter/src/main.rs
Rust ファイルで let _ = write_*( パターンを検出するルール「no-write-result-discard」を定義し、ルール動作(破棄検出・非検出ケース)、ファイル拡張子制約、およびリポジトリ全体 Rust ファイルの違反がないことを検証するテスト群を追加。
フィードバック・ポーリング - Result 失敗時ログ出力
src/cli-merge-pipeline/src/feedback.rs, src/cli-pr-monitor/src/stages/poll.rs
pending marker / failed marker / state 永続化の Result 失敗を silent にせず、stderr またはログで報告する関数追加と実装変更。feedback.rs に write_pending_marker_logged 追加、Drop 内エラーログ化;poll.rs の build_state / enrich_with_classifier / finalize_review_recheck_max_reached で state 永続化失敗をログ出力に統一。
Lint スクリーン - git diff Metadata 除去と Skip Report テスト
src/cli-push-runner/src/stages/lint_screen.rs, src/cli-push-runner/Cargo.toml
git diff metadata 行(similarity/dissimilarity index、index、file mode、rename/copy)を除去する strip_diff_metadata_lines 実装、差分内容・境界行保持、キーワード部分一致非除外の検証テスト、skip-report 書き込み失敗時エラーハンドリング・ログ動作の検証テスト、および tempfile 開発依存追加。
ドキュメント整理
docs/todo-summary.md, docs/todo8.md
todo-summary.md から完了タスク(順位 129-132)を削除;todo8.md の Retirement Workflow Step 3 に、grep ヒット後は実ファイルを開いて最新内容で参照存在を確認する手順を追記。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#6: カスタムリント エンジン・設定実装の基盤を提供し、このPRが新ルール「no-write-result-discard」を追加実装。
  • aloekun/claude-code-hook-test#155: src/cli-push-runner/src/stages/lint_screen.rsrun_lint_screen 関数、Markdown ハンク除外フィルタ、skip-report / write_skip_report_logged エラー処理が重複する実装領域。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR タイトルは rule⑩ の追加、diff metadata 除外、回帰テスト追加という複数の関連するリント改善をバンドルした本 PR の主要な変更内容を反映しており、実装内容と明確に対応しています。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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