Skip to content

実装: SubAgent result evidence gate で証跡なし成功報告を fail-closed にする #961

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "subagent(特に Haiku / fallback)の『完了』自己申告を、構造化証跡(PR/commit/changed_files/verification)が無ければ成功扱いしない Evidence Gate で fail-closed にし、control-plane の毎回手動再検証コストを削る"
change_kind: workflow

Parent Issue

none(単独改善 / mutation safety hardening の一部)

Parent Goal Ref

  • Goal: subagent の散文サマリや Done だけの報告を canonical 判定に使わず、必須 evidence field の有無で accept / rerun / human escalation を deterministic に route する
  • Desired Destination: validate_subagent_result_evidence.py が SUBAGENT_RESULT_EVIDENCE_GATE_V1 を返し、結果を LOOP_STATE に保存して散文 self-report を次 Step に渡さない

Current Validated Scope

  • .claude/skills/impl-review-loop/scripts/validate_subagent_result_evidence.py を新規追加する
  • .claude/skills/impl-review-loop/steps/preparation.md(または該当 step 文書)に gate 適用手順を追記する
  • .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py を新規追加する

Remaining Parent Gaps

  • Haiku を証跡収集専用へ寄せる capability routing は別 Issue(model capability router)で扱う
  • worktree 外 mutation の遮断は別 Issue(worktree scope guard)で扱う

Outcome

subagent raw output / expected role / issue・PR 番号 / expected contract snapshot URL を入力に、validate_subagent_result_evidence.py が SUBAGENT_RESULT_EVIDENCE_GATE_V1(status / missing_required_evidence / self_report_trusted / route)を返し、証跡欠落時に fail_closed を出し、結果を LOOP_STATE に記録して散文 self-report を次 Step に渡さない。新規 pytest と pnpm typecheck/lint/test/build が PASS する状態。

In Scope

  • implementation-worker の必須 evidence 検査(status / pr_url / worktree / branch / commit_sha / changed_files / verification.commands[] / git status 要約 / pr_number or existing_pr)
  • 散文のみ / Done のみ output の fail_closed 判定
  • status: ok でも必須 evidence 欠落なら fail_closed
  • changed_files 空かつ status: ok の indeterminate 判定
  • allowed_paths_compliance を advisory 扱いとし canonical 判定に使わない(review_subagent gate を要求する既存方針と一致)
  • low-cost agent 向け status: evidence_only(実装成功とは扱わない)
  • gate 結果の LOOP_STATE 保存
  • 対応するテスト追加

Out of Scope

  • Haiku capability routing 自体(別 Issue)
  • worktree 外 mutation 遮断(別 Issue)
  • review_subagent gate の再実装(本 Issue は evidence 有無の gate のみ)
  • Allowed Paths を impl-review-loop skill 外へ拡張すること

Acceptance Criteria

  • AC1: Done (...) だけ、または散文要約だけの output を fail_closed と判定する。
  • AC2: status: ok でも commit_sha / pr_url / verification のいずれかが欠落していれば fail_closed と判定する。
  • AC3: changed_files が空なのに status: ok の output を indeterminate と判定する。
  • AC4: allowed_paths_compliance を canonical 判定に使わず advisory 扱いとし、review_subagent gate を要求する(既存方針と一致)。
  • AC5: gate 結果を LOOP_STATE に保存し、次 Step に散文 self-report を渡さない(step 文書に明記され、保存先がテストで確認できる)。
  • AC6: Haiku / low-cost agent の output は status: evidence_only を許容し、実装成功(accept)とは扱わない。
  • AC7: uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py, pnpm typecheck, pnpm lint, pnpm test, pnpm build が PASS する。

Runtime Verification Applicability

decision: not_applicable
reason: "raw output に対する evidence 検査 script + docs 変更であり、外部 service 実行を成功条件に含まない。全 AC は fixtures + pytest で静的検証可能"

Verification Commands

baseline では新規 script / test が未作成のため、AC1〜AC6 の pytest は file not found(pytest exit 4)で baseline-fail する(baseline-expect: fail)。実装後に PASS する。AC7 は regression gate。

# AC1
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "prose_only_fail_closed" -v
# AC2
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "ok_missing_evidence" -v
# AC3
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "empty_changed_files_indeterminate" -v
# AC4
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "allowed_paths_advisory" -v
# AC5
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "loop_state_persist" -v
# AC6
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_validate_subagent_result_evidence.py -k "evidence_only_haiku" -v
# AC7
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • .claude/skills/impl-review-loop/scripts/validate_subagent_result_evidence.py
  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/impl-review-loop/tests/(evidence gate 関連テスト / fixtures のみ)

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • review_subagent gate 自体の再実装が必要になった場合
  • LOOP_STATE スキーマの破壊的変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割)
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python 3(構造化 output パース / fixtures ベーステスト)
  • impl-review-loop の subagent contract(IMPLEMENT_RESULT_V1)と LOOP_STATE の理解

Scope Delta(任意)

N/A

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jun 17, 2026
  2. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    Disposition: #1860 の結論待ち(OPEN のまま維持)

    親 Issue #1889(parent, delivery-rollup)の owner comment(https://github.com/squne121/loop-protocol/issues/1889#issuecomment-5149813241)に基づく敵対的レビューは、本 Issue が提案する新規スクリプト・新規 LOOP_STATE 永続化が、#1860(「導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する」、現在 OPEN)の方向性と整合しない可能性を指摘し、not planned 候補としました。

    ただし #1860 自体がまだ結論に至っていないため、本 Issue を close するかどうかは #1860 の結論確定後に人間が判断します。本コメントは disposition 保留の記録であり、Issue の状態・内容は変更しません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions