Skip to content

test(cli-pr-monitor): cross-module overflow safety + 2100 baseline (順位 76+77 / §A-2 P-4)#128

Merged
aloekun merged 2 commits into
masterfrom
feature/p4-overflow-safety
May 7, 2026
Merged

test(cli-pr-monitor): cross-module overflow safety + 2100 baseline (順位 76+77 / §A-2 P-4)#128
aloekun merged 2 commits into
masterfrom
feature/p4-overflow-safety

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 7, 2026

Summary

Changes

src/cli-pr-monitor/src/config.rs

順位 76: 4 新 cross-module integration tests + 1 negative test:

Test Assertion
cross_module_overflow_safety_at_max_boundary sanitize 後の MAX_SAFE_WAIT_SECSfinalize_initial_review_park / schedule_next_review_recheck_park 両 cast point で overflow しない
cross_module_overflow_safety_with_zero_input_uses_default 0 入力 → sanitize で default 300s に置換 → 加算 safe
cross_module_overflow_safety_with_u64_max_input_uses_default u64::MAX 入力 → sanitize で default 300s に置換 → 加算 safe
cross_module_overflow_safety_negative_test_large_unsanitized_value_overflows i64::MAX as u64 を直接 cast すると positive overflow (sanitize の必要性裏付け、PR #115 CR Major #2 再現)
cross_module_overflow_safety_negative_test_u64_max_wraps_to_minus_one u64::MAX as i64 = -1 で silent corruption (過去時刻にずれる、sanitize で防止)

順位 77: 既存 review_recheck_sanitize_max_safe_boundary test を year 2100 baseline (now_unix = 4.1e9) で extend:

let now_unix_2100: i64 = 4_100_000_000;
let safe_sum_2100 = now_unix_2100.checked_add(cfg_at_limit.initial_review_wait_secs as i64);
assert!(safe_sum_2100.is_some(), "year 2100 baseline でも overflow しない (順位 77: future-proof)");
assert!(safe_sum_2100.unwrap() < i64::MAX, "year 2100 baseline で safety margin が残る");

MAX_SAFE_WAIT_SECS 定数 doc 追記:

Future-proof 根拠 (順位 77): year 2100 baseline (now_unix ~ 4.1e9) でも 4.1e9 + 3.15e7 = 4.13e9 << i64::MAX (9.22e18) で safety margin が約 9 桁 (2.2e9 倍) ある。

docs/local-llm-offload-analysis.md (§A-2 計測ログ)

P-3 (PR #127) outcome 記録:

P-3 (順位 7): PR #127, merged 2026-05-08, findings: rate-limit blocked (CR が 27 min wait の rate-limit overlay で formal review 投稿不可)、classifier 未起動、計測 N/A — dogfood 不発 (但し CR rate-limit 経路が dogfood の阻害要因として観測された、§A-2 §6 注意事項 #1 を実証)

docs/todo.md / docs/todo5.md

順位 76 + 77 の row + 詳細エントリを削除 (memory: feedback_todo_no_history)。別 commit (docs(todo): 順位 76 + 77 ... 完了に伴い削除) で分離。

§A-2 dogfood 進捗 (P-1〜P-3 集計)

P PR findings classifier 起動 agreement latency fallback 備考
P-0 #123 smoke test 1 件 ✅ 1/1 妥当 enabled=true land
P-1 #125 0 (CR APPROVE) ❌ 未起動 N/A N/A N/A findings ゼロで dogfood 不発
P-2 #126 1 Nitpick (review body 内、check-ci-coderabbit 抽出漏れ) 手動 synthetic 1/1 (100%) 6.4s/件 (>5s) 1/1 (length contract) review body 経路 gap が判明
P-3 #127 rate-limit blocked ❌ 未起動 N/A N/A N/A CR 27min wait が dogfood blocker

観察: 3 PR 中 1 PR のみで classifier データ取得 (P-2)。dogfood 阻害要因が複数 (findings ゼロ / review body 抽出漏れ / rate-limit) で、§A-2 設計時の想定 (各 PR で中 3-5 件 findings) と乖離。残り P-4 (本 PR) / P-5 で classifier データ追加取得を試みるが、N=5 PR で agreement rate / latency の統計的有意性は限定的。

Test plan

  • cargo test -p cli-pr-monitor cross_module_overflow_safety — 5/5 pass
  • cargo test -p cli-pr-monitor review_recheck_sanitize_max_safe_boundary — 1/1 pass (extended)
  • cargo test -p cli-pr-monitor — 168 active passed (regression なし)
  • (post-merge) classifier 起動確認 + §A-2 P-4 計測ログ記録
  • 派生プロジェクト deploy: 影響なし (test only + doc コメント、release exe 変更なし)

関連

Summary by CodeRabbit

  • Documentation

    • ローカルLLMの活用領域と実装提案、運用ガイドラインを詳細に記述
    • タスク管理ドキュメントを統合・再構成
  • Tests

    • タイムスタンプ演算の境界値テストケースを追加し、安全性検証を強化

aloekun added 2 commits May 8, 2026 00:25
…§A-2 P-3 ledger (順位 76+77 / §A-2 P-4)

§A-2 Phase 5 dogfood P-4 (Bb-3 follow-up)。PR #115 で実証された
unit test isolation 起因の cross-module overflow 自己矛盾 (config layer の
sanitize テストが downstream poll arithmetic の overflow safety を verify
していなかった) を統合テストで machine-enforce。

順位 76 (Tier 2, T2-1):
- 4 cross-module integration tests を config.rs test module に追加
  - cross_module_overflow_safety_at_max_boundary (sanitize 後の
    MAX_SAFE_WAIT_SECS が finalize_initial_review_park / schedule_next_*
    両経路で overflow しないことを assert)
  - cross_module_overflow_safety_with_zero_input_uses_default (0 → default 300s)
  - cross_module_overflow_safety_with_u64_max_input_uses_default (u64::MAX → default 300s)
  - cross_module_overflow_safety_negative_test_large_unsanitized_value_overflows
    (i64::MAX as u64 を直接 cast すると positive overflow、sanitize の必要性裏付け)
  - cross_module_overflow_safety_negative_test_u64_max_wraps_to_minus_one
    (u64::MAX as i64 = -1 で silent corruption (過去時刻)、sanitize で防止)

順位 77 (Tier 2, T2-2):
- 既存 review_recheck_sanitize_max_safe_boundary テストを year 2100 baseline
  (now_unix = 4.1e9) でも overflow しないことを assert する形に拡張
- MAX_SAFE_WAIT_SECS 定数 doc に future-proof 根拠を追記
  (year 2100 baseline で safety margin が 9 桁残ることを明文化)

§A-2 計測ログ P-3 結果記録:
- P-3 (PR #127): rate-limit blocked (CR が 27 min wait の rate-limit overlay で
  formal review 投稿不可)、classifier 未起動、計測 N/A — dogfood 不発。但し
  CR rate-limit 経路が dogfood の阻害要因として観測 (§A-2 §6 注意事項 #1 を実証)。

テスト 168 active passed (順位 76 系 5 件追加)、regression なし。
deployed exe には影響なし (test only + doc コメント)。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

本 PR は、Ollama を活用したローカル LLM オフロード領域の構想から Phase 5 dogfood 検証まで、統合された検証フレームワークを定義します。3 層アーキテクチャの分析、ADR-038 統合状況、測定基準、運用手順、タイムスタンプ安全性の強化検証、および follow-up タスク整理を含みます。

Changes

ローカルLLMオフロード検証統合

Layer / File(s) Summary
分析と3層設計
docs/local-llm-offload-analysis.md
セッション分析に基づくローカル LLM オフロード領域の背景、3 層構造(思考層/実行層/制御層)の設計指針、Ollama 候補(mistral:7b 常駐/llama2 on-demand)を整理。
実装提案と制約
docs/local-llm-offload-analysis.md
最小工数順による 3 つの統合案(takt facet、cli-pr-monitor サブコマンド、prepare-pr skill)と期待効果、技術的制約、適用しない領域。
統合進捗と既知課題
docs/local-llm-offload-analysis.md
提案2(cli-finding-classifier)の ADR-038 land 完了、新 crate/バイナリ/スクリプト統合、検証時の既知課題(prompt injection、JSON エラー分類、monitor edge case)。
Phase 5 ステータス更新
docs/local-llm-offload-analysis.md
PR#120・PR#121 による Phase 5 と Finding C strict 化の時系列記録、Bundle f/g タスク登録、効果実測の現状。
採用基準と優先度付き将来作業
docs/local-llm-offload-analysis.md
agreement rate ≥80%・token 削減 ≥10% 等の採用/却下判定基準、prompt v2・lint screen facet・PR body draft を優先度・依存関係付きで列挙。
検証手順と計測テンプレート
docs/local-llm-offload-analysis.md
Phase 5 dogfood(P-0〜P-5)のセットアップ・計測手順、classified_findings 取得/評価/集計の流れ、計測ログ記録テンプレート、既知注意事項(rate-limit・wakeup edge case・Ollama 不安定)。
運用戦略と安全措置
docs/local-llm-offload-analysis.md
ブランチ分離運用(master で既存実装、feature/local-llm-dogfood で新実装隔離)、再開チェックリスト、グローバル設定バックアップ規約、kill-switch 削除手順。
タイムスタンプ安全性検証
src/cli-pr-monitor/src/config.rs
wait_secs 境界検証を強化:年 2100 基準での future-proof 上限根拠の文書化、initial_review_wait_secs と review_recheck_wait_secs の max 境界での overflow 安全性検証、zero・u64::MAX 入力時の default 代替パス確認、unsanitized 極値 cast による overflow/wrap リスクの negative test 追加。
follow-up タスク整理
docs/todo.md, docs/todo5.md
docs/todo.md で旧タスク 2 件を削除・統合し ADR-038 + CLAUDE.md security 拡充と docs-governance 要件強化タスクに編成。docs/todo5.md で PR#115 以降の Tier 2/3 follow-up(cross-module overflow 検証、rate-limit/transient failure auto-retry、状態遷移ガード、運用ルール codify)を時系列で整理。

🎯 2 (Simple) | ⏱️ ~12 分

Possibly related PRs

🚥 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 The PR title accurately reflects the main changes: cross-module overflow safety tests and year-2100 baseline extension, with clear reference to task ordering (順位 76+77).
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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/cli-pr-monitor/src/config.rs (1)

600-629: 💤 Low value

cross_module_* という命名は誤誘導 — 実体は sanitize 後の i64 加算 invariant の単体テスト。

このテスト群は名前と doc コメントで finalize_initial_review_park / schedule_next_review_recheck_park を参照していますが、実際には poll.rs の関数を invoke しておらず、now_unix + cfg.*_wait_secs as i64 という算術を config.rs 側で再現しているだけです。poll.rs 側の cast 箇所が将来的にリファクタされても、このテストは検知できません。

加えて、cross_module_overflow_safety_at_max_boundary は直前の review_recheck_sanitize_max_safe_boundary (586-598 拡張後) とセットアップ・境界値・加算チェックがほぼ重複しており、唯一の固有資産は「両 park フィールドを個別に assert」「> now_unix で過去巻き戻り防止を assert」の 2 点です。

提案 (任意): いずれか一方が望ましい:

  • A) 名称を sanitize_park_arithmetic_invariant_* 等の実態に合わせたものに改め、review_recheck_sanitize_max_safe_boundary と統合 or 後者に > now_unix invariant を取り込む。
  • B) 真に cross-module を担保するなら、poll.rs の finalize_initial_review_park / schedule_next_review_recheck_park 由来のヘルパ (cast 部分) を pub(crate) で抽出し、ここからそれを呼ぶ形にする。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli-pr-monitor/src/config.rs` around lines 600 - 629, The test
cross_module_overflow_safety_at_max_boundary in config.rs is misnamed and
duplicates logic from review_recheck_sanitize_max_safe_boundary while not
actually exercising poll.rs (functions finalize_initial_review_park /
schedule_next_review_recheck_park); fix by either: A) rename the test to reflect
it only validates sanitize-time arithmetic (e.g.,
sanitize_park_arithmetic_invariant_*) and merge its unique > now_unix assertions
into review_recheck_sanitize_max_safe_boundary to remove duplication, or B) make
it genuinely cross-module by extracting the cast/arithmetic helper from poll.rs
(the code paths used by finalize_initial_review_park and
schedule_next_review_recheck_park) as a pub(crate) helper and call that helper
from this test so the test exercises the same logic as poll.rs; update test name
accordingly and keep/assert both park fields and the > now_unix invariants.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/cli-pr-monitor/src/config.rs`:
- Around line 600-629: The test cross_module_overflow_safety_at_max_boundary in
config.rs is misnamed and duplicates logic from
review_recheck_sanitize_max_safe_boundary while not actually exercising poll.rs
(functions finalize_initial_review_park / schedule_next_review_recheck_park);
fix by either: A) rename the test to reflect it only validates sanitize-time
arithmetic (e.g., sanitize_park_arithmetic_invariant_*) and merge its unique >
now_unix assertions into review_recheck_sanitize_max_safe_boundary to remove
duplication, or B) make it genuinely cross-module by extracting the
cast/arithmetic helper from poll.rs (the code paths used by
finalize_initial_review_park and schedule_next_review_recheck_park) as a
pub(crate) helper and call that helper from this test so the test exercises the
same logic as poll.rs; update test name accordingly and keep/assert both park
fields and the > now_unix invariants.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8c2e540-a313-43f5-b069-2c1f47bd642d

📥 Commits

Reviewing files that changed from the base of the PR and between 205a689 and 20beea5.

📒 Files selected for processing (4)
  • docs/local-llm-offload-analysis.md
  • docs/todo.md
  • docs/todo5.md
  • src/cli-pr-monitor/src/config.rs
💤 Files with no reviewable changes (2)
  • docs/todo.md
  • docs/todo5.md

@aloekun aloekun merged commit 95c754a into master May 7, 2026
1 check passed
@aloekun aloekun deleted the feature/p4-overflow-safety branch May 7, 2026 15:41
aloekun added a commit that referenced this pull request May 7, 2026
…ailure 明文化 (順位 80+82 / §A-2 P-5) (#129)

* feat(cli-pr-monitor): rate-limit Posted 経路で park 予約 (順位 80) + ADR-018 transient failure 明文化 (順位 82) + §A-2 P-4 ledger (§A-2 P-5)

§A-2 Phase 5 dogfood P-5 (Bundle f-1 partial)。PR #120 で観測された rate-limit
auto-retry の silent exit (RateLimitOutcome::Posted → polling 継続 → max_duration
timeout) を構造的に解消。

順位 80 (Tier 1, T1-1) — finalize_posted_retrigger に park 予約を追加:
- Before: 投稿後 write_state → None 返し → polling 継続 → timeout で silent exit
- After: 投稿後 state.action = parked_review_recheck + next_wakeup_at_unix =
  now + review_recheck_wait_secs を設定 + format_park_signal で PARK 出力 →
  Some(park_poll_result) で必ず terminal を返す
- handle_rate_limit_branch / dispatch_rate_limit_outcome /
  finalize_posted_retrigger 各関数に review_recheck_wait_secs 引数を thread
- 2 unit tests 追加 (success 経路 + write_state 失敗 action_required 経路)

順位 82 (Tier 3, T3-2) — ADR-018 に追記:
- 対象 transient failure pattern を表形式で 4 種列挙
  (rate-limit 待機型/即時型 + CR 投稿エラー + wakeup 未予約 fallback)
- 順位 80 fix の実装ポイント (Before/After) を明文化
- 順位 81 (CR 投稿エラー) を defer した理由を 3 観測閾値ルールで説明

順位 81 (Bundle f-1 残部、Tier 1 T1-2):
- 1 観測のみ (PR #120) で systemic 性未確認のため defer
- 同型 error が 2 件以上観測されたら再活性化 (re-trigger 条件を ADR-018 で規定)
- 本セッションのユーザー方針 feedback_no_unenforced_rules と整合

§A-2 計測ログ P-4 結果記録:
- P-4 (PR #128): 1 finding (CR Nitpick: cross_module_* 命名 misleading)
  - classifier: action=human_review / confidence=0.9 (P-2 の 0.0 から大幅改善)
  - normalized_issue: Japanese 50 chars (length contract pass)
  - latency: 6.6s/件、fallback: 0/1 (P-2 の 1/1 から改善)
  - agreement: 1/1 (100%、私評価=human_review と一致)

170 active tests pass (新 2 件追加)、regression なし。
build + deploy 済 (.claude/cli-pr-monitor.exe)。

* docs(todo): 順位 80 + 82 (rate-limit park 予約 + ADR-018 update) 完了に伴い削除 + 順位 81 defer 注記
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