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
2 changes: 2 additions & 0 deletions .claude/skills/issue-refinement-loop/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ delivery-rollup parent の child materialization gate と、approve 後の follo

終了条件、`human_escalation` 経路、scope change signal 停止、loop termination table は `references/termination-policy.md` を参照する。

`approved` 終了時は `LOOP_HANDOFF_RESULT_V1` marker を終了コメントに出力する(形式・routing rules は `references/termination-policy.md#LOOP_HANDOFF_RESULT_V1` 参照)。出力は `<!-- LOOP_HANDOFF_RESULT_V1 -->` HTML comment と fenced YAML block の 2 要素。

## Reference Map

| topic | primary reference |
Expand Down
102 changes: 102 additions & 0 deletions .claude/skills/issue-refinement-loop/references/termination-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,105 @@ LOOP_POLICY_V1:
- required_external_research_unresolved
- unsafe_mutation
```

## LOOP_HANDOFF_RESULT_V1 — Terminal Contract (SSOT)

`issue-refinement-loop` が `approved` 終了するとき、終了コメントに `LOOP_HANDOFF_RESULT_V1` marker を出力する。
本セクションが `LOOP_HANDOFF_RESULT_V1` の唯一の SSOT である。

### Output Format

出力は HTML comment と fenced YAML block の 2 要素で構成する:

````
<!-- LOOP_HANDOFF_RESULT_V1 -->
```yaml
LOOP_HANDOFF_RESULT_V1:
status: impl_ready | human_judgment_required | blocked
...
```
````

`<!-- LOOP_HANDOFF_RESULT_V1 -->` HTML comment が marker の開始行を示す。
fenced YAML ブロックが marker の内容を保持する。

### Schema(JSON Schema: `schemas/loop_handoff_result_v1.json`)

```yaml
LOOP_HANDOFF_RESULT_V1:
status: impl_ready | human_judgment_required | blocked
routing_action: run_impl_review_loop | ask_human | blocked
contract_review:
status: go | blocked # CONTRACT_REVIEW_RESULT_V1.status を echo(衝突回避のため separated)
gate_result: fresh_go | missing_go | stale_go | invalidated_by_request_changes | blocked
latest_comment_url: string
generated_at: ISO-8601
body_sha256: string
metadata:
title_prefix_ready: bool
phase_label_ready: bool
auto_fixes:
result: auto_fixed | human_judgment_required | blocked
required:
- kind: template_hygiene | metadata_hygiene | known_marker_fix | stale_state_label_cleanup | contract_snapshot_materialization
executor: implementation-worker
result: applied | skipped | failed
evidence:
before: string
after: string
comment_url: string
skipped: []
blockers:
- kind: string
description: string
permissions:
unavailable: []
generated_at: ISO-8601
```

### `impl_ready` 定義

`status: impl_ready` を出力できるのは以下のすべてが真のときのみ:

1. `contract_review.gate_result == fresh_go` — 最新の `CONTRACT_REVIEW_RESULT_V1.status == "go"` が存在し、現 Issue body hash に対して fresh
2. `contract_review.status == go` が後続の `request_changes` / `blocked` により無効化されていない
3. `metadata.title_prefix_ready == true` または `auto_fixes.required` に `metadata_hygiene` / `template_hygiene` の `result: applied` エントリが存在する
4. `metadata.phase_label_ready == true` または同上の auto-fix applied エントリが存在する
5. `auto_fixes.required` が空(または全 applied 済み)かつ `auto_fixes.skipped` が空
6. `blockers` が空
7. `routing_action == run_impl_review_loop`

**Title prefix / phase label 不在のみを理由に `impl_ready` を拒否してはならない** — implementation-worker (repair mode) が auto-fix evidence を添付していれば `impl_ready` は許可される。

`auto_fixes.required` / `auto_fixes.skipped` の各エントリは `kind` / `executor` / `result` / `evidence`(`before` / `after` / `comment_url`)を含む。`result: skipped` または `evidence` 欠如 → `impl_ready` 禁止。

### Routing Rules

| 条件 | `status` | `routing_action` |
|---|---|---|
| 全 invariant 満足(上記 1〜7) | `impl_ready` | `run_impl_review_loop` |
| `contract_review.gate_result` が `missing_go` / `stale_go` | `blocked` | `blocked` |
| `request_changes` / `blocked` が `go` を後続で無効化 | `blocked` | `blocked` |
| scope / goal / AC に semantic change が検出された | `human_judgment_required` | `ask_human` |
| `blockers` に 1 件以上 | `blocked` | `blocked` |
| fixer unavailable かつ title/label 不在 | `human_judgment_required` | `ask_human` |
| `auto_fixes.skipped` に 1 件以上 | `human_judgment_required` | `ask_human` |

### `human_judgment_required` 停止条件

scope / goal / AC への semantic change が検出されたとき、`issue-refinement-loop` は `LOOP_HANDOFF_RESULT_V1.status: human_judgment_required` / `routing_action: ask_human` で停止し、人間の判断を仰ぐ。Semantic change の検出は `references/scope-signal-guard.md` の guard 定義を参照する。

### Hygiene Delegation Contract(routing 定義のみ)

以下の 5 種 hygiene は implementation-worker (repair mode) に委譲する:

| kind | 委譲先 | 委譲条件 |
|---|---|---|
| `template_hygiene` | implementation-worker (repair mode) | 既定テンプレートセクション欠落 |
| `metadata_hygiene` | implementation-worker (repair mode) | title prefix / phase label 不在 |
| `known_marker_fix` | implementation-worker (repair mode) | 既知の壊れた marker 形式を検出 |
| `stale_state_label_cleanup` | implementation-worker (repair mode) | stale `state/blocked` / `state/queued` を検出 |
| `contract_snapshot_materialization` | implementation-worker (repair mode) | contract snapshot comment 未作成 |

各委譲は `auto_fixes.required` エントリとして記録し、`result: applied` かつ `evidence` 完備のものだけが `impl_ready` に貢献する。

Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "loop_handoff_result_v1",
"title": "LOOP_HANDOFF_RESULT_V1",
"description": "Terminal output of issue-refinement-loop on approved termination. SSOT: references/termination-policy.md",
"type": "object",
"required": ["LOOP_HANDOFF_RESULT_V1"],
"additionalProperties": false,
"properties": {
"LOOP_HANDOFF_RESULT_V1": {
"type": "object",
"required": [
"status",
"routing_action",
"contract_review",
"metadata",
"auto_fixes",
"blockers",
"permissions",
"generated_at"
],
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"enum": ["impl_ready", "human_judgment_required", "blocked"]
},
"routing_action": {
"type": "string",
"enum": ["run_impl_review_loop", "ask_human", "blocked"]
},
"contract_review": {
"type": "object",
"required": ["status", "gate_result", "latest_comment_url", "generated_at", "body_sha256"],
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"enum": ["go", "blocked"],
"description": "Mirrors CONTRACT_REVIEW_RESULT_V1.status. Does not collide with top-level LOOP_HANDOFF_RESULT_V1.status."
},
"gate_result": {
"type": "string",
"enum": [
"fresh_go",
"missing_go",
"stale_go",
"invalidated_by_request_changes",
"blocked"
]
},
"latest_comment_url": {
"type": "string"
},
"generated_at": {
"type": "string",
"format": "date-time"
},
"body_sha256": {
"type": "string"
}
}
},
"metadata": {
"type": "object",
"required": ["title_prefix_ready", "phase_label_ready"],
"additionalProperties": false,
"properties": {
"title_prefix_ready": {
"type": "boolean"
},
"phase_label_ready": {
"type": "boolean"
}
}
},
"auto_fixes": {
"type": "object",
"required": ["result", "required", "skipped"],
"additionalProperties": false,
"properties": {
"result": {
"type": "string",
"enum": ["auto_fixed", "human_judgment_required", "blocked"]
},
"required": {
"type": "array",
"items": { "$ref": "#/definitions/auto_fix_item" }
},
"skipped": {
"type": "array",
"items": { "$ref": "#/definitions/auto_fix_item" }
}
}
},
"blockers": {
"type": "array",
"items": {
"type": "object",
"required": ["kind", "description"],
"additionalProperties": false,
"properties": {
"kind": { "type": "string" },
"description": { "type": "string" }
}
}
},
"permissions": {
"type": "object",
"required": ["unavailable"],
"additionalProperties": false,
"properties": {
"unavailable": {
"type": "array",
"items": { "type": "string" }
}
}
},
"generated_at": {
"type": "string",
"format": "date-time"
}
},
"allOf": [
{
"if": {
"properties": { "status": { "const": "impl_ready" } },
"required": ["status"]
},
"then": {
"properties": {
"routing_action": { "const": "run_impl_review_loop" },
"contract_review": {
"properties": {
"status": { "const": "go" },
"gate_result": { "const": "fresh_go" }
}
},
"blockers": { "maxItems": 0 },
"permissions": {
"properties": { "unavailable": { "maxItems": 0 } }
},
"auto_fixes": {
"properties": { "skipped": { "maxItems": 0 } }
}
}
}
}
]
}
},
"definitions": {
"auto_fix_item": {
"type": "object",
"required": ["kind", "executor", "result", "evidence"],
"additionalProperties": false,
"properties": {
"kind": {
"type": "string",
"enum": [
"template_hygiene",
"metadata_hygiene",
"known_marker_fix",
"stale_state_label_cleanup",
"contract_snapshot_materialization"
]
},
"executor": {
"type": "string",
"enum": ["implementation-worker"]
},
"result": {
"type": "string",
"enum": ["applied", "skipped", "failed"]
},
"evidence": {
"type": "object",
"required": ["before", "after", "comment_url"],
"additionalProperties": false,
"properties": {
"before": { "type": "string" },
"after": { "type": "string" },
"comment_url": { "type": "string" }
}
}
}
}
}
}
Loading
Loading