Repository navigation
feat(#594): gh api --input による body mutation を guard-japanese-prose の delta 検査対象に追加 - #600
Conversation
… delta 検査対象に追加
gh api --input <file> で Issue/PR body を PATCH する経路が guard をバイパスしていた問題を解消する。
validate_japanese_content.py に --parse-api-input / --classify-api-mutation /
--extract-api-command-endpoint サブコマンドを追加し、guard-japanese-prose.sh から
gh api --input の endpoint + payload を解析して delta 検査を適用する。
- AC4/AC17/AC18: PATCH repos/{owner}/{repo}/issues|pulls/{n} + body key → delta 検査
- AC5: body mutation でない payload (body key なし・非 issue/PR endpoint) は pass
- AC10: gh api --input は workaround として policy bypass 不可
- AC19: --input - (stdin) は fail-closed (exit 2)
- AC20: invalid JSON payload は fail-closed + api_payload_parse_failed
- AC15/AC24: test_guard_api_input.py を追加 (fake_gh PATH prepend で実 API 非依存)
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Preview URL✅ verified live: https://squne121.github.io/loop-protocol/pr-600/
|
|
Issue #594 検証済み。guard-japanese-prose.sh に gh api --input body mutation 検査実装確認。validate_japanese_content.py に changed_prose_blocks API 実装確認。test_guard_api_input.py で 21 個全テストケース PASS。#590 delta_mode API 再利用。マージ可能。TEST_VERDICT: PASS, mergeable: MERGEABLE, merge_state_status: CLEAN, verification_commands_pass: 18, verification_commands_fail: 0, verification_skipped_count: 2, baseline_only: false |
Verdict: REQUEST_CHANGESMergeability
Evidence CheckAC coverage:
Allowed Paths 遵守: 3ファイル全て Allowed Paths 内(guard-japanese-prose.sh / tests/test_guard_api_input.py / validate_japanese_content.py) CI Verification: CI run 26852853034 (head_sha=71018151e3c249562b0e3ee5aedea5aa3055ff9d) で python-test / test / typecheck / e2e / build / lint が conclusion=success。CI_CHECK_RUN_SCOPED 条件(head_sha 一致・conclusion=success)を満たす。 TEST_VERDICT_MACHINE: deferred VC: Issue #594 の Runtime Verification Applicability が Blockers
Non-blockers(任意改善)
LOOP_VERDICTverdict: REQUEST_CHANGES
blockers:
- id: safety_claim_matrix_missing
description: "Safety Claim Matrix セクションが PR 本文に存在しない(.claude/skills/** 変更 + bypass/guard キーワードで safety-sensitive 判定)"
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 71018151e3c249562b0e3ee5aedea5aa3055ff9d
recommendations: []
follow_up_issue_requests: [] |
Verdict: REQUEST_CHANGESMergeability
Evidence CheckAC coverage:
Allowed Paths 遵守: 3 ファイル全て Allowed Paths 内 CI Verification:
TEST_VERDICT_MACHINE: マーカー付きコメントなし。代替コメントに verification_skipped_count: 2 の記録あり。 Blockers
Non-blockers(任意改善)
LOOP_VERDICTverdict: REQUEST_CHANGES
blockers:
- id: ci_failure_pr_body_japanese_check
description: "PR Body Japanese Check が conclusion=failure(aggregate_ratio=0.334, threshold=0.1, failed_blocks=1)。mergeStateStatus=UNSTABLE"
- id: safety_claim_matrix_incomplete_columns
description: "Safety Claim Matrix に必須列が欠落(Implemented? / Not controlled / Follow-up が不在)。overclaim 判定不能"
mergeable: MERGEABLE
mergeStateStatus: UNSTABLE
reviewed_head_sha: 71018151e3c249562b0e3ee5aedea5aa3055ff9d
recommendations: []
follow_up_issue_requests: [] |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Verdict: APPROVEMergeability
Evidence CheckAC coverage(Issue #594 - decision: deferred):
Allowed Paths 遵守: 変更 3 ファイル全て Allowed Paths 内 CI Verification(CI_CHECK_RUN_SCOPED - head_sha=544b61e5b208c86ebfdb15edfa8245d40ac0ce23):
Safety Claim Matrix: 5 列(Claim / Implemented? / Not controlled / Evidence / Follow-up)完備。Not controlled の主張は bounded(PR title に overclaim キーワードなし)。 Schema Change Applicability: 変更はすべて .sh / .py / .py test ファイルの内部ロジック。consumer 境界をまたぐ schema 変更なし(not_schema_change)。Schema Consumer Inventory 不要。 Blockersなし Non-blockers(任意改善)
LOOP_VERDICTverdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 544b61e5b208c86ebfdb15edfa8245d40ac0ce23
recommendations: []
follow_up_issue_requests: [] |
判定: REQUEST_CHANGESPR #600 は「 最終コメントでは CI 成功・Safety Claim Matrix 充足を理由に APPROVE されていますが、下記の bypass / fail-open 経路を潰せていないため、承認は早いです。([GitHub]1) Blocker 1: GraphQL mutation が完全に bypass できる
これは仕様上の抜けです。GitHub GraphQL には 修正方針: 追加テスト: gh api graphql --input payload.jsonpayload: {
"query": "mutation($input: UpdateIssueInput!) { updateIssue(input: $input) { issue { id body } } }",
"variables": {
"input": {
"id": "I_xxx",
"body": "English prose should be blocked"
}
}
}期待値: Blocker 2:
|
…dy extract, method check, scope clarification B1: gh api graphql --input body mutation (updateIssue/updatePullRequest/updateIssueComment/addComment/createIssue/createPullRequest + body variable) を exit 2 deny に対応。--classify-graphql-mutation サブコマンドを validate_japanese_content.py に追加し guard-japanese-prose.sh に GraphQL 検査ブロックを追加。 B2: API payload body 抽出を inline Python 文字列埋め込み (single quote 等で fail-open になる問題) から環境変数 GUARD_API_INPUT_FILE 経由に変更し fail-closed を保証。 B3: HTTP method (--method PATCH/-X PATCH/--method=PATCH/未指定/GET) を判定。--extract-api-command-method サブコマンドを追加。GET は non-mutation として pass、PATCH/POST/未指定+--input は body mutation チェック継続。 B4: gh api --input による issue comment / pr review comment / GraphQL comment mutation body は本 PR scope 外として PR 本文 Safety Claim Matrix に明記。 B5 (de-scope): AC9 structured permissionDecision: ask は本 PR で実装しない。PR 本文に de-scope 明記。 テスト: 36 passed (21 既存 + 15 新規: B1/B3 カバレッジ追加) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Verdict: REQUEST_CHANGESMergeability
Evidence CheckSelf-authored check: PR author squne121 = current actor → TEST_VERDICT_MACHINE: Previous iteration comment exists but SHA is stale (reviewed_head_sha: 544b61e ≠ current head 0243e0e). Fallback to gh pr view for mergeable state + CI_CHECK_RUN_SCOPED for evidence. CI_CHECK_RUN_SCOPED (run 26854254832, headSha=0243e0ee7bd5ce8a6708fc44a6bd708524ae883e):
AC coverage (Issue #594, decision: deferred):
Allowed Paths: 3 changed files all within Allowed Paths (.claude/hooks/guard-japanese-prose.sh, .claude/hooks/tests/test_guard_api_input.py, .claude/skills/create-issue/scripts/validate_japanese_content.py). Safety Claim Matrix: 5-column format present (Claim / Implemented? / Not controlled / Evidence / Follow-up). B4/AC9 scope-outs have Follow-up Issue references. Not controlled non-empty rows have follow-up references. No overclaim keywords in PR title. Schema Change Applicability: .sh / .py / test file changes only, no consumer boundary schema change. Schema Consumer Inventory not required. B1-B5 blocker fixes from previous iterations:
Blockers
Non-blockers
LOOP_VERDICTverdict: REQUEST_CHANGES
blockers:
- id: AC25_NOT_SATISFIED
description: "test_guard_api_input.py (36 tests) is not registered in .github/workflows/ci.yml. CI does not run the new tests. PR body does not address AC25 (no de-scope, no follow-up Issue reference, no CI discovery confirmation). Issue #594 AC25 requires either CI execution or CI discovery path confirmation."
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 0243e0ee7bd5ce8a6708fc44a6bd708524ae883e
recommendations: []
follow_up_issue_requests:
- title: "CI に test_guard_api_input.py を追加し AC25 を満たす (Issue #594 AC25)"
issue_kind: implementation
severity: mandatory_follow_up
source:
kind: pr_review
url: "https://github.com/squne121/loop-protocol/pull/600"
note_id: "1"
dedupe_key: "follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/pull/600:1"
desired_destination: ".github/workflows/ci.yml が test_guard_api_input.py を実行し、AC25 が CI 証跡付きで PASS する状態"
validated_scope_delta: ".github/workflows/ci.yml に uv run --locked pytest .claude/hooks/tests/test_guard_api_input.py -q を追加する"
origin_skill: pr-review-judge
labels:
- triage-required |
Verdict: APPROVEMergeability
Note: BEHIND は base branch との差分のみ(Conflict blocker に非該当)。APPROVE + MERGEABLE + BEHIND のため Evidence CheckSelf-authored check: PR author squne121 = current actor → TEST_VERDICT_MACHINE: 既存コメントは stale SHA(前 iteration 分)。フォールバックとして CI_CHECK_RUN_SCOPED を使用。 CI_CHECK_RUN_SCOPED(run 26854254832, headSha=0243e0ee7bd5ce8a6708fc44a6bd708524ae883e):
AC coverage(Issue #594, decision: deferred):
Allowed Paths 遵守:
Schema Change Applicability: .sh / .py / test ファイルのみ。consumer 境界をまたぐ schema 変更なし → Schema Consumer Inventory 不要。 Safety Claim Matrix: 必須列 (Claim / Implemented? / Not controlled / Evidence / Follow-up) 全列あり。B4 / AC9 / AC25 の scope-out 行にそれぞれ Follow-up 参照あり。Not controlled 非空行に follow-up 参照あり。PR title に無限定 safe/isolated 等の overclaim なし。 B1-B5 blocker 修正(iteration 3 以前):
AC25 de-scope(iteration 4 修正):
Blockersなし Non-blockers(任意改善)
LOOP_VERDICTverdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: BEHIND
reviewed_head_sha: 0243e0ee7bd5ce8a6708fc44a6bd708524ae883e
recommendations: [update_branch]
follow_up_issue_requests:
- title: "実装: test_guard_api_input.py を CI ワークフローに登録する (AC25 #594)"
issue_kind: implementation
severity: mandatory_follow_up
source:
kind: pr_body
url: "https://github.com/squne121/loop-protocol/pull/600"
note_id: "1"
dedupe_key: "follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/pull/600:1"
desired_destination: ".github/workflows/ci.yml が test_guard_api_input.py を実行し、AC25 が CI 証跡付きで PASS する状態"
validated_scope_delta: ".github/workflows/ci.yml に uv run --locked pytest .claude/hooks/tests/test_guard_api_input.py -q を追加する"
origin_skill: pr-review-judge
labels:
- triage-required
materialize_status: "materialized_reuse"
materialized_issue_number: 602 |
概要
gh api --input <file>で Issue/PR body を PATCH する経路がguard-japanese-prose.shをバイパスしていた問題を解消する(Issue #594 + #595 scope rollup)。この修正により、日本語 prose チェックがgh api --input経路にも適用され、ガードの抜け穴を塞ぐ。validate_japanese_content.pyに--parse-api-input/--classify-api-mutation/--extract-api-command-endpoint/--extract-api-command-method/--classify-graphql-mutationサブコマンドを追加guard-japanese-prose.shにgh api --inputの payload 解析・delta 検査ロジックと GraphQL mutation deny ロジックを追加test_guard_api_input.pyを新規追加(36 tests, fake_gh PATH prepend で実 API 非依存)Issue #594 を解決する。Closes #594
Iteration 3 変更点 (blocker 修正)
gh api graphql --inputによるupdateIssue/updatePullRequest/updateIssueComment/addComment/createIssue/createPullRequest+bodyvariable →exit 2+api_graphql_body_mutation_blocked/api_graphql_mutation_deniedに対応GUARD_API_INPUT_FILE経由に変更し fail-closed を保証--method PATCH/-X PATCH/--method=PATCH/未指定/GET) を判定してGETは non-mutation として passgh api --inputによる issue comment / pr review comment / GraphQL comment mutation body は本 PR の scope 外 として PR 本文と Safety Claim Matrix に明記structured permissionDecision: askは本 PR では実装しない。Issue 実装: AI-safe GitHub body mutation lane を追加し guard-japanese-prose の過剰ブロックと gh api workaround 化を解消する #594 の AC9 は follow-up Issue として別途対応する検証コマンド結果
テスト: test_guard_api_input.py 全件 (AC1/AC2/AC4/AC15/AC17-AC20/AC23/AC24 + B1-B3)
B1: GraphQL mutation deny テスト
B2: 環境変数経由 fail-closed
B3: HTTP method 判定
個別 AC テスト結果
標準品質ゲート
Allowed Paths 適合
変更ファイルはすべて Allowed Paths 内:
.claude/hooks/guard-japanese-prose.sh.claude/hooks/tests/test_guard_api_input.py(新規).claude/skills/create-issue/scripts/validate_japanese_content.pyセキュリティ安全性マトリクス (Safety Claim Matrix)
bypass新規導入なしgh api --inputの既存 bypass 経路を開放しないgh api graphql --inputの body mutation keyword + body variable → exit 2 denyGRAPHQL_BODY_MUTATION_KEYWORDS+--classify-graphql-mutation--extract-api-command-methodサブコマンド実装permissionDecision: ask→ Scope 外 (B5).github/workflows/ci.ymlへのtest_guard_api_input.py登録 → Scope 外 (AC25)スコープ外 AC の記録 (De-scoped ACs)
AC25 (CI 登録) について
test_guard_api_input.pyは.claude/hooks/tests/に追加済みですが、.github/workflows/ci.ymlへの登録は本 PR の Allowed Paths(.github/workflows/**)に含まれないため scope 外です。follow-up Issue で対応します: → #602
コントラクトスナップショット
#594 (comment)
生成: Claude Code (claude-sonnet-4-6)