Skip to content

fix(contract-readiness): parent validation profile を分離 (#1844) - #1845

Merged
squne121 merged 5 commits into
mainfrom
worktree-issue-1844-contract-readiness-check-py-run-validate
Jul 29, 2026
Merged

squne121 merged 5 commits into
mainfrom
worktree-issue-1844-contract-readiness-check-py-run-validate

Conversation

@squne121

@squne121 squne121 commented Jul 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • existing-issue readiness を ISSUE_KIND_POLICY_V1 で正規化し、parent のみを版付き existing_issue_readiness_v1 profile へ明示 dispatch します。
  • implementation / research は既存の kind-agnostic 互換経路を維持し、MRC parse failure・未知 kind・空白未正規化 kind は fail-closed に分離します。
  • MRC の非 hashable mapping key を構造化 parse error に閉じ込め、parent semantic validation と実 validator を通す edit transaction 結合テストを追加します。

Contract and Scope(契約と対象範囲)

Acceptance Criteria

  • AC1: SSOT loader が canonical kind と alias(tracking → parent、design → research)を解決し、profile / legacy / parse failure / blocked を分離します。
  • AC2: parent の schema、parent_mode、closure_mode、Quality Decision Record の整合性を fail-closed で検証します。
  • AC3: duplicate / syntax / missing fence に加え、complex YAML key も JSON-safe な MRC parse error として返します。
  • AC4: existing readiness の必須 section は existing_issue_readiness_v1 に固定し、ISSUE_TEMPLATE 変更に追従しません。
  • AC5: edit transaction は実 guard・hygiene・readiness を通過してから controlled content update に到達します。
  • AC6: 追加した回帰テストと lint を current head で実行済みです。

Checks

  • AC1 / AC2: remote detached worktree evidence — 17 passed
  • AC3: remote detached worktree evidence — 95 passed
  • AC4: remote detached worktree evidence — 28 passed
  • AC5: remote detached worktree evidence — 20 passed
  • AC6: pnpm lint — passed on current remote head
  • Python lint: changed Python files — passed on current remote head
  • Allowed Paths audit: 7 / 7 changed paths are within the Issue contract
    全ての指定検証は current remote head の detached worktree で成功しています。protected TEST_VERDICT は未availableであり、本PRはこれを作成・代替・主張しません。通常CI(ci-verdict-summary)は進行中で、検証結果の代替証跡として扱いません。

Runtime Verification Applicability

  • decision: immediate
  • applicable_acs: AC1, AC2, AC3, AC4, AC5, AC6
  • execution_environment: local Python validation scripts and pytest
  • skip_conditions: なし
  • fallback_policy: validator / test failure は Draft のまま修正し、current-head evidence を再作成する
  • artifact_requirements: pytest summary、lint result、contract snapshot、overlap evidence
    この適用性は、実際の validator 実行とテスト結果をレビュー可能な証跡として残すことを意味します。

Schema Change Applicability

  • decision: not_schema_change
  • reason: MRC / readiness result の公開 schema と producer-consumer field shape は変更せず、既存 consumer の validation profile 選択と fail-closed behavior を追加します。
    公開契約の形式を変えずに、既存 Issue を安全に検証する判断分岐だけを追加しています。

Schema Consumer Inventory

  • N/A: 公開 machine-readable schema のキー・型・version は変更していません。

Safety Claim Matrix

# SAFETY_CLAIMS_V1
safety_claims:
  - claim: "未知 kind と MRC parse failure は parent profile に dispatch されない"
    implemented: "yes"
    evidence:
      - "AC1/AC2 pytest 17 passed"
    not_controlled: []
    follow_up: []
  - claim: "edit transaction は local validator 成功前に remote mutation を開始しない"
    implemented: "yes"
    evidence:
      - "AC5 pytest 20 passed"
    not_controlled: []
    follow_up: []

受け入れ条件の達成状況

  • AC1: ISSUE_KIND_POLICY_V1 による canonical / alias 解決と四状態 profile 判定を current head 69cda7ddad0ad762f8b9d57c903fc9d5c29f0ff4 で確認しました(AC1/AC2 pytest 17 passed)。
  • AC2: parent MRC の schema、mode、closure、QDR semantic validation を同じ current head で確認しました(AC1/AC2 pytest 17 passed)。
  • AC3: complex YAML key を含む MRC parse error の JSON-safe 化を確認しました(対象 regression pytest 95 passed)。
  • AC4: existing_issue_readiness_v1 が template 依存でないことを確認しました(対象 regression pytest 28 passed)。
  • AC5: 実 guard・hygiene・readiness を通る edit transaction integration を確認しました(対象 pytest 20 passed)。
  • AC6: pnpm lint と変更 Python files の Ruff が current head で成功しました。

Verification Commands(検証コマンド)

  • current head: 69cda7ddad0ad762f8b9d57c903fc9d5c29f0ff4
  • AC1 / AC2: pytest selection — 17 passed
  • AC3: MRC / readiness / edit_issue regression selection — 95 passed
  • AC4: MRC / existing_issue_readiness_v1 selection — 28 passed
  • AC5: edit_issue / mutation_started selection — 20 passed
  • AC6: pnpm lint — passed
  • changed Python files: Ruff — passed
    この一覧は全て current head に束縛した実行結果であり、各受け入れ条件に対応する検証根拠です。

Runtime Verification Evidence(実行時検証証跡)

  • Issue の decision: immediate に従い、process-level integration pytest を実行し、edit transaction が実 guard・hygiene・readiness を通過して controlled content update に到達することを確認しました。
  • runtime verification は未実施・skip ではありません。上記の current-head pytest 結果が process-level integration evidence です。

CI Evidence(CI証跡)

  • Current CI: PR #1845 checks — 16 checks passed at current head。
  • CI は engineering verification の補助証跡です。protected TEST_VERDICT の代替ではありません。
  • protected evidence は unavailable のため merge gate は blocked のままです。Draft PR を維持します。

Known Limitations(既知の制限)

  • local hook と permission profile は cooperative fail-closed guardrail であり、security boundary ではありません。
  • overlap evidence は changed-file / contract signal の観測であり、Git three-way merge conflict の証明ではありません。
  • したがって、最終的な統合可否は current-head review と GitHub 側の CI 証跡を合わせて判断する必要があります。

Notes

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1845 closed).

@squne121

Copy link
Copy Markdown
Owner Author

PR #1845 敵対的レビュー

判定: REQUEST_CHANGES

レビュー対象は Draft PR #1845、head 13308fe26258bc7511f0b26fedbd4c12a238aec7、変更 2 ファイル、+199/-1 です。parent Issue に対する LP001 誤検出を限定的に除去し、既存 implementation fixture を維持する方向性は妥当です。しかし、現状は 2 件の blocker と 3 件の high-risk finding があり、merge-ready ではありません。


1. [blocker] MRC の parse 成功を「有効な parent contract」と誤認している

新しい resolver は、MRC が構文的に parse でき、issue_kind が文字列であれば、追加の意味検証なしで parent profile を選択します。contract_schema_version の値、parent_mode、closure_mode、両者の互換性は確認していません。

たとえば、次の MRC と PR の _parent_body() が持つ各見出しだけで parent profile が選ばれます。

contract_schema_version: v1
issue_kind: parent
goal_ref: invalid-parent
change_kind: workflow
# parent_mode なし
# closure_mode なし

ところがリポジトリ SSOT は、parent_mode 欠落、placeholder、enum 外値、parent_mode と closure_mode の不整合を fail-close 条件として明示しています。parent template 自体も、この二フィールドを MRC の必須契約として提示しています。

PR が追加した「正常な parent」fixture は実際には parent_mode と closure_mode を持っていません。テストは Verification Commands と Allowed Paths の LP001 が出ないことしか確認せず、その body が semantic-invalid であることを検出していません。

さらに、現在の validator は次の挙動です。

  • LP002 は contract_schema_version と issue_kind の存在しか検証しない。
  • parent profile の LP001 は current template の必須見出しだけを見る。
  • RVA セクション自体がなくてもエラーにしない。
  • VC セクションがなければ static VC check は何も返さない。
  • 他のエラーがなければ readiness は go になる。

これは readiness 単体だけの問題ではありません。edit_issue_txn.py は、実 guard、hygiene、readiness が通れば controlled mutation に進みます。guard も parent の required heading と kind-aware validator は実行しますが、parent_mode/closure_mode の意味検証は行っていません。したがって、この PR により 構文的には読めるが parent contract として無効な本文が safe-patch 経路を通過可能になります。

必須修正

profile 選択前、または parent readiness profile 内で、少なくとも以下を機械検証してください。

  • contract_schema_version == "v1" の完全一致
  • parent_mode と closure_mode の存在
  • closed enum
  • 許可された組み合わせ
  • <required: ...> placeholder の拒否
  • quality-gate の場合の Quality Decision Record 整合

parsed.ok は構文的 parse 成功を意味するだけであり、semantic contract validity として使用してはいけません。


2. [blocker] 複合 YAML key で uncaught TypeError が発生し、JSON 出力契約が壊れる

共有 MRC parser の custom loader は、構築した key をそのまま if key in mapping および mapping[key] に使用しています。hashable かどうかを確認していません。また parser が捕捉するのは _DuplicateKeyError と yaml.YAMLError だけです。

次の YAML が最小再現です。

? [a, b]
: value

PR と同一の loader 実装を、リポジトリがロックしている PyYAML 6.0.3 で実行すると、次になります。

TypeError: unhashable type: 'list'

リポジトリは PyYAML 6.0.3 をロックしています。

YAML のデータモデルでは mapping key は scalar に限定されません。一方、PyYAML 本体の BaseConstructor.construct_mapping() は hashability を確認し、非 hashable key を ConstructorError として処理します。custom loader はこの保護を落としています。(YAML)

この parser の既存不具合は PR #1845 が新規作成したものではありません。しかし、PR は parser を run_validate_issue_body() の subprocess 呼び出し前に同一プロセスで直接実行するため、新たに readiness CLI の外へ例外を露出させます。現在の run_validate_issue_body() は timeout と JSON decode error は構造化しますが、この TypeError は捕捉しません。結果は ISSUE_CONTRACT_READINESS_RESULT_V1 ではなく traceback です。

必須修正

根本修正は custom loader を PyYAML 本体と同様にすることです。

from collections.abc import Hashable
from yaml.constructor import ConstructorError

if not isinstance(key, Hashable):
    raise ConstructorError(
        "while constructing a mapping",
        node.start_mark,
        "found unhashable key",
        key_node.start_mark,
    )

加えて resolver 境界でも parser 例外を捕捉し、raw traceback ではなく structured validator_internal_error または human_judgment を返してください。

Issue #1844 は mrc_contract_parser.py を Out of Scope としているため、根本修正を行うなら Allowed Paths の改訂と contract snapshot の更新が必要です。狭い修正に留める場合でも、少なくとも caller 側の例外正規化は必須です。


3. [high] ISSUE_KIND_POLICY_V1 と resolver が split-brain になっている

リポジトリ SSOT は次を規定しています。

  • canonical kind: implementation, research, parent
  • alias: design → research, tracking → parent
  • unknown kind: silent fallback 禁止、block
  • consumer 内の独自 kind allow-list による二重管理禁止

一方、PR の resolver は次のローカル mapping しか持ちません。

_EXISTING_ISSUE_VALIDATION_PROFILES = {
    "parent": "parent",
}

そのため、次の不整合が発生します。

  • issue_kind: tracking は SSOT 上 parent alias だが、parent profile に入らない。
  • " parent " のような空白付き string は正規化されない。
  • future-kind は SSOT 上 block 対象だが、PR のテストは no-kind legacy fallback を正しい挙動として固定している。

未知 kind の body に generic LP001 が要求する三セクションを用意すれば、readiness 単体では go に到達し得ます。これは unknown_kind_policy: block と整合しません。

ここは実装者だけの問題ではありません。改訂後の Issue #1844 自体が、未知 kind を legacy fallback に送るよう AC3 で要求しているため、Issue contract と repo SSOT が衝突しています。

必須修正

Optional[str] を返す resolver ではなく、少なくとも次の tri-state を返す構造にしてください。

supported_profile
legacy_supported_kind
invalid_or_unknown_contract
  • SSOT loader で alias を canonicalize
  • canonical だが existing profile 未対応の場合だけ、明示的な compatibility policy を適用
  • unknown/invalid は構造化 block
  • None を「parse failure」「unknown」「legacy implementation」の三用途に兼用しない

その前に Issue #1844 の AC3 を SSOT に合わせて改訂し、contract snapshot を更新する必要があります。


4. [high] 「validation profile の分離」は名目的で、実装上は --kind parent の別名にすぎない

PR 本文は issue_kind と validation_profile を分離したと説明しています。しかしコード上の profile 値は "parent" であり、そのまま validate_issue_body.py --kind parent に渡されます。独立した profile schema、profile version、profile-specific policy は存在しません。

--kind parent が有効になると validator は、実行時点の .github/ISSUE_TEMPLATE/parent.yml から required section と Stop Conditions を動的ロードします。つまり current authoring form が、既存 Issue readiness の validation profile を兼務します。

GitHub Issue Forms の required validation はフォーム送信時の入力制約です。送信後は response が Markdown Issue body となり、後から編集できます。したがって current form definition は、過去に作成された Issue の versioned schema ではありません。([GitHub Docs]2)

このままでは、将来 parent.yml に required field を一つ追加しただけで、過去の parent Issue safe-patch が再び一斉に壊れます。Issue #1346/PR #1353 が existing-issue readiness と authoring strictness を分離した理由と同型の回帰です。

必須修正

次のような明示的な profile を実装してください。

issue_kind:
  parent

validation_profile:
  existing_issue_readiness_v1

existing_issue_readiness_v1 は current Issue Form の validations.required を直接参照せず、互換性保証された versioned policy として固定すべきです。

validate_issue_body.py に profile 引数を追加するなら、現在の Allowed Paths では不足します。Issue #1844 の scope を改訂してください。


5. [high] Outcome が要求する edit-issue safe-patch 経路を統合テストしていない

Issue #1844 の Outcome は、edit_issue_txn.py 経由で parent safe-patch を実行可能にすることを要求しています。しかし新規テストは readiness helper に閉じています。

  • 一つ目は subprocess 自体を mock して、引数末尾が --kind parent であることしか検証しない。
  • 実 validator を使うテストも、二つの LP001 がないことしか確認しない。
  • edit_issue_txn.py、guard、hygiene、readiness、controlled mutation の連結は通していない。

既存の edit transaction テストも、guard/hygiene/readiness のパスを一時 fake に置き換え、_run_command() を stub しています。実 consumer integration の証拠にはなりません。

実際の production 経路は、candidate body に対して順に guard、hygiene、readiness を実行し、すべて通った後で issue_content.update を呼びます。

必須テスト

実 GitHub mutation まで行う必要はありません。mock するのは remote readback と controlled executor だけにし、ローカル validator 群は実物を通してください。

最低限、次を追加すべきです。

test_valid_parent_safe_patch_reaches_controlled_update
test_parent_missing_parent_mode_never_starts_mutation
test_parent_invalid_closure_pair_never_starts_mutation
test_invalid_schema_version_is_not_go
test_tracking_alias_resolves_to_parent_profile
test_unknown_kind_is_structurally_blocked
test_unhashable_yaml_key_returns_structured_json

valid fixture は PR 内で簡略化した body ではなく、実際の parent #1833 と同じ MRC 構造を使用するのが適切です。#1833 は parent_mode: delivery-rollup と closure_mode: child-complete を明示しています。


6. [medium] Runtime Verification の説明が実装事実と一致せず、CI も未 green

PR 本文は、変更が純粋な Python 分岐で「プロセス起動・I/O がない」ため runtime verification は不要としています。しかし対象関数は temporary file を作成し、validator subprocess を起動しています。今回の parser 例外も、まさに process boundary を変更したことで顕在化しています。

また現在の head では ci workflow が failure です。ログ上は kuromoji tarball 等の取得 timeout であり、現時点ではコード起因の test failure とは判断しませんが、merge 条件として再実行して green を確認する必要があります。

Runtime Verification の decision 自体を必ず immediate にする必要はありません。ただし reason は、少なくとも次のように事実に合わせるべきです。

product runtime への接続は不要だが、
temporary-file I/O と subprocess boundary を含むため、
process-level integration pytest で検証する。

評価できる点


マージ前の必須条件

  1. Issue 実装: contract_readiness_check.py の run_validate_issue_body が issue_kind を validate_issue_body.py へ転送せず parent 種別 Issue の safe-patch を阻害する不具合を修正する #1844 を改訂する
    unknown kind fallback を SSOT の block policy に合わせ、semantic parent validation と transaction integration test を scope/AC/Allowed Paths に追加する。

  2. resolver を structured tri-state にする
    parse failure、unknown kind、legacy-supported kind を None 一つで表現しない。

  3. parent contract の意味検証を追加する
    schema version、parent_mode、closure_mode、組み合わせ、placeholder、QDR 整合を fail-close にする。

  4. MRC parser の非 hashable key を安全に処理する
    root parser 修正、または最低でも readiness caller で例外を JSON error に正規化する。

  5. profile を kind から実質的に分離する
    current Issue Form に直結しない existing_issue_readiness_v1 を定義する。

  6. 実 consumer integration test を追加する
    valid parent は controlled update 直前まで到達し、invalid parent は mutation_started: false で停止することを確認する。

  7. CI を再実行して green にする
    現在の download timeout が解消された run を merge evidence にする。

現状の PR は、報告された false positive を narrow happy path では解消しています。しかしその代わりに、semantic-invalid parent の fail-open と readiness JSON protocol の例外破壊を導入しています。少なくとも blocker 1・2を解消し、Issue #1844 の契約矛盾を修正するまでは承認すべきではありません。

@squne121

Copy link
Copy Markdown
Owner Author

保護証跡を捏造・無効化してマージするのではなく、欠落を「マージ限定ブロッカー」に縮退させ、実装・敵対的レビュー・修正・通常検証を継続させるプロンプトです。

なお、確認時点の PR #1845 は Draft のままですが、実 head は報告内の 136903b… から d91b672… へ進んでいます。PR 本文に記載された head も古いため、固定 SHA を信用せず毎回取得させる必要があります。 現 head の CI は確認時点で実行中で、他の関連 workflow は成功済みです。 また、producer lane や workflow の追加は #1844 の Allowed Paths 外であり、Issue 本文上も別スコープとして扱う必要があります。

あなたは squne121/loop-protocol の実装・敵対的レビュー統括エージェントです。

対象:

最優先命令

TEST_VERDICT_PRODUCER_RECEIPT_V1、publish_request、command_hash_map、承認済み producer lane が存在しないことを理由に、実装・コードレビュー・修正・通常検証の全工程を停止してはならない。

この欠落は、次の操作だけを禁止する限定的ブロッカーとして扱うこと。

  • merge_ready: true の宣言
  • PR の Ready for review 化
  • auto-merge の有効化
  • PR のマージ
  • protected TEST_VERDICT が存在するとする主張

欠落していても、以下は継続すること。

  • current head の再取得
  • Issue 本文と契約の再取得
  • diff と関連実装の敵対的レビュー
  • Allowed Paths 内の修正
  • ローカルテスト、lint、通常 CI の検証
  • 回帰リスク調査
  • PR 本文とレビュー報告の整合性確認
  • protected evidence 以外の診断証跡の整理

protected_test_verdict_producer_missing を、ループ全体の termination_reason にしてはならない。

絶対禁止

次を行ってはならない。

  1. producer receipt、publish request、hash map、artifact、署名、CI 結果を捏造する。
  2. protected evidence を local test output や通常 CI で代替したと主張する。
  3. test verdict の検証コード、branch protection、required check、materializer の検証を弱める。
  4. protected evidence を生成するためだけに 実装: contract_readiness_check.py の run_validate_issue_body が issue_kind を validate_issue_body.py へ転送せず parent 種別 Issue の safe-patch を阻害する不具合を修正する #1844 の Allowed Paths 外を変更する。
  5. workflow、CI、materializer、publisher、証跡基盤を 実装: contract_readiness_check.py の run_validate_issue_body が issue_kind を validate_issue_body.py へ転送せず parent 種別 Issue の safe-patch を阻害する不具合を修正する #1844 の変更へ混入させる。
  6. テスト削除、skip 化、期待値の弱体化によって成功させる。
  7. stale な head SHA、Issue body SHA、過去の CI run を current evidence として利用する。
  8. protected verdict がない状態でマージする。

実行モデル

メインスレッドは制御だけを担当する。

可能な場合は gpt-5.3-codex-spark モデルのサブエージェントを優先して並列実行する。

最低限、次の役割を分離すること。

  • state-reader: PR、Issue、head、base、comments、CI 状態の再取得
  • adversarial-reviewer: 実装、テスト、契約、回帰リスクの敵対的レビュー
  • test-auditor: Verification Commands と関連回帰テストの実行・証跡整理
  • implementer: Allowed Paths 内で確認済み finding を修正
  • final-verifier: 修正後 head に対する独立再検証

同一サブエージェントに、実装と最終承認判定を兼務させないこと。

nested SubAgent delegation が禁止されている場合、メインスレッドから直接各サブエージェントを起動すること。

Phase 0: current state の再取得

最初に GitHub から次を取得すること。

ユーザーが提示した 136903b... は参考情報に限定し、current head と仮定してはならない。

PR 本文に書かれた head と実 head が異なる場合は、stale_pr_metadata finding として記録すること。

以後、すべてのテスト・レビュー・証跡を取得した current head に束縛すること。

Phase 1: 契約とスコープの固定

Issue #1844 の次の項目を正本として抽出すること。

  • In Scope
  • Out of Scope
  • Acceptance Criteria
  • Verification Commands
  • Allowed Paths
  • Stop Conditions
  • Delivery Rule

変更ファイルが Allowed Paths 外に存在する場合、直ちに finding として報告する。ただし、レビュー全体は継続すること。

producer lane、materializer、publisher、CI workflow の変更が必要な場合は #1844 に混入させず、別 Issue の起票案を生成すること。

別 Issue が必要でも、#1845 のコードレビューと Allowed Paths 内の修正は止めないこと。

Phase 2: protected evidence と通常証跡を分離

証跡状態を次の二軸で管理すること。

evidence_state:
  protected_test_verdict:
    status: available | unavailable | invalid
    merge_authorization: allowed | blocked
  engineering_verification:
    status: pass | fail | incomplete
    review_continuation: allowed

producer lane が存在しない場合は次のように扱う。

evidence_state:
  protected_test_verdict:
    status: unavailable
    merge_authorization: blocked
  engineering_verification:
    status: incomplete
    review_continuation: allowed

local pytest、lint、通常 CI、diff inspection は engineering_verification にだけ記録すること。

これらを protected TEST_VERDICT と呼んではならない。

Phase 3: 敵対的レビュー

protected verdict がなくても PR レビューを実施すること。

最低限、次を検証する。

  1. ISSUE_KIND_POLICY_V1 が唯一の kind policy として使用されているか。
  2. tracking → parent、design → research alias が正規化されるか。
  3. unknown kind、空白付き kind、policy load failure が fail-closed になるか。
  4. parse failure と semantic-invalid parent が別 reason code になるか。
  5. contract_schema_version == v1 が完全一致で検証されるか。
  6. parent_mode と closure_mode の存在、enum、許可組み合わせが検証されるか。
  7. placeholder が拒否されるか。
  8. quality-gate と Quality Decision Record の整合性が検証されるか。
  9. non-hashable YAML mapping key が例外を漏らさず JSON-safe result になるか。
  10. existing_issue_readiness_v1 が current Issue Form の required fields を直接参照していないか。
  11. implementation/research の legacy compatibility が意図せず厳格化されていないか。
  12. edit_issue_txn.py の guard → hygiene → readiness → controlled executor の順序が維持されるか。
  13. invalid candidate で mutation_started: false が保証されるか。
  14. valid parent だけが controlled update 直前へ到達するか。
  15. subprocess exception、timeout、invalid JSON が構造化エラーになるか。
  16. テストが production code と同じ consumer path を通っているか。
  17. mock が検証対象そのものを置き換えていないか。
  18. PR 本文の検証結果、head SHA、変更範囲が current state と一致するか。

finding は blocker / high / medium / low に分類し、各 finding に次を含めること。

  • 対象ファイルと行
  • 再現条件
  • 実害
  • 契約違反
  • 最小修正
  • 必要な回帰テスト

Phase 4: 修正

blocker または high finding がある場合、#1844 の Allowed Paths 内で修正すること。

修正後は、関連する最小テストだけで終わらず、Issue に記載された全 Verification Commands と関連回帰テストを実行すること。

Allowed Paths 外の修正が必要な finding は、次の二つに分離する。

基盤修正が未実施でも、#1844 内で安全に実行可能な防御的修正とレビューは完了させること。

Phase 5: head drift 対応

レビューまたは検証中に PR head が変更された場合、古い結果を破棄すること。

次を再実行する。

  • current head の取得
  • diff の取得
  • Verification Commands
  • finding の再評価
  • PR 本文の head/検証記録の確認

stale head に紐づく成功結果を current-head evidence として引き継いではならない。

Phase 6: 通常 CI

current head の通常 CI を確認する。

Phase 7: PR レビュー判定

protected verdict がなくても、コード品質に関するレビュー判定は出すこと。

利用可能な判定:

CODE_REVIEW_PASS
CODE_REVIEW_REQUEST_CHANGES
CODE_REVIEW_INCOMPLETE

CODE_REVIEW_PASS は「コード上の blocker/high finding がなく、通常検証が成功した」という意味だけを持つ。

これはマージ承認ではない。

protected verdict が unavailable の場合、最終統合状態は必ず次にする。

merge_ready: false
merge_blocker: protected_test_verdict_unavailable

Phase 8: producer lane 用の別 Issue 案

producer lane が本当に欠落している場合は、#1844 を変更せず、別 Issue の起票用本文を生成する。

別 Issue には最低限、次を含める。

  • current head と Issue body SHA に束縛された producer receipt
  • TEST_VERDICT_PRODUCER_RECEIPT_V1
  • publish_request
  • command_hash_map
  • TEST_VERDICT_MACHINE/v2
  • canonical materializer/publisher
  • artifact upload と readback
  • stale head/stale Issue body の拒否
  • producer identity と command allow-list
  • receipt、artifact、CI run の整合性検証
  • protected workflow と branch protection の接続
  • ローカルでの自己署名・自己承認を禁止する条件

ただし、この別 Issue を実装しないこと。#1844 の PR へ変更を混入させないこと。

完了条件

次の条件をすべて満たすまで、human_review_required を返して終了してはならない。

  • current head を取得した
  • current Issue body を取得した
  • diff を敵対的レビューした
  • Allowed Paths 内の blocker/high finding を修正した、または修正不能理由を特定した
  • Verification Commands を current head で実行した
  • 通常 CI を確認した
  • protected evidence と通常証跡を明確に分離した
  • コードレビュー判定を出した
  • producer lane 用の別 Issue 案を生成した

producer lane 欠落だけを理由に、PRレビューを未実施のまま終了してはならない。

最終出力

最終結果は次の形式で出力すること。

IMPL_REVIEW_LOOP_RESULT_V2:
  status: completed_with_merge_gate_blocked | changes_requested | implementation_blocked
  issue_number: 1844
  pr_number: 1845
  current_head: "<full SHA>"
  issue_body_sha256: "sha256:<hash>"

  code_review:
    verdict: CODE_REVIEW_PASS | CODE_REVIEW_REQUEST_CHANGES | CODE_REVIEW_INCOMPLETE
    blockers: <number>
    high_findings: <number>
    medium_findings: <number>
    low_findings: <number>
    review_performed: true

  engineering_verification:
    status: pass | fail | incomplete
    commands:
      - command: "<command>"
        result: pass | fail
        head_sha: "<full SHA>"
    normal_ci:
      run_id: "<id or null>"
      conclusion: success | failure | in_progress | unavailable

  protected_evidence:
    status: unavailable
    reason: protected_evidence_producer_missing
    fabricated: false
    substituted_with_local_evidence: false

  scope:
    allowed_paths_compliant: true | false
    out_of_scope_changes: []
    infrastructure_follow_up_required: true
    infrastructure_follow_up_issue_draft_created: true

  merge:
    merge_ready: false
    merge_performed: false
    blocker: protected_test_verdict_unavailable

  next_action:
    code: provide_approved_producer_lane
    description: >
      別 Issue で承認済み producer lane を実装し、同じ current head と
      Issue body SHA に束縛された protected TEST_VERDICT を生成する。

その後に次を出力すること。

  1. 敵対的レビュー全文
  2. 実施した修正
  3. current-head 検証結果
  4. 残存リスク
  5. producer lane 用の別 Issue 起票本文
  6. マージを実行しなかった明示的理由

protected evidence の欠落は、レビュー・修正・通常検証を止める理由ではない。マージ操作だけを停止せよ。

この形なら、human_review_required で全工程を打ち切る挙動を避けつつ、保護ゲート自体は維持できます。

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コードレビュー結果

CODE_REVIEW_PASS。current head のコード、受け入れ条件、Allowed Paths、通常検証、PR本文の整合を再確認し、blocker/high/medium/low の finding はありません。

LOOP_VERDICT_V2:
  verdict: REQUEST_CHANGES
  reviewed_head_sha: "69cda7ddad0ad762f8b9d57c903fc9d5c29f0ff4"
  merge_ready: false
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  blockers:
    - protected_test_verdict_unavailable
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []
  allowed_paths_gate:
    status: ok
    changed_files_source: github_pull_request_files_api_with_previous_filename
    changed_files_count: 7
  allowed_paths_gate_source: review_subagent
  evidence_refs:
    issue_body_sha256: "sha256:22ae80c8a2461cc8e3c2d3257942176d227dfa55f5e74e854709c96c567f16e4"
    contract_snapshot: "https://github.com/squne121/loop-protocol/issues/1844#issuecomment-5123493623"
    engineering_verification: "current-head local VC and normal CI passed"
    protected_evidence: "unavailable_not_substituted"

通常CI・ローカル検証は engineering verification の補助証跡であり、protected TEST_VERDICT の代替ではありません。PRはDraftのまま、マージは実行しません。

@squne121
squne121 marked this pull request as ready for review July 29, 2026 21:35
@squne121
squne121 merged commit 79de2b2 into main Jul 29, 2026
33 checks passed
@squne121
squne121 deleted the worktree-issue-1844-contract-readiness-check-py-run-validate branch July 29, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant