Skip to content

実装: Contract Snapshot publish で制御文字を含む VC 出力の GitHub readback binding 不一致を再発防止する #3050

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "制御文字を含む baseline VC の実行出力を snapshot comment に載せると、GitHub POST/PATCH 後の raw body readback と producer の期待本文が一致せず正式な impl-review-loop Step 4/5 が停止する障害を、既存の trusted publication と full binding verification を維持したまま解消する。"
change_kind: code
dedupe_key: "contract-snapshot:live-github-vc-control-output-publish-binding-mismatch:v1"

Parent Issue

なし(横断的な publisher 不具合。発見元 Issue #3039 / PR #3040 を implementation parent として混在させない)。

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

なし(独立修正)。#3039 の Step 4/5 の正式な再実行は、この publisher 修復の後に元の PR/workflow で行う。

Background

原因候補は VC の subprocess stdout に含まれる ESC / cursor-control 系列の transport 表現(JSON encoding、YAML scalar、GitHub Markdown raw body、PATCH/GET、またはその組合せ)と、現行の exact echo fake remote が実 GitHub の差分を再現していないこと。まず二つの失敗済み comment と current producer の expected final body 生成経路を照合し、最小の再現を作る。単なる NO_COLOR / FORCE_COLOR 再試行は成功条件にしない。

Outcome

publisher と regression test の 1 PR が作成され、制御文字を含む Vite pnpm build stdout を持つ baseline VC でも、意図した canonical comment body と GitHub raw readback が full binding を満たして CONTRACT_REVIEW_RESULT_V1 の有効な go snapshot を materialize できる。verified comment ID / issue / body digest / trusted author / source fingerprint の条件は変更しない。

Runtime Verification Applicability

decision: immediate
reason: "既存事象は実 GitHub の PATCH/GET readback 境界で観測された。まず captured difference を使った hermetic regression を必須とし、修正後は canonical controlled publisher 経由の限定 live readback を、認証済みかつ投稿先が明確な環境で行い、実コメントの完全な binding と parser 受理を検証する。権限が無ければ LIVE PASS を推測しない。"
applicable_acs: [AC3]
execution_environment: "Python / uv / pytest と git。live ではリポジトリ権限を持つ既存 GitHub CLI と Issue #3039 の approved publication workflow。"
skip_conditions: "権限・rate limit・remote 障害・Issue 本文 drift で controlled live publish が安全に実行できない場合。"
fallback_policy: "hermetic PASS を live PASS に読み替えない。既存 snapshot の hash 偽装、raw GitHub mutation bypass、blind retry は禁止。"
artifact_requirements: "expected/actual byte-diff diagnostics、hermetic test report、live で使った場合は comment URL と direct GET binding / canonical parser の結果。"

In Scope

  • .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py の current producer / materializer / publisher から、意図した final body、PATCH input、direct GET decoded raw Markdown body の最初の不一致を再現する。control bytes、JSON/YAML escaping、Markdown transport のどの境界で異なるかを根拠付きで確定する。
  • 根本原因の判明後、投稿前に transport-safe な一貫した文字表現を生成する最小修正を選ぶ。必要なら verbose stdout_head / stderr_head のみに決定論的な printable escaping または既存の advisory compaction を適用する。非 verbose の classification/command_hash/decision/count/digest/fingerprint など authority-bearing fields は失わず、同一正規化後の本文に対して hash を算出する。実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 の small/large semantic round-trip 契約からの変更が必要なら差分と合理性を明示する。
  • .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py に、本番 builder + 本番 PATCH/GET reconciliation + 本番 parser を使う focused regression を追加する。mock は GitHub HTTP 境界に限定し、実 GitHub と同等と確認した観測済み変換を再現する。従来の exact echo fake remote だけでは PASS としない。修正を取り消す mutation が fail する negative control を確認する。
  • 既存の staging/final binding、trusted publisher、invalid readback fail-closed、POST/PATCH at-most-once/no-blind-retry、idempotency と compacted-large transport の非回帰を検証する。
  • orphan comment #6116019175 / #6116042102 は診断用証跡として保持し、既存の canonical parser が valid go と誤認しないことを確認する。削除・本文の hash 捏造・成功扱いへの書換えは行わない。

Out of Scope

Acceptance Criteria

  • AC1: 既存の2件の失敗に結びつく expected / actual final comment body の byte-level mismatch を、制御文字・escaping・remote round-trip の観測で局所化し、原因と不確実性を PR 本文に記録する。境界の未証明な仮説を断定しない。
  • AC2: 本番 builder + PATCH/GET + canonical parser を通す focused test が、実障害に対応する stdout/control fixture と GitHub raw readback の観測済み変換で修正前 FAIL・修正後 PASS となる。実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 の literal/actual ESC 区別、small/large、YAML/JSON escape、advisory と authority field の契約を維持または明示的に整合させる。
  • AC3: 正規 controlled publisher が実 GitHub comment を作成/更新した場合、authoritative direct GET の decoded Markdown body hash、comment ID、Issue、publisher identity、fingerprint が一致し、canonical parser の go と subsequent check-only adoption が確認できる。権限やドリフトで実行不能なら実測 PASS としない。
  • AC4: 失敗時は controlled_publisher_binding_failed を fail-closed に維持し、blind retry や staging hash の流用、valid go でない orphan の成功採用を行わない。
  • AC5: 既存 test_ensure_contract_snapshot.py と authority-binding 回帰、typecheck/lint/test/build が PASS する。

Verification Commands

# AC1
$ uv run --locked pytest -q .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
# AC2
$ uv run --locked pytest -q .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
# AC3
$ uv run --locked pytest -q .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
# AC4
$ uv run --locked pytest -q .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py
# AC5
$ uv run --locked pytest -q .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

注: AC3 の live controlled readback は pytest による代替証明ではない。既存 canonical publisher の成功・comment URL・GET binding の実測を別途 PR に記録する。

Allowed Paths

  • .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py
  • .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py

Stop Conditions

  • Allowed Paths 外の変更が不可避で、既存の controlled Issue contract 更新でも整合できない場合。
  • In Scope の公開 schema / authority-bearing key / parser 契約の非互換変更が必要な場合。
  • 別の再発原因に対する新規 Issue が必要と判明し、重複・所有権を確定できない場合。
  • 後続 Phase や別スコープへ波及し、今回の単独 Outcome で閉じない場合。
  • repository-native Skill の nested delegation 制約または真正の human_judgment_required に該当する場合。
  • 秘密情報操作・権限昇格・破壊的 GitHub mutation・evidence integrity の維持不能が判明した場合。
  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

通常の修正可能な test / CI / review failure は停止条件ではなく修復対象とする。

Required Skills

なし

Required Design References

  • #2619(ANSI/control fixture を持つ既存の closed producer/PATCH/parser contract)
  • #2635、#1513(既存の reconciliation と diagnostics)
  • #3039、PR #3040(今回の障害発生元)
  • .claude/skills/impl-review-loop/SKILL.md、.claude/skills/impl-review-loop/steps/step-4-pr-review.md、docs/dev/workflow.md
  • GitHub REST Issue comments(raw Markdown body の GET/PATCH 契約)

Delivery Rule

1 Issue = 1 PR。専用 worktree / Draft PR を既定とし、PR に Closes #<本Issue> を記載。#3039 は close target にしない。publisher 修正が merge される前に PR #3040 の Step 4/5 を実行する場合は、現行 repository canonical workflow がその producer バージョンを正式に許容するか確認し、未検証の別実装から作った証跡を正式な承認としない。

Notes for Reviewer

Dedupe disposition: #2619 は controlled fake GitHub state が PATCH input を exact echo していたため、実 GitHub readback 差の新 failure class を固定していない。#2635・#1513 は別原因で CLOSED。#2845・#1490・#3013 は別 Outcome で OPEN。今回の Issue は GitHub raw Markdown transport の byte identity に限定して重複を避ける。

発見元の状態: PR #3040 は正常な CI と ad hoc reviewer APPROVE の報告があるが、valid snapshot が無いので terminal approval 未成立。これを unblock するために、publisher 側の独立修復が必要。

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    triage-required
    on Oct 12, 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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions