Repository navigation
Description
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
- Goal: 正当な VC 証跡を持つ Issue が、comment transport の文字表現差だけで
controlled_publisher_binding_failedとなり、正式なstep4-adjudicateとstep5-terminal-gateに到達できない状況を修正する。 - Desired Destination: 現行
ensure_contract_snapshot.pyの producer / publisher と focused regression。実装: root review producer の scratch を executor snapshot の外へ移し repair_action.apply の peer 競合による unauthorized_write_path を解消する #3039 の scratch placement 実装とは別の 1 Issue = 1 PR。
Current Validated Scope
- 2026-10-12、Issue 実装: root review producer の scratch を executor snapshot の外へ移し repair_action.apply の peer 競合による unauthorized_write_path を解消する #3039 の snapshot materialization を PR fix: root review producer の scratch を repo 外の system temp へ移す (#3039) #3040 の検証用に clean main(観測時
ac82972d1e62b6327227173a430862b4451a60c5)から実行した際、ensure_contract_snapshot.py --issue-number 3039 --repo squne121/loop-protocol --evidence-mode baseline --mode auto --postが2回とも exit 60、status: controlled_publisher_binding_failed/fingerprint_patch_failed: patch_get_reconciliation_failed:binding_body_hash_mismatchを返した。 - 1回目の bounded diagnostics:
expected_byte_len=24956,actual_byte_len=24935,first_diff_byte_offset=15800;post_status=posted。2回目もNO_COLOR=1 FORCE_COLOR=0を指定したが同じ failure class。発生した comment: 6116019175、6116042102。 - GitHub の raw comment body には
pnpm build/ Vite の stdout に対応するstdout_head(ANSI ESC の JSON 文字列表現・画面制御系列を含む)が存在する。producer が期待した本文と raw GitHub readback の厳密にどの変換が異なったかは未確定。GitHub による「ESC 除去」と断定せず、expected/actual の byte-level diff と JSON/YAML/Markdown 各境界から再確認すること。 - 既存 #2619 は CLOSED。実
_build_contract_review_comment()→patch_comment()→ parser を模擬 remote(PATCHでremote["body"]=payload["body"]とする exact echo)で検証し、literal\\^[[2Kと actual ESC の分離 fixture を持つ。しかし実 GitHub 側の readback 不一致を固定する fixture は確認できない。#2635 は staging/final digest 混同、#1513 は binding diagnostics、いずれも CLOSED。 - OPEN #2845 は classification transport 上限と 40 VC の parity、#1490 は既存 snapshot reuse の receipt、#3013 は artifact 保存失敗時の旧 envelope 誤利用。今回の live GitHub 投稿後の byte-level mismatch とは別スコープ。
- 実装: root review producer の scratch を executor snapshot の外へ移し repair_action.apply の peer 競合による unauthorized_write_path を解消する #3039 / PR fix: root review producer の scratch を repo 外の system temp へ移す (#3039) #3040 は scratch 修正・検証・独立 reviewer APPROVE まで報告済み。ただし有効な snapshot /
dispatch_seqを経る正式な terminal approval は未取得。暫定 APPROVE を正式な承認に繰り上げない。
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
- PR fix: root review producer の scratch を repo 外の system temp へ移す (#3039) #3040 の scratch placement 実装・Allowed Paths の拡張、executor guard 無効化。
step4-adjudicate/step5-terminal-gate/dispatch_seq検査の緩和、既存 reviewer verdict の流用。- 新しい gate / approval layer / schema family / wrapper / 恒久 CI job。
- 実装: contract snapshot の vc_preflight_classifications transport 上限(16,000 文字)と readiness の VC 上限(40 件)の不整合を解消し、VC が 14 件以上の Issue でも snapshot を materialize できるようにする #2845 の VC 数上限調整、実装: contract snapshot既存再利用パスにpublish receipt bindingを追加する #1490 の receipt 導入、実装: Step 4 の contract snapshot artifact 保存失敗で旧 envelope を fresh 成功と誤認しない #3013 の stale artifact 問題。
- 盲目的な繰返し実 GitHub POST、既存 orphan comment の破壊的削除。
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と subsequentcheck-onlyadoption が確認できる。権限やドリフトで実行不能なら実測 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
fix: Contract Snapshot の制御文字 transport を gh 受信時 sanitizer 前提に是正する (#3050