Repository navigation
feat: repair_issue_contract に template-derived structural repair producer を追加する - #2206
Conversation
…ucer を追加する (#995) resolved implementation template の required field (id/label/value/order/ template path/digest) と issue_kind 別 authoring SSOT の required contract key を読み取り、heading set membership 単独に頼らず missing/duplicate/ empty/placeholder-only な required section と Machine-Readable Contract key を一回の producer run で deterministic order(template field order → field id)の単一 handoff bundle に束ねる。 - 自動提案は template_value_exact / source_span_exact / derived_scalar_exact の closed derivation enum のみを使い、exact source のない semantic field は human_review_required とする(semantic prose を生成しない)。 - duplicate heading・multiple-source conflict は human_review_required とし、 安全な item と混在しても同一 bundle に残す。 - repair_issue_contract_result_v1 / refinement_preflight_result_v1 の両 schema に structural_repair_action を additive(optional)に追加し、 既存の repair_action 契約とは独立させる。 - production path は GitHub mutation / readback を一切呼ばず、#2039 opaque consumer 互換性のみを検証する。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2206 closed). |
impl-review-loop 判定結果(iteration 0)
verdict: APPROVE
reviewed_head_sha: "8aa0e839fcd281b85c88e774d9e330f3d9194287"
blockers: []
warnings: [] |
判定REQUEST_CHANGES — 現状のままではマージ不可です。 レビュー対象は current head PR本文が列挙するテスト成功自体は否定しません。しかし、テストが実装の permissive な挙動をそのまま正解として固定しており、Issue #995 の安全契約を証明していません。特に、production control-plane から到達不能、actionable bundle が verdict: REQUEST_CHANGES
reviewed_head_sha: "98cbbdc66162834952b678d660383f688fa39b3d"
confidence: highP0-1.
|
…anchor を強化する (#995) OWNER REQUEST_CHANGES (PR #2206 review comment) への対応。 - P0-1: route_structural_repair_disposition() を追加し、disposition_summary と status/next_action の矛盾(pass/proceed のまま human_review_required が同居する等)を schema allOf invariant で fail-closed にする。AC8 は test-local な _opaque_consumer_read を実 production 関数呼び出しに置換。 - P0-2: 各 item に insertion(disposition/relation/anchor_*/rendered_heading/ candidate_section_digest)を追加。anchor が一意に決定できない場合は human_review_required に強制ダウングレードする。 - P0-3: source_span_exact に authority_kind/source_repo/source_object_kind/ source_object_id/source_revision/source_text_sha256/candidate_sha256 を 必須化。derived_scalar_exact は field 単位の closed validator を追加。 - P0-4: template のプレースホルダ scaffold(<...> / 未選択 a|b|c enum)を 再帰検出し auto_apply_safe から除外。contract_schema_version は template 自身の宣言値から derive する。 - P0-5: mrc_contract_parser(Issue #1135 SSOT)を再利用した discriminated MRC parse result(ok/missing/malformed/duplicate_key/ambiguous)に置換。 missing/malformed でも issue_kind 別の全 required key を列挙する。 - P1-1: CommonMark 準拠に近い fence open/close 判定(trailing text で close させない)と H2 heading の indent/closing-hash 対応。 - P1-2: schema に invariant(required:true の const 化、reason_codes minItems、SHA256 pattern、disposition_summary と items[] の整合、 human_review_required での candidate フィールド禁止)を追加。 - P1-3: REQUIRED_CONTRACT_KEYS_BY_KIND を body-authoring.md から実際に parse する。empty/placeholder-only section は observed_cardinality を 維持し content_state で区別する。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
fix_delta 対応報告(REQUEST_CHANGES への応答)対象コメント: #2206 (comment) 前回 review 時点の実装は「検出器の追加ではなく到達不能な permissive classifier」というご指摘は正しく、本 fix_delta で構造的に作り直しました。対応状況を P0/P1 ごとに明記します(部分対応・未対応を隠さず記載)。 P0-1:
|
PR #2206 (Issue #995) レビュー結果 — head
|
…te provenance を追加する (#995) pr-reviewer REQUEST_CHANGES (P0-1, P1-3) への対応。 P0-1: run_refinement_preflight.py が build_structural_repair_bundle() / route_structural_repair_disposition() を実際に呼び出すよう接続した。 body 自身が自己申告する machine-readable-contract の issue_kind から ローカルの .github/ISSUE_TEMPLATE/<kind>.yml を解決し(GitHub 呼び出し なし)、disposition_summary に応じて status/next_action を schema の const invariant どおりに強制する(auto_apply_safe→needs_fix、 human_review_required→blocked)。既存の environment_failure > blocked > needs_fix > warn > pass precedence を尊重し、より重大な既存 status を サイレントに降格しない(該当時は structural_repair_action を今回の run では付与せず、reason_codes を informational blocker として残す)。 P1-3: build_structural_repair_bundle() に template_git_blob_sha / template_source_ref を追加した(任意・additive)。repair_issue_contract.py 自体は git を呼ばない pure module のまま、呼び出し側 (run_refinement_preflight.py) が git hash-object / HEAD SHA を解決して provenance として渡す。両 schema ファイルに additionalProperties: false と整合する形でフィールド定義を追加した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
fix_delta 対応(P0-1, P1-3)pr-reviewer の REQUEST_CHANGES(head Blocker 1 (P0-1):
|
CI の python-test-core job で Ruff E501 (Line too long) が test_template_section_repair.py の121文字行で失敗していたため、 by_id からの参照を中間変数に切り出して120文字以内に収める。
Verdict: REQUEST_CHANGES検証結果サマリー(head
|
…e コメントを追従させる (#995) pr-reviewer REQUEST_CHANGES 対応。route_structural_repair_disposition() 直前の NOTE (scope disclosure) が e7c1e42 時点の wiring 後も 0fd2fba 当時(「run_refinement_preflight.py は build_structural_repair_bundle() を呼ばない」)のまま残存しており、実装(production preflight から 条件付きで呼び出し済み)と矛盾していた。実際の呼び出し条件 (body 内 self-declared issue_kind の local-only resolution)を明記する形に コメントのみ更新する。ロジック変更なし。
Verdict: APPROVE確認事項
verdict: APPROVE
reviewed_head_sha: "e72dbca0f39c5c947aa51e2d538270e245f46e61"
blockers: []
warnings:
- "P1-3: template_git_blob_sha は working-tree git hash-object であり HEAD commit との一致を検証する _git_head_tree_blob_sha() より弱い binding。専用テストも未追加"
- "structural repair の production wiring追加により既存OPEN issueのpreflight結果が新たにblocked/needs_fixへ変わりうる(意図された安全強化だが波及範囲は要観察)"
- "P1-1: tilde fence/blockquote内heading/CRLFは未テストのまま"
- "P1-2: schema 2ファイル間の重複(約200行)は未解消"
- "P0-3: derived_scalar_exact のfield-specific validatorはparent-issue系のみ" |
Summary
repair_issue_contract.pyに template-derived structural repair の detector / classifier / proposal producer を追加した。.github/ISSUE_TEMPLATE/implementation.yml)の required field を field id / label / value / order / template path / immutable digest とともに取得し、issue_kind 別 authoring SSOT(create-issue/references/body-authoring.md)の required contract key と突き合わせる。template_value_exact/source_span_exact/derived_scalar_exactの closed derivation enum のみを使用し、exact source のない semantic field(Outcome / Acceptance Criteria 等)は必ずhuman_review_requiredとする(prose を捏造しない)。repair_issue_contract_result_v1.schema.json/refinement_preflight_result_v1.schema.jsonの両方にstructural_repair_actionを additive(optional) に追加した。既存のrepair_action契約は変更していない。e7c1e42b)でrun_refinement_preflight.pyの production preflight 経路にbuild_structural_repair_bundle()/route_structural_repair_disposition()を実際に接続した(詳細は Schema Consumer Inventory / Safety Claim Matrix を参照)。呼び出しは body 内の self-declaredissue_kind:scalar を local-only で解決できた場合のみ発火する条件付き wiring であり、live GitHub Issue の issue_kind fetch は行わない。build_structural_repair_bundle/detect_missing_template_sections)は GitHub mutation / readback を一切呼ばない(純粋な Python 文字列・YAML 処理のみ)。実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039(out of scope)が consumer 側の GitHub mutation・authoritative readback・per-item transaction を所有する。Checks
以下の検証コマンドをすべて実行し、全件 PASS したことを確認した(Issue #995 の Verification Commands に対応)。
uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_required_fields_include_id_value_order_and_template_digest -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_all_missing_required_fields_are_reported_in_one_batch -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_semantic_field_without_exact_source_requires_human_review -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_exact_template_value_can_be_auto_apply_safe -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_duplicate_heading_or_conflicting_sources_are_ambiguous -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_structural_repair_provenance_validates_against_schema -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_producer_path_does_not_invoke_github_mutation -q— 成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_2039_opaque_action_compatibility_does_not_claim_transaction -q— 成功test_template_section_repair.py+test_repair_diagnostics_routing.py+test_plan_refinement_loop.py+test_refinement_preflight.pyを同時実行し、186 件すべて成功した(PR 本文修正時点の heade72dbca0で再実行して再確認)。pnpm typecheck/pnpm lint/pnpm test(1872 件成功)/pnpm build/uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(24 件成功)を heade72dbca0で再実行しすべて成功を確認した。Schema Change Applicability
repair_issue_contract_result_v1.schema.jsonとrefinement_preflight_result_v1.schema.jsonの両方に、新規 optional top-level fieldstructural_repair_action(Issue 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の structural-repair 版 provenance schema)を additive に追加した。既存の必須フィールド集合・repair_action契約は変更していない。Schema Consumer Inventory
Before
After
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pye7c1e42bでbuild_structural_repair_bundle()/route_structural_repair_disposition()を production preflight 経路に接続し、disposition_summary を status/next_action へルーティングするロジックを追加した(回帰suiteで確認済み).claude/skills/issue-refinement-loop/tests/test_template_section_repair.py.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.pySafety Claim Matrix
.claude/skills/配下の変更を含むため safety-sensitive path 判定の対象になる。ただし変更内容は GitHub mutation / auth / hook boundary に触れない、mutation-free な Python classifier と additive JSON Schema 追加、およびその production wiring のみである。detect_missing_template_sections/build_structural_repair_bundle)は GitHub mutation / readback /gh/requests/urllibを一切呼ばないtest_producer_path_does_not_invoke_github_mutation(subprocess monkeypatch +inspect.getsource静的検査)template_value_exact/source_span_exact/derived_scalar_exact)のみを使い semantic prose を捏造しないtest_semantic_field_without_exact_source_requires_human_review/test_exact_template_value_can_be_auto_apply_safestructural_repair_actionschema field は additive(optional)で既存repair_action契約を破壊しないtest_structural_repair_provenance_validates_against_schema(後方互換ペイロードも同一テストで検証)+ aggregate regression 186 passedrun_refinement_preflight.pyはbuild_structural_repair_bundle()/route_structural_repair_disposition()を production preflight 経路から実際に呼び出し、disposition_summaryをstatus/next_actionに接続する(auto_apply_safe → needs_fix / apply_deterministic_structural_repair、human_review_required → blocked / human_judgment_required)run_refinement_preflight.pyの「Structural (template-derived) repair pass」ブロック(_resolve_structural_repair_template()呼び出しと後続の status/next_action 反映)+ schemaallOfinvariant +test_refinement_preflight.py回帰test_2039_opaque_action_compatibility_does_not_claim_transactionNotes
detect_missing_template_sections/build_structural_repair_bundle)は subprocess /gh/requests/urllibを一切呼ばないことを AC7 テストで monkeypatch + 静的ソース検査の両方で確認済み。run_refinement_preflight.pyは本 PR で未変更」と記載していた点を、実際の production wiring(fix_delta commite7c1e42b)を反映するよう修正した。あわせてrepair_issue_contract.pyのroute_structural_repair_disposition()直前にあった stale な scope-disclosure コメント(run_refinement_preflight.pyがbuild_structural_repair_bundle()を呼ばない、という 0fd2fba 当時の記述)も、実際の条件付き wiring を反映するよう commite72dbca0で更新した(ロジック変更なし、コメントのみ)。