Skip to content

feat(pre-push-review): WP-06 反証(refute) facet 追加 — reviewers→verify(haiku)→fix (ADR-047 試験運用) - #250

Merged
aloekun merged 1 commit into
masterfrom
wp-06-refute-facet
Jul 6, 2026
Merged

feat(pre-push-review): WP-06 反証(refute) facet 追加 — reviewers→verify(haiku)→fix (ADR-047 試験運用)#250
aloekun merged 1 commit into
masterfrom
wp-06-refute-facet

Conversation

@aloekun

@aloekun aloekun commented Jul 6, 2026

Copy link
Copy Markdown
Owner

概要

ハーネス改善実行計画書 (docs/harness-improvement-plan.md) の WP-06: 反証(refute)facet 追加 を実装する。pre-push review の false positive 起因の無駄な fix iteration を、reviewers と fix の間に挟んだ verify (refute) step で削減する (adversarial verification)。

設計根拠は ADR-047 (試験運用、ADR-039 標準パターン準拠) に集約。

フロー

reviewers (simplicity + security, sonnet)
   | any needs_fix
   v
verify (refute, haiku)  <- 各 finding を反証。false positive を reject
   |
   +- SOME_SURVIVE -> fix (survived finding のみ)
   +- ALL_REFUTED  -> supervise (コード変更なし、push 前最終確認)
  • 非対称モデル構成 (sonnet reviewer の finding を haiku で安く検証)。
  • 不確実なら reject に倒す: 誤って survive させた finding は fix→reviewers の 1 cycle を無駄にする (pre-push で高コスト) が、誤って reject した finding は post-pr の CodeRabbit 層で回収される (安全網)。

変更内容

  • workflow: .takt/workflows/pre-push-review-refute.yaml を新設 (reviewers→verify→fix→supervise)。loop_monitors.cycle[reviewers, verify, fix] に更新し膠着検出を維持。
  • facets: refute-finding.md (instruction) + refutation-report.md (output-contract) を新規追加。
  • 後方互換: fix.md / supervise.mdrefutation-report.md が存在する場合のみ参照 (post-pr-review / refute 無効時は従来動作、ADR-020)。
  • config opt-in (ADR-039): push-runner-config.toml[pre_push_review] section を追加。本 PR は導入のみで default OFF (refute_enabled = false)。workflow 切替判定を cli-push-runner の resolve_takt_workflow に単一集約。templates/push-runner-config.toml も default OFF を継承。
  • Rust: PrePushReviewConfig + resolve_takt_workflow + main.rs/takt.rs 配線 + ユニットテスト 4 本。

Kill-switch / Bounded lifetime

  • refute_enabled = false で即座に現行 pre-push-review (verify なし) へ。永続停止は pre-push-review-refute.yaml を削除する revert PR。
  • 本リポジトリの dogfood 有効化 (refute_enabled = true) はマージ後の別 PR で開始する (未検証の refute workflow でこの導入 PR 自体を自己レビューするブートストラップを回避)。dogfood 開始から 2 週間で採否判定。

検証

  • cargo test -p cli-push-runner: 175 passed / 0 failed (resolve_takt_workflow の 4 テスト含む)
  • push pipeline の quality_gate: cargo test --release / clippy / lint:docs / lint:md すべて通過
  • markdownlint: 0 errors

関連

  • ADR-047 (本 PR で新規起票)
  • WP-06 / docs/harness-improvement-plan.md の状態を「実装済」に更新

Summary by CodeRabbit

  • 新機能

    • pre-push レビューに「反証(refute)」の流れを追加し、見直し対象を絞って進められるようになりました。
    • 反証結果をまとめる新しいレポート形式に対応しました。
    • 新しいワークフロー設定を追加し、必要に応じて反証フローへ切り替え可能になりました。
  • 改善

    • レビュー指摘が全部取り下げられた場合の判定をより安全な手順に更新しました。
    • 設定の既定値と切り替え処理を整理し、従来動作との互換性を維持しました。

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 946797f3-fabf-4be4-bedd-cb50cac2d8c4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

pre-push-review-refute facetを追加し、reviewersとfixの間にverify(反証)ステップを挟む新workflowを導入した。関連するfacet指示書、出力契約、ADR-047ドキュメント、push-runner設定(refute_enabled/refute_workflow)とRust側のworkflow解決ロジックを追加・更新した。

Changes

Refute Facet 導入

Layer / File(s) Summary
Refute関連facet指示書と出力契約
.takt/facets/instructions/refute-finding.md, .takt/facets/instructions/fix.md, .takt/facets/instructions/supervise.md, .takt/facets/output-contracts/refutation-report.md
refute-finding手順書を新規作成し、fix/supervise手順にrefutation-report.md存在時の分岐を追記、Survived/Rejected表とVerdictを定義する出力契約を新設した。
pre-push-review-refute workflowの定義
.takt/workflows/pre-push-review-refute.yaml
reviewers、verify(haikuによる反証)、fix、supervise、fix_supervisorの各ステップとloop_monitor(reviewers→verify→fixサイクル)を定義した新workflowを追加した。
ADRと改善計画ドキュメントの更新
docs/adr/adr-047-prepush-refute-facet.md, CLAUDE.md, docs/harness-improvement-plan.md
ADR-047を新規作成し、CLAUDE.mdのADR一覧に追記、harness-improvement-planのWP-06ステータスを実装済みに更新した。
push-runner設定へのrefute_enabled/refute_workflow追加とworkflow解決実装
push-runner-config.toml, templates/push-runner-config.toml, src/cli-push-runner/src/config/mod.rs, src/cli-push-runner/src/config/lint_screen.rs, src/cli-push-runner/src/main.rs, src/cli-push-runner/src/stages/takt.rs
pre_push_reviewセクションとPrePushReviewConfig型を追加し、resolve_takt_workflowでrefute有効時のworkflow切替を実装、run_takt/main.rsを更新してテストを追加した。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PushRunner
  participant Reviewers
  participant Verify
  participant Fix
  participant Supervise

  PushRunner->>Reviewers: run simplicity + security review
  Reviewers->>Verify: needs_fix findings
  Verify->>Verify: refute findings (haiku)
  alt findings survive
    Verify->>Fix: survived findings
    Fix->>Reviewers: apply fix / loop back
    Fix->>Supervise: unable to proceed
  else all refuted
    Verify->>Supervise: ALL_REFUTED
  end
  Supervise-->>PushRunner: COMPLETE (ready to push)
Loading

Possibly related PRs

  • aloekun/claude-code-hook-test#33: 同じcli-push-runnerのtakt workflow選択・実行機構(stages/takt.rs、config)を扱っており、本PRの拡張基盤にあたる。
  • aloekun/claude-code-hook-test#242: docs/harness-improvement-plan.mdのWP-06関連内容を先行して作成しており、本PRはそれを更新する形で拡張している。
🚥 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 主要変更である pre-push-review への refute facet 追加と reviewers→verify→fix の新フローを具体的に示しており、内容と整合しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wp-06-refute-facet

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.

@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: 1

🧹 Nitpick comments (1)
src/cli-push-runner/src/config/mod.rs (1)

114-129: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

誤設定時にサイレントにフォールバックする点の可観測性を改善できる。

refute_enabled = true かつ refute_workflow 未指定(または空文字列)の場合、警告なしに既存ワークフローへフォールバックします。設計上のフェイルセーフとしては妥当ですが、ユーザーが「有効化したつもりが実は反証facetが動いていない」ことに長期間気づけない可能性があります。main.rs の呼び出し元でこの分岐時にログを1行出すと運用上の助けになります。

♻️ 提案例
 pub(crate) fn resolve_takt_workflow(config: &Config) -> String {
     if let Some(pre_push) = &config.pre_push_review {
         if pre_push.refute_enabled == Some(true) {
             if let Some(workflow) = &pre_push.refute_workflow {
-                return workflow.clone();
+                if !workflow.is_empty() {
+                    return workflow.clone();
+                }
+                log_info("pre_push_review.refute_workflow が空文字列のため base workflow にフォールバックします");
             }
+            log_info("pre_push_review.refute_enabled=true ですが refute_workflow 未指定のため base workflow にフォールバックします");
         }
     }
     config.takt.workflow.clone()
 }
🤖 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-push-runner/src/config/mod.rs` around lines 114 - 129,
`resolve_takt_workflow` は誤設定時に現行 `config.takt.workflow`
へ静かにフォールバックするため、`main.rs` でこの関数の戻り値を使う直前に分岐を追加し、`pre_push_review.refute_enabled
= true` なのに `refute_workflow` が未指定・空のときは警告ログを1行出してください。`resolve_takt_workflow` と
`Config.pre_push_review` を参照して、フォールバック発生時にユーザーが気づけるように可観測性を上げてください。
🤖 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.

Inline comments:
In @.takt/facets/instructions/supervise.md:
- Around line 10-13: The current ready-to-push check is looking at the entire
Report Directory instead of only the fix report for the current verify run, so
it can be blocked by older timestamped reports. Update the logic in the
refutation-report handling path to identify and inspect only the report tied to
the current verify execution, using the same report-selection behavior as
fix.md, and ignore past iteration files like {filename}.{timestamp} when
deciding whether there is “no fix report.” Ensure the ALL_REFUTED path in the
refutation-report flow only evaluates the current run’s report before marking
ready to push.

---

Nitpick comments:
In `@src/cli-push-runner/src/config/mod.rs`:
- Around line 114-129: `resolve_takt_workflow` は誤設定時に現行 `config.takt.workflow`
へ静かにフォールバックするため、`main.rs` でこの関数の戻り値を使う直前に分岐を追加し、`pre_push_review.refute_enabled
= true` なのに `refute_workflow` が未指定・空のときは警告ログを1行出してください。`resolve_takt_workflow` と
`Config.pre_push_review` を参照して、フォールバック発生時にユーザーが気づけるように可観測性を上げてください。
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 106fd782-31ce-4f44-9695-fffd7a4d28d9

📥 Commits

Reviewing files that changed from the base of the PR and between f557472 and 5459c02.

📒 Files selected for processing (14)
  • .takt/facets/instructions/fix.md
  • .takt/facets/instructions/refute-finding.md
  • .takt/facets/instructions/supervise.md
  • .takt/facets/output-contracts/refutation-report.md
  • .takt/workflows/pre-push-review-refute.yaml
  • CLAUDE.md
  • docs/adr/adr-047-prepush-refute-facet.md
  • docs/harness-improvement-plan.md
  • push-runner-config.toml
  • src/cli-push-runner/src/config/lint_screen.rs
  • src/cli-push-runner/src/config/mod.rs
  • src/cli-push-runner/src/main.rs
  • src/cli-push-runner/src/stages/takt.rs
  • templates/push-runner-config.toml

Comment on lines +10 to +13
## Optional: refutation-report.md (pre-push-review-refute only)

If the Report Directory contains `refutation-report.md` with Verdict `ALL_REFUTED` and there is no fix report, the verify (refute) step rejected every reviewer finding as a false positive, so there is intentionally no code change. Confirm the rejection reasons are sound (each should cite concrete code-level evidence). If they are, this is **ready to push** -- any wrongly-rejected finding is recaught by the post-pr CodeRabbit layer. If a rejection reason looks unsound, treat it as **issues detected**.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== supervise.md ==\n'
cat -n .takt/facets/instructions/supervise.md | sed -n '1,120p'

printf '\n== fix.md ==\n'
cat -n .takt/facets/instructions/fix.md | sed -n '1,220p'

printf '\n== search: ALL_REFUTED / fix report / timestamp ==\n'
rg -n "ALL_REFUTED|fix report|refutation-report|timestamp|current iteration|current run|current execution|pre-push-review-refute|ready to push" .takt -S

Repository: aloekun/claude-code-hook-test

Length of output: 16054


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== pre-push-review-refute.yaml (relevant sections) ==\n'
sed -n '1,240p' .takt/workflows/pre-push-review-refute.yaml

printf '\n== refutation-report output contract ==\n'
sed -n '1,220p' .takt/facets/output-contracts/refutation-report.md

printf '\n== refute-finding instruction ==\n'
sed -n '1,220p' .takt/facets/instructions/refute-finding.md

printf '\n== search for fix report file names ==\n'
rg -n "fix report|fix-report|refutation-report|Report Directory|Survived Findings|Rejected Findings" .takt -S

Repository: aloekun/claude-code-hook-test

Length of output: 19826


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== fix-supervisor.md ==\n'
sed -n '1,220p' .takt/facets/instructions/fix-supervisor.md

printf '\n== search for fix report / report name definitions ==\n'
rg -n "name: fix|fix report|fix-report|convergence_verdict|Work results|Convergence verdict|Report Directory.*fix" .takt -S

printf '\n== workflow around fix/supervise in pre-push-review.yaml ==\n'
sed -n '1,260p' .takt/workflows/pre-push-review.yaml

Repository: aloekun/claude-code-hook-test

Length of output: 12482


現在イテレーションの fix report だけを判定してください
fix.md の通り past iteration reports は {filename}.{timestamp} で同じ Report Directory に残るため、ディレクトリ全体で「fix report がない」を見ると、古い fix report が 1 つ残っているだけで ALL_REFUTED でも ready-to-push に進めません。判定対象は現在の verify 実行に紐づく report に限定してください。

🧰 Tools
🪛 LanguageTool

[grammar] ~10-~10: Ensure spelling is correct
Context: ...: refutation-report.md (pre-push-review-refute only) If the Report Directory contains `refuta...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 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 @.takt/facets/instructions/supervise.md around lines 10 - 13, The current
ready-to-push check is looking at the entire Report Directory instead of only
the fix report for the current verify run, so it can be blocked by older
timestamped reports. Update the logic in the refutation-report handling path to
identify and inspect only the report tied to the current verify execution, using
the same report-selection behavior as fix.md, and ignore past iteration files
like {filename}.{timestamp} when deciding whether there is “no fix report.”
Ensure the ALL_REFUTED path in the refutation-report flow only evaluates the
current run’s report before marking ready to push.

…aiku)→fix (ADR-047 試験運用)

reviewers と fix の間に verify(refute, haiku) step を挟み、reviewer(sonnet) の false positive を fix 前に反証・却下して無駄な fix iteration を削減する。誤って却下した真の finding は post-pr CodeRabbit 層で回収 (安全網、ADR-019)。

- 新 workflow .takt/workflows/pre-push-review-refute.yaml — loop_monitors.cycle を [reviewers, verify, fix] に更新し膠着検出を維持
- refute-finding.md instruction + refutation-report.md output-contract を新設
- fix.md / supervise.md は refutation-report.md 存在時のみ参照で後方互換 (ADR-020)
- opt-in: push-runner-config.toml [pre_push_review] refute_enabled (本リポ dogfood で true、templates は default OFF)。cli-push-runner の resolve_takt_workflow で workflow 切替 (ADR-039)
- verify 全却下時は supervise 経由 (安全側)
- ADR-047 起票 (試験運用、2026-07-20 に採否判定)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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