Skip to content

ステータスレポート機能#71

Merged
HappyOnigiri merged 7 commits intomainfrom
cursor/-bc-cc2d5d07-d935-42ff-a224-d30ec9dc8c07-b4b0
Mar 12, 2026
Merged

ステータスレポート機能#71
HappyOnigiri merged 7 commits intomainfrom
cursor/-bc-cc2d5d07-d935-42ff-a224-d30ec9dc8c07-b4b0

Conversation

@HappyOnigiri
Copy link
Owner

@HappyOnigiri HappyOnigiri commented Mar 12, 2026

概要 / Summary

Refix が PR に出力するステータス管理コメントと実行レポートの表示・管理方法を改善します。

変更内容 / Changes

  • PR ステータスコメントの「処理済みレビュー一覧 (System Use Only)」を「対応済みレビュー一覧」に変更し、(System Use Only) を削除しました。
  • 実行レポートを PR コメントに「実行レポート」として折りたたみ形式で追記する機能を追加しました。
  • レポートのログ出力時、内容がない場合は「レポート出力なし」と表示し、CI 出力時は折りたたみ表示されるように変更しました。
  • Claude へのレポート指示に UTC タイムスタンプを含むフォーマットを追加しました。
  • execution_report 設定を追加し、レポート機能の ON/OFF を制御できるようにしました(デフォルト OFF)。OFF の場合は Claude へのレポート指示も行いません。
  • README.md, README.ja.md, .refix.yaml.sampleexecution_report 設定の説明を追加しました。

テスト / Testing

  • pytest tests/test_state_manager.py tests/test_auto_fixer.py -q で変更点近傍のテストを実行し、回帰がないことを確認済み。
  • make ci を実行し、lint、型検査、全テストがパスすることを確認済み。
  • UI 変更ではないため、手動での UI テストは行っていません。

関連 issues / Related issues

なし

Open in Web Open in Cursor 

Summary by CodeRabbit

  • 新機能

    • 新しい設定オプション execution_report を追加。各フェーズの実行レポートを生成し、折りたたみ可能なCIログとして出力、PRステータスコメント内に段階別レポートを埋め込む(デフォルト無効)。状態コメントへの挿入・差分更新・表示幅超過時の切り詰めに対応。
  • ドキュメント

    • サンプル設定とREADMEに execution_report の挙動と表示方法を追記。
  • テスト

    • execution_report の検証、報告ブロックの埋め込み・除外・切り詰め挙動を検証するテストを追加。

Co-authored-by: HappyOnigiri <nodemeld+happy-onigiri@gmail.com>
@cursor
Copy link

cursor bot commented Mar 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 69fac3bb-1df9-40d2-9b17-5d27bd88f5b0

📥 Commits

Reviewing files that changed from the base of the PR and between d25a167 and c8ac832.

📒 Files selected for processing (1)
  • tests/test_auto_fixer.py

📝 Walkthrough

Walkthrough

トップレベル設定 execution_report(boolean)を追加し、有効時に各修正フェーズでClaudeが出力する実行レポートを収集・格納してPRステートコメントに埋め込む処理を自動修正ロジック、ステートマネージャ、ドキュメント、テストへ展開します。

Changes

Cohort / File(s) Summary
ドキュメントと設定サンプル
\.refix.yaml.sample, README.md, README.ja.md
execution_report設定キー(boolean, default false)の説明を追加。有効時のレポート出力・CIログ折りたたみ・ステートコメント埋め込みの挙動を記載。
自動修正エンジン
src/auto_fixer.py
execution_reportのデフォルト設定・検証を追加。_run_claude_prompt等のシグネチャを拡張し、レポートの作成/読取/マージ/フェーズ別ブロック生成とPRステートコメントへの蓄積・条件更新を実装。
ステート管理
src/state_manager.py
レポート用マーカー/正規表現定数とヘルパーを追加。StateCommentreport_bodyフィールドを追加し、レポートセクションの抽出・除去・組立・切り詰めを行うレンダ/解析/upsert/loadの拡張を導入。
テスト
tests/test_auto_fixer.py, tests/test_state_manager.py
execution_reportの読み込み・型検証テスト、レポート生成とステートコメントへの埋め込みを検証するCIフロー系テスト、報告セクション描画・解析テストを追加・更新。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

refix:done

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive PR タイトル「ステータスレポート機能」は、実行レポートを PR コメントに追記する機能追加という変更内容の主要な部分を指していますが、変更の全体像を十分に説明していません。 タイトルを「PR ステータスコメント改善とレポート機能の追加」のようにより具体的で説明的なものに変更することをお勧めします。
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed PR の説明は、概要、変更内容、テスト、関連 issues のすべてのセクションを含む適切な構造で、実装の詳細と検証内容が記載されており、テンプレートに準拠しています。

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/-bc-cc2d5d07-d935-42ff-a224-d30ec9dc8c07-b4b0

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

@HappyOnigiri HappyOnigiri marked this pull request as ready for review March 12, 2026 11:29
@HappyOnigiri HappyOnigiri added the refix:running Refix is currently processing review fixes. label Mar 12, 2026
Copy link
Contributor

@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.

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (2)
src/auto_fixer.py (2)

2633-2649: ⚠️ Potential issue | 🟠 Major

失敗したフェーズの実行レポートが PR コメントに残りません。

_capture_state_comment_report()_run_claude_prompt() 成功後にしか呼ばれていないうえ、例外時はそのまま再送出しているので、Claude が途中で失敗したフェーズは CI ログにしか出ず report_blocks / state comment に保存されません。実行レポート機能の中でも一番見たい失敗ケースが欠落します。

Also applies to: 2728-2748, 2970-2981, 3124-3126

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/auto_fixer.py` around lines 2633 - 2649, The exception path currently
re-raises before saving the execution report so failed Claude phases are never
recorded; ensure _capture_state_comment_report(report_blocks, "ci-fix",
ci_report_path) is invoked even on failure by moving the call into a finally
block or by calling it from the except handler before re-raising the exception
for the ci-fix section around _run_claude_prompt (symbols: ci_commits,
_run_claude_prompt, _capture_state_comment_report, report_blocks,
ci_report_path); apply the same fix pattern to the other similar blocks
referenced (the blocks around the other _run_claude_prompt calls at the ranges
you noted) so every phase captures its state comment/report before the exception
is propagated.

3097-3122: ⚠️ Potential issue | 🟠 Major

この state comment 更新ロジックは既存レポートを消しつつ、失敗ケースを完了扱いにできます。

Line 3097 で execution_report_enabledFalse のとき report_body_to_save = "" にしており、Line 3109 でそれを upsert_state_comment() に渡すと、src/state_manager.py の実装上は既存 report_body を保持せず空で上書きします。さらに Line 3104-3115 では state_entries が 0 件でもレポート差分だけで should_write_state_comment が真になり、更新成功後に state_saved = True になります。インライン comment の resolve が失敗して any_comment_failed=True でも、_update_done_label_if_completed() 側で完了扱いに進める経路ができています。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/auto_fixer.py` around lines 3097 - 3122, The logic overwrites existing
report text when execution_report_enabled is False and can mark state as
completed incorrectly; change the assignment and comparison so we only attempt
to update the report when reporting is enabled: keep report_body_to_save as
state_comment.report_body.strip() (or None) instead of "" when
execution_report_enabled is False, and only include the report-diff check in
should_write_state_comment if execution_report_enabled is True; ensure
upsert_state_comment is only called when should_write_state_comment is true and
only set state_saved = True after a successful upsert (and not merely because
the report string changed while reporting is disabled). Reference
variables/functions: report_body_to_save, execution_report_enabled,
state_comment.report_body, should_write_state_comment, upsert_state_comment,
any_comment_failed, and _update_done_label_if_completed.
🤖 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/auto_fixer.py`:
- Around line 618-629: Replace the English "no report was recorded." messages
with the required Japanese text "レポート出力なし" for both the missing-file and
empty-content cases: update the print calls guarded by report_file.exists() (the
branch that currently prints at the check if not report_file.exists()) and the
subsequent check if not content (after reading report_file.read_text()) so they
write "レポート出力なし" to sys.stderr; keep the existing exception handling and stderr
target intact.

---

Outside diff comments:
In `@src/auto_fixer.py`:
- Around line 2633-2649: The exception path currently re-raises before saving
the execution report so failed Claude phases are never recorded; ensure
_capture_state_comment_report(report_blocks, "ci-fix", ci_report_path) is
invoked even on failure by moving the call into a finally block or by calling it
from the except handler before re-raising the exception for the ci-fix section
around _run_claude_prompt (symbols: ci_commits, _run_claude_prompt,
_capture_state_comment_report, report_blocks, ci_report_path); apply the same
fix pattern to the other similar blocks referenced (the blocks around the other
_run_claude_prompt calls at the ranges you noted) so every phase captures its
state comment/report before the exception is propagated.
- Around line 3097-3122: The logic overwrites existing report text when
execution_report_enabled is False and can mark state as completed incorrectly;
change the assignment and comparison so we only attempt to update the report
when reporting is enabled: keep report_body_to_save as
state_comment.report_body.strip() (or None) instead of "" when
execution_report_enabled is False, and only include the report-diff check in
should_write_state_comment if execution_report_enabled is True; ensure
upsert_state_comment is only called when should_write_state_comment is true and
only set state_saved = True after a successful upsert (and not merely because
the report string changed while reporting is disabled). Reference
variables/functions: report_body_to_save, execution_report_enabled,
state_comment.report_body, should_write_state_comment, upsert_state_comment,
any_comment_failed, and _update_done_label_if_completed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6cc4b717-1ba3-47ce-8bd5-04fb99e451fb

📥 Commits

Reviewing files that changed from the base of the PR and between cf19a44 and 12bf9cd.

📒 Files selected for processing (7)
  • .refix.yaml.sample
  • README.ja.md
  • README.md
  • src/auto_fixer.py
  • src/state_manager.py
  • tests/test_auto_fixer.py
  • tests/test_state_manager.py

_run_claude_prompt() が例外を送出した場合でも _capture_state_comment_report()
が呼ばれるよう、ci-fix・merge-conflict-resolution・review-fix の各フェーズで
finally ブロックに移動した。
execution_report_enabled が False のとき report_body_to_save が "" になり既存の
report_body を上書きしていた問題を修正。state_comment.report_body.strip() を維持
するよう変更し、should_write_state_comment のレポート差分チェックも
execution_report_enabled が True の場合のみ評価するよう修正した。
@HappyOnigiri
Copy link
Owner Author

HappyOnigiri commented Mar 12, 2026

🤖 Refix Status

処理済みレビュー一覧 (System Use Only)
Comment ID 処理日時
r3935878177 2026-03-12 20:46:50 JST
discussion_r2924019156 2026-03-12 20:46:50 JST
r3935953122 2026-03-12 21:08:37 JST
discussion_r2924088915 2026-03-12 21:08:37 JST
discussion_r2924088920 2026-03-12 21:08:37 JST

Copy link
Contributor

@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.

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/auto_fixer.py`:
- Around line 2781-2787: Race condition: before calling
_persist_state_comment_report_if_changed (which ultimately calls
upsert_state_comment that replaces report_body), re-fetch the latest
state_comment.report_body from the source of truth and re-run the merge to
incorporate concurrent updates so we don't overwrite other runs' appended
reports. Concretely, in the block around merged_report_body =
_merge_state_comment_report_body(...), call the same reader used to obtain
state_comment (or a get_state_comment/get_latest_state_comment function) to
obtain the current report_body, re-merge that latest body with report_blocks
(e.g. via _merge_state_comment_report_body) to produce a final
merged_report_body, then pass that into
_persist_state_comment_report_if_changed; apply the same fix to the other
occurrences referenced (around the blocks at ~2852-2858 and ~3101-3119).
- Around line 2649-2650: The finally block currently only calls
_capture_state_comment_report(report_blocks, "ci-fix", ci_report_path) which
only appends to report_blocks but does not persist to GitHub because exceptions
are re-raised before upsert_state_comment runs; update the flow so the
accumulated report is persisted even on failure—either call
upsert_state_comment(report_blocks, ...) inside this finally (or in the outer
_process_single_pr() finally) before re-raising, or move the persistence logic
into _capture_state_comment_report so it both captures and calls
upsert_state_comment; target references: _capture_state_comment_report,
upsert_state_comment, _process_single_pr, and report_blocks, and apply the same
change to the other occurrences noted (around the ci-fix /
merge-conflict-resolution / review-fix finally blocks).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ca2d3640-bf33-4383-864e-639a4436c8d3

📥 Commits

Reviewing files that changed from the base of the PR and between 12bf9cd and d25a167.

📒 Files selected for processing (1)
  • src/auto_fixer.py

The source was changed to output "レポート出力なし" in 5a52687 but
the test was not updated accordingly.
ci-fix / merge-conflict-resolution / review-fix の各フェーズで例外が発生した際、
_capture_state_comment_report が finally で report_blocks に追加するだけで
upsert_state_comment が呼ばれないまま例外が再送出されていた問題を修正。

- ci-fix: finally を削除し、except で capture + 保存後に raise、成功時は try/except 後で capture
- merge-conflict-resolution: 同様のパターンを適用
- ClaudeCommandFailedError / subprocess.CalledProcessError: 再送出・終了前に保存ロジックを追加

いずれも load_state_comment で最新状態を再取得してから _persist_state_comment_report_if_changed
を呼び出すため、後述の race condition 対策も兼ねている。
_persist_state_comment_report_if_changed や upsert_state_comment を呼ぶ直前に
load_state_comment で最新状態を再取得し、古い report_body への上書きによる
別 run のレポート消去リスクを低減する。

対象箇所: has_review_targets=False パス、skip_review_fix パス、
および通常完了時の report_body_to_save 構築(3 か所)。
@HappyOnigiri HappyOnigiri added the refix:done Refix finished review checks/fixes for now. label Mar 12, 2026
@HappyOnigiri HappyOnigiri merged commit b642f07 into main Mar 12, 2026
1 check passed
@HappyOnigiri HappyOnigiri deleted the cursor/-bc-cc2d5d07-d935-42ff-a224-d30ec9dc8c07-b4b0 branch March 12, 2026 12:10
@HappyOnigiri HappyOnigiri added refix:auto-merge-requested Refix has requested auto-merge for this PR. refix:merged PR has been merged after Refix auto-merge. and removed refix:running Refix is currently processing review fixes. refix:auto-merge-requested Refix has requested auto-merge for this PR. labels Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refix:done Refix finished review checks/fixes for now. refix:merged PR has been merged after Refix auto-merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants