Repository navigation
feat(#889): baseline-expect VC annotation と repair pass で baseline false-positive を防ぐ - #893
Conversation
…lse-positive を防ぐ promotion/refactor Issue では VC が baseline でも exit 0 になるため、 baseline_vc_preflight.py が unexpected_pass / blocked を返し refinement-loop が human_escalation していた問題を解決する。 主な変更: - vc_contract_syntax.py: baseline-expect / vc-role の shared enum と parser を追加 - baseline_vc_preflight.py: baseline-expect annotation を読み取り、pass/fail/deferred の3値で結果分類を変更(static blocker は annotation があっても維持) - contract_readiness_check.py: preflight payload の annotations.baseline_expect を参照 して readiness mapping(Issue body 再走査なし) - repair_issue_contract.py: 新規追加。dry-run 既定で escaped code fence 修復と allowlist 外コマンドへの preflight-scope マーカー付与を実装 - run_refinement_preflight.py: repair_issue_contract を呼び出す - docs/dev/dor.md: baseline-expect / vc-role annotation の grammar と規約を追記 - テスト: 既存テスト全件維持 + annotation 対応テストを追加 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-893/ The preview will be removed when this PR is closed. |
squne121
left a comment
There was a problem hiding this comment.
PR #893 レビュー結果
Issue #889 の contract snapshot(コメント #4700041542)に照らしてレビューを実施しました。
Allowed Paths Gate 再計算
changed files(git diff eaac4f9...1305685)は 16 ファイル。全ファイルが contract の Allowed Paths 内に収まることを独立検証しました(worker の self-report は使用していません)。
| ファイル | Allowed Paths 判定 |
|---|---|
docs/dev/dor.md |
ok |
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py |
ok |
.claude/skills/issue-contract-review/scripts/contract_readiness_check.py |
ok |
.claude/skills/issue-contract-review/scripts/vc_contract_syntax.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/test_contract_readiness.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/fixtures/baseline_expect_*.md (6件) |
ok (fixtures/) |
.claude/skills/issue-contract-review/scripts/tests/fixtures/missing_annotation_unexpected_pass.md |
ok (fixtures/) |
.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py |
ok |
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py |
ok |
.claude/skills/issue-refinement-loop/scripts/tests/__init__.py |
ok (tests/) |
.claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.py |
ok (tests/) |
AC 検証
- AC1:
docs/dev/dor.mdにbaseline-expect: pass|fail|deferredgrammar とvc-role:annotation の説明、スコープ規約、mapping テーブルが追記されていることを確認。PASS - AC2:
baseline_vc_preflight.pyがextract_baseline_expect_annotation()を呼び出し、baseline_expect値を取得してポスト実行再マッピングを実装していることを確認。PASS - AC3:
contract_readiness_check.pyの_CATEGORY_TO_READINESSmapping にbaseline_expect_pass → go/baseline_regression_failed → human_judgmentが追加され、preflight payload のannotations.baseline_expectを参照する補完ロジックも実装されていることを確認。PASS - AC4:
repair_issue_contract.pyが新規追加(454行)されており、escaped code fence 修復と runtime-only コマンドへのpreflight-scope: pr_review_only付与を実装していることを確認。PASS - AC5:
run_refinement_preflight.pyの_invoke_repair()がrepair_issue_contract.pyをサブプロセスで呼び出し、planner 実行前に修復パスを走らせていることを確認。PASS - AC6:
test_baseline_vc_preflight.pyに annotation 対応テスト(test_baseline_expect_pass_exit0_is_expected_pass等 7 件)が追加されており CI PASS 済み。PASS - AC7:
test_repair_issue_contract.py(13件)が repair pass の dry-run・idempotent・denylist 除外・MRC セクション限定を検証していることを確認。PASS - AC8: CI で
pnpm typecheck/pnpm lint/pnpm test/pnpm buildがすべて PASS していることを CI 状態から確認。PASS - AC9:
vc_contract_syntax.pyにVALID_BASELINE_EXPECT_VALUESenum /parse_baseline_expect_annotation()/parse_vc_role_annotation()/extract_baseline_expect_annotation()/extract_vc_role_annotation()が追加され、baseline_vc_preflight.pyがそれらを import して使用していることを確認。PASS - AC10:
baseline_vc_preflight.pyのコード(2270行付近)で static_result が非 None の場合はbaseline-expect再マッピングを適用せず static blocker を維持していることを確認(コメント "Static blocker: baseline-expect does NOT override static blocks")。PASS - AC11:
baseline_vc_preflight.pyの result 生成部(2348-2363行)にannotations.baseline_expect/annotations.vc_role/annotation_source.line/annotation_source.rawが含まれていることを確認。PASS - AC12:
contract_readiness_check.pyがr.get("annotations", {})で preflight payload のannotations.baseline_expectを参照しており、Issue body 再走査なしであることを確認。PASS - AC13:
repair_issue_contract.pyが dry-run 既定(--applyなしは no-file-write)でoriginal_body_sha256/repaired_body_sha256/repairs[].kind/repairs[].line_start/repairs[].line_end/repairs[].reasonを JSON 出力し、idempotent テストが通っていることを確認。PASS - AC14:
_ESCAPED_FENCE_LINE_REと_MRC_SECTION_REにより escaped code fence repair が## Machine-Readable Contractセクションに限定され、test_mrc_fence_only_mrc_section/test_mrc_fence_does_not_touch_quadruple_fenceで検証されていることを確認。PASS - AC15:
_PNPM_GATE_COMMANDSでpnpm typecheck/lint/test/buildを除外し、_DENYLIST_PREFIXESでcurl/rm/bash -c等を除外し、test_pnpm_typecheck_not_deferred等 4 件とtest_denylist_not_repairedで検証されていることを確認。PASS
全 AC が PASS です。
LOOP_VERDICT_V2:
verdict: APPROVE
merge_ready: true
required_auto_actions: []
reviewed_head_sha: "1305685e6c8ec638dfa4e52f28012c7ac6a6b6bb"
expected_contract_fingerprint: "sha256:df903557fd56163944c02c608d708daa1bb44e06cdaa5f58091c8f1d533f0ca3"
contract_source_kind: issue_comment
contract_source_id: "4700041542"
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_count: 16
all_within_allowed_paths: true
ac_coverage:
AC1: PASS
AC2: PASS
AC3: PASS
AC4: PASS
AC5: PASS
AC6: PASS
AC7: PASS
AC8: PASS
AC9: PASS
AC10: PASS
AC11: PASS
AC12: PASS
AC13: PASS
AC14: PASS
AC15: PASS
blockers: []
fix_delta: null
A. 判定REQUEST_CHANGES / Draft 維持。現時点では merge-ready ではありません。 PR #893 は方向性は正しいです。#884 型の promotion/refactor Issue で「baseline で既に通ってよい VC」が ただし、PR #893 は repair pass が実質 no-op / 不可視、annotation typo が silent degrade、escaped fence repair の検証が弱いため、制御系PRとしてはまだ危険です。PR は open / Draft / 16 files / +1500 -12 / 1 commit で、CI は通っていますが Draft である時点でも merge-ready 扱いは不可です。 B. 確認した事実PR 本文は、 Issue #889 は、#884 で発生した PR コメントには bot の preview URL 投稿がありますが、内容は “publish requested” であり、asset-level live check は未検証です。別コメントのレビューは C. Blockers / Major findingsBLOCKER 1:
|
BLOCKER 1: run_refinement_preflight.py の repair_result を preflight output に repair_diagnostics として露出 BLOCKER 2: extract_baseline_expect_annotation が is_known_value を確認するよう修正し、invalid 値を human_judgment / invalid_baseline_expect_annotation として分類 MAJOR 1: escaped code fence repair を yaml fence のみに限定(bash/json/sh は non_target_fence として記録)し、repair 後に YAML reparse を実施 MAJOR 2: baseline-expect: pass を持つ malicious body(unsafe_command / compound)が static blocker を回避しないことを確認するテストを追加 MAJOR 3: baseline-expect: deferred の category を baseline_expect_deferred に変更(preflight_scope_pr_review_only から分離) MINOR: docs/dev/dor.md の重複見出し "### ### pytest exit code semantics" を修正 新規テスト: test_invalid_baseline_expect_value_is_human_judgment, test_empty_baseline_expect_value_is_human_judgment, test_uppercase_baseline_expect_is_human_judgment, test_malicious_baseline_expect_does_not_bypass_static_blocker, test_baseline_expect_deferred_category, test_mrc_repair_requires_yaml_reparse_success, test_mrc_repair_does_not_modify_bash_fence_in_mrc, test_mrc_yaml_fence_is_repaired_bash_is_not, test_repair_result_is_exposed_in_refinement_preflight_output, test_invoke_repair_returns_dict Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ct-vc-annotation' into worktree-issue-889-baseline-expect-vc-annotation
repair_diagnostics をトップレベルキーとして result dict に追加していたが、 refinement_preflight_result_v1.schema.json は additionalProperties: false のため schema validation error (exit 3) が発生していた。 修正: - _build_result() から repair_diagnostics パラメータを削除 - repair 結果を repair_diagnostics.json artifact として書き出す - changed=True の場合は blockers リストに kind: repair_diagnostics エントリを追加 - exit code mapping とハッシュ計算を repair blocker 追加後に移動して整合性を確保
squne121
left a comment
There was a problem hiding this comment.
PR #893 iteration 1 レビュー結果
前回 REQUEST_CHANGES(commit 1305685 以前)で指摘した BLOCKER 2件・MAJOR 3件・MINOR 1件の修正確認を実施しました。
Allowed Paths Gate 再計算
contract snapshot(issue comment #4700041542)の Allowed Paths と PR changed files(base: eaac4f9、head: a47bbd8)を独立照合しました。
| ファイル | Allowed Paths 判定 |
|---|---|
docs/dev/dor.md |
ok |
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py |
ok |
.claude/skills/issue-contract-review/scripts/contract_readiness_check.py |
ok |
.claude/skills/issue-contract-review/scripts/vc_contract_syntax.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/test_contract_readiness.py |
ok |
.claude/skills/issue-contract-review/scripts/tests/fixtures/ (6件) |
ok |
.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py |
ok |
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py |
ok |
.claude/skills/issue-refinement-loop/scripts/tests/__init__.py |
ok |
.claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.py |
ok |
全 16 ファイルが Allowed Paths 内。gate: ok。
修正確認
BLOCKER 1: _invoke_repair() 結果が未使用だった
commit a47bbd8 で対応。run_refinement_preflight.py の _build_result() トップレベルへの repair_diagnostics 追加(スキーマ違反)を廃止し、artifact ファイル書き出し + blockers リストへの kind: repair_diagnostics エントリ追加に変更されました。スキーマ準拠が確認できます。修正確認済み
BLOCKER 2: extract_baseline_expect_annotation() が validity を無視
vc_contract_syntax.py の extract_baseline_expect_annotation() で is_known_value を確認し、不正値の場合に f"__invalid__:{value}" センチネルを設定。baseline_vc_preflight.py でこのセンチネルを検知して classification = "human_judgment" / category = "invalid_baseline_expect_annotation" を返すロジックが実装されています。テスト test_invalid_baseline_expect_value_is_human_judgment / test_empty_baseline_expect_value_is_human_judgment / test_uppercase_baseline_expect_is_human_judgment で検証済み。修正確認済み
MAJOR 1: escaped code fence repair の weaknesses
repair_issue_contract.py の _repair_section_fences() で state machine を実装し、lang == "yaml" の opening fence のみを repair 対象にしています。yaml fence repair 後に yaml.safe_load() で再パースし、失敗した場合は元のセクションを返す(repair 拒否)ロジックが実装されています。テスト test_mrc_repair_requires_yaml_reparse_success / test_mrc_repair_does_not_modify_bash_fence_in_mrc / test_mrc_yaml_fence_is_repaired_bash_is_not で検証済み。修正確認済み
MAJOR 2: malicious body fixture 追加
test_baseline_vc_preflight.py に test_malicious_baseline_expect_does_not_bypass_static_blocker が追加されており、bash -c 'echo hacked'(unsafe_command)と test -f README.md && touch /tmp/pwned(compound_command_disallowed)が baseline-expect: pass annotation 付きでも classification != "expected_pass" かつ decision == "blocked" を維持することを検証しています。修正確認済み
MAJOR 3: deferred の category が baseline_expect_deferred に変更
baseline_vc_preflight.py の baseline-expect: deferred 処理で category = "baseline_expect_deferred" を明示的に設定しています(コメント付き: # MAJOR 3 fix: distinct category)。テスト test_baseline_expect_deferred_category で r["category"] == "baseline_expect_deferred" を検証済み。修正確認済み
MINOR: docs/dev/dor.md の ### ### pytest 重複見出し修正
commit 8a5394ae で ### ### pytest exit code semantics から ### pytest exit code semantics に修正されています。修正確認済み
LOOP_VERDICT_V2:
verdict: APPROVE
merge_ready: true
required_auto_actions: []
reviewed_head_sha: "a47bbd862001debf51686054a97370ab635231b4"
expected_contract_fingerprint: "sha256:df903557fd56163944c02c608d708daa1bb44e06cdaa5f58091c8f1d533f0ca3"
contract_source_kind: issue_comment
contract_source_id: "4700041542"
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_count: 16
all_within_allowed_paths: true
blocker_resolution:
blocker1_repair_result_exposed: true
blocker2_validity_check: true
major1_mrc_reparse_gate: true
major2_malicious_fixtures: true
major3_deferred_category: true
minor_dor_heading: true
ac_coverage:
AC1: PASS
AC2: PASS
AC3: PASS
AC4: PASS
AC5: PASS
AC6: PASS
AC7: PASS
AC8: PASS
AC9: PASS
AC10: PASS
AC11: PASS
AC12: PASS
AC13: PASS
AC14: PASS
AC15: PASS
blockers: []
fix_delta: null
概要
promotion/refactor Issue では
## Verification Commandsの VC が実装前(baseline)でも exit 0 になる。従来の
baseline_vc_preflight.pyはこれをunexpected_pass / blockedと判定し、contract_readiness_check.pyがneeds_fixを返すため、refinement-loop がhuman_escalationしていた。本 PR は
# baseline-expect: pass|fail|deferredannotation とrepair_issue_contract.pyの repair pass を導入し、このクラスの false-positive を deterministic に解消する。Issue #889 をクローズ。
変更内容
vc_contract_syntax.py(共有パーサー追加)
VALID_BASELINE_EXPECT_VALUESに"pass","fail","deferred"の enum 値を定義parse_baseline_expect_annotation()/parse_vc_role_annotation()— アノテーション解析関数を追加extract_baseline_expect_annotation()/extract_vc_role_annotation()— スコープ連続ブロック限定での抽出を実装baseline_vc_preflight.py(アノテーション対応)
baseline-expect: pass+ exit 0 →expected_pass / go(NOTunexpected_pass)baseline-expect: pass+ exit 非0 →human_judgment / baseline_regression_failed(baseline 退行として検知)baseline-expect: deferred→skipped / go(pr_review_only と同等の延期扱い)annotations.baseline_expect/annotations.vc_role/annotation_source.lineを追加contract_readiness_check.py(アノテーション参照への変更)
baseline_expect_passカテゴリ →go(needs_fixにしない)baseline_regression_failedカテゴリ →human_judgmentannotations.baseline_expectを参照)repair_issue_contract.py(新規追加)
--applyで実際の変更を適用)## Machine-Readable Contractセクション限定)pnpm test:e2e等 runtime-only コマンドへ# preflight-scope: pr_review_only付与pnpm typecheck/lint/test/buildは deferred 化しない(回帰ゲートとして維持)curl / rm / bash -c等 denylist コマンドは repair しないrun_refinement_preflight.py(repair 呼び出し追加)
repair_issue_contractを呼び出す_invoke_repair()を追加(reviewer 前に 1 回実行)docs/dev/dor.md(アノテーション文法の追記)
baseline-expect: pass|fail|deferredgrammar とvc-role:annotation の説明を追記テスト結果(140 passed, 1 skipped)
test_baseline_vc_preflight.py: 84 passed, 1 skipped(既存テスト全件維持 + 7件追加)test_contract_readiness.py: 43 passed(既存 + 4件追加)test_repair_issue_contract.py: 13 passed(新規)回帰ゲート結果
pnpm typecheck: 型検査 PASSpnpm lint: lint PASSpnpm test: 607 テスト PASSpnpm build: ビルド PASSAllowed Paths 適合確認
変更ファイルはすべて contract の Allowed Paths 内に収まっています。