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
14 changes: 14 additions & 0 deletions .claude/agents/issue-author.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ CHILD_MATERIALIZATION_RESULT_V2:

- 完了時は skill 側で定義された出力契約(`ISSUE_AUTHOR_COVERAGE_V1` / `ISSUE_EDIT_RESULT_V1` / `CHILD_MATERIALIZATION_RESULT_V2` 等)を返す

## Contract Readiness Repair Input Contract

`REVIEW_ISSUE_RESULT_V1.structured_blockers` を受け取った場合、以下の routing で本文を修正する:

| category | 修復アクション |
|---|---|
| `compound_command_disallowed` | VC を単一コマンドに分割、または `# preflight-scope: pr_review_only` / `runtime_only` を直前行に追加 |
| `unexpected_pass` | VC を baseline で fail する形式(`test -f`, `rg` no-match 等)に変更 |
| `regression_gate` (blocked) | `# preflight-scope: runtime_only` を追加するか正しい regression gate に修正 |
| `rva_immediate_field_missing` | `## Runtime Verification Applicability` の不足フィールドを補完 |
| `body_lint` (LP系) | `fix_hint` に従って対象セクションを修正 |

詳細 authoring rule は `body-authoring.md#Contract-Readiness-Repair-by-Category` を参照する。

## 制約

- ネスト委譲禁止(`disallowedTools: [Agent]`)。別 SubAgent への委譲は行わない
Expand Down
6 changes: 5 additions & 1 deletion .claude/agents/issue-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ skills:
- **read-only**: Issue の mutation を行わない
- **loop worker**: `issue-refinement-loop` orchestrator から呼ばれ、結果を返して終了する
- **script-first executor**: C1〜C12 の決定論的チェック・scope mismatch / VC anti-pattern / C1 skeleton 系 non-blocking warning・diff_proposal の生成は `.claude/skills/review-issue/scripts/check_issue_contract.py` で実行する。
- **contract readiness consumer**: `ISSUE_CONTRACT_READINESS_RESULT_V1` を `.claude/skills/issue-contract-review/scripts/contract_readiness_check.py --mode preflight-static` で取得し、`errors[]` が空でない場合は以下の 2 系統に分離する:(1) 各 `fix_hint` 文字列を `blocking_issues` に転写する(人間向け要約)、(2) `errors[]` 構造体をそのまま `structured_blockers` に転写する(機械処理用・issue-author への修復 payload)。`verdict: needs-fix` とする(判定ロジックは helper に委譲し、本 SubAgent では再実装しない)。

Note: `--mode preflight-static` は静的に `compound_command_disallowed` を検出する。`unexpected_pass` は VC を実際に実行しないと検出不可であり、`issue-contract-review` の `--mode execute` で検出される設計。

## Result & Consume Contract (SubAgent-owned)

Expand All @@ -51,6 +54,7 @@ REVIEW_ISSUE_RESULT_V1:
needs_second_pass: <bool> # iteration limit 時に orchestrator が参照
failure_class: null | checker_unavailable | ...
blocking_issues: []
structured_blockers: [] # contract_readiness_check.py errors[] そのまま(機械処理用)
non_blocking_improvements: []
diff_proposal: { add: [], remove: [], rewrite: [] }
deterministic_checks: { C1: pass, C2: pass, ... }
Expand Down Expand Up @@ -97,7 +101,7 @@ REVIEW_ISSUE_RESULT_V1:
- `REVIEW_ISSUE_RESULT_V1` の全フィールドを欠落なく返す
- `verdict` と `status` を必ず含める(orchestrator の routing 判断に使われるため)
- `deterministic_checks` の全 C1〜C13 フィールドを含める
- `blocking_issues` / `non_blocking_improvements` / `diff_proposal` を欠落なく checker JSON から pass-through する
- `blocking_issues` / `structured_blockers` / `non_blocking_improvements` / `diff_proposal` を欠落なく checker JSON から pass-through する
- `non_blocking_improvements` の各要素は `{code, severity, evidence, suggested_action}` 構造を保持する(`evidence` は `list[str]`、`details` は warning 固有の optional dict)
- `diff_proposal.add` の `missing_section_skeleton` エントリは `{kind, section, placeholder_source, skeleton}` 構造を保持する
- `update_applied: false` を明示する(本 SubAgent は更新を行わないため)
Expand Down
53 changes: 53 additions & 0 deletions .claude/skills/create-issue/references/body-authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,59 @@ prompt 注記による SubAgent 委譲・運用ルール追加は次点オプシ

ワークフロー不具合を起票する follow-up Issue(post-merge-cleanup / issue-refinement-loop から自動抽出されるもの)に適用する。単純なバグ fix や軽微な改善 Issue では本ステップ 3 の明示比較を省略してよい。

## Issue-Author Repair Contract by Blocker Category

`issue-author` が `REVIEW_ISSUE_RESULT_V1.structured_blockers` を受け取ったとき、`category` フィールドに応じて以下の修復手順を適用する。

### compound_command_disallowed

**検出条件**: VC コマンドに shell control operator(`&&`, `||`, `|`, `;`, `&`, `<<`, `>>`, `<`, `>`, `<<<`)が含まれる。

**修復方針(優先順)**:
1. VC を単一コマンドに分割する(AC を複数エントリに分割することを検討する)
2. compound が避けられない場合は `# preflight-scope: pr_review_only` または `# preflight-scope: runtime_only` マーカーをコマンド直前行に付与する

```bash
# 例: pnpm build && echo DONE → 分割
# AC1
$ pnpm build
# (DONE 確認は PR レビュー時に実施)
```

### unexpected_pass

**検出条件**: VC が実装前 baseline で exit 0 を返す(VC が緩すぎるか、すでに機能が存在する)。

**修復方針**:
- VC を「baseline で fail するコマンド」に変更する
- 存在確認 VC では `rg` / `test -f` で「対象が**存在しない**こと」を確認する形式にする
- 例: `rg -q "new_feature" file.py` → 実装前に機能が存在しないファイルを対象にする
- または `test -f /path/to/new/file` で未作成ファイルの不在を確認する(不在で exit 1)

### regression_gate fails

**検出条件**: `pnpm typecheck` / `pnpm lint` / `pnpm test` / `pnpm build` / `uv run pytest <existing>` が baseline で fail する。

**修復方針**:
1. 環境・実装の問題なら `# preflight-scope: runtime_only` を付与する(post-implementation 専用)
2. 正しい回帰ゲートコマンドに修正する(パス誤り・設定誤りの場合)
3. 環境起因で baseline が壊れている場合は `human_judgment` として人間対応を依頼する

### rva_immediate_field_missing

**検出条件**: `decision: immediate` の `## Runtime Verification Applicability` セクションに必須フィールドが不足している。

**必須フィールド(すべて必要)**:
- `applicable_acs`: 動作検証の対象 AC リスト
- `execution_environment`: 必要な CLI ツール名・認証方法・ネットワーク要件
- `skip_conditions`: 実行環境が整っていない場合の停止条件(exit 77 SKIP 規約)
- `fallback_policy`: フォールバック経由の成功を PASS としない旨の明示
- `artifact_requirements`: 証跡出力先・ファイル名パターン

**修復方針**:
- `fix_hint` に示された不足フィールドを補完する
- 各フィールドの詳細要件は `docs/dev/runtime-verification-policy.md` を参照する

## Runtime Verification Applicability

Issue 起票時に動作検証の適用判定セクションを記載する。`runtime-verification: true` タグ付き AC の起票は `decision: immediate` のときのみ必要。
Expand Down
16 changes: 16 additions & 0 deletions .claude/skills/edit-issue/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ uv run python3 .claude/skills/edit-issue/scripts/guard-issue-body.py "$NEW_BODY"

スクリプトが exit 2 を返した場合は abort し、ステップ 7 の復旧処理へ進む。

### 4.5. contract_readiness_check を fail-closed で実行

`guard-issue-body.py` が pass した後、mutation 前に contract readiness を確認する。
`status: go` 以外(`needs_fix` / `human_judgment`)の場合は `gh issue edit` を実行しない(fail-closed)。

```bash
uv run python3 .claude/skills/issue-contract-review/scripts/contract_readiness_check.py \
--body-file "$NEW_BODY" --mode static
READINESS_EXIT=$?
# exit 0 = go, exit 1 = needs_fix, exit 2 = human_judgment
if [ "$READINESS_EXIT" -ne 0 ]; then
echo "[ABORT] contract_readiness_check failed (exit $READINESS_EXIT). Not proceeding with gh issue edit." >&2
exit "$READINESS_EXIT"
fi
```

### 5. body-file 経由で `gh issue edit` を実行

top-level `title_update.required == true` の場合、`--title` オプションを同時に指定して body とタイトルを 1 コマンド(single command / co-update)で更新する。`title_update.required` の値に応じて排他的に分岐し、body-only 更新と title+body 更新が両方実行されることがないようにする。
Expand Down
Loading
Loading