Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "PR #1463 review Finding 3 の mandatory follow-up として、contract snapshot の GitHub provenance を実装開始認可に組み込む"
change_kind: workflow
dedupe_key: "follow-up:squne121/loop-protocol:pr-1463:snapshot-author-trust"Parent Issue
なし(単独改善)
Parent Goal Ref
- Goal: schema-valid な contract snapshot を、GitHub 上の信頼済み投稿者と controlled publisher の comment ID binding を満たす場合だけ実装開始根拠として採用する
- Desired Destination: PR fix: legacy contract snapshot を更新可能にする #1463 Finding 3 の mandatory follow-up を 実装: legacy contract snapshot を fresh schema 準拠で更新可能にする #1459 から分離し、1 Issue = 1 PR で provenance 検証を実装する
Current Validated Scope
contract_review_result_parser.pyの comment fetch は現在id、URL、日時、本文だけを保持し、GitHub comment object のuser.loginとauthor_associationを取得していない- parser は本文内の
generated_by: issue-contract-reviewを検証する一方、GitHub 上の投稿者 identity を authoritative snapshot の採用条件にしていない ensure_contract_snapshot.py、run_contract_review_once.py、build_intake_capsule.pyは contract snapshot parser または同等の comment projection を使うため、共有 trust policy と controlled publisher comment ID binding を consumer 間で一貫させる- 一次ソース: fix: legacy contract snapshot を更新可能にする #1463 (comment)
- mandatory follow-up verdict: fix: legacy contract snapshot を更新可能にする #1463 (review)
Remaining Parent Gaps
- なし。PR fix: legacy contract snapshot を更新可能にする #1463 の P1 修正および Issue 実装: legacy contract snapshot を fresh schema 準拠で更新可能にする #1459 の legacy snapshot refresh は本 Issue に含めない
Outcome
contract snapshot comment の GitHub provenance と controlled publisher comment ID binding を検証する共有 parser・consumer 更新および回帰テストが 1 PR として作成され、untrusted author が投稿した schema-valid status: go が実装開始根拠として採用されないことを pytest で確認できる状態。
In Scope
- GitHub comment fetch projection に
user.loginとauthor_associationを追加し、parse result へ provenance を保持する - authoritative snapshot として許可する bot/user identity と
author_associationの trust policy を明示的かつ決定論的に実装する - controlled publisher が返した comment ID と remote readback comment ID の binding を検証し、不一致・欠落を fail-closed にする
run_contract_review_once.py、ensure_contract_snapshot.py、build_intake_capsule.pyの snapshot 採用経路を共有 trust policy に揃える- trusted author、untrusted author、identity/association 欠落、controlled comment ID 不一致を覆う回帰テストを追加する
- PR fix: legacy contract snapshot を更新可能にする #1463 の source URL と dedupe key を実装証跡へ保持する
Out of Scope
- PR fix: legacy contract snapshot を更新可能にする #1463 / Issue 実装: legacy contract snapshot を fresh schema 準拠で更新可能にする #1459 の legacy snapshot refresh、Product Spec payload、remote marker readback の再実装
- GitHub organization membership の動的照会、OAuth scope、repository permission の変更
- GitHub App の新規導入、credential rotation、secret 管理
- issue-contract-review の4チェックや contract schema 自体の意味変更
- trusted publisher allowlist を repo 外のサービスへ移管すること
Runtime Verification Applicability
decision: not_applicable
reason: "GitHub API comment objectをfixture化したunit testと静的parser/consumer testで全ACを決定論的に検証でき、実GitHubへの投稿・認証・ネットワークアクセスを必要としないため"Acceptance Criteria
- AC1: comment fetch が
user.loginとauthor_associationを保持し、parser result の provenance として downstream consumer へ渡すことを unit test で確認できる - AC2: trusted publisher identity と許可された
author_associationを満たす schema-valid snapshot だけが authoritative candidate として採用され、identity/association 欠落を含む untrusted snapshot は無視されることを unit test で確認できる - AC3: controlled publisher の expected comment ID と remote readback comment ID が一致する場合だけ materialized snapshot を成功扱いし、不一致・欠落を fail-closed にすることを unit test で確認できる
- AC4:
run_contract_review_once.py、ensure_contract_snapshot.py、build_intake_capsule.pyの各 snapshot 採用経路で、untrusted author が投稿した完全な schema-validstatus: goを採用しない回帰テストが PASS する - AC5: trusted author の current
status: goと最新 trustedstatus: blockedの既存 precedence、body hash freshness、schema validation の既存契約が regression なく PASS する
Verification Commands
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_fetch_and_parser_preserve_trusted_comment_provenance # AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_untrusted_schema_valid_go_is_ignored # AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_controlled_publisher_comment_id_binding_is_required # AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_all_snapshot_consumers_reject_untrusted_go # AC4
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py # AC5Allowed Paths
.claude/skills/issue-contract-review/scripts/contract_review_result_parser.py.claude/skills/issue-contract-review/scripts/run_contract_review_once.py.claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py.claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py(新規作成).claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py.claude/skills/impl-review-loop/scripts/build_intake_capsule.py.claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py.claude/skills/impl-review-loop/tests/test_build_intake_capsule.py.claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py(新規作成)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- trusted publisher identity を repo 内の決定論的 policy として表現できず、GitHub organization membership や新規 credential が必要と判明した場合
- PR fix: legacy contract snapshot を更新可能にする #1463 の未マージ変更を前提にしなければ本 Issue の baseline または AC を成立させられない場合
Required Skills
- Python / pytest
- GitHub Issue Comments REST API provenance
- fail-closed trust policy 設計
Required Design References
docs/dev/agent-skill-boundaries.mddocs/dev/workflows/impl-review-loop-design.mddocs/dev/workflow.md- fix: legacy contract snapshot を更新可能にする #1463 (comment)
- fix: legacy contract snapshot を更新可能にする #1463 (review)
Delivery Rule
- 1 Issue = 1 PR
- Dedicated worktree を作成して実装する
- Draft PR を既定とする
- 実装: legacy contract snapshot を fresh schema 準拠で更新可能にする #1459 とは分離し、PR fix: legacy contract snapshot を更新可能にする #1463 のマージ可否を本 Issue の完了で block しない
- PR fix: legacy contract snapshot を更新可能にする #1463 と共有する Allowed Paths があるため、PR fix: legacy contract snapshot を更新可能にする #1463 の merge 後の main から実装を開始し、並行変更しない
Scope Delta(任意)
N/A
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Jul 12, 2026
you asked
message time: 2026-07-12 10:18:50
#1475
内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。
chatgpt response
Issue #1475の本文・議論・関連PR・変更対象コード・既存テストを確認し、実装上の破綻点を優先度順に洗い出します。その後、採用技術の一次資料と比較し、Issue本文へ反映できる改善案まで落とします。
現時点で、Issue #1475は「投稿本文の署名らしき文字列」ではなく、GitHub comment object自体の provenance を信頼境界にする方向です。ただし、allowlist・association・comment IDの3条件だけでは、投稿経路の真正性や再利用時の一貫性がまだ曖昧です。
判定:REQUEST_CHANGES
Issue #1475の方向性自体は妥当です。しかし、現状のスコープでは「trusted publisher identity」と「controlled publisher comment ID binding」を満たしたことを証明できません。
特にAC3は、現在のAPI境界とAllowed Pathsのままでは実装不能です。Issue #1475にはまだコメントがなく、設計上の未解決事項も議論されていません。
主要Finding
1.
[P1 / Merge blocker]AC3のcomment ID bindingには、独立した「expected comment ID」が存在しない現在の
ensure_contract_snapshot.py::post_comment()は、POST応答から.html_urlだけを取得し、comment IDを返していません。一方、controlled publisher側の
_readback_contract_snapshot()は、markerを含むremote commentを検索した後、そのremote objectからcomment IDを取得しています。つまり、比較元と比較先を同じreadbackから生成しています。さらに、readbackで取得した
comment_idは最終的なcontrolled publisher resultから捨てられています。この状態で実装できるのは次の確認だけです。
これはcomment ID bindingではありません。remote comment IDをremote comment ID自身と比較する実装は、形式上のチェックにしかなりません。
必要な修正
ensure_contract_snapshot.pyのPOST応答を少なくとも次の構造に変更します。{ "id": 123456789, "html_url": "...", "issue_url": "...", "user": { "id": 63350259, "login": "squne121", "type": "User" }, "author_association": "OWNER", "created_at": "...", "updated_at": "..." }そのIDをcontrolled publisherへ返し、別リクエストで取得したremote objectのIDと比較する必要があります。
したがって、Allowed Pathsには最低でも以下を追加しなければなりません。
Issue #1459では、まさにこのファイルがproductionの
contract_snapshot.publish境界として扱われています。2.
[P1 / Security model gap]trusted accountとcontrolled publishing pathは同義ではないuser.login、user.id、author_associationを確認しても証明できるのは、どのGitHubアカウントが投稿したかまでです。同じtrusted userが次のいずれを行ったかは区別できません。
contract_snapshot.publishを経由して投稿したgh issue commentで手動投稿したしたがって、IssueのGoalにある「controlled publisherのcomment ID bindingを満たす場合だけ既存snapshotを採用する」を実現するには、consumerが期待されるcomment IDを取得できる永続的なreceiptが必要です。
推奨するreceiptは次のようなものです。
選択肢は二つです。
現行Issueは前者を主張していますが、receiptの生成・保存・consumerへの受け渡しがスコープにありません。
3.
[P1] user.loginをtrust anchorにしてはいけないIssue #1475は
user.loginの取得を要求していますが、login単独のallowlistは長期的なtrust anchorとして不適切です。GitHubではusernameを変更でき、旧usernameが別ユーザーに取得される可能性があります。GitHubのcomment objectにはnumericな
user.id、user.type、author_associationも含まれるため、少なくともuser.idをprimary trust keyにすべきです。これはGitHubの公開仕様からの設計上の推論です。(GitHub Docs) (GitHub Docs)推奨ポリシーは独立allowlistの直積ではなく、許可された組み合わせです。
次はすべてfail-closedにします。
loginは監査表示とdrift検出用であり、認可の唯一のキーにはしない方が安全です。4. `[P1] trust filteringをlatest precedenceより先に実施する必要がある
現在のconsumerは、全commentを解析した後に次の順序で処理しています。
find_latest_result()blockedなら停止find_latest_go()信頼判定を
is_go_current()にだけ追加すると、次の攻撃や障害が残ります。blockedがtrustedなgoをDoSするgoが、それより古いtrustedなblockedを隠す必要なのは次の構造です。
あるいは明示的に次を公開します。
ACには「untrusted
goを無視する」だけでなく、以下も追加すべきです。blockedはtrustedgoをblockしないgoはtrustedblockedをmaskしないblockedのprecedenceはuntrusted commentの新旧に影響されない5. `[P1] build_intake_capsule.pyの独自parserがpolicy driftを起こす
build_intake_capsule.pyは共有parserを利用していません。独自に以下を実装しています。そのlive pathは、body hashまたは日時だけで
goと判断し、最終的にproceed_to_step_1へ進めます。Issue本文には「共有trust policyに揃える」とありますが、それだけでは実装者が次のような重複修正をする可能性があります。
build_intake_capsule.py側にも似た関数をコピーAC4を次のように強化すべきです。
少なくとも、trust policy定数や判定関数の複製は禁止すべきです。
6. `[P2] marker検索ではなくcomment IDによるdirect readbackを使うべき
現在のcontrolled readbackは、全commentをpaginationしてmarker文字列で検索しています。
しかしGitHub REST APIには、uniqueな
comment_idを指定して単一commentを取得するendpointがあります。(GitHub Docs)推奨フローは次です。
remote readbackでは最低限、以下を検証します。
markerは内容確認や重複検出には使えますが、comment identityの主キーにすべきではありません。
7. `[P2] malformed NDJSONを無視する処理がfail-openになっている
共有parserのcomment fetchは、JSON parseに失敗した行を無条件で捨てています。
この状態では、例えば最新のtrusted
blockedを含む行だけが壊れた場合、古いgoが採用される可能性があります。security-sensitiveなsnapshot gateでは、次のどちらかにすべきです。
invalid_json_lines_count > 0をevidence incompleteとして実装開始を禁止するbuild_intake_capsule.pyは既にinvalid JSON countを持っているため、共有fetch resultも同様のdiagnosticsを返す形へ統一できます。8. `[P2] Runtime Verificationを完全なnot_applicableにするのは弱い
unit testで分岐を決定論的に検証できる点には同意します。ただし、実際にcontrolled laneが投稿したcommentの次の値はproduction環境依存です。
user.iduser.loginuser.typeauthor_associationしたがって、mutationを伴うE2Eを必須にする必要はありませんが、少なくとも既存のcontrolled snapshotを対象としたread-only verificationは実施した方がよいです。
Issue #1475に必要な具体的修正
Allowed Paths追加
これがなければ、AC3はconsumer内部の疑似bindingで終わります。
provenance projection
user.loginとauthor_associationだけでなく、次を保持します。推奨AC構成
追加すべき敵対的テスト
最低限、次のケースが必要です。
Verification Commandsには、現在不足している以下も追加してください。
最終評価
Issue #1475は、PR #1463で発見された「誰でもschema-validな
status: goを投稿できる」という問題への対応としては正しい出発点です。ただし現状では、
build_intake_capsule.pyの重複parserが残るという状態です。
実装開始前にIssue本文を修正すべきです。特にFinding 1と2を解消しない限り、ACをPASSしても宣言されたセキュリティ保証は成立しません。
you asked
message time: 2026-07-12 10:33:09
個人趣味開発で正確なID把握などは不要に思う。厳格な制限は不要。ある程度ClaudeCodeやCodexCLIの暴走を止められればいい。
chatgpt response
その前提なら、前回のレビューは過剰です。個人趣味開発で、敵対者ではなくClaude CodeやCodex CLIの誤操作・経路逸脱を抑える目的なら、ユーザーのnumeric ID、永続receipt、暗号学的なprovenanceまでは不要です。
現状のparserはコメント本文の
generated_byやschemaだけを見て、投稿者を確認していません。ここに軽い投稿者チェックを足すだけでも、誤って別経路で生成されたコメントを採用する事故は減らせます。適切な脅威モデル
対象にするもの:
status: goを採用する対象外にするもの:
squne121本人になりすました投稿この対象外をIssue本文に書けば、実装のセキュリティ主張も過大になりません。
最小限の実装
1.
user.loginとauthor_associationだけを見る以下の場合はsnapshot候補から除外します。
user.login欠落author_association欠落squne121以外OWNER以外numericな
user.idやuser.typeは不要です。2. trust filteringをlatest判定より先に行う
これは残すべきです。
そうしないと、untrustedな最新
blockedが既存のtrustedgoを止めるなど、単純な誤判定が残ります。3. controlled publisherは軽いreadbackだけ行う
PR #1463側では既に、markerの一意性、URL一致、remote snapshotのcurrentnessをreadbackしています。
ここに投稿者確認を加えれば十分です。
永続的なpublish receiptは不要です。
user IDとcomment IDは分けて考える
comment IDはallowlist管理のためではなく、「POSTしたコメントとreadbackしたコメントが同じか」の確認に使います。
ただし、既存のURL比較とmarker一意性で十分と判断するなら、IssueタイトルとACから「comment ID binding」を削除した方が正確です。
推奨タイトル:
簡略化したAcceptance Criteria
不要になるもの
前回提案した以下は削除して問題ありません。
user.idによる認可user.type検証修正後の評価
Issue #1475は、軽量なガードレールとしては妥当です。
判定は次のように変更します。
Claude CodeやCodex CLIが同じGitHub credentialを使って意図的に正規コメントを偽造するケースまでは防げませんが、個人開発の誤操作防止としては費用対効果のよい境界です。
squne121 commentedon Jul 12, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 12, 2026
Contract Review Result
squne121 commentedon Jul 12, 2026
implement-issue: 実装完了・Draft PR 起票は overlap preflight hard gate によりブロック
実装状況
.claude/worktrees/issue-1475-contract-snapshot-author-trustworktree-issue-1475-contract-snapshot-author-trust(push 済み)46afeccb.claude/skills/issue-contract-review/scripts/contract_review_result_parser.py.claude/skills/issue-contract-review/scripts/run_contract_review_once.py.claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py.claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py(新規).claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py.claude/skills/impl-review-loop/scripts/build_intake_capsule.py.claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py.claude/skills/impl-review-loop/tests/test_build_intake_capsule.py.claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py(新規)Verification Commands(全て PASS)
test_fetch_and_parser_preserve_trusted_comment_provenance— PASStest_untrusted_schema_valid_go_is_ignored— PASStest_controlled_publisher_comment_id_binding_is_required— PASStest_all_snapshot_consumers_reject_untrusted_go— PASStest_contract_review_result_parser.py/test_ensure_contract_snapshot.py/test_build_intake_capsule.py)— 88 passedpnpm typecheck/pnpm lint/pnpm test(96 files, 1575 tests)/pnpm build— 全て PASSuv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py— 21 passedDraft PR 起票がブロックされている理由
open_pr.pyの overlap preflight hard gate(linked issue がphase/implementationラベルを持つため強制発動)が、check_implementation_overlap.py(open_pr.py 内部の subprocess 呼び出しは--limit未指定 = デフォルト値)をオンライン再実行した結果、以下を検出した:つまり現在 repo 上の OPEN
phase/implementationラベル Issue 数がデフォルト limit を超えており、check_implementation_overlap.pyが全件性を証明できずsaturated: trueで fail-closed に倒れている。open_pr.pyはこの subprocess 呼び出しに--limitを渡す CLI オプションを持たないため、worker 側からは saturation を回避できない。--limit 300を明示した手動実行(本 Issue の contract-review 時点および実装開始前に control-plane が実施したもの)ではroute: human_review_requiredながらsource.complete: true/source.saturated: falseであり、候補 #351 は producer 自身がreadback_confirmed_disjointとして disjoint 確定、#961 / #962 / #966 / #1053 / #1338 / #1348 は control-plane の人間 readback により意味的 disjoint と確認済み(詳細は本 Issue の直前コメントおよび PR 本文予定稿を参照)。しかしopen_pr.pyはこの--limit 300runの evidence をそのまま採用せず、gate 直前に自前で再実行するため、この収集済み evidence を渡してもdecision_inputs_sha256drift として拒否される。人間判断が必要な事項
open_pr.pyの overlap preflight subprocess 呼び出しに--limitを渡せるようにする(saturation 回避)follow-up Issue が必要。gh pr createを実行して起票する(open_pr.pyの hard gate を経由しない、人間による明示的な override)。--limit 300の evidence(decision_inputs_sha256: sha256:da00ec03f9cd09665416d52242d90459952645cecb7b24ca62f820f54a2f27f8)を正本として扱うポリシー変更をopen_pr.py側に導入する。いずれも本 Issue の Allowed Paths(issue-contract-review / impl-review-loop の trust policy 実装)の範囲外であるため、本 Issue 自体はこれ以上変更しない。
次のアクション
worktree-issue-1475-contract-snapshot-author-trust)、PR body 案・検証結果は上記の通り準備済みです。squne121 commentedon Jul 12, 2026
Draft PR 起票済み
Draft PR を起票しました: #1485
worktree-issue-1475-contract-snapshot-author-trust46afeccb3b3c5977a087f369cba75a98b2dd8dd3mainopen_pr.pyの overlap preflight hard gate が現在 OPEN なphase/implementationIssue 数(100件超)による saturation で fail-closed するため、人間の明示的な承認のもとopen_pr.pyを経由せず直接gh pr createで起票しています。PR 本文には--limit 300での overlap preflight evidence(decision_inputs_sha256: sha256:da00ec03f9cd09665416d52242d90459952645cecb7b24ca62f820f54a2f27f8)と disjoint 確認結果を記載済みです。次のアクションとして通常どおり pr-review-judge によるレビューへ進めます。
fix: contract snapshot publisher の identity検証と trust precedenceを強化する (#…
実装: contract snapshotのtrusted publisher identityとcomment ID bindingを検…
fix: PR #1548 の Allowed Paths 外テストを移設し pr-review-judge blocker を解消する
feat: source-bound contract fingerprint を materialize する (#1548)