Skip to content

実装: review compact artifact の provenance attestation を追加する #1532

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "PR #1519 の残余リスクを閉じる: 親所有の入力で review compact replay を再実行・束縛し、child 自己申告を provenance と誤認しない V2 契約を導入する"
change_kind: workflow

Parent Issue

なし(PR #1519 の post-merge follow-up)

Parent Goal Ref

  • Goal: issue-refinement-loop が、親自身で取得・保存・readback した決定論的入力と bounded な reviewer claim を分離し、親側 replay の検証済み結果だけを state consumer へ渡せるようにする。
  • Desired Destination: parent-owned reviewer replay binding V2。

Current Validated Scope

  • REPLAY_ARTIFACT_DIGEST は child SubAgent が reviewer_claim_replay.py の stdout 全体から算出する digest であり、親 artifact の digest へ意味変更してはならない。
  • 親は child isolation worktree の raw review/readiness artifact を読まない。現行の raw REPLAY_* を親 artifact に再直列化するだけでは、child claim の独立検証にならない。
  • REPLAY_NEXT_STATE は state store の永続化対象だが、現行 compact validator の needs-fix grammar には存在しない。V2 では producer、validator、normalized payload、state consumer を同時に更新する。

Remaining Parent Gaps

Outcome

親が自ら所有する body snapshot・deterministic checker results・previous state・session/iteration identity と、child が返す bounded reviewer blocker claim を別入力として扱い、親側 replay binding V2 を生成する。V2 validator が全 field と exact digest を fail-closed に照合し、検証済み normalized result だけが state store を更新する状態。

Background

In Scope

  • ISSUE_REVIEW_RESULT_COMPACT_V2 と REVIEW_COMPACT_VALIDATION_RESULT_V2 を定義し、既存 REPLAY_ARTIFACT_DIGEST は child stdout digest として意味を維持し、親側の値は別 field REPLAY_PARENT_BINDING_DIGEST とする。
  • parent orchestrator が body snapshot、readiness/VC の deterministic checker output、previous state、repository/issue/session/iteration identity を自ら取得・保存・readback し、child は bounded REVIEWER_BLOCKER_CLAIM_V1 のみ返す input ownership boundary を実装する。
  • 親側で deterministic replay と canonical binding artifact を生成し、REPLAY_NEXT_STATE を含む expected replay values、input digest、body/session/iteration identity を V2 artifact に束縛する。
  • V2 validator が child claim、parent expected replay values、binding artifact の canonical exact bytes、digest、schema、regular-file/path/identity/session/iteration binding を照合し、不一致時は human_judgment_required に fail-closed する。
  • parent-provided iteration id を利用して replay output から wall-clock 値を除去し、同一 parent-owned inputs の exact-byte 再生成を可能にする。
  • state store が V2 validator の validated normalized payload からのみ REPLAY_NEXT_STATE を永続化し、raw child value・validation failure・tamper 時は state を更新しないようにする。
  • command registry、Step 2/2a、issue-reviewer producer contract、schema governance、loop design SSOT と consumer inventory を V2 に同期する。
  • actual isolation boundary を通す runtime E2E と、digest/field tamper、cross-issue/session/iteration replay、symlink/hardlink/non-regular/oversized/non-canonical JSON の negative matrix を追加する。

Out of Scope

Acceptance Criteria

  • AC1: compact V2 と validator result V2 は child stdout digest と parent binding digest を別 field として定義し、producer/validator/consumer parity test が両方の意味を固定する。
  • AC2: 親は reviewer 実行前に parent-owned input inventory を取得・保存・readback し、child raw artifact または raw REPLAY_* を parent replay の入力に使用しない。
  • AC3: parent replay binding artifact は canonical exact bytes、body snapshot、repository/issue/session/iteration identity、全 expected replay fields(REPLAY_NEXT_STATE を含む)と input digest を束縛し、同一入力では同一 digest を生成する。
  • AC4: V2 validator は binding digest、schema、canonical bytes、全 replay field、identity/session/iteration を照合し、field/digest/JSON/path tamper、不在、namespace mismatch で human_judgment_required を返す。
  • AC5: state store は V2 validator の validated normalized payload に含まれる REPLAY_NEXT_STATE だけを永続化し、raw child output、invalid validation、または binding mismatch では state file を更新しない。
  • AC6: 親入力取得 → isolation child claim → parent replay binding → V2 validator → normalized state write の実経路を subprocess で検証し、tamper と cross-issue/session/iteration artifact を fail-closed にする。
  • AC7: schema governance と issue-refinement-loop design SSOT に V2 schema、producer/consumer、trust boundary、非保証(署名・同一 UID identity は対象外)、detection pattern、consumer inventory を登録する。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py -q -k test_v2_producer_validator_consumer_preserve_distinct_digest_semantics

# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py -q -k test_parent_replay_uses_only_parent_owned_inventory

# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py -q -k test_canonical_binding_is_repeatable_and_binds_next_state

# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py -q

# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_state_store.py -q

# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_isolation_runtime.py -q -k test_parent_child_binding_runtime_e2e

# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py -q -k test_v2_schema_governance_and_consumer_inventory

Allowed Paths

  • .claude/agents/issue-reviewer.md
  • .codex/agents/issue-reviewer.toml
  • .claude/skills/issue-refinement-loop/scripts/parent_replay_binding.py
  • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
  • .claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.py
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay_state_store.py
  • .claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.py
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py
  • .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py
  • .claude/skills/issue-refinement-loop/tests/test_parent_replay_isolation_runtime.py
  • .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_state_store.py
  • .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam.py
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/loop-state.md
  • docs/dev/schema-governance.md
  • docs/dev/workflows/issue-refinement-loop-design.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • compact V1 の既存 consumer を V2 互換または明示的な migration なしに破壊する必要がある場合
  • 親が child raw artifact または raw REPLAY_* 以外の trusted input を取得できない場合
  • actual isolation runtime で parent-owned input boundary を検証できない場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 外部サービス利用、権限昇格、署名・鍵管理、または既存テスト大規模改変が必要になった場合

Required Skills

  • Python 3
  • pytest

Required Design References

  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/schema-governance.md
  • docs/dev/runtime-verification-policy.md
  • docs/dev/workflows/issue-refinement-loop-design.md
  • .claude/agents/issue-reviewer.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/loop-state.md
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py

Scope Delta(任意)

  • anchor comment #issuecomment-4982325282 に基づき、parent artifact を raw child output の再包装として扱う設計を撤回した。
  • V1 の同名 digest の意味変更を禁止し、parent-owned replay binding を V2 の別 field として導入する。
  • producer、validator、state consumer、runtime isolation E2E を同一 contract に含めるため、Allowed Paths と AC/VC を拡張した。

Runtime Verification Applicability

decision: immediate
reason: "親と child の isolation worktree 境界、親所有入力の readback、child claim の transport、parent binding、validator、state write の順序は、実 subprocess/isolation 経路でのみ確認できる。"
applicable_acs:
  - AC6
execution_environment:
  cli_tools:
    - python3
    - uv
  auth_required: false
  network_required: false
  harness: "canonical main root から起動する親 subprocess と isolation child worktree"
skip_conditions:
  - "isolation worktree runtime を起動できない場合は stdout を SKIP: で開始して exit 77 を返す"
fallback_policy:
  fallback_success_is_pass: false
  notes: "SKIP を PASS に変換せず、implementation と PR review を fail-closed に停止する"
artifact_requirements:
  - "親入力 snapshot"
  - "binding artifact"
  - "validator result"
  - "state write 判定"
  - "実行日時"

Delivery Rule

  • 1 Issue = 1 PR で完結する。
  • worktree: .claude/worktrees/issue-1532-parent-owned-replay-v2
  • Draft PR を既定とする。

Source

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 15, 2026
  2. squne121 commented on Jul 15, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結果

    判定: REQUEST_CHANGES — 現在の Issue 契約のまま実装へ進めるべきではありません。

    Issue #1532 が対象としている残余リスク自体は実在します。PR #1519 のレビューでも、REPLAY_ARTIFACT_DIGEST は SubAgent による自己申告値であり、現行 validator は SHA-256 の字句形式しか検証していないため、provenance や producer authenticity を証明しないと指摘されています。Issue #1532 はこの問題を「親側で再生成した artifact bytes との照合」によって閉じようとしています。

    しかし、現行の producer contract、isolation worktree 境界、REPLAY_NEXT_STATE の追加後の契約、JSON byte representation を突き合わせると、AC1・AC2はそのままでは同時に満たせません。実装を強行すると、**SubAgent の偽値を親が canonicalize してハッシュし直すだけの「自己申告の再包装」**になる可能性が高く、むしろ誤った安全性主張を固定します。

    Issue #1532 自体には現時点でコメントがないため、関連議論として主に Issue #1507、PR #1519、Issue #1472/PR #1473、Issue #1504、Issue #1515 と、現在の main 上の実装・テストを参照しました。


    P0-1: REPLAY_ARTIFACT_DIGEST の現行意味と #1532 の意味が両立しない

    現行の issue-reviewer contract は、次のように明記されています。

    • REPLAY_ARTIFACT_DIGEST は、child SubAgent が実行した reviewer_claim_replay.py の stdout JSON 全体の SHA-256。

    • child SubAgent が digest を計算して compact envelope に追記する。

    • 親は child worktree の raw artifact を直接 open/read しない。

    一方、Issue #1532 は、同じ REPLAY_ARTIFACT_DIGEST を、後から親が作成する canonical replay artifact の exact bytes に一致させようとしています。

    すなわち、現在と提案後では意味が異なります。

    現行:
    REPLAY_ARTIFACT_DIGEST = SHA256(child reviewer_claim_replay stdout bytes)
    

    #1532:
    REPLAY_ARTIFACT_DIGEST = SHA256(parent-created replay artifact bytes)

    これは validator の追加検査ではなく、既存 schema field の breaking semantic changeです。child は親が後から生成する artifact bytes を知りません。親 artifact が child stdout と完全に同じ bytes でない限り、同じ digest にはなりません。逆に親 artifact を child stdout の単なるコピーにすれば、親による独立再生成にはならず、元の self-claim 問題が残ります。

    さらに、実際の replay stdout には next_state が含まれ、その updated_at_iteration_id は実行時の UTC 時刻から生成されています。同じ機能入力で再実行しても exact bytes は一致しません。

    必須修正

    次のどちらかを選ぶ必要があります。

    互換性維持案

    • REPLAY_ARTIFACT_DIGEST は現行どおり child stdout digest とする。

    • 親側 artifact digest は、child envelope の field にせず、REVIEW_COMPACT_VALIDATION_RESULT_V2 内の parent_replay_binding_digest として親だけが生成する。

    • この場合、保証は「親が受領・検証した値の downstream integrity」であり、child provenance ではありません。

    breaking change 案

    • ISSUE_REVIEW_RESULT_COMPACT_V2 を導入する。

    • REPLAY_PARENT_BINDING_DIGEST など別名の field を追加する。

    • .claude/agents/issue-reviewer.md、.codex/agents/issue-reviewer.toml、SKILL、validator、state consumer、parity test を同時更新する。

    • 親が生成する iteration ID を reviewer_claim_replay.py に渡し、wall-clock timestamp を deterministic output から除外する。

    現在の「SubAgent prompt change は Out of Scope」「既存キー集合の変更が必要なら停止」という条件では、どちらも実装できません。


    P0-2: 親が所有する「deterministic replay inputs」が現行データフローに存在しない

    Issue #1532 は「親 orchestrator が既存 deterministic replay inputs から artifact を生成する」としていますが、その入力集合、owner、transport、trust classification が定義されていません。

    現行の reviewer_claim_replay.py は少なくとも以下を入力とします。

    • review_result

    • readiness_result

    • optional な vc_syntax_result

    • optional な vc_preflight_result

    • previous_state

    • repository/issue/session identity

    また、判定には reviewer blocker、structured findings、deterministic check 結果、readiness error evidence が必要です。

    しかし現行 contract では、これらの主要 artifact は child isolation worktree 内にあります。review-result-file は child の compact artifact、readiness-result-file は child が /tmp に保存したものです。親が child artifact を読まないようにしたこと自体が Issue #1472 の目的でした。

    親が受け取る compact envelope には replay の結果しかなく、replay を独立再実行するための blocker/findings/checker evidence 一式はありません。SKILL も、親は normalized REPLAY_ を消費し、child raw artifact を別途 open/read しないとしています。

    敵対的な反例

    親 writer が raw REPLAY_ を入力として artifact を作る実装なら、攻撃者は任意の偽値 F を選べます。

    F = 攻撃者が選んだ replay fields
    A = Canonicalize(F)
    D = SHA256(A)

    compact envelope = (F, D)

    validator は SHA256(A) == D を確認して成功しますが、これは任意の F について成立します。検証しているのは偽値の一貫性であり、偽値の正しさではありません。

    さらに、PR #1519 が固定した現行 invariant は「validator 完了前に raw REPLAY_* を consume しない」です。attestation writer が raw envelope を独自に parse して artifact を作ると、validator-first gate を迂回し、PR #1519 が閉じた parser/routing bypass を再導入します。

    必須修正

    Issue 本文に次の input ownership matrix が必要です。

    replay_input_inventory:

    • name: reviewer_blocker_claim
      producer: issue-reviewer
      trust: untrusted_claim
      transport: bounded_compact_schema
    • name: body_snapshot
      producer: parent_orchestrator
      trust: parent_owned
    • name: readiness_result
      producer: parent_deterministic_checker
      trust: parent_owned
    • name: vc_results
      producer: parent_deterministic_checker
      trust: parent_owned
    • name: previous_state
      producer: parent_state_store
      trust: parent_owned

    親側にこれらが存在しないなら、先に runtime evidence を取得する research Issue に分割すべきです。


    P0-3: REPLAY_NEXT_STATE が validator と #1532 の契約から脱落している

    現在の main では、child contract と SKILL は REPLAY_NEXT_STATE を必須出力として扱っています。親はその値を reviewer_claim_replay_state_store.py --write に渡して永続化します。

    ところが validator の exact needs-fix grammar は次の5 fieldしか認識しません。

    • REPLAY_VERDICT

    • REPLAY_ROUTING

    • REPLAY_SHOULD_CONSUME

    • REPLAY_BODY_SHA256

    • REPLAY_ARTIFACT_DIGEST

    REPLAY_NEXT_STATE は ALL_KNOWN_FIELDS に含まれず、入力された場合は unknown_field になります。

    したがって現在の契約には、次の二者択一があります。

    1. child が正規 contract に従って REPLAY_NEXT_STATE を出す
      → validator が needs-fix envelope を拒否する。

    2. validator を通すため REPLAY_NEXT_STATE を省略する
      → orchestrator-owned state persistence が動作しない。

    これを回避するため親が raw REPLAY_NEXT_STATE だけを別取りすれば、validator-first invariant を破り、state poisoning surface になります。state は次回の human_escalation 判定を左右するため、routing fieldsだけを attestationして next state を無検証で保存する設計は成立しません。state store は schema validation後、その next_state を atomic replace で正本として保存します。

    既存の「producer parity test」もこの drift を捕捉していません。テストは analyze() の第2戻り値である _next_state を捨て、5 fieldを手作業で組み立てています。また production の compact serializerではなく、default separator付きの json.dumps(..., sort_keys=True) をハッシュしています。実際の CLI stdout exact bytes を検証する parity testにはなっていません。

    必須修正

    • needs-fix grammar に REPLAY_NEXT_STATE を追加するか、V2 envelopeへversion upする。

    • attestation artifact の expected fields に next_state 全体を含める。

    • state store は raw envelopeからではなく、attestation verification済み normalized payloadからのみ書き込む。

    • next_state の repository、issue、session、body、lane、counter transition を親側 expected values と照合する。

    • parity test は reviewer_claim_replay.py を実 subprocessとして起動し、実際の proc.stdout bytesをそのままハッシュする。


    P0-4: 「canonical exact bytes」が wall-clock 値と serializer drift により再現不能

    reviewer_claim_replay.py は compact JSON を sort_keys=True、空白なし、UTF-8文字を非escape、NaN禁止でserializeしています。一方、既存 parity testは別のserializer設定を使っています。さらに CLI結果にはwall-clock由来の next_state.updated_at_iteration_id が含まれます。

    このため、「同じ deterministic inputsから親がexact bytesを再生成する」というIssueの前提は現在の実装では偽です。

    必須修正

    • 親が iteration 開始時に iteration_id を生成する。

    • reviewer_claim_replay.py --iteration-id <value> として明示入力する。

    • updated_at_iteration_id に現在時刻を内部生成しない。

    • trailing LFをdigest対象に含めるか否かを明記する。

    • hash subjectを「CLI stdout」ではなく、versioned deterministic projectionとして定義する。


    P1-1: canonical JSON の byte contract が未定義

    Issue本文には「canonical JSON artifact」とありますが、次が未定義です。

    • UTF-8/BOM

    • trailing newline

    • whitespace

    • recursive key ordering

    • duplicate keys

    • NaN/Infinity

    • number serialization

    • Unicode handling

    • unknown fields

    • maximum bytes

    • canonicalityの検証方法

    RFC 8785 JCSは、暗号学的ハッシュ・署名の再現性のため、I-JSON制約、duplicate property禁止、whitespace禁止、決定的なproperty sorting、UTF-8出力などを規定しています。単にPythonの json.dumps(sort_keys=True) を使うことは、一般的な意味でのRFC 8785 canonicalizationとは同義ではありません。(RFC Editor)

    このリポジトリの用途では、必ずしもRFC 8785 dependencyを追加する必要はありません。ただしその場合は、次のような project-specific profile をversion付きで固定すべきです。

    canonical_profile: REPLAY_BINDING_CANONICAL_JSON_V1
    encoding: utf-8
    bom: forbidden
    trailing_newline: forbidden
    object_keys: fixed ASCII schema keys
    numbers: integers_only
    floats: forbidden
    duplicate_keys: forbidden
    unknown_fields: forbidden
    nan_infinity: forbidden
    whitespace_between_tokens: forbidden
    max_bytes: 16384

    writerとvalidatorは同じcanonicalizerを共有し、validatorは parse後に再serializeして raw_bytes == canonical_bytes(parsed) も検証する必要があります。RFC test vector相当のgolden byte fixturesも必要です。


    P1-2: path check後のopenではTOCTOUを閉じられない

    Issue #1532 の AC3 は canonical path、regular file、namespace mismatchを挙げていますが、単純な次の実装では不十分です。

    if path.resolve().is_relative_to(root) and path.is_file():
    raw = path.read_bytes()

    checkとreadの間でpath targetを差し替えられます。MITRE CWE-367は、resourceの状態がcheckとuseの間に変化することをTOCTOUとして定義し、checkとuseのatomicityまたは同一resource identityの確保を求めています。Python公式文書も、事前のaccess check後にopenする方式をsecurity holeとして警告しています。(CWE)

    このリポジトリには、既により適切な実装例があります。temp_residue_marker.py は次を行っています。

    • O_NOFOLLOW

    • directory fd相対open

    • open後の fstat

    • regular file確認

    • group/other writable拒否

    • hardlink拒否

    • max byte制限

    • duplicate JSON key拒否

    • NaN/Infinity拒否

    • 同じopen fdからのread

    これは新規attestation readerの基礎として再利用すべきrepository assetです。

    writer側も、既存の簡易 _atomic_write() はtemp fileとos.replace()を使っていますが、flush/fsyncがありません。os.replace() は成功時のrename atomicityを提供しますが、bufferの永続化にはflushとos.fsync()が別途必要です。 (Python documentation)

    推奨実装は、上書き可能な固定名よりも次です。

    .claude/artifacts/issue-refinement-loop/
    <issue>/
    <session_id>/
    <iteration_id>/
    replay-binding-sha256-<digest>.json

    content-addressed immutable fileを O_CREAT | O_EXCL | O_NOFOLLOW で作成すれば、writer→validator間のreplacement riskを減らせます。


    P1-3: issue namespaceだけではfreshness・context bindingにならない

    現在のACではactive issue namespaceとの一致が中心ですが、同一Issue内の古いsession/古いiteration artifactを再利用する攻撃を防げません。

    最低限、artifactには次を含める必要があります。

    context:
    repository_full_name: squne121/loop-protocol
    issue_number: 1532
    refinement_session_id: <parent-generated>
    iteration_id: <parent-generated>
    body_snapshot_sha256: sha256:...
    inputs:
    reviewer_claim_sha256: sha256:...
    readiness_result_sha256: sha256:...
    vc_syntax_result_sha256: sha256:... | null
    vc_preflight_result_sha256: sha256:... | null
    previous_state_sha256: sha256:...
    producer:
    kind: parent_orchestrator
    replay_tool_git_blob_sha: ...
    expected:
    verdict: ...
    routing: ...
    should_consume_iteration: ...
    body_sha256: ...
    next_state: {...}

    Issue #1532 は live issue bodyとのexpected-value bindingを別follow-upにしていますが、少なくとも SubAgent起動前に親が取得したbody snapshot とのbindingは同じIssueで実施すべきです。そうでなければ、親が独立に知っているexpected valueがほとんど残らず、provenance claimを支えられません。


    P1-4: Runtime Verificationをnot_applicableにはできない

    Issue #1532 は「ローカルPython subprocessとpytestだけで決定論的に検証可能」としてruntime verificationをnot_applicableにしています。

    しかし、このIssueで最も重要な前提は次です。

    これはunit fixtureでは証明できません。Issue #1472がco-locationを導入した理由そのものが、実Agent runtimeで親からchild artifact pathを解決できなかったことです。

    必須修正

    Runtime Verification Applicability は immediate とし、実際のisolation worktree Agent invocationで次を確認すべきです。

    1. 親が利用する全入力のownerとpath。

    2. childが親artifact rootを変更できるか。

    3. writer→validator→phase gateの実順序。

    4. field tamper後にstate fileが更新されないこと。

    5. same issue/different session artifactが拒否されること。

    6. runtimeが利用不能ならSKIPとして記録し、unit testをE2E PASSの代替にしないこと。


    P1-5: 同一OS userのchildを敵対者とするなら、unsigned local artifactはprovenanceにならない

    リポジトリ内の既存実装も、同一OS userのself-claimはforge可能であり、trust boundaryやauthorizationにはならないと明記しています。

    したがって、Issue本文に明示的なthreat modelが必要です。


    想定する脅威 | 親側SHA-256 artifactで対処可能か
    -- | --
    accidental corruption | 可能
    parser/consumer drift | 可能
    stale artifact replay | context binding追加後は可能
    childによる任意field偽造 | 独立再計算がなければ不可
    同一UID childによるfilesystem tamper | OS隔離・署名等がなければ保証困難
    producer identityの証明 | bare SHA-256では不可

    少なくともSLSA/in-totoの用語法では、software attestationはauthenticated statementであり、envelopeのsignatureがattester identityを表します。SLSA provenance verificationもbuilder identity、signature、artifact subject digest、期待値の検証を要求します。Issue #1532 は署名・鍵管理を明示的にOut of Scopeとしているため、成果物を「provenance attestation」と呼ぶのは過大です。(SLSA)

    名称は、例えば次のいずれかが適切です。

    • parent-side replay integrity binding

    • parent replay expectation record

    • reviewer replay verification record


    推奨する設計

    選択肢A: 最小変更だが、保証を「integrity」に限定する

    1. 現行compact validatorでgrammarを検証する。

    2. normalized replay fieldsを親がversioned artifactに保存する。

    3. 親がartifact digestをvalidation resultに記録する。

    4. downstream consumerはそのvalidation resultだけを使う。

    5. REPLAY_ARTIFACT_DIGEST の意味は変更しない。

    6. 「child claimの正しさ」や「provenance」は保証しないとSafety Claim Matrixに明記する。

    これはparser driftやdownstream mutationには効きますが、SubAgentの虚偽には効きません。

    選択肢B: Issueの本来目的を満たす設計

    1. 親がbody snapshot、readiness、VC checker、previous stateを所有する。

    2. childはboundedな REVIEWER_BLOCKER_CLAIM_V1 だけを返す。

    3. 親がそのclaimをstrict parseする。

    4. 親がparent-owned deterministic artifactsを使ってreplay arbitrationを実行する。

    5. 親が REVIEWER_CLAIM_REPLAY_BINDING_V1 を生成する。

    6. validatorがchild replay claimsと親expected valuesを照合する。

    7. next_state は親expected resultからのみstate storeへcommitする。

    8. child側replayはadvisory/cross-checkとして残すか、不要なら廃止する。

    #1532 の「provenanceを閉じる」というGoalを維持するなら、必要なのは選択肢Bです。


    Issue #1532 に反映すべき変更

    Scope

    Out of Scopeから次を外す必要があります。

    • .claude/agents/issue-reviewer.md の出力contract変更

    • .codex/agents/issue-reviewer.toml の同期

    • reviewer_claim_replay.py へのparent-generated iteration ID追加

    • REPLAY_NEXT_STATE のvalidator/attestation binding

    • parent input ownershipのruntime検証

    Allowed Paths

    少なくとも次を追加すべきです。

    .claude/agents/issue-reviewer.md
    .codex/agents/issue-reviewer.toml
    .claude/skills/issue-refinement-loop/references/loop-state.md
    .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
    .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay_state_store.py
    .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py
    .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_stdout_budget.py
    .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_state_store.py
    tests/test_agent_parity.py
    

    現行Allowed Pathsは、新規writer、validator、registry、単一test、SKILL、schema-governanceだけであり、実際に変更が必要なproducer/state consumer/parity surfacesを含んでいません。

    追加すべきnegative tests

    • REPLAY_NEXT_STATE 一値改変

    • duplicate JSON key

    • NaN/Infinity

    • invalid UTF-8

    • noncanonical whitespace/trailing LF

    • symlink

    • hardlink

    • FIFO/directory

    • group/other writable file

    • oversized artifact

    • same issue/different session

    • same session/different iteration

    • wrong body snapshot

    • wrong previous-state digest

    • writer後validator前のpath replacement

    • raw next stateが異なる場合にstate fileが未更新であること

    • actual child CLI stdoutとdigestのexact-byte parity


    最終Verdict

    LOOP_VERDICT_V2:
      verdict: REQUEST_CHANGES
      merge_ready: false
      blockers:
        - "REPLAY_ARTIFACT_DIGEST の現行 child-stdout digest semantics と、提案する parent-artifact digest semantics が両立せず、schema versioning / producer update が欠落している"
        - "親が所有する deterministic replay input の inventory・transport・trust boundary が未定義であり、実装が untrusted self-claim の再包装に退化し得る"
        - "REPLAY_NEXT_STATE が現行 producer / state consumer contractには存在する一方、validator exact grammar・Issue #1532 attestation scopeから脱落している"
        - "next_state に wall-clock由来値が含まれ、同一入力から exact bytes を再生成できない"
        - "canonical JSON、TOCTOU-safe open、freshness/session binding、same-UID threat modelが未定義"
        - "実isolation worktree境界を扱うにもかかわらず Runtime Verification が not_applicable とされている"
      required_resolution:
        - "integrity-only設計へGoalを縮小するか、parent-owned replay inputsを導入する設計へScopeを拡張する"
        - "compact/replay/state schemaをversion upし、REPLAY_NEXT_STATEを含む全consumer inventoryを更新する"
        - "実Agent runtime E2Eとfile-security negative matrixをAcceptance Criteriaへ追加する"
    

    このIssueの根本問題はSHA-256の実装方法ではなく、何を誰が独立に知っており、どの値を信頼の根として照合するのかが定義されていないことです。そこを固定せずartifact hashingだけを追加しても、provenanceは成立しません。

    # 敵対的レビュー結果

    判定: REQUEST_CHANGES — 現在の Issue 契約のまま実装へ進めるべきではありません。

    Issue #1532 が対象としている残余リスク自体は実在します。PR #1519 のレビューでも、REPLAY_ARTIFACT_DIGEST は SubAgent による自己申告値であり、現行 validator は SHA-256 の字句形式しか検証していないため、provenance や producer authenticity を証明しないと指摘されています。Issue #1532 はこの問題を「親側で再生成した artifact bytes との照合」によって閉じようとしています。

    しかし、現行の producer contract、isolation worktree 境界、REPLAY_NEXT_STATE の追加後の契約、JSON byte representation を突き合わせると、AC1・AC2はそのままでは同時に満たせません。実装を強行すると、**SubAgent の偽値を親が canonicalize してハッシュし直すだけの「自己申告の再包装」**になる可能性が高く、むしろ誤った安全性主張を固定します。

    Issue #1532 自体には現時点でコメントがないため、関連議論として主に Issue #1507、PR #1519、Issue #1472/PR #1473、Issue #1504、Issue #1515 と、現在の main 上の実装・テストを参照しました。


    P0-1: REPLAY_ARTIFACT_DIGEST の現行意味と #1532 の意味が両立しない

    現行の issue-reviewer contract は、次のように明記されています。

    • REPLAY_ARTIFACT_DIGEST は、child SubAgent が実行した reviewer_claim_replay.py の stdout JSON 全体の SHA-256。
    • child SubAgent が digest を計算して compact envelope に追記する。
    • 親は child worktree の raw artifact を直接 open/read しない。

    一方、Issue #1532 は、同じ REPLAY_ARTIFACT_DIGEST を、後から親が作成する canonical replay artifact の exact bytes に一致させようとしています。

    すなわち、現在と提案後では意味が異なります。

    現行:
    REPLAY_ARTIFACT_DIGEST = SHA256(child reviewer_claim_replay stdout bytes)
    
    #1532:
    REPLAY_ARTIFACT_DIGEST = SHA256(parent-created replay artifact bytes)
    

    これは validator の追加検査ではなく、既存 schema field の breaking semantic changeです。child は親が後から生成する artifact bytes を知りません。親 artifact が child stdout と完全に同じ bytes でない限り、同じ digest にはなりません。逆に親 artifact を child stdout の単なるコピーにすれば、親による独立再生成にはならず、元の self-claim 問題が残ります。

    さらに、実際の replay stdout には next_state が含まれ、その updated_at_iteration_id は実行時の UTC 時刻から生成されています。同じ機能入力で再実行しても exact bytes は一致しません。

    必須修正

    次のどちらかを選ぶ必要があります。

    互換性維持案

    • REPLAY_ARTIFACT_DIGEST は現行どおり child stdout digest とする。
    • 親側 artifact digest は、child envelope の field にせず、REVIEW_COMPACT_VALIDATION_RESULT_V2 内の parent_replay_binding_digest として親だけが生成する。
    • この場合、保証は「親が受領・検証した値の downstream integrity」であり、child provenance ではありません。

    breaking change 案

    • ISSUE_REVIEW_RESULT_COMPACT_V2 を導入する。
    • REPLAY_PARENT_BINDING_DIGEST など別名の field を追加する。
    • .claude/agents/issue-reviewer.md、.codex/agents/issue-reviewer.toml、SKILL、validator、state consumer、parity test を同時更新する。
    • 親が生成する iteration ID を reviewer_claim_replay.py に渡し、wall-clock timestamp を deterministic output から除外する。

    現在の「SubAgent prompt change は Out of Scope」「既存キー集合の変更が必要なら停止」という条件では、どちらも実装できません。


    P0-2: 親が所有する「deterministic replay inputs」が現行データフローに存在しない

    Issue #1532 は「親 orchestrator が既存 deterministic replay inputs から artifact を生成する」としていますが、その入力集合、owner、transport、trust classification が定義されていません。

    現行の reviewer_claim_replay.py は少なくとも以下を入力とします。

    • review_result
    • readiness_result
    • optional な vc_syntax_result
    • optional な vc_preflight_result
    • previous_state
    • repository/issue/session identity

    また、判定には reviewer blocker、structured findings、deterministic check 結果、readiness error evidence が必要です。

    しかし現行 contract では、これらの主要 artifact は child isolation worktree 内にあります。review-result-file は child の compact artifact、readiness-result-file は child が /tmp に保存したものです。親が child artifact を読まないようにしたこと自体が Issue #1472 の目的でした。

    親が受け取る compact envelope には replay の結果しかなく、replay を独立再実行するための blocker/findings/checker evidence 一式はありません。SKILL も、親は normalized REPLAY_* を消費し、child raw artifact を別途 open/read しないとしています。

    敵対的な反例

    親 writer が raw REPLAY_* を入力として artifact を作る実装なら、攻撃者は任意の偽値 F を選べます。

    F = 攻撃者が選んだ replay fields
    A = Canonicalize(F)
    D = SHA256(A)
    
    compact envelope = (F, D)
    

    validator は SHA256(A) == D を確認して成功しますが、これは任意の F について成立します。検証しているのは偽値の一貫性であり、偽値の正しさではありません。

    さらに、PR #1519 が固定した現行 invariant は「validator 完了前に raw REPLAY_* を consume しない」です。attestation writer が raw envelope を独自に parse して artifact を作ると、validator-first gate を迂回し、PR #1519 が閉じた parser/routing bypass を再導入します。

    必須修正

    Issue 本文に次の input ownership matrix が必要です。

    replay_input_inventory:
      - name: reviewer_blocker_claim
        producer: issue-reviewer
        trust: untrusted_claim
        transport: bounded_compact_schema
      - name: body_snapshot
        producer: parent_orchestrator
        trust: parent_owned
      - name: readiness_result
        producer: parent_deterministic_checker
        trust: parent_owned
      - name: vc_results
        producer: parent_deterministic_checker
        trust: parent_owned
      - name: previous_state
        producer: parent_state_store
        trust: parent_owned

    親側にこれらが存在しないなら、先に runtime evidence を取得する research Issue に分割すべきです。


    P0-3: REPLAY_NEXT_STATE が validator と #1532 の契約から脱落している

    現在の main では、child contract と SKILL は REPLAY_NEXT_STATE を必須出力として扱っています。親はその値を reviewer_claim_replay_state_store.py --write に渡して永続化します。

    ところが validator の exact needs-fix grammar は次の5 fieldしか認識しません。

    • REPLAY_VERDICT
    • REPLAY_ROUTING
    • REPLAY_SHOULD_CONSUME
    • REPLAY_BODY_SHA256
    • REPLAY_ARTIFACT_DIGEST

    REPLAY_NEXT_STATE は ALL_KNOWN_FIELDS に含まれず、入力された場合は unknown_field になります。

    したがって現在の契約には、次の二者択一があります。

    1. child が正規 contract に従って REPLAY_NEXT_STATE を出す
      → validator が needs-fix envelope を拒否する。

    2. validator を通すため REPLAY_NEXT_STATE を省略する
      → orchestrator-owned state persistence が動作しない。

    これを回避するため親が raw REPLAY_NEXT_STATE だけを別取りすれば、validator-first invariant を破り、state poisoning surface になります。state は次回の human_escalation 判定を左右するため、routing fieldsだけを attestationして next state を無検証で保存する設計は成立しません。state store は schema validation後、その next_state を atomic replace で正本として保存します。

    既存の「producer parity test」もこの drift を捕捉していません。テストは analyze() の第2戻り値である _next_state を捨て、5 fieldを手作業で組み立てています。また production の compact serializerではなく、default separator付きの json.dumps(..., sort_keys=True) をハッシュしています。実際の CLI stdout exact bytes を検証する parity testにはなっていません。

    必須修正

    • needs-fix grammar に REPLAY_NEXT_STATE を追加するか、V2 envelopeへversion upする。
    • attestation artifact の expected fields に next_state 全体を含める。
    • state store は raw envelopeからではなく、attestation verification済み normalized payloadからのみ書き込む。
    • next_state の repository、issue、session、body、lane、counter transition を親側 expected values と照合する。
    • parity test は reviewer_claim_replay.py を実 subprocessとして起動し、実際の proc.stdout bytesをそのままハッシュする。

    P0-4: 「canonical exact bytes」が wall-clock 値と serializer drift により再現不能

    reviewer_claim_replay.py は compact JSON を sort_keys=True、空白なし、UTF-8文字を非escape、NaN禁止でserializeしています。一方、既存 parity testは別のserializer設定を使っています。さらに CLI結果にはwall-clock由来の next_state.updated_at_iteration_id が含まれます。

    このため、「同じ deterministic inputsから親がexact bytesを再生成する」というIssueの前提は現在の実装では偽です。

    必須修正

    • 親が iteration 開始時に iteration_id を生成する。
    • reviewer_claim_replay.py --iteration-id <value> として明示入力する。
    • updated_at_iteration_id に現在時刻を内部生成しない。
    • trailing LFをdigest対象に含めるか否かを明記する。
    • hash subjectを「CLI stdout」ではなく、versioned deterministic projectionとして定義する。

    P1-1: canonical JSON の byte contract が未定義

    Issue本文には「canonical JSON artifact」とありますが、次が未定義です。

    • UTF-8/BOM
    • trailing newline
    • whitespace
    • recursive key ordering
    • duplicate keys
    • NaN/Infinity
    • number serialization
    • Unicode handling
    • unknown fields
    • maximum bytes
    • canonicalityの検証方法

    RFC 8785 JCSは、暗号学的ハッシュ・署名の再現性のため、I-JSON制約、duplicate property禁止、whitespace禁止、決定的なproperty sorting、UTF-8出力などを規定しています。単にPythonの json.dumps(sort_keys=True) を使うことは、一般的な意味でのRFC 8785 canonicalizationとは同義ではありません。([RFC Editor]1)

    このリポジトリの用途では、必ずしもRFC 8785 dependencyを追加する必要はありません。ただしその場合は、次のような project-specific profile をversion付きで固定すべきです。

    canonical_profile: REPLAY_BINDING_CANONICAL_JSON_V1
    encoding: utf-8
    bom: forbidden
    trailing_newline: forbidden
    object_keys: fixed ASCII schema keys
    numbers: integers_only
    floats: forbidden
    duplicate_keys: forbidden
    unknown_fields: forbidden
    nan_infinity: forbidden
    whitespace_between_tokens: forbidden
    max_bytes: 16384

    writerとvalidatorは同じcanonicalizerを共有し、validatorは parse後に再serializeして raw_bytes == canonical_bytes(parsed) も検証する必要があります。RFC test vector相当のgolden byte fixturesも必要です。


    P1-2: path check後のopenではTOCTOUを閉じられない

    Issue #1532 の AC3 は canonical path、regular file、namespace mismatchを挙げていますが、単純な次の実装では不十分です。

    if path.resolve().is_relative_to(root) and path.is_file():
        raw = path.read_bytes()

    checkとreadの間でpath targetを差し替えられます。MITRE CWE-367は、resourceの状態がcheckとuseの間に変化することをTOCTOUとして定義し、checkとuseのatomicityまたは同一resource identityの確保を求めています。Python公式文書も、事前のaccess check後にopenする方式をsecurity holeとして警告しています。([CWE]2)

    このリポジトリには、既により適切な実装例があります。temp_residue_marker.py は次を行っています。

    • O_NOFOLLOW
    • directory fd相対open
    • open後の fstat
    • regular file確認
    • group/other writable拒否
    • hardlink拒否
    • max byte制限
    • duplicate JSON key拒否
    • NaN/Infinity拒否
    • 同じopen fdからのread

    これは新規attestation readerの基礎として再利用すべきrepository assetです。

    writer側も、既存の簡易 _atomic_write() はtemp fileとos.replace()を使っていますが、flush/fsyncがありません。os.replace() は成功時のrename atomicityを提供しますが、bufferの永続化にはflushとos.fsync()が別途必要です。 ([Python documentation]3)

    推奨実装は、上書き可能な固定名よりも次です。

    .claude/artifacts/issue-refinement-loop/
      <issue>/
        <session_id>/
          <iteration_id>/
            replay-binding-sha256-<digest>.json
    

    content-addressed immutable fileを O_CREAT | O_EXCL | O_NOFOLLOW で作成すれば、writer→validator間のreplacement riskを減らせます。


    P1-3: issue namespaceだけではfreshness・context bindingにならない

    現在のACではactive issue namespaceとの一致が中心ですが、同一Issue内の古いsession/古いiteration artifactを再利用する攻撃を防げません。

    最低限、artifactには次を含める必要があります。

    context:
      repository_full_name: squne121/loop-protocol
      issue_number: 1532
      refinement_session_id: <parent-generated>
      iteration_id: <parent-generated>
      body_snapshot_sha256: sha256:...
    inputs:
      reviewer_claim_sha256: sha256:...
      readiness_result_sha256: sha256:...
      vc_syntax_result_sha256: sha256:... | null
      vc_preflight_result_sha256: sha256:... | null
      previous_state_sha256: sha256:...
    producer:
      kind: parent_orchestrator
      replay_tool_git_blob_sha: ...
    expected:
      verdict: ...
      routing: ...
      should_consume_iteration: ...
      body_sha256: ...
      next_state: {...}

    Issue #1532 は live issue bodyとのexpected-value bindingを別follow-upにしていますが、少なくとも SubAgent起動前に親が取得したbody snapshot とのbindingは同じIssueで実施すべきです。そうでなければ、親が独立に知っているexpected valueがほとんど残らず、provenance claimを支えられません。


    P1-4: Runtime Verificationをnot_applicableにはできない

    Issue #1532 は「ローカルPython subprocessとpytestだけで決定論的に検証可能」としてruntime verificationをnot_applicableにしています。

    しかし、このIssueで最も重要な前提は次です。

    これはunit fixtureでは証明できません。Issue #1472がco-locationを導入した理由そのものが、実Agent runtimeで親からchild artifact pathを解決できなかったことです。

    必須修正

    Runtime Verification Applicability は immediate とし、実際のisolation worktree Agent invocationで次を確認すべきです。

    1. 親が利用する全入力のownerとpath。
    2. childが親artifact rootを変更できるか。
    3. writer→validator→phase gateの実順序。
    4. field tamper後にstate fileが更新されないこと。
    5. same issue/different session artifactが拒否されること。
    6. runtimeが利用不能ならSKIPとして記録し、unit testをE2E PASSの代替にしないこと。

    P1-5: 同一OS userのchildを敵対者とするなら、unsigned local artifactはprovenanceにならない

    リポジトリ内の既存実装も、同一OS userのself-claimはforge可能であり、trust boundaryやauthorizationにはならないと明記しています。

    したがって、Issue本文に明示的なthreat modelが必要です。

    想定する脅威 親側SHA-256 artifactで対処可能か
    accidental corruption 可能
    parser/consumer drift 可能
    stale artifact replay context binding追加後は可能
    childによる任意field偽造 独立再計算がなければ不可
    同一UID childによるfilesystem tamper OS隔離・署名等がなければ保証困難
    producer identityの証明 bare SHA-256では不可

    少なくともSLSA/in-totoの用語法では、software attestationはauthenticated statementであり、envelopeのsignatureがattester identityを表します。SLSA provenance verificationもbuilder identity、signature、artifact subject digest、期待値の検証を要求します。Issue #1532 は署名・鍵管理を明示的にOut of Scopeとしているため、成果物を「provenance attestation」と呼ぶのは過大です。(SLSA)

    名称は、例えば次のいずれかが適切です。

    • parent-side replay integrity binding
    • parent replay expectation record
    • reviewer replay verification record

    推奨する設計

    選択肢A: 最小変更だが、保証を「integrity」に限定する

    1. 現行compact validatorでgrammarを検証する。
    2. normalized replay fieldsを親がversioned artifactに保存する。
    3. 親がartifact digestをvalidation resultに記録する。
    4. downstream consumerはそのvalidation resultだけを使う。
    5. REPLAY_ARTIFACT_DIGEST の意味は変更しない。
    6. 「child claimの正しさ」や「provenance」は保証しないとSafety Claim Matrixに明記する。

    これはparser driftやdownstream mutationには効きますが、SubAgentの虚偽には効きません。

    選択肢B: Issueの本来目的を満たす設計

    1. 親がbody snapshot、readiness、VC checker、previous stateを所有する。
    2. childはboundedな REVIEWER_BLOCKER_CLAIM_V1 だけを返す。
    3. 親がそのclaimをstrict parseする。
    4. 親がparent-owned deterministic artifactsを使ってreplay arbitrationを実行する。
    5. 親が REVIEWER_CLAIM_REPLAY_BINDING_V1 を生成する。
    6. validatorがchild replay claimsと親expected valuesを照合する。
    7. next_state は親expected resultからのみstate storeへcommitする。
    8. child側replayはadvisory/cross-checkとして残すか、不要なら廃止する。

    #1532 の「provenanceを閉じる」というGoalを維持するなら、必要なのは選択肢Bです。


    Issue #1532 に反映すべき変更

    Scope

    Out of Scopeから次を外す必要があります。

    • .claude/agents/issue-reviewer.md の出力contract変更
    • .codex/agents/issue-reviewer.toml の同期
    • reviewer_claim_replay.py へのparent-generated iteration ID追加
    • REPLAY_NEXT_STATE のvalidator/attestation binding
    • parent input ownershipのruntime検証

    Allowed Paths

    少なくとも次を追加すべきです。

    .claude/agents/issue-reviewer.md
    .codex/agents/issue-reviewer.toml
    .claude/skills/issue-refinement-loop/references/loop-state.md
    .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
    .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay_state_store.py
    .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py
    .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_stdout_budget.py
    .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_state_store.py
    tests/test_agent_parity.py
    

    現行Allowed Pathsは、新規writer、validator、registry、単一test、SKILL、schema-governanceだけであり、実際に変更が必要なproducer/state consumer/parity surfacesを含んでいません。

    追加すべきnegative tests

    • REPLAY_NEXT_STATE 一値改変
    • duplicate JSON key
    • NaN/Infinity
    • invalid UTF-8
    • noncanonical whitespace/trailing LF
    • symlink
    • hardlink
    • FIFO/directory
    • group/other writable file
    • oversized artifact
    • same issue/different session
    • same session/different iteration
    • wrong body snapshot
    • wrong previous-state digest
    • writer後validator前のpath replacement
    • raw next stateが異なる場合にstate fileが未更新であること
    • actual child CLI stdoutとdigestのexact-byte parity

    最終Verdict

    LOOP_VERDICT_V2:
      verdict: REQUEST_CHANGES
      merge_ready: false
      blockers:
        - "REPLAY_ARTIFACT_DIGEST の現行 child-stdout digest semantics と、提案する parent-artifact digest semantics が両立せず、schema versioning / producer update が欠落している"
        - "親が所有する deterministic replay input の inventory・transport・trust boundary が未定義であり、実装が untrusted self-claim の再包装に退化し得る"
        - "REPLAY_NEXT_STATE が現行 producer / state consumer contractには存在する一方、validator exact grammar・Issue #1532 attestation scopeから脱落している"
        - "next_state に wall-clock由来値が含まれ、同一入力から exact bytes を再生成できない"
        - "canonical JSON、TOCTOU-safe open、freshness/session binding、same-UID threat modelが未定義"
        - "実isolation worktree境界を扱うにもかかわらず Runtime Verification が not_applicable とされている"
      required_resolution:
        - "integrity-only設計へGoalを縮小するか、parent-owned replay inputsを導入する設計へScopeを拡張する"
        - "compact/replay/state schemaをversion upし、REPLAY_NEXT_STATEを含む全consumer inventoryを更新する"
        - "実Agent runtime E2Eとfile-security negative matrixをAcceptance Criteriaへ追加する"

    このIssueの根本問題はSHA-256の実装方法ではなく、何を誰が独立に知っており、どの値を信頼の根として照合するのかが定義されていないことです。そこを固定せずartifact hashingだけを追加しても、provenanceは成立しません。

  3. squne121 commented on Jul 15, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-15T15:44:13Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1532
      body_sha256: "sha256:3abae887a93ec12574f2785dac62f0e94881b1f7d5318476e3691407e048f9d2"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:3abae887a93ec12574f2785dac62f0e94881b1f7d5318476e3691407e048f9d2","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":3,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py -q -k test_v2_producer_validator_consumer_preserve_distinct_digest_semantics","command_hash":"sha256:6554eeb23a4bb7f99f307d7d44b1c614e2c0b7088c88e866642f18808a9e7007","execution_key_hash":"sha256:e748dde6792cccd42e6f6ff427dbaaac6543cc73ba175a1a2cd9af79180e38ff","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":146,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":7,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py -q -k test_parent_replay_uses_only_parent_owned_inventory","command_hash":"sha256:876306e9863429d5a655b945bf96a1c33d8c2c7033a3fe40bb0649c1bf7f1204","execution_key_hash":"sha256:fdb4bc4f7bd3067c26a556ac0894d24fd60411a3aac523862d93085c3eaf733f","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":143,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":6,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":11,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py -q -k test_canonical_binding_is_repeatable_and_binds_next_state","command_hash":"sha256:10eadb6b72d981b4c98922cd158ee2911d2e2a1cfedcb05ec26430f4cd30cd80","execution_key_hash":"sha256:3b517cd2f84b85e225996aa90f822e7fb1bffaecb02deaa68725dc90fb2331f0","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_parent_replay_binding.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":143,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":10,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC4","line":14,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py -q","command_hash":"sha256:ac6f474b96d0227167e12592a2dc126dabedf0eee521e0314659101785e8694f","execution_key_hash":"sha256:53b6f3f22a9b0441d7c1d1a22796d5dcfa7505013a782b82b3539a66b26ca3e2","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":[".......................................................                  [100%]","55 passed in 0.26s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":408,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":17,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_state_store.py -q","command_hash":"sha256:97b85a1f03c4de64aedd8124c40d49c95586d1753c645a89c3715bce343fb255","execution_key_hash":"sha256:64d01e877fcb6475aa9f4247fad95d989e196b14a4d27b0f33ce1843770e16f4","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":[".....................                                                    [100%]","21 passed in 0.44s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":584,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC6","line":21,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_parent_replay_isolation_runtime.py -q -k test_parent_child_binding_runtime_e2e","command_hash":"sha256:56ba425a9d3bd614f22a89220b66a466d0f8b4bb106806b7253be10a983f91f4","execution_key_hash":"sha256:f46f46d795c17793cb44cfc26986b90744b2b0b8d84643d2a62d12d7f0315556","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_parent_replay_isolation_runtime.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":143,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":20,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC7","line":25,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py -q -k test_v2_schema_governance_and_consumer_inventory","command_hash":"sha256:0a73dae33ba3e556e7dd4afa37b1af005519f2ab2a9b7547f28503cec4d5b9fc","execution_key_hash":"sha256:201f633137b92b852e54f235a819bcae72fd1da7ef57b413e61d23695581d0ae","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_review_compact_v2_contract.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":144,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":24,"raw":"# baseline-expect: fail"},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  4. squne121 commented on Jul 15, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1532#issuecomment-4982505560
        generated_at: '2026-07-15T15:44:13Z'
        body_sha256: sha256:3abae887a93ec12574f2785dac62f0e94881b1f7d5318476e3691407e048f9d2
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: '2026-07-15T15:46:33Z'
      checked_body_sha256: sha256:3abae887a93ec12574f2785dac62f0e94881b1f7d5318476e3691407e048f9d2
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions