Skip to content

feat(cli-pr-monitor): takt ベースの sequential chain に移行 (Phase 1) - #40

Merged
aloekun merged 1 commit into
masterfrom
feat/pr-monitor-takt-phase1
Apr 15, 2026
Merged

feat(cli-pr-monitor): takt ベースの sequential chain に移行 (Phase 1)#40
aloekun merged 1 commit into
masterfrom
feat/pr-monitor-takt-phase1

Conversation

@aloekun

@aloekun aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary\

\

  • daemon spawn + CronCreate を廃止し、in-process ポーリング + takt 分析の sequential chain に移行\
  • ADR-015 の「機械的ステップは Rust、AI ステップは takt」原則を cli-pr-monitor にも適用\
  • takt はオプショナル (pr-monitor-config.toml に [takt] セクションがなければスキップ)
    \

実行フロー\



\

変更内容\

\

新規\

  • stages/poll.rs: in-process 同期ポーリングループ (daemon.rs の同期版)\
  • stages/collect.rs: .takt/review-comments.json 書き出し\
  • stages/takt.rs: takt ワークフロー呼び出し (push-runner と同パターン)\
  • pr-monitor-config.toml: 専用設定ファイル\
  • .takt/workflows/post-pr-review.yaml: Phase 1 分析ワークフロー\
  • .takt/facets/instructions/analyze-coderabbit.md: 分析用 instruction\
  • ADR-018: cli-pr-monitor takt 移行の決定記録
    \

変更\

  • config.rs: hooks-config.toml から pr-monitor-config.toml ベースに移行\
  • runner.rs: run_cmd_inherit() 追加\
  • stages/monitor.rs: sequential chain に書き換え\
  • main.rs: --daemon フラグ削除\
  • package.json: mark-notified/check-monitor スクリプト削除
    \

削除\

  • stages/daemon.rs: daemon spawn + ポーリングループ
    \

Test plan\

\

  • cargo test -- 全46テストパス\
  • cargo clippy -- -D warnings -- 警告ゼロ\
  • pnpm build:cli-pr-monitor -- release ビルド成功\
  • takt push-runner 経由で push 成功

Summary by CodeRabbit

  • 新機能

    • PR レビュー向けの自動分析ワークフローと Takt 連携を追加しました(分析結果をファイル/標準出力で生成)。
    • pr-monitor の設定ファイルでポーリング間隔や最大監視時間、Takt 実行を指定可能にしました。
  • 変更

    • 監視はデーモンではなくプロセス内のポーリング実行へ移行し、構造化された重大度別レポート(合否判定・推奨アクション含む)を出力します。
    • 空差分時は差分出力を作成せず早期終了するよう改善。
  • 削除

    • 旧デーモン実装と npm スクリプト(mark-notified、check-monitor)を削除しました。
  • ドキュメント

    • 移行方針をまとめた ADR-018 と設定テンプレートを追加しました.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@aloekun has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 33 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 33 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1032aa1-18aa-4f74-afe6-eb0e3bc443ca

📥 Commits

Reviewing files that changed from the base of the PR and between 06fbf10 and dd03968.

📒 Files selected for processing (20)
  • .takt/facets/instructions/analyze-coderabbit.md
  • .takt/workflows/post-pr-review.yaml
  • CLAUDE.md
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • package.json
  • pr-monitor-config.toml
  • scripts/deploy-hooks.ts
  • src/cli-pr-monitor/src/config.rs
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/collect.rs
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • src/cli-pr-monitor/src/stages/daemon.rs
  • src/cli-pr-monitor/src/stages/mod.rs
  • src/cli-pr-monitor/src/stages/monitor.rs
  • src/cli-pr-monitor/src/stages/poll.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/util.rs
  • src/cli-push-runner/src/stages/diff.rs
  • templates/pr-monitor-config.toml
📝 Walkthrough

Walkthrough

cli-pr-monitor をデーモン+CronCreate 方式から、インプロセスの順次実行 takt ベースパイプライン(poll → collect → optional takt → レポート出力)へ移行し、設定を pr-monitor-config.toml に移動。daemon 関連コード・スクリプトを削除し、.takt ワークフローと CodeRabbit 分析 instruction を追加した。

Changes

Cohort / File(s) Summary
Takt ワークフロー & Instruction
\.takt/workflows/post-pr-review.yaml, \.takt/facets/instructions/analyze-coderabbit.md
post-pr-review ワークフロー追加と、.takt/review-comments.json を解析して構造化 Markdown レポートを出力する analyze-coderabbit instruction を追加。
設定ファイルテンプレート / 追加
pr-monitor-config.toml, templates/pr-monitor-config.toml
監視設定を移動・追加(poll_interval 120s / max_duration 600s、takt workflow/task と optional extra_args)。
構成リファクタ
src/cli-pr-monitor/src/config.rs
Configmonitor: MonitorConfig + takt: Option<TaktConfig> に変更。設定読み込み経路を pr-monitor-config.toml に向け、Serde デフォルトと Default 実装を導入。
メイン / ランナー更新
src/cli-pr-monitor/src/main.rs, src/cli-pr-monitor/src/runner.rs
--daemon 実行パス削除。新しい run_cmd_inheritTAKT_TIMEOUT_SECS 定数を追加し、外部コマンド実行のタイムアウト/ログ管理を導入。
ポーリング・収集・takt ステージ追加
src/cli-pr-monitor/src/stages/poll.rs, src/cli-pr-monitor/src/stages/collect.rs, src/cli-pr-monitor/src/stages/takt.rs, src/cli-pr-monitor/src/stages/mod.rs
同期ポーリングループ(run_poll_loop, PollResult)を追加。findings を .takt/review-comments.json に書き出す collect_findings を追加。takt を呼ぶ run_takt を追加。daemon モジュール削除。
監視フロー & PR 作成連携
src/cli-pr-monitor/src/stages/monitor.rs, src/cli-pr-monitor/src/stages/create_pr.rs, src/cli-pr-monitor/src/util.rs
start_monitoring をインプロセスパイプラインに切替え(シグネチャ更新)。PrInfo に push_time フィールド追加。状態ファイル/daemon 指示の削除と stdout レポート出力追加。
デプロイ / スクリプト / ドキュメント
scripts/deploy-hooks.ts, package.json, CLAUDE.md, docs/adr/adr-018-pr-monitor-takt-migration.md, templates/pr-monitor-config.toml
deploy スクリプトに pr-monitor-config.toml チェック追加。mark-notified / check-monitor npm スクリプト削除。ADR-018 を追加しアーキテクチャ変更を文書化。
その他モジュール修正
src/cli-push-runner/src/stages/diff.rs
diff 出力が空の場合はファイルを作成せず早期 return する挙動を追加(テスト追加)。

Sequence Diagram(s)

sequenceDiagram
    participant User as User / PR作成
    participant Main as cli-pr-monitor\n(main)
    participant Monitor as start_monitoring()
    participant Poll as run_poll_loop()
    participant Checker as check-ci-coderabbit.exe
    participant Collect as collect_findings()
    participant Takt as run_takt()
    participant Report as print_report()

    User->>Main: PR 作成でトリガ
    Main->>Monitor: start_monitoring(&pr_info)
    Monitor->>Poll: run_poll_loop(&config, &pr_info)
    
    loop Poll ループ (max_duration)
        Poll->>Checker: 実行(タイムアウト付き)
        Checker-->>Poll: JSON 出力
        Poll->>Poll: JSON 解析・状態更新
        Poll->>Poll: action 判定
        alt 続行
            Poll->>Poll: sleep(poll_interval)
        else 終端
            Poll-->>Monitor: PollResult {action, summary, findings,...}
        end
    end
    
    Monitor->>Collect: collect_findings(&result)
    Collect->>Collect: ディレクトリ作成 -> .takt/review-comments.json 書込
    Collect-->>Monitor: success

    alt takt 設定あり
        Monitor->>Takt: run_takt(&takt_config)
        Takt->>Takt: pnpm exec takt -w <workflow> -t <task> [+extra_args]
        Takt-->>Monitor: success
    end

    Monitor->>Report: print_report(&result)
    Report-->>User: 標準出力へレポート
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • #24 — 元のデーモン + 状態ファイルベースの post-pr-monitor 実装を導入した PR。今回の変更はその実装を削除・置換しているため強く関連。
  • #25 — findings の生成/シリアライズ経路を変更する PR。check-ci-coderabbit の findings モデルと本 PR の collect_findings/.takt 出力が直接連携。
  • #38 — cli-pr-monitor 内の構成・モジュール分割を触る PR。config/main/stages 周りの同一領域に対する変更が重複している。
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、cli-pr-monitorのdaemonベースからtaktベースの順序実行チェーンへの移行という主要な変更を明確に要約している。

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


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli-pr-monitor/src/stages/create_pr.rs (1)

192-216: ⚠️ Potential issue | 🟠 Major

push_time の採取が遅く、初回イベントを取りこぼす可能性があります。

Line 192 で時刻を取ると、gh pr create 完了までに出た CI / CodeRabbit の最初のイベントが push_time より前扱いになります。push_time をポーリングの下限に使うなら、ここは gh pr create 実行前に確定させるべきです。

💡 修正イメージ
+    let push_time = utc_now_iso8601();
     let (success, output) = run_cmd_direct(
         "gh",
         &["pr", "create"],
         &final_args,
         DEFAULT_STEP_TIMEOUT_SECS,
     );
@@
-    let pr_number_from_url = parse_pr_number_from_url(&output);
-    let push_time = utc_now_iso8601();
+    let pr_number_from_url = parse_pr_number_from_url(&output);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli-pr-monitor/src/stages/create_pr.rs` around lines 192 - 216, Capture
push_time (call utc_now_iso8601) before executing the PR creation flow (i.e.,
prior to any gh pr create / run_gh_quiet invocation) and use that value when
constructing PrInfo or assigning info.push_time; specifically, move the
utc_now_iso8601 call out of this block to occur earlier and then replace the
local let push_time usages here with that precomputed variable so
start_monitoring(&pr_info) receives a push_time that predates the first external
events; ensure functions/vars referenced are utc_now_iso8601,
pr_number_from_url, run_gh_quiet, get_pr_info, PrInfo, and start_monitoring.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/adr/adr-018-pr-monitor-takt-migration.md`:
- Around line 30-47: The fenced code block containing the CLI stage diagram (the
block that starts with "cli-pr-monitor.exe --monitor-only" and lists Stage 1..4)
is missing a language tag and triggers MD040; update the opening fence to
include a language (e.g., replace ``` with ```bash or ```text) so the linter
accepts it, leaving the block contents unchanged and keeping the diagram
formatting intact.

In `@src/cli-pr-monitor/src/config.rs`:
- Around line 11-15: The Config struct currently requires monitor causing
parsing to fail when only [takt] is provided; update the monitor field in the
Config struct to use #[serde(default)] so missing monitor falls back to a
default, and ensure MonitorConfig implements or derives Default (e.g., provide a
MonitorConfig::default() implementation) so deserialization can supply
MonitorConfig::default() when the field is absent; modify the Config definition
(the monitor field) and add or derive Default for MonitorConfig accordingly.

In `@src/cli-pr-monitor/src/main.rs`:
- Around line 3-10: モジュールドキュメント(main.rs の先頭コメント)で「takt
分析が常に実行される」ように読める記述があるため、これを実装どおり「任意([takt]
セクションが設定されている場合にのみ実行)」と明確に修正してください。具体的には main.rs のモジュールレベルコメント内の該当行(現在 "takt 分析"
を断定的に書いている箇所)を、「[takt] セクションが設定されている場合のみ takt
分析を実行する」旨に書き換え、テンプレート説明(templates/pr-monitor-config.toml)と整合させてください。変更はドキュメント文字列のみでロジックは触らず、"takt
分析" の説明を条件付きの文言に更新してください。

In `@src/cli-pr-monitor/src/runner.rs`:
- Around line 109-125: The current run_cmd_inherit function blocks forever
because it calls Command::status() directly; change it to spawn the process
(Command::new(...).args(...).stdin(...).stdout(...).stderr(...).spawn()), wait
with a bounded timeout (use a Duration constant or parameter and a
wait-with-timeout helper such as the wait-timeout crate or an async timeout),
and if the wait times out call child.kill() and child.wait() to reap it; update
log messages (in run_cmd_inherit) to report timeout vs. other errors and return
false on timeout or kill, true only when the process exited successfully before
the timeout.

In `@src/cli-pr-monitor/src/stages/collect.rs`:
- Around line 9-16: The saved JSON currently writes only the raw check_output
from PollResult (see collect_findings and the check_output handling), which
breaks the contract expected by the instruction
(.takt/facets/instructions/analyze-coderabbit.md) that requires a wrapper
containing monitor metadata; modify the writer so that instead of persisting
check_output raw, you serialize a wrapper object including fields action,
summary, ci, coderabbit, and findings (populated from PollResult and/or
check_output as appropriate) so downstream code can reliably read those keys;
alternatively, if you intentionally want raw check_output, update the
instruction/schema to match, but prefer adding the wrapper around check_output
to preserve monitor-side metadata consistency (affecting the same logic
referenced around collect_findings and the subsequent 30-38 block).

In `@src/cli-pr-monitor/src/stages/monitor.rs`:
- Around line 33-46: The current has_findings uses poll_result.action ==
"action_required" which triggers takt for CI-only failures; change the condition
so takt only runs when there are actual findings or the action_required signal
came from CodeRabbit (e.g., require poll_result.findings.is_empty() == false OR
(poll_result.action == "action_required" && poll_result.source == "coderabbit")
), then keep the downstream calls to collect_findings(&poll_result) and
run_takt(takt_config) the same; alternatively, if you prefer analysis-side
handling, ensure the analyzer marks CI failures as a FAIL in
poll_result.findings before evaluating has_findings so run_takt only sees true
positives.

In `@src/cli-pr-monitor/src/stages/poll.rs`:
- Around line 111-128: The code replaces state.ci/state.coderabbit with
"skipped" after update_state_from_check_result() but does not recompute
state.action, leaving stale decisions; after applying the skip branches (the
blocks that set CiState and CodeRabbitState when skip_ci/skip_coderabbit are
true), call the same logic that derives the overall action from the current
enabled checks (i.e. re-run the action-derivation performed in
update_state_from_check_result() or extract that into a helper like
derive_action_from_state(state) and use it here), ensuring the recomputation
only considers the enabled checks (ci and coderabbit values) so action reflects
the post-skip state.

---

Outside diff comments:
In `@src/cli-pr-monitor/src/stages/create_pr.rs`:
- Around line 192-216: Capture push_time (call utc_now_iso8601) before executing
the PR creation flow (i.e., prior to any gh pr create / run_gh_quiet invocation)
and use that value when constructing PrInfo or assigning info.push_time;
specifically, move the utc_now_iso8601 call out of this block to occur earlier
and then replace the local let push_time usages here with that precomputed
variable so start_monitoring(&pr_info) receives a push_time that predates the
first external events; ensure functions/vars referenced are utc_now_iso8601,
pr_number_from_url, run_gh_quiet, get_pr_info, PrInfo, and start_monitoring.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10d3967f-ea08-425d-be76-e4a6a4a633d5

📥 Commits

Reviewing files that changed from the base of the PR and between 587eb30 and 6e1ab3f.

📒 Files selected for processing (19)
  • .takt/facets/instructions/analyze-coderabbit.md
  • .takt/workflows/post-pr-review.yaml
  • CLAUDE.md
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • package.json
  • pr-monitor-config.toml
  • scripts/deploy-hooks.ts
  • src/cli-pr-monitor/src/config.rs
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/collect.rs
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • src/cli-pr-monitor/src/stages/daemon.rs
  • src/cli-pr-monitor/src/stages/mod.rs
  • src/cli-pr-monitor/src/stages/monitor.rs
  • src/cli-pr-monitor/src/stages/poll.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/util.rs
  • templates/pr-monitor-config.toml
💤 Files with no reviewable changes (2)
  • package.json
  • src/cli-pr-monitor/src/stages/daemon.rs

Comment thread docs/adr/adr-018-pr-monitor-takt-migration.md Outdated
Comment thread src/cli-pr-monitor/src/config.rs Outdated
Comment thread src/cli-pr-monitor/src/main.rs Outdated
Comment thread src/cli-pr-monitor/src/runner.rs Outdated
Comment thread src/cli-pr-monitor/src/stages/collect.rs Outdated
Comment thread src/cli-pr-monitor/src/stages/monitor.rs
Comment thread src/cli-pr-monitor/src/stages/poll.rs Outdated
@aloekun
aloekun force-pushed the feat/pr-monitor-takt-phase1 branch from 6e1ab3f to 4c0eace Compare April 15, 2026 08:33
@aloekun

aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aloekun

aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

27-37: MonitorConfig::default() と空の [monitor] セクションで挙動が異なります。

MonitorConfig::default() は全フィールドに Some(...) を返しますが、空の [monitor] セクションをパースした場合は全フィールドが None になります(テスト config_defaults_when_empty_monitor の Line 137-138 で確認)。これにより、設定ファイルがない場合と空の [monitor] セクションがある場合で異なるデフォルト値が適用されます。

意図的な設計であれば問題ありませんが、明確にするために MonitorConfig 自体に #[serde(default)] を各フィールドに付けるか、この挙動をドキュメント化することを推奨します。

♻️ 各フィールドにデフォルト値を適用する案
 #[derive(Deserialize, Clone)]
 pub(crate) struct MonitorConfig {
+    #[serde(default = "default_enabled")]
     pub(crate) enabled: Option<bool>,
+    #[serde(default = "default_poll_interval")]
     pub(crate) poll_interval_secs: Option<u64>,
+    #[serde(default = "default_max_duration")]
     pub(crate) max_duration_secs: Option<u64>,
+    #[serde(default = "default_check_ci")]
     pub(crate) check_ci: Option<bool>,
+    #[serde(default = "default_check_coderabbit")]
     pub(crate) check_coderabbit: Option<bool>,
 }
+
+fn default_enabled() -> Option<bool> { Some(true) }
+fn default_poll_interval() -> Option<u64> { Some(DEFAULT_POLL_INTERVAL) }
+fn default_max_duration() -> Option<u64> { Some(DEFAULT_MAX_DURATION) }
+fn default_check_ci() -> Option<bool> { Some(true) }
+fn default_check_coderabbit() -> Option<bool> { Some(true) }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli-pr-monitor/src/config.rs` around lines 27 - 37,
MonitorConfig::default() populates every Option field with Some(...) but when
parsing an empty [monitor] table Serde leaves those fields as None, causing
different defaults depending on presence of the section; to fix make parsing and
programmatic defaults consistent: add serde defaults so parsed empty sections
get the same defaults—apply #[serde(default)] to the MonitorConfig struct or to
each field (e.g., fields like enabled, poll_interval_secs, max_duration_secs,
check_ci, check_coderabbit) and ensure MonitorConfig::default() returns the
desired values, or alternatively document the intended behavior clearly.

67-86: デフォルト Config の作成がエラーパスで重複しています。

Lines 69-72 と Lines 82-85 で同じ Config { monitor: MonitorConfig::default(), takt: None } を構築しています。軽微な重複ですが、将来フィールドが増えた場合のメンテナンス性を考慮すると、ConfigDefault を derive することで簡潔にできます。

♻️ Config に Default を derive する案
-#[derive(Deserialize)]
+#[derive(Deserialize, Default)]
 pub(crate) struct Config {
     #[serde(default)]
     pub(crate) monitor: MonitorConfig,
     pub(crate) takt: Option<TaktConfig>,
 }
         Err(_) => {
             log_info("pr-monitor-config.toml が見つかりません (デフォルト使用)");
-            return Config {
-                monitor: MonitorConfig::default(),
-                takt: None,
-            };
+            return Config::default();
         }
         Err(e) => {
             log_info(&format!(
                 "pr-monitor-config.toml パースエラー (デフォルト使用): {}",
                 e
             ));
-            Config {
-                monitor: MonitorConfig::default(),
-                takt: None,
-            }
+            Config::default()
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli-pr-monitor/src/config.rs` around lines 67 - 86, Duplicate
construction of the fallback Config in the error paths should be replaced by a
single Default implementation: derive or implement Default for the Config struct
(so Config::default() yields monitor: MonitorConfig::default() and takt: None),
then replace the repeated explicit constructions in the file (the Err(_) branch
and the toml::from_str Err(e) branch) with return Config::default() (or just
Config::default() where appropriate); reference Config and
MonitorConfig::default() to locate the struct and update callers accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/cli-pr-monitor/src/config.rs`:
- Around line 27-37: MonitorConfig::default() populates every Option field with
Some(...) but when parsing an empty [monitor] table Serde leaves those fields as
None, causing different defaults depending on presence of the section; to fix
make parsing and programmatic defaults consistent: add serde defaults so parsed
empty sections get the same defaults—apply #[serde(default)] to the
MonitorConfig struct or to each field (e.g., fields like enabled,
poll_interval_secs, max_duration_secs, check_ci, check_coderabbit) and ensure
MonitorConfig::default() returns the desired values, or alternatively document
the intended behavior clearly.
- Around line 67-86: Duplicate construction of the fallback Config in the error
paths should be replaced by a single Default implementation: derive or implement
Default for the Config struct (so Config::default() yields monitor:
MonitorConfig::default() and takt: None), then replace the repeated explicit
constructions in the file (the Err(_) branch and the toml::from_str Err(e)
branch) with return Config::default() (or just Config::default() where
appropriate); reference Config and MonitorConfig::default() to locate the struct
and update callers accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c34c04ce-e319-41c9-aeb0-05376b4d31aa

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1ab3f and 4c0eace.

📒 Files selected for processing (19)
  • .takt/facets/instructions/analyze-coderabbit.md
  • .takt/workflows/post-pr-review.yaml
  • CLAUDE.md
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • package.json
  • pr-monitor-config.toml
  • scripts/deploy-hooks.ts
  • src/cli-pr-monitor/src/config.rs
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/collect.rs
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • src/cli-pr-monitor/src/stages/daemon.rs
  • src/cli-pr-monitor/src/stages/mod.rs
  • src/cli-pr-monitor/src/stages/monitor.rs
  • src/cli-pr-monitor/src/stages/poll.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/util.rs
  • templates/pr-monitor-config.toml
💤 Files with no reviewable changes (2)
  • package.json
  • src/cli-pr-monitor/src/stages/daemon.rs
✅ Files skipped from review due to trivial changes (9)
  • scripts/deploy-hooks.ts
  • pr-monitor-config.toml
  • .takt/workflows/post-pr-review.yaml
  • src/cli-pr-monitor/src/stages/mod.rs
  • templates/pr-monitor-config.toml
  • CLAUDE.md
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • .takt/facets/instructions/analyze-coderabbit.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/util.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/collect.rs
  • src/cli-pr-monitor/src/stages/poll.rs

@aloekun

aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aloekun
aloekun force-pushed the feat/pr-monitor-takt-phase1 branch from 4c0eace to 06fbf10 Compare April 15, 2026 10:08
@aloekun

aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

Nitpick 2 件を修正しました (commit 06fbf10):

  1. MonitorConfig の serde default 一貫性: 各フィールドに #[serde(default = "...")] を追加し、空の [monitor] セクションでも MonitorConfig::default() と同じ値が適用されるようにしました。
  2. Config に Default derive: Config#[derive(Default)] を追加し、エラーパスの重複構築を Config::default() に統一しました。

@aloekun

aloekun commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cli-pr-monitor/src/config.rs`:
- Around line 86-91: Change the error handling around
std::fs::read_to_string(&path) so you match the error (Err(e)) and inspect
e.kind(): if e.kind() == std::io::ErrorKind::NotFound then keep the current
behavior (log_info(...) and return Config::default()), but for any other error
kind log a distinct error (e.g., log_error or log_warn) that includes the actual
error (e) and the path so it's not silently treated as missing; use the same
function scope that calls std::fs::read_to_string, reference the path variable,
and keep returning or propagating appropriately instead of treating all errors
as NotFound.
- Around line 67-82: The config_path() fallback should look for the config in
the repo root when the binary sits under a subdirectory (e.g. <repo>/.claude/),
so change the current_exe() path resolution to prefer the exe's parent parent
(repo root) instead of just parent; in practice update the expression in
config_path() that builds the fallback from
std::env::current_exe().unwrap_or_default().parent().unwrap_or(Path::new(".")).join(filename)
to walk up one more level (e.g. .parent().and_then(|p|
p.parent()).unwrap_or(Path::new("."))).join(filename) so pr-monitor-config.toml
in the repo root is found when the binary lives in a subdir.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ac3d917-175c-4cfe-bc30-a820ca0a9667

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1ab3f and 06fbf10.

📒 Files selected for processing (20)
  • .takt/facets/instructions/analyze-coderabbit.md
  • .takt/workflows/post-pr-review.yaml
  • CLAUDE.md
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • package.json
  • pr-monitor-config.toml
  • scripts/deploy-hooks.ts
  • src/cli-pr-monitor/src/config.rs
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/collect.rs
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • src/cli-pr-monitor/src/stages/daemon.rs
  • src/cli-pr-monitor/src/stages/mod.rs
  • src/cli-pr-monitor/src/stages/monitor.rs
  • src/cli-pr-monitor/src/stages/poll.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/util.rs
  • src/cli-push-runner/src/stages/diff.rs
  • templates/pr-monitor-config.toml
💤 Files with no reviewable changes (2)
  • package.json
  • src/cli-pr-monitor/src/stages/daemon.rs
✅ Files skipped from review due to trivial changes (5)
  • CLAUDE.md
  • templates/pr-monitor-config.toml
  • .takt/workflows/post-pr-review.yaml
  • docs/adr/adr-018-pr-monitor-takt-migration.md
  • .takt/facets/instructions/analyze-coderabbit.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/cli-pr-monitor/src/stages/create_pr.rs
  • pr-monitor-config.toml
  • src/cli-pr-monitor/src/util.rs
  • src/cli-pr-monitor/src/stages/takt.rs
  • src/cli-pr-monitor/src/main.rs
  • src/cli-pr-monitor/src/runner.rs
  • src/cli-pr-monitor/src/stages/mod.rs

Comment thread src/cli-pr-monitor/src/config.rs
Comment thread src/cli-pr-monitor/src/config.rs
daemon spawn + CronCreate を廃止し、in-process ポーリング + takt 分析に移行:
- Stage 1: poll_loop (Rust, in-process) - CI/CodeRabbit を同期ポーリング
- Stage 2: collect_findings - .takt/review-comments.json に書き出し
- Stage 3: run_takt - post-pr-review ワークフローで深刻度別分析
- Stage 4: print_report - stdout にレポート出力

ADR-015 の「機械的ステップは Rust、AI ステップは takt」原則を適用。
takt はオプショナル (pr-monitor-config.toml に [takt] セクションがなければスキップ)。

ADR-018 で決定を記録。ADR-009 の daemon + CronCreate 部分を Supersede。
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