Skip to content

実装: contract snapshotのtrusted publisher identityとcomment ID bindingを検証する #1475

Closed

Description

@squne121

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

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

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

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-valid status: go を採用しない回帰テストが PASS する
  • AC5: trusted author の current status: go と最新 trusted status: 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 # AC5

Allowed 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

Delivery Rule

Scope Delta(任意)

N/A

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    triage-required
    on Jul 11, 2026
  2. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    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から捨てられています。

    この状態で実装できるのは次の確認だけです。

    • markerが1件ある
    • child processが返したURLとremote URLが一致する
    • remote bodyがcurrent snapshotとして解析できる

    これは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には最低でも以下を追加しなければなりません。

    scripts/agent-guards/controlled_skill_mutation_exec.py
    scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py
    

    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で手動投稿した
    • GitHub Web UIからコピーした本文を投稿した
    • 別のスクリプトから投稿した

    したがって、IssueのGoalにある「controlled publisherのcomment ID bindingを満たす場合だけ既存snapshotを採用する」を実現するには、consumerが期待されるcomment IDを取得できる永続的なreceiptが必要です。

    推奨するreceiptは次のようなものです。

    CONTRACT_SNAPSHOT_PUBLISH_RECEIPT_V1:
      repo: squne121/loop-protocol
      issue_number: 1475
      issue_body_sha256: sha256:...
      comment_id: 123456789
      comment_body_sha256: sha256:...
      publisher_user_id: 63350259
      author_association: OWNER
      published_at: ...

    選択肢は二つです。

    1. receiptをcontrolled artifactとして保存し、既存snapshot採用時にも照合する
    2. セキュリティ主張を「trusted account provenanceを検証する」に弱め、controlled path由来までは保証しない

    現行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の直積ではなく、許可された組み合わせです。

    TRUSTED_CONTRACT_PUBLISHERS = {
        63350259: {
            "expected_login": "squne121",
            "user_type": "User",
            "allowed_author_associations": {"OWNER"},
        },
    }

    次はすべてfail-closedにします。

    • login一致・user ID不一致
    • user ID一致・type不一致
    • user ID一致・association不一致
    • ID、login、type、associationの欠落
    • IDが文字列、boolean、0、負数
    • 未知のassociation

    loginは監査表示とdrift検出用であり、認可の唯一のキーにはしない方が安全です。


    4. `[P1] trust filteringをlatest precedenceより先に実施する必要がある

    現在のconsumerは、全commentを解析した後に次の順序で処理しています。

    1. find_latest_result()
    2. latestがblockedなら停止
    3. find_latest_go()
    4. currentness判定

    信頼判定をis_go_current()にだけ追加すると、次の攻撃や障害が残ります。

    • untrustedな最新blockedがtrustedなgoをDoSする
    • untrustedな最新goが、それより古いtrustedなblockedを隠す
    • untrusted commentの日時とIDでprecedenceを操作できる
    • consumerごとにtrusted/untrustedの扱いが変わる

    必要なのは次の構造です。

    parsed_results = parse_contract_review_results(comments, issue_url)
    authoritative_results = [
        result
        for result in parsed_results
        if is_trusted_contract_publisher(result["provenance"])
    ]
    
    latest = find_latest_result(authoritative_results)
    latest_go = find_latest_go(authoritative_results)

    あるいは明示的に次を公開します。

    find_latest_trusted_result(...)
    find_latest_trusted_go(...)

    ACには「untrusted goを無視する」だけでなく、以下も追加すべきです。

    • untrusted blockedはtrusted goをblockしない
    • untrusted goはtrusted blockedをmaskしない
    • trusted blockedのprecedenceはuntrusted commentの新旧に影響されない

    5. `[P1] build_intake_capsule.pyの独自parserがpolicy driftを起こす

    build_intake_capsule.pyは共有parserを利用していません。独自に以下を実装しています。

    • YAML block抽出
    • schema validation
    • issue comment fetch
    • latest result選択
    • snapshot normalization

    そのlive pathは、body hashまたは日時だけでgoと判断し、最終的にproceed_to_step_1へ進めます。

    Issue本文には「共有trust policyに揃える」とありますが、それだけでは実装者が次のような重複修正をする可能性があります。

    • parser側にtrust関数を追加
    • build_intake_capsule.py側にも似た関数をコピー
    • 数か月後に一方だけallowlistが更新される

    AC4を次のように強化すべきです。

    build_intake_capsule.pyはcontract commentのfetch・parse・trust判定を共有parser moduleへ委譲し、独自のauthoritative snapshot判定を持たない。

    少なくとも、trust policy定数や判定関数の複製は禁止すべきです。


    6. `[P2] marker検索ではなくcomment IDによるdirect readbackを使うべき

    現在のcontrolled readbackは、全commentをpaginationしてmarker文字列で検索しています。

    しかしGitHub REST APIには、uniqueなcomment_idを指定して単一commentを取得するendpointがあります。(GitHub Docs)

    推奨フローは次です。

    POST comment
      ↓ response.id をexpected_comment_idとして保持
    GET /repos/{owner}/{repo}/issues/comments/{expected_comment_id}
      ↓
    id、issue_url、html_url、body hash、user identity、associationを照合
    

    remote readbackでは最低限、以下を検証します。

    remote.id == expected_comment_id
    remote.issue_url == expected issue API URL
    remote.html_url == expected comment URL
    sha256(remote.body) == expected comment body hash
    remote.user.id == trusted publisher user ID
    remote.user.type == expected type
    remote.author_association in allowed associations
    parsed snapshot body_sha256 == current issue body hash
    

    markerは内容確認や重複検出には使えますが、comment identityの主キーにすべきではありません。


    7. `[P2] malformed NDJSONを無視する処理がfail-openになっている

    共有parserのcomment fetchは、JSON parseに失敗した行を無条件で捨てています。

    この状態では、例えば最新のtrusted blockedを含む行だけが壊れた場合、古いgoが採用される可能性があります。

    security-sensitiveなsnapshot gateでは、次のどちらかにすべきです。

    • 1行でもparse失敗したらcomments fetch全体をerrorにする
    • 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.id
    • user.login
    • user.type
    • author_association
    • POST応答とGET応答のfield shape

    したがって、mutationを伴うE2Eを必須にする必要はありませんが、少なくとも既存のcontrolled snapshotを対象としたread-only verificationは実施した方がよいです。

    decision: applicable
    scope: read_only
    reason: >
      既存のcontrolled snapshot commentをGitHub REST APIで取得し、
      user.id、user.type、author_association、issue_url、
      comment ID direct readbackのproduction shapeを確認する。
      新規コメント投稿は行わない。

    Issue #1475に必要な具体的修正

    Allowed Paths追加

    scripts/agent-guards/controlled_skill_mutation_exec.py
    scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py
    

    これがなければ、AC3はconsumer内部の疑似bindingで終わります。

    provenance projection

    user.loginとauthor_associationだけでなく、次を保持します。

    provenance:
      comment_id: 123456789
      issue_url: ...
      user:
        id: 63350259
        login: squne121
        type: User
      author_association: OWNER
      created_at: ...
      updated_at: ...

    推奨AC構成

    AC1:
    comment projectionがid、issue_url、user.id、user.login、user.type、
    author_association、created_at、updated_atを型を維持して保持する。
    
    AC2:
    user.idをprimary keyとする許可済みidentity/type/association tupleだけを
    authoritativeとし、欠落・型不正・組み合わせ不一致をfail-closedにする。
    
    AC3:
    trust filteringをlatest go/blocked precedenceより前に実行し、
    untrusted goとuntrusted blockedがtrusted resultをmask/blockしない。
    
    AC4:
    POST responseから得たexpected comment IDと、
    comment ID指定のdirect GET readback結果を比較する。
    ID、issue、URL、body hash、provenance、snapshot currentnessの
    いずれかが不一致なら失敗する。
    
    AC5:
    controlled publisher resultがcomment IDとbody hashを含むreceiptを返し、
    既存snapshotをcontrolled publisher由来と主張するconsumerは
    そのreceiptとのbindingを検証する。
    receiptを導入しない場合は、controlled-path provenanceの主張を削除する。
    
    AC6:
    run_contract_review_once、ensure_contract_snapshot、
    build_intake_capsuleの全経路が共有parser・共有trust policyを使用する。
    
    AC7:
    trusted blocked precedence、body hash freshness、Product Spec payload、
    VC classifications、atomicity guardの既存契約がregressionしない。
    

    追加すべき敵対的テスト

    最低限、次のケースが必要です。

    trusted user ID + 正しいassociation
    正しいlogin + 異なるuser ID
    正しいuser ID + 異なるlogin
    正しいuser ID + Bot/User type不一致
    identity/association欠落
    untrusted go
    untrusted blocked
    untrusted goがtrusted blockedより新しい
    untrusted blockedがtrusted goより新しい
    POST expected IDとGET ID不一致
    comment IDがnull/string/bool/0
    readback issue_url不一致
    readback body hash不一致
    投稿後にcomment bodyが編集された
    duplicate marker
    malformed NDJSON line
    build_intake_capsule単独live pathでuntrusted go
    

    Verification Commandsには、現在不足している以下も追加してください。

    uv run --locked pytest \
      .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/issue-contract-review/tests/test_run_contract_review_once.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 \
      scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py

    最終評価

    Issue #1475は、PR #1463で発見された「誰でもschema-validなstatus: goを投稿できる」という問題への対応としては正しい出発点です。

    ただし現状では、

    • ID bindingの比較元が存在しない
    • controlled publishing path由来を後続consumerが証明できない
    • mutableなloginをtrust anchorにしようとしている
    • trust判定とprecedenceの順序が未定義
    • build_intake_capsule.pyの重複parserが残る
    • controlled executorがAllowed Paths外

    という状態です。

    実装開始前に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だけを見て、投稿者を確認していません。ここに軽い投稿者チェックを足すだけでも、誤って別経路で生成されたコメントを採用する事故は減らせます。

    適切な脅威モデル

    対象にするもの:

    • エージェントが不正確なコメントを生成する
    • 別ユーザーやbotのコメントを誤採用する
    • 古い、または別Issue用のstatus: goを採用する
    • 投稿処理のstdoutだけを信じて、実際には異なるコメントを採用する
    • consumerごとに判定がずれる

    対象外にするもの:

    • GitHubアカウントやtokenの侵害
    • owner権限を持つ悪意あるプロセス
    • squne121本人になりすました投稿
    • username変更や再取得への長期的な防御
    • 改ざん不能な監査証跡

    この対象外をIssue本文に書けば、実装のセキュリティ主張も過大になりません。

    最小限の実装

    1. user.loginとauthor_associationだけを見る

    TRUSTED_SNAPSHOT_AUTHORS = {
        ("squne121", "OWNER"),
    }

    以下の場合はsnapshot候補から除外します。

    • user.login欠落
    • author_association欠落
    • loginがsqune121以外
    • associationがOWNER以外

    numericなuser.idやuser.typeは不要です。

    2. trust filteringをlatest判定より先に行う

    これは残すべきです。

    parsed = parse_contract_review_results(comments, issue_url)
    trusted = [result for result in parsed if is_trusted_snapshot_author(result)]
    latest = find_latest_result(trusted)
    go = find_latest_go(trusted)

    そうしないと、untrustedな最新blockedが既存のtrusted goを止めるなど、単純な誤判定が残ります。

    3. controlled publisherは軽いreadbackだけ行う

    PR #1463側では既に、markerの一意性、URL一致、remote snapshotのcurrentnessをreadbackしています。

    ここに投稿者確認を加えれば十分です。

    markerが1件だけ存在する
    remote URL == publisherが返したURL
    remote user.login == squne121
    remote author_association == OWNER
    remote snapshotがcurrent
    

    永続的なpublish receiptは不要です。

    user IDとcomment IDは分けて考える

    • GitHub user numeric ID:不要
    • GitHub comment ID:取得コストが低いため、残してもよい

    comment IDはallowlist管理のためではなく、「POSTしたコメントとreadbackしたコメントが同じか」の確認に使います。

    ただし、既存のURL比較とmarker一意性で十分と判断するなら、IssueタイトルとACから「comment ID binding」を削除した方が正確です。

    推奨タイトル:

    実装: contract snapshotのtrusted authorとpublisher readbackを検証する

    簡略化したAcceptance Criteria

    AC1:
    comment fetchがuser.loginとauthor_associationを保持する。
    
    AC2:
    user.login=squne121かつauthor_association=OWNERの
    schema-valid snapshotだけをauthoritative候補とする。
    provenance欠落や不一致は候補から除外する。
    
    AC3:
    trusted filteringをlatest go/blockedのprecedence判定より前に行う。
    
    AC4:
    controlled publisherのreadbackでmarker一意性、URL一致、
    trusted author、snapshot currentnessを確認する。
    不一致時は成功扱いにしない。
    
    AC5:
    run_contract_review_once.py、ensure_contract_snapshot.py、
    build_intake_capsule.pyが同じtrust判定を使用する。
    
    AC6:
    既存のbody hash freshness、latest trusted blocked precedence、
    Product Spec payload、schema validationがregressionしない。
    

    不要になるもの

    前回提案した以下は削除して問題ありません。

    • user.idによる認可
    • user.type検証
    • login変更対策
    • publish receiptの永続化
    • runtimeでの実GitHub検証
    • comment本文の暗号学的署名
    • GitHub App導入
    • organization membership照会

    修正後の評価

    Issue #1475は、軽量なガードレールとしては妥当です。

    判定は次のように変更します。

    非ブロッキングの軽微修正で実装可能。
    user numeric IDや永続receiptは不要。
    login + OWNER、trust-first precedence、既存publisher readbackへのauthor確認追加で十分。

    Claude CodeやCodex CLIが同じGitHub credentialを使って意図的に正規コメントを偽造するケースまでは防げませんが、個人開発の誤操作防止としては費用対効果のよい境界です。

  3. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-12T04:40:06Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1475
      body_sha256: "sha256:bf80f3fa61e0a27c89a3b62907256ea046490e642882536a6573edddd326d7ac"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_fetch_and_parser_preserve_trusted_comment_provenance","command_hash":"sha256:cb8a4bf318972e9de29272807010c7b7127e5378dd0ca37cfcd763ac19032bf6","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_fetch_and_parser_preserve_trusted_comment_provenance"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":142,"fix_hint":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":1,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":4,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_untrusted_schema_valid_go_is_ignored","command_hash":"sha256:1850df49e278705c54b5be04b0e5f963a668414f53c8cca29e5ffc826ac47f9b","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-contract-review/tests/test_contract_snapshot_author_trust.py::test_untrusted_schema_valid_go_is_ignored"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":135,"fix_hint":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":3,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":6,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_controlled_publisher_comment_id_binding_is_required","command_hash":"sha256:e8590412f62ab4e60750b278ab1496beba530a0bf8c89cdc87709cdd616a2818","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_controlled_publisher_comment_id_binding_is_required"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":139,"fix_hint":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":5,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC4","line":8,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_all_snapshot_consumers_reject_untrusted_go","command_hash":"sha256:e4c7e2e46f68dcf8fc952615da356f57d5ff9a4900d525a2ea82c770962d64b2","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py::test_all_snapshot_consumers_reject_untrusted_go"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":132,"fix_hint":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":7,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC5","line":10,"raw_command":"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","command_hash":"sha256:08ca1da7b79ed3a80b3c0e2c93e39b51c2fb1c58c66f47e03e4941fb6a52432d","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 87 items",".claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py . [  1%]",".............................                                            [ 34%]",".claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py . [ 35%]","................................................                         [ 90%]",".claude/skills/impl-review-loop/tests/test_build_intake_capsule.py ..... [ 96%]","...                                                                      [100%]","============================== 87 passed in 0.11s =============================="],"stdout_truncated":false,"stdout_original_line_count":16,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":301,"fix_hint":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":9,"raw":"# baseline-expect: pass"},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  5. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了・Draft PR 起票は overlap preflight hard gate によりブロック

    実装状況

    • worktree: .claude/worktrees/issue-1475-contract-snapshot-author-trust
    • branch: worktree-issue-1475-contract-snapshot-author-trust(push 済み)
    • commit: 46afeccb
    • 対象ファイル(Allowed 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(新規)

    Verification Commands(全て PASS)

    • AC1 test_fetch_and_parser_preserve_trusted_comment_provenance — PASS
    • AC2 test_untrusted_schema_valid_go_is_ignored — PASS
    • AC3 test_controlled_publisher_comment_id_binding_is_required — PASS
    • AC4 test_all_snapshot_consumers_reject_untrusted_go — PASS
    • AC5 regression(test_contract_review_result_parser.py / test_ensure_contract_snapshot.py / test_build_intake_capsule.py)— 88 passed
    • pnpm typecheck / pnpm lint / pnpm test(96 files, 1575 tests)/ pnpm build — 全て PASS
    • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 21 passed

    Draft PR 起票がブロックされている理由

    open_pr.py の overlap preflight hard gate(linked issue が phase/implementation ラベルを持つため強制発動)が、check_implementation_overlap.py(open_pr.py 内部の subprocess 呼び出しは --limit 未指定 = デフォルト値)をオンライン再実行した結果、以下を検出した:

    route: human_review_required
    source.complete: false
    source.saturated: true
    

    つまり現在 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 300 runの evidence をそのまま採用せず、gate 直前に自前で再実行するため、この収集済み evidence を渡しても decision_inputs_sha256 drift として拒否される。

    人間判断が必要な事項

    1. open_pr.py の overlap preflight subprocess 呼び出しに --limit を渡せるようにする(saturation 回避)follow-up Issue が必要。
    2. 上記 follow-up 実装前に本 PR を起票する場合は、人間が直接 gh pr create を実行して起票する(open_pr.py の hard gate を経由しない、人間による明示的な override)。
    3. または --limit 300 の evidence(decision_inputs_sha256: sha256:da00ec03f9cd09665416d52242d90459952645cecb7b24ca62f820f54a2f27f8)を正本として扱うポリシー変更を open_pr.py 側に導入する。

    いずれも本 Issue の Allowed Paths(issue-contract-review / impl-review-loop の trust policy 実装)の範囲外であるため、本 Issue 自体はこれ以上変更しない。

    次のアクション

    • 人間が上記のいずれかの方法で Draft PR を起票してください。branch は push 済み(worktree-issue-1475-contract-snapshot-author-trust)、PR body 案・検証結果は上記の通り準備済みです。
    • PR 起票後は通常どおり pr-review-judge によるレビューへ進めます。
  6. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    Draft PR 起票済み

    Draft PR を起票しました: #1485

    • branch: worktree-issue-1475-contract-snapshot-author-trust
    • head commit: 46afeccb3b3c5977a087f369cba75a98b2dd8dd3
    • base: main

    open_pr.py の overlap preflight hard gate が現在 OPEN な phase/implementation Issue 数(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 によるレビューへ進めます。

  7. added 2 commits that reference this issue on Jul 16, 2026
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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions