Skip to content

実装: root review pipeline の persisted artifact readback を V2 SSOT に再接続し gate-final-review の恒常 mismatch を解消する #2242

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "run_root_review_pipeline の final-review readback を reviewer_transport V2 artifact SSOT と一致させ、producer が生成した canonical artifact を canonical consumer が正常に検証できる状態へ戻す"
change_kind: code

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue の検証はすべて pytest 単体テスト(tempfile 経由の artifact 書き込み/読み取りを含む)と ruff 静的検査で完結し、実プロセス起動・ネットワーク通信・外部 I/O を伴う動作検証を必要としない。

Background

Issue #2231 の refinement 中に run_root_review_pipeline.py gate-final-review を実行したところ、fresh producer artifact に対しても body_sha256_mismatch / verdict_mismatch が恒常的に発生した(参照: #2231 issuecomment-5315427655 / issuecomment-5316915493)。

#2054 / PR #2142 では、reviewer transport と persisted semantic artifact の V2 contract を reviewer_transport.py に集約し、producer / validator / artifact verifier / router / root pipeline が同じ SSOT を利用する設計を確立している。本件はその contract の新設ではなく regression として扱う。

Current-main defect(source-level確認済み)

readback_persisted_artifact()(.claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py:760,764)は persisted JSON を独自に parse した後、

actual_body_sha256 = payload.get("body_sha256")   # line 760
actual_verdict = payload.get("verdict")           # line 764

を直接参照する。

一方、canonical V2 writer write_semantic_artifact()(.claude/skills/issue-refinement-loop/scripts/reviewer_transport.py:704-735)は artifact を次の top-level key で永続化する。

schema
repository
issue_number
reviewed_body_sha256   # not "body_sha256"
invocation_id
attempt
semantic_result        # nested dict; "verdict" lives INSIDE this, not top-level

body_sha256 という top-level key は存在せず、verdict も top-level ではなく semantic_result.verdict にしか存在しない。したがって readback_persisted_artifact() は canonical writer が生成した あらゆる fresh V2 artifact に対して常に payload.get("body_sha256") is None / payload.get("verdict") is None となり、expected_body_sha256 / expected_verdict と一致し得ないため、gate-final-review は恒常的に body_sha256_mismatch / verdict_mismatch を返す。

既存テストがこの regression を検出できていない理由

.claude/skills/issue-refinement-loop/tests/test_issue_reviewer_contract_static.py:273-339 の readback_persisted_artifact() 向けテスト(test_readback_rejects_actual_nan_json_token 等4件)は、hand-written fixture として旧・V1時代のフラット schema

{"body_sha256": "sha256:aa", "verdict": "approve", ...}

を直接 tmp_path に書き込んでテストしている。これは production writer (write_semantic_artifact()) が実際に生成する V2 schema と一致しておらず、writer/reader drift を検出できない false-green になっている。

Outcome

canonical producer が fresh に生成した persisted V2 artifact を、canonical readback/final-review gate が追加の変換・手動照合なしで正常に consume できる。

malformed / stale / wrong-body / wrong-repository / wrong-issue / wrong-invocation / wrong-attempt / wrong-hash / semantic wire mismatch は従来どおり fail-closed する。

Required design

単純に payload.get("body_sha256") を payload["semantic_result"]["body_sha256"] へ置換するだけの修正は禁止する。理由: semantic_result が実際に body_sha256 というキーを持つとは限らず(semantic_result は REVIEW_ISSUE_RESULT_V1 形状のペイロードで、body 束縛は reviewed_body_sha256(top-level)が正本)、また schema knowledge の重複が残り、次の schema 変更で再度 drift するため。

優先設計:

  1. reviewer_transport.verify_artifact()(同ファイル :671-701)を readback から利用する。body binding は canonical artifact binding field reviewed_body_sha256 を verifier に検証させる(.get() による緩い一致ではなく、verify_artifact() の artifact_binding_mismatch fail-closed 判定を再利用する)。
  2. verdict の semantic projection は reviewer_transport.project_compact_v2_from_artifact() / _semantic_verdict_and_count() 相当の shared accessor を経由し、run_root_review_pipeline.py 自身が semantic_result の内部 key layout を再実装しない。
  3. wire ↔ artifact cross-binding が必要な箇所は PR 実装: reviewer transport failure を semantic judgment から分離し compact V2 verdict を artifact に暗号学的束縛する #2142 で確立した verify_wire_matches_artifact() を再利用する。
  4. shared accessor が不足している場合は reviewer_transport.py に最小の純粋関数を追加し、producer/readback 双方がそれを利用する。

In Scope

  • .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
  • .claude/skills/issue-refinement-loop/scripts/reviewer_transport.py(shared accessor が必要な場合のみ)
  • .claude/skills/issue-refinement-loop/tests/test_issue_reviewer_contract_static.py(既存 readback テストの fixture を production writer 出力へ更新)
  • root review / artifact consumer 関連の他 regression tests(必要な範囲のみ)

Out of Scope

Acceptance Criteria

  • AC1: canonical producer(write_semantic_artifact())→ persisted V2 artifact → readback_persisted_artifact() → gate_final_review() の real roundtrip が fresh approve artifact で final_review_allowed: true に到達する。
  • AC2: needs-fix artifact でも expected verdict identity が正しく検証される。
  • AC3: wrong reviewed_body_sha256 は verdict_identity: false で fail-closed する。
  • AC4: wrong repo / issue / invocation / attempt / artifact SHA は fail-closed する。
  • AC5: artifact semantic_result と compact wire の改ざん不一致は fail-closed する(verify_wire_matches_artifact() 経路)。
  • AC6: malformed JSON / duplicate key / non-finite JSON / symlink / non-regular artifact の既存 security regression(test_readback_rejects_actual_nan_json_token 等)が維持される。
  • AC7: run_root_review_pipeline.py が canonical V2 persisted artifact layout(semantic_result 内部構造を含む)の第二の field-map を独自に持たない。
  • AC8: implement: recover reviewer transport failures and cryptographically bind compact verdicts to artifacts #2054 AC8 / PR 実装: reviewer transport failure を semantic judgment から分離し compact V2 verdict を artifact に暗号学的束縛する #2142 の SSOT contract(reviewer_transport.py が artifact schema の唯一の owner)が regression test で明示的に固定される。
  • AC9: gate-final-review の CLI E2E test が、canonical producer が生成した artifact に対して final_review_allowed: true へ到達する。
  • AC10: test_issue_reviewer_contract_static.py の既存 hand-written flat-schema fixture({"body_sha256": ..., "verdict": ...})が production writer 出力形状へ更新され、修正前は fail・修正後は pass することを示す(この regression の再現と解消の直接証拠)。

Required regression test

特に以下のテストを追加する。

GIVEN reviewer_transport.write_semantic_artifact() が実際に書き込んだ artifact
WHEN run_root_review_pipeline.readback_persisted_artifact() がその exact artifact を consume する
THEN writer と reader が test 側の payload reshaping なしで一致する

hand-written JSON fixture だけでこのテストを満たさないこと(production writer を実際に呼び出す)。これにより writer/reader の片側だけを同じ誤った fixture に合わせて false-green にすることを防ぐ。

Verification Commands

実装時に current test inventory を確認して正確な command を固定すること。最低限:

uv run pytest .claude/skills/issue-refinement-loop/tests/test_issue_reviewer_contract_static.py -q
uv run pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_transport_e2e.py -q
uv run pytest .claude/skills/issue-refinement-loop/tests/ -q
uv run ruff check .claude/skills/issue-refinement-loop/scripts/

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
  • .claude/skills/issue-refinement-loop/scripts/reviewer_transport.py
  • .claude/skills/issue-refinement-loop/tests/

追加 path が必要なら勝手に拡張せず Stop Condition として報告する。

Related

Stop Conditions

  • V2 schema 自体を変更する必要がある
  • backward compatibility のため downgrade fallback が必要になる
  • reviewer transport の semantic authority 境界変更が必要になる
  • Allowed Paths 外への変更が必要になる

Activity

  1. changed the title [-]修正: root review pipeline の persisted artifact readback を V2 SSOT に再接続し gate-final-review の恒常 mismatch を解消する[/-] [+]実装: root review pipeline の persisted artifact readback を V2 SSOT に再接続し gate-final-review の恒常 mismatch を解消する[/+] on Aug 17, 2026
  2. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-17T15:07:29Z)

  3. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-18T00:00:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2246"
      head_sha: "96fbab58c2a3cb6d88b89958a968ce397a5bec5f"
      issue_number: 2242
      termination_reason: approved
      merge_ready: false
      iteration: 0
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "readback-binding-tautological-fields-2242"
          source_url: "https://github.com/squne121/loop-protocol/pull/2246"
          source_note_id: "pr-reviewer-warning-1"
          summary: "readback_persisted_artifact()'s repo/issue/invocation_id/attempt binding check is self-referential (derived from same payload being validated); only expected_body_sha256 is a real caller-supplied comparison. Not a regression, but worth a follow-up if independent binding verification of these fields is ever required at this call site."
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

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions