Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"src/cli-autonomy-gate",
"src/cli-docs-lint",
"src/cli-finding-classifier",
"src/cli-fix-push-gate",
"src/cli-merge-pipeline",
"src/cli-pr-monitor",
"src/cli-push-runner",
Expand All @@ -37,12 +38,14 @@ members = [
"src/hooks-stop-quality",
"src/hooks-stop-tool-call-leak",
"src/hooks-user-prompt-feedback-recovery",
"src/lib-autonomy-policy",
"src/lib-docs-policy",
"src/lib-hook-output",
"src/lib-jj-helpers",
"src/lib-ollama-client",
"src/lib-pending-file",
"src/lib-report-formatter",
"src/lib-scope-guard",
"src/lib-subprocess",
"src/lib-telemetry",
]
Expand Down
10 changes: 7 additions & 3 deletions docs/harness-improvement-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jj log -r 'ylkowqkp | unksnyts | mxzwmsyp | lwpktvpm | lqxzpvuw | utpvkwql | rxv

**jj 運用の注意(本セッションで 3 回発生した事故の予防)**: ファイル編集を始める前に必ず `jj new -m "wip: <内容>"` で新コミットを作ること。描述済みコミットが `@` のまま編集すると、後続の `jj describe` が既存コミットのメッセージを上書きし、変更が混入する。`pnpm push` は必ず timeout 600000ms + `run_in_background: true`(ADR-016)。PR 作成・マージは AskUserQuestion または本文提示でユーザー承認を得る(ADR-028。VSCode では AskUserQuestion の preview・同一ターンの本文が見えないことがあるため、**draft はツール呼び出しを伴わない単独メッセージで提示**する)。

##### 2a: 計画書更新 + rename パーサ修正(約 130〜200 行) — 実施中(本 PR
##### 2a: 計画書更新 + rename パーサ修正(約 130〜200 行) — 完了(PR #350、2026-08-03 マージ

1. 本計画書の更新コミット(`jj log -r 'master..'` で description が `docs(harness-plan): WP-17 の実行状況と再分割計画` のもの)が既にあれば、それを 2a の先頭として流用する。
2. **パーサ修正の回収**: `mxzwmsyp` は rename パーサ修正(`src/cli-push-runner/src/stages/diff.rs` + `src/cli-push-runner/src/stages/diff/tests.rs` の 2 ファイル)と incident の gut-revert(lib 削除等)が混在しており、**rebase / duplicate では回収できない**。次の手順で 2 ファイル分だけ取り出す:
Expand All @@ -168,7 +168,7 @@ jj log -r 'ylkowqkp | unksnyts | mxzwmsyp | lwpktvpm | lqxzpvuw | utpvkwql | rxv
4. push(bookmark 例 `feat/wp17-r2a-docs-parser`)→ PR 作成(承認フロー)→ マージ(ユーザー)。
5. マージ後、stale remote ブランチ `feat/wp17-pr2a-policy-libs` の削除をユーザーへ依頼。

##### 2b: lib 抽出 2 件 + cli-fix-push-gate(約 1,130 行、warning 帯)
##### 2b: lib 抽出 2 件 + cli-fix-push-gate(約 1,130 行、warning 帯) — 実施中(本 PR)

抽出(`lib-scope-guard` / `lib-autonomy-policy`)と最初の呼び手(`cli-fix-push-gate`)を**同一 PR に入れる**ことで ADR-044 層 1 を充足する(incident の初回分割はここを分離して失敗した)。

Expand All @@ -179,7 +179,11 @@ jj log -r 'ylkowqkp | unksnyts | mxzwmsyp | lwpktvpm | lqxzpvuw | utpvkwql | rxv
5. 検証: `cargo test --workspace` 全緑(1936 件規模 + 新規 33 件)、`cargo clippy --workspace --all-targets -- -D warnings`、`pnpm lint:docs` / `lint:md`。
6. push 時は `jj edit` で `@` を 2b tip(lib module doc 修正コミット)に置く(push-runner のレビュー範囲と bookmark 自動更新は `master..@`)。bookmark 例 `feat/wp17-r2b-libs-gate` → PR → マージ。

**2b の chain 宣言**(ADR-069 準拠。2b PR の diff にこの計画書が含まれることで有効になる): 2b が導入する `cli-fix-push-gate`(crate `src/cli-fix-push-gate`)の workflow 呼び手は、**後続 PR 2c の `.github/workflows/pr-monitor.yml` fix job**(step `Gate fix push` が `master-ref/target/release/cli-fix-push-gate` を実行)として land する。`lib-scope-guard` の 2 呼び手(`cli-pr-monitor` scope_guard / `cli-fix-push-gate`)と `lib-autonomy-policy` の 2 呼び手(`cli-autonomy-gate` / `cli-fix-push-gate`)は **2b 自身の diff 内**に存在する。
**2b の chain 宣言**(ADR-069 準拠。2b PR の diff にこの計画書が含まれることで有効になる):

- **未消費なのは 1 つだけ**: 2b が導入する `cli-fix-push-gate`(crate `src/cli-fix-push-gate`、bin 同名)の **workflow 呼び手**。これは**後続 PR 2c** の `.github/workflows/pr-monitor.yml` の `fix` job として、step 名 `Gate fix push (deterministic, 4-axis AND)` で `master-ref/target/release/cli-fix-push-gate` を `--branch` / `--config` / `--diff-summary-file` / `--findings-file` 付きで実行する形で land する。
- **この宣言の検証状態**(ADR-069 § 決定 1 の名前一致要件に対する自己申告): 引数 4 種と exe 名は**本 PR の diff 内**(`src/cli-fix-push-gate/src/main.rs` の `parse_args` / `USAGE`)で照合できる。step 名と exe パスは 2c の実装(ローカルに存在する未 land コミット。本 PR の diff には**含まれない**)と照合済みだが、**本 PR の diff だけでは検証できない主張**である。レビュアーによる名前一致の最終確認は 2c の diff で行う。
- **lib 2 件の呼び手は 2b 自身の diff 内に揃っている**(未消費ではない): `lib-scope-guard` → `cli-pr-monitor::stages::scope_guard`(既存)+ `cli-fix-push-gate`(本 PR)。`lib-autonomy-policy` → `cli-autonomy-gate`(既存)+ `cli-fix-push-gate`(本 PR)。ADR-069 § 決定 3-1「抽出と最初の呼び手の間で切らない」に従い、incident の初回分割が分離したこの境界を同一 PR に戻してある。
Comment on lines +182 to +186

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 | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 期待結果: chain 宣言と workflow の step 名、パス、引数が一致する。
rg -n -C 8 \
  'Gate fix push \(deterministic, 4-axis AND\)|cli-fix-push-gate|--branch|--config|--diff-summary-file|--findings-file' \
  .github/workflows/pr-monitor.yml

Repository: aloekun/claude-code-hook-test

Length of output: 167


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== git status/stat =="
git status --short
git diff --stat

echo "== files with relevant names =="
git ls-files | rg '(^docs/harness-improvement-plan\.md$|\.github/workflows/pr-monitor\.yml$|cli-fix-push-gate|pr-monitor)' || true

echo "== docs/harness-improvement-plan.md relevant section =="
if [ -f docs/harness-improvement-plan.md ]; then
  nl -ba docs/harness-improvement-plan.md | sed -n '160,205p'
fi

echo "== workflow target if present =="
if [ -f .github/workflows/pr-monitor.yml ]; then
  nl -ba .github/workflows/pr-monitor.yml | sed -n '1,260p' | rg -n -C 8 'cli-fix-push-gate|--branch|--config|--diff-summary-file|--findings-file|Gate fix push|fix[[:space:]]*:' || true
else
  echo ".github/workflows/pr-monitor.yml not present"
fi

Repository: aloekun/claude-code-hook-test

Length of output: 2033


🏁 Script executed:

#!/bin/bash
set -u

echo "== docs/harness-improvement-plan.md lines 160-210 =="
awk 'NR>=160 && NR<=210 { printf "%5d  %s\n", NR, $0 }' docs/harness-improvement-plan.md || true

echo "== pr-monitor workflow matching lines =="
awk '
  /cli-fix-push-gate|--branch|--config|--diff-summary-file|--findings-file|Gate fix push|fix[[:space:]]*:/ || /Gate fix push \(deterministic/
  { s=$0; for(i=1;i<=4;i++) {if(getline line) s=s"\n"line} print NR": "s }
' .github/workflows/pr-monitor.yml || true

echo "== pr-monitor workflow context =="
awk 'NR>=1 && NR<=280 { printf "%5d  %s\n", NR, $0 }' .github/workflows/pr-monitor.yml

Repository: aloekun/claude-code-hook-test

Length of output: 39279


2c の workflow に一致する chain 宣言に更新してください。

.github/workflows/pr-monitor.yml には fix job、step 名 Gate fix push (deterministic, 4-axis AND)cli-fix-push-gate の実行パス、または --branch / --config / --diff-summary-file / --findings-file がありません。ADR-069 の chain 判定が参照する契約値が workflow と一致するように、2c とこの宣言を同じ値で揃えてください。

🤖 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 `@docs/harness-improvement-plan.md` around lines 182 - 185, 2b の chain 宣言を、2c
の実際の workflow 契約値に更新してください。docs/harness-improvement-plan.md の chain 記述で、fix
job、step 名、cli-fix-push-gate の実行パス、および
--branch/--config/--diff-summary-file/--findings-file の指定を
.github/workflows/pr-monitor.yml と完全に一致させ、lib-scope-guard と lib-autonomy-policy
の既存呼び手の記述は変更しないでください。


##### 2c: Phase B workflow + config 有効化 + ADR-067(約 470 行)

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"build:cli-takt-timings": "cargo build --release -p cli-takt-timings && node scripts/deploy-artifacts.mjs cli-takt-timings",
"build:cli-telemetry-report": "cargo build --release -p cli-telemetry-report && node scripts/deploy-artifacts.mjs cli-telemetry-report",
"build:cli-autonomy-gate": "cargo build --release -p cli-autonomy-gate && node scripts/deploy-artifacts.mjs cli-autonomy-gate",
"build:cli-fix-push-gate": "cargo build --release -p cli-fix-push-gate && node scripts/deploy-artifacts.mjs cli-fix-push-gate",
"build:hooks-settings": "node scripts/build-hooks-settings.mjs",
"build:all": "pnpm build:hooks-session-start && pnpm build:hooks-pre-tool-validate && pnpm build:hooks-post-tool-linter && pnpm build:hooks-post-tool-comment-lint-rust && pnpm build:hooks-post-tool-jj-op-verify && pnpm build:hooks-stop-quality && pnpm build:hooks-stop-feedback-dispatch && pnpm build:hooks-stop-tool-call-leak && pnpm build:hooks-user-prompt-feedback-recovery && pnpm build:cli-push-runner && pnpm build:cli-pr-monitor && pnpm build:cli-merge-pipeline && pnpm build:check-ci-coderabbit && pnpm build:cli-finding-classifier && pnpm build:cli-docs-lint && pnpm build:cli-takt-timings && pnpm build:cli-telemetry-report && pnpm build:cli-autonomy-gate && pnpm build:hooks-settings",
"build:all": "pnpm build:hooks-session-start && pnpm build:hooks-pre-tool-validate && pnpm build:hooks-post-tool-linter && pnpm build:hooks-post-tool-comment-lint-rust && pnpm build:hooks-post-tool-jj-op-verify && pnpm build:hooks-stop-quality && pnpm build:hooks-stop-feedback-dispatch && pnpm build:hooks-stop-tool-call-leak && pnpm build:hooks-user-prompt-feedback-recovery && pnpm build:cli-push-runner && pnpm build:cli-pr-monitor && pnpm build:cli-merge-pipeline && pnpm build:check-ci-coderabbit && pnpm build:cli-finding-classifier && pnpm build:cli-docs-lint && pnpm build:cli-takt-timings && pnpm build:cli-telemetry-report && pnpm build:cli-autonomy-gate && pnpm build:cli-fix-push-gate && pnpm build:hooks-settings",
"push": "node scripts/run-artifact.mjs cli-push-runner && node scripts/run-artifact.mjs cli-pr-monitor --monitor-only",
"create-pr": "node scripts/run-artifact.mjs cli-pr-monitor",
"mark-notified": "node scripts/run-artifact.mjs cli-pr-monitor --mark-notified",
Expand Down
10 changes: 3 additions & 7 deletions src/cli-autonomy-gate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
toml = "0.8"
# is_truthy (受理集合 1|true|yes|on) と発火テレメトリ (ADR-055) の両方を借りる。
# 受理集合を再実装すると kill-switch ごとに truthy 解釈が drift するため必ず共有する。
# 判定コアは lib へ集約 (ADR-066 § 決定 4)。本 crate は CLI 面だけを持つ。
lib-autonomy-policy = { path = "../lib-autonomy-policy" }
# deny の発火記録 (ADR-055)。
lib-telemetry = { path = "../lib-telemetry" }

[dev-dependencies]
tempfile = "3"

# [profile.release] は workspace root (Cargo.toml) に集約 (ADR-026)
32 changes: 18 additions & 14 deletions src/cli-autonomy-gate/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
//! `cli-autonomy-gate` — 自律実行の全体 kill-switch ゲート (WP-17 PR 1、ADR-066)。
//!
//! 自律 actor (GitHub Actions の無人 fix push、夜間 todo 消化ループ、cloud routine) が
//! ADR-052 の自動実行可クラスの操作を行う **直前** に呼び、許可されているかを exit コードで
//! 受け取るための決定論ゲート。run 冒頭で 1 回だけ判定するのではなく操作境界ごとに呼ぶ
//! (ADR-052 停止手順「フラグを OFF にすると次の自律実行判定から無効化される」を満たすため)。
//! 判定そのものは [`lib_autonomy_policy`] が持つ。本 exe はその CLI 面 (引数解析・loud 出力・
//! exit コード・telemetry) だけを担う汎用ゲートで、`pnpm autonomy-status` と drill が呼ぶ。
//!
//! Phase B の fix push 直前ゲートは `cli-fix-push-gate` を使うこと (ADR-067)。あちらは
//! kill-switch に加えて ADR-052 の target / 内容軸と ADR-054 scope guard も 1 回で評価する。
//! 本 exe と `&&` で連鎖させる運用は**しない** — 連鎖の書き忘れで kill-switch を通り越す
//! 合成ミスを構造的に防ぐため、fix push 経路は単一 exe に閉じる方針とする。
//!
//! # 使い方
//!
Expand All @@ -20,20 +23,21 @@
//! **呼び手は非ゼロをすべて拒否として扱うこと。** `1` だけを拒否とみなして `2` を通すと、
//! 引数を間違えた瞬間に fail-open する。
//!
//! # bounded lifetime (ADR-066)
//!
//! decision trigger: Phase B 稼働後の自律 fix push 3〜5 run で (a) 有効時に通ること、
//! (b) いずれかのフラグを倒すと次の操作境界で止まること、(c) deny 理由が run log だけで
//! 切り分けられること、を確認したら本採用。2026-11-02 までに未判定なら延長 / 却下を判断する。
//!
//! # 出力
//!
//! 判定は必ず loud に出す (無音 no-op 禁止)。allow は stdout の `[AUTONOMY_ALLOW]`、deny は
//! stderr の `[AUTONOMY_OFF]` で、どちらも全ソースの状態と読み取り先 config パスを含む。
//! 「何もしなかった run」の原因が run log だけで切り分けられることを要件とする
//! (ADR-064 の silent-success 排除と同じ論理)。ADR-060 の `CLOUD_HARNESS` は無効時無音を
//! 選んだが、あれはローカル常時発火のノイズ対策という個別事情で本 exe には適用しない。

mod decision;
mod sources;

use std::path::PathBuf;

use decision::{Decision, DenyReason, GateInputs, Operation};
use lib_autonomy_policy::{describe_sources, evaluate, Decision, DenyReason, GateInputs, Operation};
use lib_autonomy_policy::sources;

/// 許可時の grep マーカー (stdout)。
const MARKER_ALLOW: &str = "[AUTONOMY_ALLOW]";
Expand All @@ -53,7 +57,7 @@ fn main() {
/// コマンドライン設定。既定値は設けない — 両方とも明示必須。
///
/// `--config` を省略可能にして cwd から推測すると、CI で master ref の写しを渡し忘れた
/// 呼び手が PR ブランチの config を黙って読む (上記 [`sources`] の信頼境界)。省略を
/// 呼び手が PR ブランチの config を黙って読む (ADR-066 § 決定 3 の信頼境界)。省略を
/// 引数不正として弾くことで、呼び手にパスの出所を必ず意識させる。
struct Cli {
operation: Operation,
Expand Down Expand Up @@ -111,9 +115,9 @@ fn run(args: Vec<String>) -> i32 {
/// 判定と loud 出力。allow / deny のどちらでも全ソースの状態を 1 行目に出す。
fn report(cli: &Cli, inputs: GateInputs<'_>) -> i32 {
let config_display = cli.config_path.display();
let state = decision::describe_sources(inputs, sources::EXTERNAL_ENV);
let state = describe_sources(inputs, sources::EXTERNAL_ENV);
let operation = cli.operation.as_str();
match decision::evaluate(inputs) {
match evaluate(inputs) {
Decision::Allowed => {
println!("{MARKER_ALLOW} operation={operation} config={config_display} {state}");
EXIT_ALLOWED
Expand Down
19 changes: 19 additions & 0 deletions src/cli-fix-push-gate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "cli-fix-push-gate"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# 4 軸すべて既存の単一実装を借りる。本 crate 固有の判定ロジックは AND 合成と順序だけで、
# 各軸の基準を再実装しない (再実装は ADR-035 / ADR-054 の drift 再生産にあたる)。
lib-autonomy-policy = { path = "../lib-autonomy-policy" }
lib-docs-policy = { path = "../lib-docs-policy" }
lib-scope-guard = { path = "../lib-scope-guard" }
lib-telemetry = { path = "../lib-telemetry" }

[dev-dependencies]
tempfile = "3"

# [profile.release] は workspace root (Cargo.toml) に集約 (ADR-026)
Loading
Loading