Repository navigation
Closed
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "baseline_vc_preflight が GitHub milestone metadata readback を deterministic / non-mutating / exit-code based assertion として検証できるようにする"
change_kind: toolingParent Issue
none(単独改善)
Parent Goal Ref
- Goal: Issue 実装: M3 persistence 語彙(reload 自動復元)・probe spec 乖離・E2E フロー表記をドキュメント修正で整合させる #931 で発生した
gh apiallowlist ブロックと# preflight-scope: pr_review_onlyworkaround を再発させない - Desired Destination: GitHub milestone metadata の readback を、raw
gh apiを一般解禁することなく、baseline_vc_preflightが exit code で判定できる first-class assertion として VC に記述できる状態
Current Validated Scope
baseline_vc_preflight.pyは現在_ALLOWED_GH_PREFIXES(gh issue view/gh pr view/gh pr list/gh issue list/gh repo view)のみを許可し、gh apiをcommand_not_allowedとして block している(test_gh_api_is_blockedが回帰防止済み)。- negated search(
! rg ...)は_is_negated_search_command()で静的にexpected_fail/expected_baseline_fail/go分類される実装が存在する。 references/vc-preflight.mdはpr_review_only/runtime_onlyを skipped/go として扱う category 表を持つ。- 現状
baseline_vc_preflight.pyには GitHub milestone metadata readback assertion(gh api --method GETの固定 argv 実行・JSON parse・contains/not_containsの exit code 変換)に相当する first-class command / allowlist validator / authoring guidance が存在しない。
Remaining Parent Gaps
本 Issue で閉じるギャップ:
- GitHub milestone metadata(特に description)の forbidden phrase absence/presence を exit code で assertion する経路が存在しない(
gh api ... --jqは出力するだけで assertion にならない)。 - そのため 実装: M3 persistence 語彙(reload 自動復元)・probe spec 乖離・E2E フロー表記をドキュメント修正で整合させる #931 では
# preflight-scope: pr_review_onlyworkaround に逃げた。
本 Issue でも閉じないギャップ(Out of Scope):
- milestone 以外の GitHub resource(issue/pr/label 等)への readback assertion 一般化
- mutating
gh api(書き込み)の許可 - Issue 実装: M3 persistence 語彙(reload 自動復元)・probe spec 乖離・E2E フロー表記をドキュメント修正で整合させる #931 の product docs 修正
Outcome
baseline_vc_preflight.py が、gh api の一般 allowlist 解禁ではなく、固定 argv の gh api --method GET repos/<owner>/<repo>/milestones/<number> を内部実行して JSON を Python 側で parse する first-class な GitHub metadata assertion を持ち、contains / not_contains を exit code(present/absent を 0 / non-zero)に変換できる。raw gh api と危険な flags / mutating method は引き続き block され、環境エラー(gh 不在・auth 失敗・404・rate limit・timeout・invalid JSON)は assertion の pass/fail と区別され false pass にならない。authoring guidance が 3 つの docs に同期され、既存の block テストが regression しない。
In Scope
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py:- GitHub milestone metadata readback assertion を first-class command(
baseline_vc_preflight自身の assertion サブコマンド/pseudo-command)として認識・分類する - 内部実行は固定 argv
["gh","api","--method","GET",f"repos/{owner}/{repo}/milestones/{number}"]をsubprocess.run(..., shell=False)で行い、JSON を Python で parse してcontains/not_containsを exit code に変換する - allowlist validator(例:
_is_allowed_github_metadata_assert)で endpoint / method / flags を exact subset に限定する
- GitHub milestone metadata readback assertion を first-class command(
.claude/skills/issue-contract-review/tests/: present/absent の exit code、各種 deny、環境エラー分類のテスト追加- docs 同期:
body-authoring.md/issue-contract-review/SKILL.md/references/vc-preflight.mdに GitHub metadata assertion の authoring guidance と禁止 rawgh api例を追記
Out of Scope
- raw
gh apiの一般 allowlist 解禁 - mutating
gh apiの許可(-f,-F,--field,--raw-field,--input,--method POST/PATCH/PUT/DELETE) - milestone 以外の GitHub resource への readback assertion 一般化
--jqexpression をそのまま VC surface に出す設計(jq の-eを使わない限り false/null でも exit 0 になり assertion 契約に適合しないため不採用)- Issue 実装: M3 persistence 語彙(reload 自動復元)・probe spec 乖離・E2E フロー表記をドキュメント修正で整合させる #931 の product docs 修正
- checker scripts 以外の
src/変更
Acceptance Criteria
- AC1:
baseline_vc_preflight.pyが GitHub milestone metadata readback assertion を first-class command として認識・分類する(rawgh apiの一般 allowlist 解禁ではない) - AC2: 許可される readback は method GET かつ endpoint 形
repos/<owner>/<repo>/milestones/<number>のみで、絶対 URL endpoint・query string(?)・path traversal(../)・placeholder endpoint は reject される - AC3:
not_contains <literal>assertion は、対象 field に literal が含まれる場合 exit non-zero、含まれない場合 exit 0 を返す - AC4:
contains <literal>assertion は、対象 field に literal が含まれる場合 exit 0、含まれない場合 exit non-zero を返す - AC5: raw
gh api、および-f/-F/--field/--raw-field/--input/--header(-H)/--include(-i)/--paginate/--slurp/--cache/--template/--preview/graphqlを含む invocation は block される - AC6: mutating method(
--method POST/PATCH/PUT/DELETE、-X ...、--method=...、大文字小文字混在 variant)は block される - AC7: gh 不在 / auth 失敗 / 404 / rate limit / timeout / invalid JSON は assertion の pass/fail と区別される分類になり、false pass(exit 0)にならない
- AC8: 既存の unsafe command / compound command /
test_gh_api_is_blocked系テストが regression しない - AC9:
body-authoring.md/issue-contract-review/SKILL.md/references/vc-preflight.mdに GitHub metadata assertion の authoring guidance(許可される形と禁止 rawgh api例)が同期記載される - AC10:
pnpm typecheck/pnpm lint/pnpm test/pnpm buildが pass する
Runtime Verification Applicability
applicability: not_applicable
decision: not_applicable
reason: tooling script change(baseline_vc_preflight.py の assertion 追加とテスト・docs 同期)— runtime behavior / 起動するサーバーが無く、検証は pytest と静的 grep で完結するVerification Commands
# AC1
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_recognized# AC2
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_endpoint_subset# AC3
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_not_contains# AC4
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_contains# AC5
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_dangerous_flags_blocked# AC6
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_mutating_method_blocked# AC7
$ uv run pytest .claude/skills/issue-contract-review/tests/test_github_metadata_assert.py -k github_metadata_assert_environment_error# AC8
# baseline-expect: pass
$ uv run pytest .claude/skills/issue-contract-review/tests/ -k gh_api_is_blocked# AC9
$ rg -c "github_metadata_assert" .claude/skills/create-issue/references/body-authoring.md# AC9
$ rg -c "github_metadata_assert" .claude/skills/issue-contract-review/SKILL.md# AC9
$ rg -c "github_metadata_assert" .claude/skills/issue-contract-review/references/vc-preflight.md# AC10
$ pnpm typecheck# AC10
$ pnpm lint# AC10
$ pnpm test# AC10
# preflight-scope: runtime_only
$ pnpm buildAllowed Paths
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py.claude/skills/issue-contract-review/tests/**.claude/skills/create-issue/references/body-authoring.md.claude/skills/issue-contract-review/SKILL.md.claude/skills/issue-contract-review/references/vc-preflight.md
Stop Conditions
- raw
gh apiを VC command として一般許可する必要が出た場合(→ 本 Issue の安全方針に反するため停止) - mutating
gh api(書き込み)の許可が必要になった場合 - assertion ロジックを
baseline_vc_preflight.py単一ファイルに収められず、新規 helper module の追加が必要になった場合(→ Scope Delta + contract 再レビューが必要) - checker 以外の
src/変更が必要になった場合 - Allowed Paths 外の変更が必要と判明した場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- main への直接 push、force push が必要と判明した場合
- secret 取得・表示が必要と判明した場合
- GitHub 権限不足で操作が失敗した場合
Required Skills
- Python
subprocess(shell=False固定 argv 実行)と JSON parse - GitHub CLI
gh apiの flag surface と read/write 境界(GET milestone vs PATCH/DELETE)の理解 baseline_vc_preflightの command classification / scope_class / skipped semantics- pytest による deny-list / exit-code 回帰テスト設計
Scope Delta(任意)
原 Issue(AC 6 個・Allowed Paths 3 件)からの差分。差分の出所は #942 の anchor comment(issuecomment-4712275602、Request Changes / BLOCK レビュー)であり、unilateral なスコープ拡張ではなく authoritative review decision の反映である。
- AC を 6 → 10 に拡張(exit-code deterministic 化、deny surface の網羅、環境エラー分類の追加)。新 AC はいずれも従来より検証可能性が高い。
- 設計を「raw
gh api --method GETsubset の許可」から「baseline_vc_preflight内 first-class assertion(固定 argv + Python JSON parse + exit code 変換)」へ変更。 - Allowed Paths に
issue-contract-review/SKILL.mdとreferences/vc-preflight.mdを追加(category / classification の docs drift 防止)。同一 skill 内に閉じており、新規アーキテクチャ層の追加ではない。
Delivery Rule
1 Issue = 1 PR- worktree:
impl/942-github-metadata-assert - Draft PR で開始し、検証 green 後に ready for review へ変更
- PR body に「raw
gh apiを解禁していないこと」「許可された endpoint/method/flags の exact subset」「deny テスト一覧」「環境エラー分類」を記録する
Notes for Reviewer
- 本 Issue は「
gh apiを少し許可する」Issue ではなく、「GitHub metadata readback を deterministic / non-mutating / exit-code based assertion として preflight に導入する」Issue である(anchor comment の結論: 方向性 GO・現契約 BLOCK)。 --jqを assertion exit code として扱う設計は不採用。gh api --jqは output filter であり false/null を failure にする契約は jq の-e側のもの。Python 側で JSON parse して exit code に変換する。- AC9 の VC は実装が docs に追記する固定トークン
github_metadata_assertを positive grep で検出する(baseline では absence で fail)。実装ではこのトークンを assertion mode のキーワード兼 docs 見出し語として一貫使用すること。 - AC7 の環境エラー(gh 不在 / auth / 404 / rate limit / timeout / invalid JSON)は assertion の present/absent と必ず別分類にし、
false(exit 0 = absent)に誤分類しないこと。 ! rg型の repo 静的 absence check と GitHub live metadata assertion を混同しないこと。前者は negated search の静的 expected_fail 分類、後者は live readback の exit-code assertion で別物。- 関連文脈: 実装: M3 persistence 語彙(reload 自動復元)・probe spec 乖離・E2E フロー表記をドキュメント修正で整合させる #931(root cause)、実装: GitHub Milestone #3 の title・description を M3 Result Persistence 境界に再同期する #913(milestone metadata 運用方針: stale cache / UI 目視を PASS にしない)。
--cache許可や stdout 目視へ戻る設計は 実装: GitHub Milestone #3 の title・description を M3 Result Persistence 境界に再同期する #913 方針に逆行するため不可。
Metadata
Metadata
Assignees
Labels
No labels
Activity
squne121 commentedon Jun 15, 2026
判定: Request Changes / BLOCK 推奨
#942 の問題意識は正しいです。#931 で Milestone #3 description の禁止語句 absence check が必要になったが、
baseline_vc_preflight.pyがgh apiを block し、Issue 本文側で# preflight-scope: pr_review_onlyworkaround に逃げた、という起点は確認できます。#942 本文も、gh api ... --jq '.description'が「出力するだけ」で absence/presence assertion の exit code にならない点を明示しています。ただし、この Issue は現状のままだと 「安全な GitHub metadata assertion 経路」ではなく、「
gh apiの危険な一部解禁」になりやすいです。gh apiは GitHub CLI 公式仕様上、endpoint と flags 次第で GET / POST / PATCH / GraphQL / request body / header / pagination / cache / template 出力まで触れる汎用 API クライアントです。-f/-Fを付けると request parameters が追加され、通常 POST に切り替わる仕様もあります。([GitHub CLI]1)#942 自体にはコメントがありませんでした。 そのため、関連判断材料は #931 の refinement コメント、#913 の milestone metadata 実行 Issue、PR #854 / #739 の M3 persistence 文脈、そして現行
baseline_vc_preflight.py実装です。主要な敵対的指摘
BLOCKER 1: 「
gh api --method GETsubset 許可」は表現が広すぎる#942 AC1 は
gh api --method GET repos/<owner>/<repo>/milestones/<number>を safe として扱う、としています。しかし GitHub CLI のgh apiは--method,--field,--raw-field,--input,--header,--paginate,--slurp,--cache,--template,graphqlなどを持つ汎用 surface です。特に-Fは@file/@-でファイルや stdin を読み、--inputも request body をファイル/stdin から読むため、VC preflight の「read-only metadata check」とは別種の I/O surface を開きます。([GitHub CLI]1)現行実装はこの危険を理解しており、
_ALLOWED_GH_PREFIXESはgh issue view,gh pr view,gh pr list,gh issue list,gh repo viewだけを許可し、コメントでgh apiは mutation potential のため block と明記しています。 実際の classifier もgh apiを allowlist 外としてcommand_not_allowedに落とします。 さらにテストにもtest_gh_api_is_blocked()があり、gh api repos/owner/repo/issuesはblocked / command_not_allowed / exit_code Noneを期待しています。修正方針: raw
gh apiを VC command として一般許可しないでください。どうしても許可するなら、_is_allowed_gh_api_readback(argv)のような専用 validator を作り、次のような exact subset に絞るべきです。BLOCKER 2:
--jqを assertion exit code として扱う設計は脆い#942 の背景認識どおり、
gh api ... --jq '.description'は readback 表示であって assertion ではありません。GitHub CLI manual は--jqを「response から値を選択する query」と説明していますが、boolean false を assertion failure にする契約はgh api --jqには明示されていません。(GitHub CLI) 一方、jq 本体では--exit-status/-eを使った場合だけ、最後の出力がfalse/nullなら exit 1、結果なしなら exit 4 になると明記されています。([JQ Language]2)つまり、次のような VC は危険です。
$ gh api --method GET repos/squne121/loop-protocol/milestones/3 --jq '.description | contains("reload 後に復元する") | not'これは
falseを出しても exit 0 になり得るため、baseline_vc_preflightの「exit code で判定する」契約に適合しません。現行 skill も AC は決定論的な exit code / 数値比較で検証可能であることを求めています。修正方針: jq expression をそのまま VC surface に出さず、Python 側で JSON を parse して boolean を exit code に変換する専用 helper に寄せてください。
subprocess.run([...], shell=False)で固定 argv を組めば、Python 公式 docs の security consideration 上も shell metacharacter を shell が解釈しない構造にできます。([Python documentation]3)BLOCKER 3:
! rg型の absence check と metadata assertion を混同している#931 レビューでは、禁止語句 absence は
! rg -n ...+ positive grep にすべきだという指摘がありました。これは repo file の静的 grep なら妥当です。 しかし GitHub metadata readback では同じ設計を使えません。現行
baseline_vc_preflight.pyは negated search command を_is_negated_search_command()で検出し、実行前にexpected_fail / expected_baseline_fail / goと静的分類します。 これは「実装前 baseline で禁止語句がまだ存在するので! rgは fail する」という preflight 用の扱いであって、実装後に GitHub metadata が本当に修正されたことを読む assertion helper ではありません。修正方針: #942 の AC3/AC4 は「forbidden phrase present/absent を exit code で表現する経路がある」では弱いです。次のように、baseline classification と実行後 assertion を分けてください。
BLOCKER 4: GitHub REST milestone API の read/write 境界が AC に埋め込まれていない
GitHub REST API では milestone の GET は
GET /repos/{owner}/{repo}/milestones/{milestone_number}で、read permission か public resource なら利用可能です。一方、Update milestone はPATCH /repos/{owner}/{repo}/milestones/{milestone_number}で write permission を要求し、title,state,description,due_onを変更できます。Delete はDELETEです。([GitHub Docs]4)#942 の Out of Scope は mutating method を block と書いていますが、AC/VC には「GET milestone のみを allow し、PATCH/DELETE/create/list/graphql は deny」という検証が不足しています。
gh api --method GETという文字列だけを見て通すと、endpoint や flags によって readback 以外の挙動が混入します。修正方針: allowlist は HTTP method だけでなく、endpoint schema と resource kind まで固定してください。最低限、初回実装は milestone description の readback だけに絞るべきです。
BLOCKER 5: Allowed Paths と docs scope が不足している
#942 の In Scope は
baseline_vc_preflight.py、テスト、body-authoring.mdを含みます。これは最低限としては良いです。 しかし実際にbaseline_vc_preflightの command category / scope_class / skipped semantics を変えるなら、issue-contract-review/SKILL.mdとreferences/vc-preflight.mdも同期対象に入れるべきです。現行vc-preflight.mdはpr_review_only/runtime_onlyは skipped/go であり、通常のbaseline_fail_expectedと別扱いだと説明しています。このままだと、実装は新しい
github_metadata_readbackcategory を持つが、skill docs は古い category table のままという drift が起きます。修正方針: Allowed Paths に最低限以下を追加してください。
また、ディレクトリ指定は gate 互換のため、曖昧な trailing slash より
.../tests/**のような recursive pattern に寄せる方が安全です。PR #802 のレビューでも、Allowed Paths の trailing-slash directory entry が review gate と噛み合わず fail_closed になった事例があります。実装提案: raw
gh api解禁ではなく pseudo-command / helper 化推奨は、VC command として raw
gh apiを許可するのではなく、baseline_vc_preflight.py内で扱う pseudo-command を追加することです。内部処理は次のようにします。
この方式なら、VC author は
gh apiの多すぎる flags を触れません。--jqの exit code 問題も避けられます。stdout には full milestone JSON を出さず、次のような最小 artifact だけを返すべきです。{ "resource_kind": "milestone", "repo": "squne121/loop-protocol", "number": 3, "field": "description", "assertion": "not_contains", "literal_sha256": "<hash>", "matched": false, "result": "pass" }秘密情報を扱う surface ではありませんが、GitHub metadata は workflow evidence としてログに残るため、full response をそのまま stdout に流す必要はありません。
改訂 AC 案
追加すべきテスト
#931 / #913 / #854 との関連評価
#942 は #931 の単なる便利機能ではありません。#931 レビューでは、Milestone #3 description の禁止語句 readback が
preflight-scope: pr_review_onlyworkaround になっており、さらに #931 自体も docs-only cleanup としては範囲不足、E2E 証跡の主張過剰、rg -cabsence check の exit code 問題、pnpm buildだけでは docs lint 不足と指摘されています。#913 では milestone metadata の PATCH / readback / close 運用がすでに問題化しており、GitHub UI 目視や stale cache を PASS にしない、gh api / gh issue list の CLI readback のみを PASS とする、という運用方針が書かれています。 #942 はこの運用を preflight に取り込む Issueなので、
--cacheを許す設計や stdout 目視に戻る設計は逆行です。PR #854 は M3 persistence の実装側で、reward claim 後に
persistProgressionSnapshot('reward-claim')を呼ぶ wiring と progression-only snapshot test を追加していますが、レビュー上は save failure 時のhasLoadableSnapshot = false、reward-claim save wiring 未証明、HTTP origin evidence の弱さが問題化しています。 つまり #942 の価値は「GitHub metadata readback だけを通す」ことではなく、M3 close gate の証跡全体を exit-code deterministic にすることです。GitHub に貼るレビューコメント案
結論として、#942 は 方向性 GO、現契約は BLOCK です。安全な着地点は raw
gh apiの allowlist 拡張ではなく、GitHub metadata assertion をbaseline_vc_preflightの専用機能として閉じ込める実装です。squne121 commentedon Jun 15, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 15, 2026
VC 修正記録(impl-review-loop preflight 由来)
issue-contract-reviewの deterministic preflight 実行時、AC1–AC7 の Verification Command がbaseline_vc_preflight.pyでblocked判定となったため、実装スコープを変えずに VC 形式のみを修正した。修正内容
AC1–AC7 の対象を
…/tests/ -k <name>から…/tests/test_github_metadata_assert.py -k <name>へ変更(specific file 参照化)。理由
pytest …/tests/ -k <未作成テスト名>は baseline で 0 件収集 → exit 5 となり、baseline_vc_preflight.pyは exit 5 を「typo / wrong path と未作成を区別できない」として常にvc_no_tests_collected/blockedに分類する(baseline-expect: failannotation でも override されない)。ERROR: file or directory not found:を返し、preflight はexpected_baseline_fail/goと決定論的に分類できる。tests/test_github_metadata_assert.pyに作成すれば post-impl で collect & pass する。tests/**は既に Allowed Paths 内のためスコープ拡張ではない。不変点
tests/ -k gh_api_is_blocked、# baseline-expect: pass)は既存ファイル参照で baseline pass のため変更なし。squne121 commentedon Jun 15, 2026
Contract Review Result
fix(#942): close false-pass holes in github_metadata_assert (review B…
fix(#942): close false-pass holes in github_metadata_assert (review B…
github_metadata_assert で GitHub milestone metadata の安全な exit code ass…