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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
scenario: v2_unknown_required_auto_actions_kind
description: "AC4/AC6: unknown required_auto_actions.kind must fail closed"
verdict:
verdict: APPROVE
merge_ready: false
reviewed_head_sha: "abc123def456"
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
required_auto_actions:
- kind: rotate_branch_magic
executor: implementation-worker
skill: implement-issue
expected_head_sha: "abc123def456"
expected:
route: fail_closed_unknown_required_auto_actions_kind
fail_closed: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
scenario: v2_update_branch_behind
description: "AC3: BEHIND verdict routes to update_branch via LOOP_VERDICT_V2.required_auto_actions"
verdict:
verdict: APPROVE
merge_ready: false
reviewed_head_sha: "abc123def456"
mergeability:
mergeable: MERGEABLE
merge_state_status: BEHIND
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue
expected_head_sha: "abc123def456"
expected:
route: route_to_update_branch
fail_closed: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
scenario: v2_update_branch_expected_head_sha_guard
description: "AC5: expected_head_sha guard must fail closed when missing or mismatched"
cases:
- name: missing_expected_head_sha
verdict:
verdict: APPROVE
merge_ready: false
reviewed_head_sha: "abc123def456"
mergeability:
mergeable: MERGEABLE
merge_state_status: BEHIND
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue
expected_head_sha: null
expected:
route: fail_closed_expected_head_sha_guard
fail_closed: true
- name: mismatched_expected_head_sha
verdict:
verdict: APPROVE
merge_ready: false
reviewed_head_sha: "abc123def456"
mergeability:
mergeable: MERGEABLE
merge_state_status: BEHIND
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue
expected_head_sha: "zzz999yyy888"
expected:
route: fail_closed_expected_head_sha_guard
fail_closed: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""
Regression fixtures for impl-review-loop V2 routing boundary.

Issue #454 fixes the consumer-side boundary registry for
TEST_VERDICT_MACHINE/v1.branch_behind_main and
LOOP_VERDICT_V2.required_auto_actions[].kind|executor|skill|expected_head_sha.
The fixtures in this module freeze the canonical V2 path and the fail-closed
behavior for unknown action kinds and stale/missing expected_head_sha guards.

TEST_VERDICT_MACHINE:
version: 1
result: pass
head_sha: "pending"
commands:
- command: "uv run pytest .claude/skills/impl-review-loop/tests/test_v2_routing_boundary_regression.py -v"
exit_code: 0
stdout_sha256: "pending"
fixtures:
- case: "AC3_v2_update_branch_behind"
after_pass_verified: true
- case: "AC4_v2_unknown_required_auto_actions_kind"
after_pass_verified: true
- case: "AC5_v2_expected_head_sha_guard"
after_pass_verified: true
skipped: []
"""

from __future__ import annotations

from pathlib import Path

import yaml

REPO_ROOT = Path(__file__).resolve().parents[4]
BOUNDARY_DOC = REPO_ROOT / "docs" / "dev" / "agent-skill-boundaries.md"
FIXTURES_DIR = REPO_ROOT / ".claude" / "skills" / "impl-review-loop" / "tests" / "fixtures"

ALLOWED_ACTION_KINDS = {
"ensure_closing_keyword",
"update_pr_body_hygiene",
"update_branch",
"apply_pr_review_fix_delta",
}


def _read(path: Path) -> str:
return path.read_text(encoding="utf-8")


def _load_yaml_fixture(name: str) -> dict:
return yaml.safe_load((FIXTURES_DIR / name).read_text(encoding="utf-8"))


def _route_required_auto_action(verdict: dict) -> str:
merge_state_status = verdict.get("mergeability", {}).get("merge_state_status")
required_auto_actions = verdict.get("required_auto_actions", [])
reviewed_head_sha = verdict.get("reviewed_head_sha")

if merge_state_status == "BEHIND" and not required_auto_actions:
return "fail_closed_missing_required_auto_actions"

for action in required_auto_actions:
kind = action.get("kind")
if kind not in ALLOWED_ACTION_KINDS:
return "fail_closed_unknown_required_auto_actions_kind"

if kind == "update_branch":
expected_head_sha = action.get("expected_head_sha")
if not expected_head_sha or expected_head_sha != reviewed_head_sha:
return "fail_closed_expected_head_sha_guard"
return "route_to_update_branch"

return "route_to_required_auto_action"


def test_given_boundary_doc_when_read_then_v2_routing_fields_are_registered() -> None:
body = _read(BOUNDARY_DOC)
assert "TEST_VERDICT_MACHINE/v1.branch_behind_main" in body
assert "LOOP_VERDICT_V2.required_auto_actions[].kind" in body
assert "LOOP_VERDICT_V2.required_auto_actions[].executor" in body
assert "LOOP_VERDICT_V2.required_auto_actions[].skill" in body
assert "LOOP_VERDICT_V2.required_auto_actions[].expected_head_sha" in body


def test_given_boundary_doc_when_read_then_stale_v1_wording_is_marked_noncanonical() -> None:
body = _read(BOUNDARY_DOC)
assert "LOOP_VERDICT.recommendations must not be treated as a canonical routing field" in body
assert "unknown required_auto_actions.kind must fail closed" in body


def test_given_v2_update_branch_fixture_when_routed_then_update_branch_path_is_selected() -> None:
fixture = _load_yaml_fixture("v2_update_branch_behind.yml")
verdict = fixture["verdict"]
action = verdict["required_auto_actions"][0]

assert action["kind"] == "update_branch"
assert action["executor"] == "implementation-worker"
assert action["skill"] == "implement-issue"
assert action["expected_head_sha"] == verdict["reviewed_head_sha"]
assert _route_required_auto_action(verdict) == fixture["expected"]["route"]


def test_given_unknown_kind_fixture_when_routed_then_it_fails_closed() -> None:
fixture = _load_yaml_fixture("v2_unknown_required_auto_actions_kind.yml")
verdict = fixture["verdict"]

assert verdict["required_auto_actions"][0]["kind"] == "rotate_branch_magic"
assert _route_required_auto_action(verdict) == fixture["expected"]["route"]
assert fixture["expected"]["fail_closed"] is True


def test_given_expected_head_sha_guard_fixture_when_routed_then_missing_or_mismatch_fails_closed() -> None:
fixture = _load_yaml_fixture("v2_update_branch_expected_head_sha_guard.yml")

for case in fixture["cases"]:
route = _route_required_auto_action(case["verdict"])
assert route == case["expected"]["route"], case["name"]
assert case["expected"]["fail_closed"] is True
26 changes: 26 additions & 0 deletions docs/dev/agent-skill-boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ routing_allowed_fields:
TEST_VERDICT_MACHINE/v1:
- status # pass | partial | fail
- summary # 統計のみ(raw 出力は参照しない)
- branch_behind_main # impl-review-loop Step 5 の BEHIND reroute 判定で使う routing-critical field
LOOP_VERDICT:
- verdict # APPROVE | REQUEST_CHANGES
- status # ok | failed
Expand All @@ -686,6 +687,31 @@ routing_allowed_fields:

詳細な domain judgment(blocking_issues のテキスト / diff_proposal の内容 / test failure の詳細 等)は、後続 SubAgent へ参照(GitHub comment URL / issue_url)として渡す。オーケストレーターが詳細を再解釈しない。

#### impl-review-loop V2 routing boundary

`impl-review-loop` Step 5 は `LOOP_VERDICT_V2.required_auto_actions` を canonical な routing source として扱う。`LOOP_VERDICT.recommendations` は V1 時代の stale wording であり、現行 consumer path の canonical field として復活させてはならない。

```yaml
impl_review_loop_v2_routing_boundary:
TEST_VERDICT_MACHINE/v1.branch_behind_main:
classification: routing_critical
LOOP_VERDICT_V2.required_auto_actions[].kind:
classification: routing_critical
LOOP_VERDICT_V2.required_auto_actions[].executor:
classification: routing_critical
LOOP_VERDICT_V2.required_auto_actions[].skill:
classification: routing_critical
LOOP_VERDICT_V2.required_auto_actions[].expected_head_sha:
classification: routing_critical
LOOP_VERDICT_V2:
negative_rules:
- LOOP_VERDICT.recommendations must not be treated as a canonical routing field
- unknown required_auto_actions.kind must fail closed
- missing or mismatched expected_head_sha must fail closed before update_branch dispatch
```

`required_auto_actions[].kind` は action 種別の分岐点、`executor` / `skill` は data-plane 委譲先の決定、`expected_head_sha` は stale verdict を防ぐ race guard であり、いずれも routing-critical である。`branch_behind_main` は test-runner から Step 5 へ渡る補助信号で、BEHIND 状態の reroute 判断を `TEST_VERDICT_MACHINE/v1` 側から補強する field として扱う。

### 一時例外(temporary_exceptions)

以下は ORCHESTRATOR_IO_BOUNDARY_V1 の `forbidden_context` に対する一時的な例外として承認された項目:
Expand Down
Loading