Repository navigation
fix(issue-contract-review): fallback parserでcontract fingerprintのJSON flow mappingを保持する - #1929
Conversation
Preview URLPreview removed (PR #1929 closed). |
判定REQUEST_CHANGES。現状のままではマージ非推奨です。 根本原因の特定と「producer/comparatorを緩めずparser境界で型を復元する」という方針自体は妥当です。しかし実装は、PRが主張する「strict JSONの最小修正」より広く、未信頼コメントからparserを例外終了させられる経路も追加しています。PRはDraftで、変更規模は3ファイル・追加312行・削除44行です。 指摘事項1. P1 Blocker: 未信頼コメントからparser全体を例外終了できる
例えば、次のような約5,000桁の整数を含むコメントを投稿すると、PyYAMLの CONTRACT_REVIEW_RESULT_V1:
bomb: [111111111111111111...約5000桁...]手元のPython 3.13では、これは次の例外として再現します。 Python 3.11以降は巨大整数に変換長制限があり、標準ドキュメントも未信頼JSONのCPU・メモリ消費と入力サイズ制限を明示的に警告しています。([Python documentation]1) PyYAMLはruntime dependencyとして宣言されていますが、現在のコードは「PyYAMLがない場合」だけでなく、PyYAMLが何らかの例外を出した場合すべてfallbackへ移ります。したがって通常環境でも成立する経路です。 必要な修正は以下です。
2. P1 Major: scalar修正ではなく、多段YAML parserへの拡張になっているIssue #1927は、変更対象を「fallback scalar parsing」に限定し、任意YAML parserの導入を明示的にOut of Scopeにしています。 しかし実装は、従来の限定的な一段mapping処理を 実際、 一方、PR本文のconsumer inventoryは次の2件しか記載していません。
少なくとも直接consumerの 推奨は、従来parser構造を維持したまま、既存の値代入箇所だけを 3. P2 Major:
|
Summary
Closes #1927(この実装 Issue を関連付ける)
#1153 の controlled contract snapshot(終了報告: https://github.com/squne121/loop-protocol/issues/1153#issuecomment-5150887495)では、producer が
expected_contract_fingerprintを一行の JSON flow mapping として投稿していた一方、PyYAML が利用できない fallback parser がその値を文字列として保持しました。そのため authority postcondition がauthority_comment_fingerprint_mismatchで fail-closed になりました。本PRは generic contract snapshot parser の型保存修正です。Latitude / EntireCLI 固有の変更ではありません。#1153 の本文、既存
goコメント、snapshot は変更していません。型契約と修正内容
_build_contract_review_comment)dictstr{/[の値だけ、サイズ・深さを制限した strictjson.loads()によりdict/listdictの完全一致を要求fallback は legacy の flat + 一段 mapping を維持し、任意深度の indentation mapping は受理しません。authority が必要とする producer の
checks.vc_preflightだけは、既存 producer 出力に限定した二段互換経路として保持します。JSON flow collection は 16,384 文字・32 階層までの strict JSON のみで、malformed、巨大整数、過剰ネスト、NaN、Infinity、重複 key は候補を無効化して fail-closed にします。ast.literal_eval()は使用せず、Python dict literal、set、tuple、single-quote依存構文を collection として受理しません。文字列を comparator 側で辞書へ暗黙変換する変更もありません。回帰テスト
sha256:2875f1a5982e327face1b5fdcd3b7d76a89cdd6459b21a1147d7a18d5b31323fと fingerprint 形状を、PyYAML import 強制失敗時にdictとして保持する。_validate_authority_postconditions()の実境界を通し、body SHA、product gate、base binding、fingerprint の完全一致を確認する(comparator は mock しない)。{...}/[...]、Python literal、非標準 JSON 定数、重複 key、入力サイズ・深さ超過を fail-closed にし、悪性コメントを skip して後続の trusted comment を継続解析する。materialize_issue_scope_snapshot.pyの contract-source consumer を PyYAML 強制不在で実行し、bounded fallback がdictfingerprint を渡すことを回帰する。SubAgent 調査
snapshot_parser_investigator—gpt-5.3-codex-spark— completed: live OWNER go comment の JSON serialization、PyYAML/fallback の型差、producer→parser→comparator の最小修正境界を確認。snapshot_parser_adversarial_tests—gpt-5.3-codex-spark— completed: PyYAML 不在の強制、malformed JSON、Python literal、strict comparator を通す negative/integration test を設計。受け入れ条件の達成状況
dictとして7 key・値を損失なく保持する parser regression を、parser pytest(63 passed)で確認した。{...}/[...]を文字列成功へ降格せず parse failure とすることを、parser pytest(63 passed)で確認した。{を含む plain string を JSON flow collection と誤解析しないことを、parser pytest(63 passed)で確認した。git diff --checkのすべてで回帰なしと確認した。上記の証跡はすべて current code head
5d22213ac720996e7f4d5415da5c4114bd33ede2で test-runner が独立実行した結果である。検証コマンド結果
すべて test-runner が current code head
5d22213ac720996e7f4d5415da5c4114bd33ede2で独立実行した。Allowed Paths 遵守
.claude/skills/issue-contract-review/scripts/contract_review_result_parser.py.claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py.claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.pyChecks
テスト・lint・diff check の実行結果は上記「検証コマンド結果」に集約した。すべて current code head で独立実行済みである。
Schema Change Applicability
Schema Consumer Inventory
この変更は schema_change ではないが、型契約の消費箇所を明示する。
.claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.pydictの完全一致とauthority_comment_fingerprint_mismatchを維持する。.claude/skills/issue-contract-review/scripts/run_contract_review_once.pyscripts/agent-guards/materialize_issue_scope_snapshot.pySafety Claim Matrix
ValueError・後続 trusted comment の回帰 testchecks.vc_preflighttestNotes
#1153 との関係
この修正は optional な controlled materialization の正確性を改善します。default branch 反映後に fresh snapshot を試行する場合は、その
dict型・body SHA・product gate・base binding・fingerprint postcondition を telemetry として確認できます。ただし、#1153 の review/refinement routing は live Issue、review verdict、実テスト等で継続可能です。snapshot の欠落・失敗・freshness 不一致は warning/telemetry であり、単独では
impl_readyの拒否理由にしません。fresh snapshot 成功も単独ではimpl_readyを付与しません。controlled commit authority(コミット権限)
このPRは Draft とし、auto merge は使用しない。