Skip to content

実装: Step 4 の contract snapshot artifact 保存失敗で旧 envelope を fresh 成功と誤認しない #3013

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "impl-review-loop Step 4 が、ensure_contract_snapshot.py の artifact 保存失敗後に残った旧 envelope を今回の snapshot 保存成功として扱わない"
change_kind: workflow
dedupe_key: "impl-review-loop:step4:artifact-write-error-stale-envelope-reuse:v1"

Parent Issue

none(独立した再発防止)。発見元は Issue #3005 の OWNER review の P2-2。#3005 は producer の既存挙動の文書化が scope であり、本 Issue は Step 4 利用側の保存成功判定を所有する。

Parent Goal Ref

Evidence / Current Validated Scope

調査基準: main bde4bce1242144c84d426ba11ff29f7024e05faf(実装着手時は fresh 再取得すること)。

  1. .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py::main() は --artifact-dir 保存の例外を捕捉し、result.errors[] に artifact_write_error: ... を追加するが、result.status と終了コードの判定は変更しない。result.status=ok なら保存失敗でも exit 0 になり得る。artifact_path は保存成功後にのみ stdout result に追加される。
  2. .claude/skills/impl-review-loop/steps/step-4-pr-review.md の「ensure_contract_snapshot.py の出力の渡し方」は、全 status で envelope を保存すると説明し、CLI stdout を >/dev/null へ捨てた後に $SNAPSHOT_DIR/contract-snapshot-$ISSUE_NUMBER.json を組み立てて step4-adjudicate へ渡す例を掲示している。保存成功を確認しないまま、同じパスに残る旧 artifact が input になる余地がある。
  3. step4-adjudicate は --producer-exit-code、trusted comment、Issue/body/head/command binding を検証するため、旧ファイルが実際に gate を通過したことは未確認。本 Issue は failure injection を用いてその条件・影響を確定したうえで最小修正する。未観測の false-green を発生済みとして扱わない。
  4. Issue 実装: ensure_contract_snapshot.py の exit code 表と artifact 出力の文書を実挙動に一致させる #3005 は docstring + 単体 pytest の2パスに限定され、producer ロジックを変えない。Step 4 側の変更を 実装: ensure_contract_snapshot.py の exit code 表と artifact 出力の文書を実挙動に一致させる #3005 に押し込まない。

Outcome

正常な producer 実行で artifact が保存された場合だけ、その invocation の envelope が Step 4 に渡る。artifact 保存失敗・保存なし・同名の旧ファイル残存時は、終了コード 0 でも「今回の保存成功」と誤判定せず、step4-adjudicate の既存 rejection / same-binding stored PASS 失効を迂回しない。正常経路の --producer-exit-code / --repo handoff は保つ。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: repository-owned CLI と fake filesystem/GitHub boundary の deterministic integration regression で検証でき、実 GitHub mutation や Claude Code session の常設実行を要しない。

In Scope

  • Step 4 の snapshot 取得例と必須前提を、current invocation に束縛された artifact 成功判定へ訂正する。既存の step4-adjudicate が所有する unwrap / source binding / invalidation は維持する。
  • 保存成功・保存失敗・旧ファイルの残存・保存指定なしのケースを fake producer / controlled I/O で再現する regression。特に status=ok + exit 0 + artifact_write_error + 旧 envelope 残存の反例を固定する。
  • 最小手段を選ぶ。例えば run-owned な新規出力ディレクトリを使用し、同一 invocation で保存された artifact 以外を current result と扱わない。単に producer の stdout を捨てたまま path existence のみで判断しない。
  • step4-adjudicate に到達できる失敗は既存の invalidate-on-nonpass に流す。もし別途検証を追加する場合も、前置で失敗して step4-adjudicate の既存 PASS 失効を阻害しないようにする。

Out of Scope

Acceptance Criteria

  • AC1: Step 4 の手順が、--artifact-dir 保存失敗でも status=ok / exit 0 があり得ることを明記し、今回の保存成功を確認しない旧 artifact の再利用を禁止する。
  • AC2: controlled failure injection により status=ok / exit 0 / stdout の artifact_write_error / artifact_path 不在 / 同名旧 artifact 残存を再現し、Step 4 が旧 artifact を fresh 成功として扱わないことを示す。
  • AC3: producer の保存成功では、元の envelope を無加工で step4-adjudicate に渡し、実際の --producer-exit-code と independently supplied --repo / Issue/body binding を維持する。
  • AC4: artifact が欠ける/不正な場合は step4-adjudicate の既存エラー処理と同一 binding の stale PASS 失効が有効。事前 normalizer の失敗でそれらを迂回しない。
  • AC5: 調査で実害が認められなければ、証拠を記録して docs-only の最小修正へ縮小する。canonical tests は PASS、変更は Allowed Paths 内、1 Issue = 1 PR。

Verification Commands

# AC1-AC4: 新規 regression(実装時に追加)
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_snapshot_artifact_write_failure.py -q

# AC3-AC4: 既存 handoff regression
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q

# AC4-AC5: 既存 Step 4 adjudicator regression
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q

Allowed Paths

  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • .claude/skills/impl-review-loop/tests/test_step4_snapshot_artifact_write_failure.py(新規)
  • .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py
  • .claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py(同一 binding の失効処理に実修正が不可欠と立証された場合のみ)

Stop Conditions

  • 既存 ensure_contract_snapshot.py の published exit code / schema 変更が不可避
  • Allowed Paths 外の実装拡大、既存 source authority の緩和、不可逆 GitHub mutation が不可避
  • 仮説を検証した結果、独立実装の必要性が否定された場合は、証拠とともに scope を縮小・終了判断する

Delivery Rule

1 Issue = 1 PR。既存の canonical impl-review-loop で独立実装・テスト・独立レビューし、merge は人間判断まで保留する。

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions