Skip to content

実装: CONTRACT_REVIEW_RESULT_V1 の巨大 advisory check が fingerprint readback を破壊しないよう snapshot producer/parser 契約を修正する #2056

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "CONTRACT_REVIEW_RESULT_V1 の advisory check が巨大でも、trusted owner が投稿した go snapshot の strict fingerprint readback・reuse を壊さない producer/parser round-trip を復旧する"
change_kind: code

Parent Issue

なし(単独改善。#2040 を native dependency の後続として停止させる前提修正)

Parent Goal Ref

Current Validated Scope

  • ensure_contract_snapshot.py が出力する authoritative comment の advisory classifications と declared_path_overlap を、YAML/strict JSON の境界で安全に round-trip できるようにする。
  • contract_review_result_parser.py の trusted publisher、fingerprint の dict 型、comment/id/issue/body/Allowed Paths/base SHA binding、malformed input の fail-closed を維持する。
  • 新しい ledger、receipt、digest、state hierarchy を追加せず、producer/parser と既存回帰テストだけで最小に復旧する。

Remaining Parent Gaps

なし。本 Issue のマージ後に #2040 は fresh contract snapshot と通常の review/CI route を再実行する。

Outcome

巨大または合理的に複雑な advisory check を含む CONTRACT_REVIEW_RESULT_V1 を producer が安全に表現し、PyYAML 経路と bounded strict-JSON fallback の双方で authoritative status: go、dict fingerprint、全 binding を保持して materialize→parse→reuse できる source/test 修正と Draft PR が完成している状態。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: Python の producer/parser unit・integration regression で完結し、外部 runtime、CheckRun、実環境 artifact を必要としないため。

In Scope

  • checks.vc_preflight.classifications を含む producer 出力を YAML と strict JSON fallback の両方で安全に parse 可能な最小表現へ直す。
  • declared_path_overlap を 実装: issue-contract-review を fresh structural gate に縮小し、OPEN PR の実編集競合のときだけ停止させる #1680 の advisory-only observation として保持し、削除しない。
  • real publisher/parser output を用い、declared_path_overlap が 16,384 bytes 未満であっても classifications の 16,198-byte flow 値が snapshot を無効化しない回帰を追加する。
  • producer comment → parser → trusted existing-go reuse の正経路で、fingerprint が dict のまま comment/id/issue/body/Allowed Paths/base SHA binding を満たすことを確認する。
  • PyYAML と forced fallback の各経路で、malformed JSON、duplicate keys、NaN、Infinity、deep nesting、無関係な untrusted oversized input を fail-closed に維持する。

Out of Scope

Acceptance Criteria

  • AC1: advisory fields が巨大または合理的に複雑でも、authoritative status: go と expected_contract_fingerprint が parser で失われず、fingerprint は dict として残る。
  • AC2: real producer/parser output で declared_path_overlap が 2,999 bytes(2,771 chars)かつ 16,384 未満でも、16,198-byte classifications が PyYAML ScannerError と fallback の invalid-escape を起こさず go retention を阻害しない。
  • AC3: materialize→parse→trusted existing-go reuse が comment ID、issue URL/number、body SHA、Allowed Paths hash、base SHA を含む strict fingerprint binding を維持する。
  • AC4: declared_path_overlap は 実装: issue-contract-review を fresh structural gate に縮小し、OPEN PR の実編集競合のときだけ停止させる #1680 の advisory-only semantics のまま保存され、削除・authoritative gate 化・size-limit 根因との誤記をしない。
  • AC5: PyYAML 利用時と forced fallback の双方で producer output を受理し、fallback は strict JSON object/array を必要な型としてのみ保持する。
  • AC6: malformed JSON、duplicate keys、NaN、Infinity、deep nesting、untrusted oversized input は従来どおり fail-closed であり、status-string-only fallback や arbitrary/unbounded YAML parse を導入しない。
  • AC7: JSON flow collection の depth/size DoS controls、trusted publisher validation、fingerprint strictness、および既存 binding regressions が維持される。
  • AC8: Allowed Paths に限定した targeted pytest と変更 Python の Ruff check が PASS する。

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q
# AC2
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q
# AC3
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py -q
# AC4
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q
# AC5
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q
# AC6
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q
# AC7
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q
# AC8
# preflight-scope: pr_review_only
$ uv run --locked ruff check .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py

Allowed Paths

  • .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py
  • .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
  • .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py
  • .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py
  • .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py

Stop Conditions

Required Skills

  • Python
  • pytest
  • JSON

Required Design References

  • docs/dev/workflow.md
  • docs/dev/workflows/impl-review-loop-design.md
  • docs/dev/agent-skill-boundaries.md

Scope Delta(任意)

N/A

Delivery Rule

Notes for Reviewer

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 9, 2026
  2. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-08-09T09:32:17Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/2056
      body_sha256: "sha256:4850521a4d29c97774e376686d11fb79f9a40e5bf22e17fbff7acd8e77ea938a"
      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:4850521a4d29c97774e376686d11fb79f9a40e5bf22e17fbff7acd8e77ea938a","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_evhbpc7u.md"}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q","command_hash":"sha256:0c98ce996dfb8281ab8b3f4a08c8b28e3ca333d84e32695f861c8ec93e7eead3","execution_key_hash":"sha256:6678beffc7f992fa3cc1295766dc8b63195094f458d019861cc9980df6ae74f1","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................................          [100%]","63 passed in 0.10s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":664,"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":"AC2","line":2,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q","command_hash":"sha256:847601667a9d9a65148d3296f1d44295772727dbfbbd802fb60565d6c87116fd","execution_key_hash":"sha256:87a46742e4c48b36169b1e838322da00d00e1a9f75fb16cfcb47fb7a86db3a9a","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 67%]","..................................                                       [100%]","106 passed in 0.57s"],"stdout_truncated":false,"stdout_original_line_count":4,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1024,"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":"AC3","line":3,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py -q","command_hash":"sha256:6be2859166e1730e9aa039da5b595233927e58a294851ac67333d336a51da231","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"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,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC4","line":2,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q","command_hash":"sha256:847601667a9d9a65148d3296f1d44295772727dbfbbd802fb60565d6c87116fd","execution_key_hash":"sha256:3dd4c5872d3ad52a6563ecbef70e7eabee4eaf36317e1293413440e63bb184c6","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 67%]","..................................                                       [100%]","106 passed in 0.40s"],"stdout_truncated":false,"stdout_original_line_count":4,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1876,"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":2,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q","command_hash":"sha256:0c98ce996dfb8281ab8b3f4a08c8b28e3ca333d84e32695f861c8ec93e7eead3","execution_key_hash":"sha256:65676057a38c084825111aba11324c40744f955b972035a09aacf1ef0ac9abfd","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................................          [100%]","63 passed in 0.08s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2384,"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":2,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py -q","command_hash":"sha256:0c98ce996dfb8281ab8b3f4a08c8b28e3ca333d84e32695f861c8ec93e7eead3","execution_key_hash":"sha256:6b5a3e0cad7989e05a7b4e440840a0b0b19f2381ba3e3790221e3ffd3fa755a7","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................................          [100%]","63 passed in 0.07s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":358,"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":"AC7","line":2,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q","command_hash":"sha256:847601667a9d9a65148d3296f1d44295772727dbfbbd802fb60565d6c87116fd","execution_key_hash":"sha256:8d4b857ca4f7d9befe954f2edbc02b7409a45d9fc4ce26f7e9b9126560877334","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 67%]","..................................                                       [100%]","106 passed in 0.45s"],"stdout_truncated":false,"stdout_original_line_count":4,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":836,"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":"AC8","line":3,"raw_command":"uv run --locked ruff check .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py","command_hash":"sha256:d200eaef1894f696bd2a7b353e78dfb02868edf1a47b441df12556d45732a72f","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"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,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"2fe791560ae9a27c2e64d4e2a8c936a983b4a64c","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":2044,"title":"実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する","base_ref_name":"main","head_ref_name":"worktree-issue-2015-local-asset-research-route-live-serena-m","head_ref_oid":"6b03f91af17d6115da5513c62174109b272c78b6","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2044","changed_files_count_graphql":12},{"number":2045,"title":"実装: visual-surface dependency registry と required visual-impact policy check を導入する","base_ref_name":"main","head_ref_name":"worktree-issue-2019-visual-impact-policy","head_ref_oid":"0d2e0f7b99c6389f33e5bd9b15a1e6bc995d3acb","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2045","changed_files_count_graphql":46},{"number":2057,"title":"fix: approved scope reframe の empty operations を issue_editor_required へ route (#2048)","base_ref_name":"main","head_ref_name":"worktree-issue-2048-scope-reframe-empty-ops-route","head_ref_oid":"461a5716edbc49d6e086ad17078ed88df4f2f30c","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2057","changed_files_count_graphql":5}],"fetched_count":4,"totalCount":4,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:fcb7acae50607dba347fda20288a81f625ea1b8040d228f53c9609a510a5e4e3","errors":[]},"inventory_digest_extended":"sha256:6fbc0d0aa92bba1a770cfa0e9508b62eaf9644fdd183c15485b6a5032fd563a7","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":2056,"contract_source_kind":"issue_comment","contract_source_id":"5230821259","contract_body_sha256":"sha256:4850521a4d29c97774e376686d11fb79f9a40e5bf22e17fbff7acd8e77ea938a","allowed_paths_normalized_sha256":"7740828a850bf4c2446074449fc3c0f33b4d1a1cb99fde0913cf556056014bfc","base_ref":"main","base_sha_at_snapshot":"2fe791560ae9a27c2e64d4e2a8c936a983b4a64c"}
    
  3. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

    • PR: fix-contract-review-escape-advisory-snapshot-json #2058
    • Worktree: .claude/worktrees/issue-2056-snapshot-advisory-roundtrip
    • Branch: worktree-issue-2056-snapshot-advisory-roundtrip
    • Commit: 68b80fca7794759732974bead2dd62c9a731a96d
    • Verification: literal VC、targeted regression、pnpm typecheck/lint/test/build が PASS
    • 後続: current-head PR review → CI → merge
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