Skip to content

実装: SAFETY_CLAIMS_V1 parser を追加して Safety Claim Matrix を機械的に検証する決定論的ゲートを導入する(#137 Phase 2) #144

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#137"
goal_ref: "AI エージェント自律ループにおける安全主張の機械的検証ゲートを導入し、SAFETY_CLAIMS_V1 形式で記述された claim が parse・検査されることで過大主張が決定論的に検出される状態を実現する"
change_kind: mixed

Parent Issue

#137

Parent Goal Ref

Current Validated Scope

  • .claude/skills/pr-review-judge/scripts/check_safety_claims.py の新規実装(SAFETY_CLAIMS_V1 parse + fail-closed verdict 出力)
  • docs/dev/safety-claim-policy.md の新規作成(SAFETY_CLAIMS_V1 schema 定義 + 人間向け原則)

Remaining Parent Gaps

Outcome

check_safety_claims.py が PR body / diff / linked issue を入力として SAFETY_CLAIM_VERDICT_V1 を出力し、SAFETY_CLAIMS_V1 が存在しない / parse 不能 / 整合性不備の場合に fail-closed(exit 非 0)となり、docs/dev/safety-claim-policy.md に schema 定義と原則が明文化されている状態

In Scope

  • docs/dev/safety-claim-policy.md の新規作成
    • SAFETY_CLAIMS_V1 YAML schema の定義(フィールド: id / claim / claim_scope / closed_by / not_controlled / evidence_commands / follow_up / allowed_public_phrasing / prohibited_unqualified_phrases)
    • safety-sensitive PR の判定条件(changed paths / diff keywords / linked issue text)
    • APPROVE 禁止条件(nuanced: not_controlled 非空 + 無限定表現 or follow-up なし)
    • bounded claim(not_controlled 非空でも表現が閉じた経路に限定)の扱い
  • .claude/skills/pr-review-judge/scripts/check_safety_claims.py の新規実装
    • 入力: PR body(テキスト)、changed files リスト、linked issue body(テキスト)、PR diff(テキスト)
    • SAFETY_CLAIMS_V1 ブロックを PR body から抽出・parse
    • SAFETY_CLAIM_VERDICT_V1 を stdout に出力
    • fail-closed: SAFETY_CLAIMS_V1 が必要なのに欠落・parse 不能・整合性不備の場合は exit 1

Out of Scope

Acceptance Criteria

  • AC1: docs/dev/safety-claim-policy.md が新規作成されており、SAFETY_CLAIMS_V1 YAML schema の全フィールド(id / claim / claim_scope / closed_by / not_controlled / evidence_commands / follow_up / allowed_public_phrasing / prohibited_unqualified_phrases)が定義されている
  • AC2: docs/dev/safety-claim-policy.md に safety-sensitive PR の判定条件(changed paths / diff keywords / linked issue text)が記述されている
  • AC3: docs/dev/safety-claim-policy.md に APPROVE 禁止条件(nuanced: not_controlled 非空 + 無限定表現 or follow-up なし / bounded claim は禁止しない)が記述されている
  • AC4: .claude/skills/pr-review-judge/scripts/check_safety_claims.py が存在し、SAFETY_CLAIMS_V1 ブロックを PR body から抽出・parse できる
  • AC5: check_safety_claims.py に SAFETY_CLAIMS_V1 が欠落している場合(safety-sensitive PR 判定で)exit 1 を返す fail-closed 動作が実装されている
  • AC6: check_safety_claims.py に SAFETY_CLAIMS_V1 が parse 不能な場合 exit 1 を返す動作が実装されている
  • AC7: check_safety_claims.py に not_controlled 非空 + 無限定表現(safe / read-only / sandboxed / isolated / complete)がある場合 exit 1 を返す動作が実装されている
  • AC8: check_safety_claims.py に not_controlled 非空 + follow_up 空の場合 exit 1 を返す動作が実装されている

Verification Commands

  • test -f docs/dev/safety-claim-policy.md && echo "PASS: AC1 file exists" || echo "FAIL: AC1 file missing" — AC1 確認
  • rg -n "claim_scope|closed_by|not_controlled|evidence_commands|follow_up|allowed_public_phrasing|prohibited_unqualified_phrases" docs/dev/safety-claim-policy.md — AC1 確認(全フィールドが存在)
  • rg -n "changed path|diff.*keyword|linked issue" docs/dev/safety-claim-policy.md — AC2 確認
  • rg -n "not_controlled|bounded claim|無限定" docs/dev/safety-claim-policy.md — AC3 確認
  • test -f .claude/skills/pr-review-judge/scripts/check_safety_claims.py && echo "PASS: AC4 script exists" || echo "FAIL: AC4 script missing" — AC4 確認
  • python3 -c "import ast; ast.parse(open('.claude/skills/pr-review-judge/scripts/check_safety_claims.py').read()); print('PASS: AC4 parse ok')" — AC4 確認(Python 構文 OK)
  • rg -n "exit 1|sys.exit|raise SystemExit" .claude/skills/pr-review-judge/scripts/check_safety_claims.py — AC5/AC6/AC7/AC8 確認(fail-closed 実装)
  • rg -n "SAFETY_CLAIMS_V1|safety_claims" .claude/skills/pr-review-judge/scripts/check_safety_claims.py — AC4 確認(SAFETY_CLAIMS_V1 を認識)
  • pnpm typecheck && pnpm lint && pnpm test && pnpm build

Allowed Paths

  • docs/dev/safety-claim-policy.md
  • .claude/skills/pr-review-judge/scripts/check_safety_claims.py

Stop Conditions

Required Skills

Python / YAML

Scope Delta(任意)

N/A

Delivery Rule

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions