Repository navigation
実装: HEAD-bound TEST_VERDICT publisher transaction を追加する - #1827
Conversation
Preview URLPreview removed (PR #1827 closed). |
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=CLEAN
Evidence Check
- Linked Issue: #1647(
Closes #1647確認済み)。parent #1645、Child A=#1646 マージ済み。 - rebase コンフリクト解決確認: #1822 由来の
_PR_REVIEW_PUBLISH_ONLY_FLAGS/enforce_issue_pr_matchが破壊されず現存することをコード直接確認。 - AC1-AC4:
_validate_test_verdict_publish_fields/_run_test_verdict_publishを直接読解し、target_pr_number/linked_issue_number独立検証、pre/post HEAD readback fail-closed、duplicate marker precheck、genericなissue_comment.publishとのschema非同一性を確認。 - 実テスト実行: test_test_verdict_publish_exec.py 6 passed、test_controlled_skill_mutation_policy.py 80 passed(回帰なし)、test_controlled_pr_review_publish_exec.py 51 passed(回帰なし)。
- CI Verification: 全 required CI PASS。
- Allowed Paths: review_subagent 独立再計算(正しい current base sha使用)で changed files 4件、Allowed Paths 4件と完全一致、violations なし。
Blockers
- なし
Non-blockers
- なし
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "f4ac8887285851e6658c1e38f3281c8d38efd224"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
allowed_paths_gate:
status: "ok"
producer_role: "review_subagent"
worker_report_used_as_canonical: false
pr_number: 1827
changed_files_count: 4
violations: []
contract_fingerprint:
contract_source_kind: "github_issue"
contract_source_id: "1647"
contract_body_sha256: "sha256:69e52cdb0a80edded6501fafb94dc3a1b83f8913d30223d7daedda7efa568114"
base_ref: "main"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
判定REQUEST_CHANGES — PR #1827 は現在 open・draft、HEAD は FindingsP0-1: protected producer receipt を検証しておらず、自己申告JSONでPASSを公開できる親 Issue #1645 の目的は、手書き入力や self-attested JSON だけでは current-head PASS を公開できない trust chain です。Issue #1647 も「Child A の protected receipt だけを受け取る」ことを中核要件としています。 しかし
これは既存の正式な receipt schema と明確に不一致です。同 schema は さらに新規テストの「正常入力」は、必須の Child A の producer 自体は、REST artifact ID・repository identity・run identity・HEAD・digest・downloaded payload SHAまで確認して receipt を組み立てています。この保証を Child B がすべて捨てています。 GitHub の公式APIでは、artifact IDから digest、expired、workflow run ID、repository ID、head repository ID、head SHAを取得できます。workflow jobも run ID、HEAD、conclusion、check run URLをreadbackできます。これらを検証しない理由はありません。([GitHub Docs]1) 必要な修正 入力として任意の nested receipt を受け取る設計をやめ、少なくとも次を行う必要があります。
P0-2: コメント本文がreceiptに束縛されておらず、任意の「PASS」本文を投稿できる本文検証は、非空文字列であることと、どこかに文字列 以下はすべて検証されません。
Step 2 の既存仕様は、これらのidentity、artifact、command coverageを検証し、不一致や欠落をfail-closedにする契約です。 したがって、現在は次のような本文でも投稿できます。 さらに、入力本文に生成予定のmarkerをあらかじめ埋め込むと、executorは同じmarkerをもう一度追加してPOSTします。その後、markerが一意でないためpostconditionで失敗しますが、不正コメントは既にGitHub上へ公開済みです。これは「marker mismatchなら公開しない」というAC3を満たしません。markerは本文追加前に検出して拒否する必要があります。 必要な修正
自由入力を残す場合は、完全な P1-1: idempotent retry経路では、comment readback後のHEAD・Issue再検証がない既存markerが1件ある経路では、処理順が次のようになっています。
手順1と手順5の間でPR HEADまたはIssue本文が更新されても、staleなTEST_VERDICTを 既存の retry経路では 必要なテスト
P1-2: marker precheckとPOSTがatomicではなく、並列実行で重複投稿される現在のidempotencyは次のcheck-then-actです。
2つのexecutorが同時に実行されると、両方が0件を観測して両方がPOSTできます。POST後にmarker一覧を再取得して一意性を確認する処理もありません。 GitHub Actionsは、 必要な修正
P1-3:
|
…back + deterministic body (#1647 fix_delta) Addresses PR #1827 REQUEST_CHANGES (P0-1/P0-2/P1-1/P1-2/P1-4, Issue #1647 Scope Delta AC5-AC11): - AC5: producer_receipt is now fully validated against schemas/test-verdict-producer-receipt.schema.json with jsonschema.Draft202012Validator (required producer / execution_payload_sha256, additionalProperties: false). Unknown fields / missing producer / missing execution_payload_sha256 are fail-closed. - AC6: live GitHub Actions readback of the receipt's workflow run / job / check run identity (repository, head SHA, run<->job<->check-run linkage) before any mutation. - AC7: the execution-record artifact archive is downloaded and its sha256 is recomputed against the receipt's artifact_archive_digest; the archived record's own payload_sha256 is cross-checked against the receipt's execution_payload_sha256, and its per_ac coverage feeds the published body. - AC8: the published comment body is no longer accepted as free-form caller input -- it is rendered deterministically from the verified receipt (PR/Issue/HEAD/artifact/result/per-AC coverage) and self-cross-checked before POST. - AC9: the idempotent-retry path now performs a second fresh PR HEAD / linked Issue body readback (and a tracked-changes recheck) after validating the existing comment, to catch drift that occurred during that validation window. - AC10: rejects any rendered body that already embeds the marker literal before POST, and re-lists markers after POST -- anything other than exactly one match is treated as published_but_conflicted (best-effort only; full distributed exactly-once is out of scope, documented in the Safety Claim Matrix). - AC11: _fetch_linked_issue_body_sha256 now rejects endpoints that carry a pull_request field (mirrors _fetch_issue_content's isPullRequest: has("pull_request") pattern). scripts/agent-guards/tests/test_test_verdict_publish_exec.py: 24 tests (was 6), covering schema-validation failures, live-readback failures, artifact digest mismatch, body/receipt cross-check mismatch, retry-path HEAD/Issue drift, marker pre-embed rejection, post-POST marker conflict, and linked-issue-is-a-PR rejection. Verification: - uv run --locked pytest scripts/agent-guards/tests/test_test_verdict_publish_exec.py -q -> 24 passed - uv run --locked pytest scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py -q -> 80 passed - uv run --locked pytest scripts/agent-guards/tests/test_controlled_pr_review_publish_exec.py -q -> 51 passed - uv run --locked ruff check (4 files) -> All checks passed - pnpm policy:check -> All checks passed Co-Authored-By: Claude Sonnet 5 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=CLEAN
Evidence Check
- 人間 OWNER の敵対的レビュー(REQUEST_CHANGES、https://github.com/squne121/loop-protocol/pull/1827#issuecomment-5106705482)で指摘された P0×2/P1×4 を、Issue #1647 Scope Delta(AC5-AC11)で契約更新後、fix_delta で修正。
- AC5:
_validate_producer_receipt_schemaで jsonschema.Draft202012Validator によるフルスキーマ検証をコード直接確認。 - AC6/AC7: workflow run/job/check run/artifactのGitHub API live readback、artifact archiveの実ダウンロード・digest再計算・内部execution recordの自己整合性確認を実装、実際に呼び出されていることを確認。
- AC8: receiptから決定論的body生成+cross-check、自由入力bodyフィールド廃止を確認。
- AC9: retry経路でのHEAD/Issue body再fresh readback実装確認。
- AC10: marker事前埋め込み拒否+POST後marker再確認(published_but_conflicted)実装確認。
- AC11: linked issueのpull_requestフィールド確認実装確認。
- テスト実測: 隔離環境で155 tests合計PASS(新規24件含む)。
- CI Verification: 全 required CI PASS。
- Allowed Paths: 4変更ファイル、Allowed Paths完全一致。
Blockers
- なし
Non-blockers
- なし
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "1b00610c2da52e223a133998413ceb15061e2938"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
allowed_paths_gate:
status: "ok"
producer_role: "review_subagent"
worker_report_used_as_canonical: false
changed_files_count: 4
violations: []
contract_fingerprint:
contract_source_kind: "issue_comment"
contract_source_id: "5106786451"
contract_body_sha256: "sha256:adb43021ed2beb4d42d714bbdb4e30a9642a0c90f136f1df9bfe084fd13ffd22"
base_ref: "main"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
Summary
Child A(protected execution artifact producer receipt)に束縛された current-head TEST_VERDICT だけを idempotent に公開できる、専用
test_verdict.publishtransaction を追加した。genericissue_comment.publishは target PR HEAD を検証しないため、この新 command id は既存pr_review.publishの expected head precondition / commit-bound postcondition の precedent を踏襲しつつ、target PR と linked Issue を別 field として検証する。scripts/agent-guards/controlled_skill_mutation_policy.py: 新 command idtest_verdict.publishとTEST_VERDICT_PUBLISH_INPUT_V1closed input schema をCONTROLLED_SKILL_MUTATION_COMMAND_POLICYに追加。既存 command id(pr_review.publishの--pr-numbergrammar /_PR_REVIEW_PUBLISH_ONLY_FLAGSを含む)の schema/dispatch/argv/postcondition は不変。scripts/agent-guards/controlled_skill_mutation_exec.py:_validate_test_verdict_publish_fields(target PR / linked Issue を独立 required field として検証)、pre/post publish の PR HEAD readback、linked Issue body SHA readback、marker precheck(duplicate 検出)、投稿後の author/marker/body 一致検証、idempotency marker 書き込みを実装。test_test_verdict_publish_exec.py(新規)で AC1〜AC4 の成功経路・fail-closed 経路を検証。test_controlled_skill_mutation_policy.pyに registry scope pin 更新を追加。pr_review.publishrender mode--pr-number分離ロジック(enforce_issue_pr_match/_PR_REVIEW_PUBLISH_ONLY_FLAGS/ command-id/mode grammar)は変更・削除していない。受け入れ条件の達成状況
test_verdict.publishは target PR と linked Issue を別の required field として検証する —_validate_test_verdict_publish_fieldsがtarget_pr_number/linked_issue_numberを独立に検証する。両者が同一値の場合は(別々の entity である PR と Issue が偶然同じ番号を持つことはあり得ないため)test_verdict_publish_target_pr_number_invalidとして fail-closed で拒否する(fix_delta P1-3 でこの挙動を維持したまま本文の記述矛盾を修正、test_given_closed_request_when_validated_then_target_pr_and_linked_issue_are_independent,scripts/agent-guards/tests/test_test_verdict_publish_exec.py)。_run_test_verdict_publishが pre-publish で_fetch_pr_head_sha/_fetch_linked_issue_body_sha256を readback してから POST し、投稿後に marker/body/author を再検証する(test_given_current_receipt_when_publish_then_pre_and_post_head_and_comment_are_verified, 同ファイル:87)。test_given_pre_publish_head_drift_when_publish_then_post_is_not_attempted(同ファイル:113)、test_given_postcondition_author_or_marker_or_body_mismatch_when_published_then_fail_closed(同ファイル:133)、test_given_duplicate_marker_when_publish_then_fail_before_post(同ファイル:161)で検証済み。issue_comment.publishrequest は TEST_VERDICT publish transaction の代替にならない —test_given_generic_issue_comment_command_when_test_verdict_is_requested_then_no_alias_exists(同ファイル:81)でCOMMAND_ID_ISSUE_COMMENT_PUBLISHの input schema がTEST_VERDICT_PUBLISH_INPUT_V1と異なることを検証。producer_receiptはschemas/test-verdict-producer-receipt.schema.jsonに対してjsonschema.Draft202012Validatorでフル検証される —_validate_producer_receipt_schema(test_given_receipt_missing_producer_field_when_validated_then_schema_rejects等)。_verify_producer_run_and_job/_verify_execution_artifact_metadata(test_verify_producer_run_and_job_checks_run_repo_job_and_check_run_linkage等)。_download_and_verify_artifact_archive(test_download_and_verify_artifact_archive_recomputes_digest_and_extracts_per_ac等)。_render_test_verdict_body/_cross_check_test_verdict_body。test_given_retry_path_head_drifts_between_readbacks_when_publish_then_stale。test_given_body_already_contains_marker_prefix_when_publish_then_rejected_before_post/test_given_post_marker_recheck_finds_more_than_one_when_publish_then_conflicted。_fetch_linked_issue_body_sha256(test_fetch_linked_issue_body_sha256_rejects_pull_request等)。検証コマンド結果(fix_delta 反映後、head
1b00610c2da52e223a133998413ceb15061e2938)uv run --locked pytest scripts/agent-guards/tests/test_test_verdict_publish_exec.py -q→ 24 passed(AC1〜AC11。旧6件 + fix_delta 新規18件)uv run --locked pytest scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py -q→ 80 passed(実装: pr_review.publish render mode の linked Issue / target PR 分離を復旧する #1822 由来のTestPrReviewPublishPrNumberGrammarを含む既存テスト回帰なし)uv run --locked pytest scripts/agent-guards/tests/test_controlled_pr_review_publish_exec.py -q→ 51 passed(実装: pr_review.publish render mode の linked Issue / target PR 分離を復旧する #1822 由来のpr_review.publishテスト回帰なし)uv run --locked ruff check scripts/agent-guards/controlled_skill_mutation_exec.py scripts/agent-guards/controlled_skill_mutation_policy.py scripts/agent-guards/tests/test_test_verdict_publish_exec.py scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py→ All checks passedpnpm policy:check→ All checks passed(secret policy / session recording policy / CI performance assessment 108 tests 全 PASS)Rebase 経緯
本 PR の base commit は旧 main(
d1cae8fb1b5245a9d88f6994a109ec0be138fb8f)から分岐していたため、origin/main(765154b4729fba1b9c3bbf8ddafbff807c049cab、#1825 マージ後)へgit rebaseした。controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.pyで #1822(pr_review.publishrender mode の--pr-number独立化・command-id/mode grammar)とコンフリクトが発生し、両方の変更意図を保持する形で手動解決した(#1822 側のenforce_issue_pr_match/_PR_REVIEW_PUBLISH_ONLY_FLAGSを維持しつつ、#1647 のtest_verdict.publishdispatch を追加)。test_controlled_skill_mutation_policy.pyはコンフリクトなく自動マージされ、#1822 由来のTestPrReviewPublishPrNumberGrammarと #1647 新規テストの両方が現存することを確認済み。修正差分(Fix Delta): Issue #1647 の Scope Delta AC5〜AC11 への対応(PR #1827 REQUEST_CHANGES 反映)
人間 OWNER の敵対的レビュー(PR #1827 comment、REQUEST_CHANGES)で判明した P0×2/P1×4 に対応した。Issue #1647 の Scope Delta(issue comment)で追加された AC5〜AC11 を実装。新しい head:
1b00610c2da52e223a133998413ceb15061e2938。_validate_producer_receipt_schemaを追加し、producer_receiptをschemas/test-verdict-producer-receipt.schema.jsonに対してjsonschema.Draft202012Validatorでフル検証する(producerオブジェクト全体・execution_payload_sha256を含むrequired+additionalProperties: falseを強制)。scripts/agent-ops/test_verdict_execution_record_producer.py::_validate_against_schemaと同じパターン。未知フィールド・producer欠落・execution_payload_sha256欠落は fail-closed で拒否する。_verify_producer_run_and_job/_verify_execution_artifact_metadataを追加し、receipt のproducer.workflow_run_id/workflow_run_attempt/job_id/check_run_idを GitHub API(actions/runs/{id}/attempts/{attempt}、actions/jobs/{id}、check-runs/{id}、actions/artifacts/{id})から live readback する。workflow run の repository/head SHA、job の run 紐付けと head SHA、check run の job/run 紐付けと head SHA、artifact メタデータの id/非期限切れを照合し、不一致・readback 失敗はtest_verdict_publish_receipt_live_readback_failedとして fail-closed で拒否する。_download_and_verify_artifact_archiveを追加し、gh api repos/{repo}/actions/artifacts/{id}/zipで execution-record artifact を実ダウンロードし、そのバイト列の sha256 を再計算して receipt のexecution_artifact.artifact_archive_digestと照合する(scripts/agent-ops/test_verdict_execution_record_producer.py::_cmd_download_artifactと同じ zip 展開パターン)。展開した execution-record 自身のpayload_sha256自己検証、および receipt のexecution_payload_sha256との相互検証も行う。この artifact に含まれるper_accoverage を後続の body 生成に用いる。_render_test_verdict_bodyを追加し、公開する comment body は自由入力を受け付けず、検証済み receipt(PR番号・Issue番号・HEAD・artifact_id・result・per-AC coverage)から決定論的に生成する。_cross_check_test_verdict_bodyで生成直後に自己 cross-check し、不一致があれば fail-closed で拒否する(防御的二重チェック)。_TEST_VERDICT_PUBLISH_ALLOWED_KEYSからbody/body_sha256を削除し、idempotency_key の式からもbody_sha256を除去した。published_but_staleとして扱い、_check_no_tracked_changesによるトラッキング済み変更の再確認も追加した(従来この経路には postcondition の tracked-changes チェックが欠落していた)。TEST_VERDICT_PUBLISH_MARKER_PREFIXが既に含まれる場合は POST 前に fail-closed で拒否する。POST 後に marker 一覧を再取得し、該当 marker を持つコメントが1件以外ならtest_verdict_publish_post_marker_recheck_failedとしてpublished_but_conflicted扱いにする。完全な分散 exactly-once(workflow 側のconcurrencygroup 設定等)は Out of Scope のまま(Safety Claim Matrix に明記)。target_pr_number == issue_numberを拒否する現行実装は変更していない。PR 本文 AC1 の説明が「同一値でも受理する」ように読める記述だったため、実装の実際の挙動(同値はtest_verdict_publish_target_pr_number_invalidで拒否)と一致するよう本文を修正した。_fetch_linked_issue_body_sha256を、GitHub API レスポンスのpull_requestフィールド有無(isPullRequest: has("pull_request")jq 式、_fetch_issue_contentと同一パターン)で判定するよう変更し、対象が PR の場合はtest_verdict_linked_issue_is_pull_requestで fail-closed 拒否するようにした。新規テスト18件(既存6件 + 新規18件 = 24件): schema検証失敗(producer欠落/execution_payload_sha256欠落/未知フィールド)、live readback失敗(workflow run head SHA mismatch)、artifact digest不一致、body/receipt cross-check不一致、retry経路でのHEAD drift検出、marker事前埋め込み拒否、POST後marker競合検出、linked issueがPRの場合の拒否を追加。
Allowed Paths 遵守
Allowed Paths(4ファイル):
scripts/agent-guards/controlled_skill_mutation_policy.pyscripts/agent-guards/controlled_skill_mutation_exec.pyscripts/agent-guards/tests/test_test_verdict_publish_exec.pyscripts/agent-guards/tests/test_controlled_skill_mutation_policy.py実際の変更ファイル(
git diff --name-only origin/main...HEAD、4ファイル)は上記 Allowed Paths と完全一致し、範囲外の変更はない。Checks
uv run --locked pytest scripts/agent-guards/tests/test_test_verdict_publish_exec.py -q→ 24 passed(AC1〜AC11、fix_delta 反映後)uv run --locked pytest scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py -q→ 80 passed(実装: pr_review.publish render mode の linked Issue / target PR 分離を復旧する #1822 由来の既存テストも回帰なし)uv run --locked pytest scripts/agent-guards/tests/test_controlled_pr_review_publish_exec.py -q→ 51 passed(実装: pr_review.publish render mode の linked Issue / target PR 分離を復旧する #1822 由来のpr_review.publishテストも回帰なし)uv run --locked ruff check scripts/agent-guards/controlled_skill_mutation_exec.py scripts/agent-guards/controlled_skill_mutation_policy.py scripts/agent-guards/tests/test_test_verdict_publish_exec.py scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py→ All checks passed(lint エラーなし)pnpm policy:check→ All checks passed(secret policy / session recording policy / CI performance の全ゲート通過)Schema Change Applicability
CONTROLLED_SKILL_MUTATION_COMMAND_POLICYに新 command idtest_verdict.publishと新 input schemaTEST_VERDICT_PUBLISH_INPUT_V1を追加した。Schema Consumer Inventory
scripts/agent-guards/controlled_skill_mutation_exec.pypr_review.publishrender mode ロジックは不変)scripts/agent-guards/tests/test_controlled_skill_mutation_policy.pypr_review.publishgrammar テストは無変更のまま存続)scripts/agent-guards/tests/test_test_verdict_publish_exec.pySafety Claim Matrix
Notes