Repository navigation
fix: anchor scope reframe の payload 不在判定を fail_closed から freeform lane 継続へ変更する - #2171
Conversation
…e 継続へ変更する (#2156) _classify_anchor_scope_reframe() の genuine absence(```yaml fence 自体が 存在しない)分岐を status: not_applicable へ変更し、trusted author の freeform コメントが不要に hard stop されないようにする。present-but-invalid (fence は存在するが malformed YAML / wrong schema_version、blockquote 埋め込み含む)は新設の _anchor_scope_reframe_fence_present() で区別し、従来 どおり fail_closed(schema_invalid: reason)を維持する。 _apply_multi_turn_candidate_route() は upstream status が fail_closed / not_applicable いずれでも no_anchor_scope_reframe_v1_payload reason を 正しく認識し、retrieval integrity confirmed 時の advisory upgrade と unconfirmed 時の blocking 維持(not_applicable への意味的降格防止)を両立 する。plan_refinement_loop.py::_project_scope_delta_decision_to_approval() は not_applicable ケースでも trusted author の anchor comment 証跡 (comment_url/body_sha256/author_association/required_rerun)を失わない よう修正した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2171 closed). |
- .claude/settings.json を origin/main の内容に revert(Allowed Paths 外の意図しない変更だったため) - run_refinement_preflight.py の schema_invalid reason 文字列を implicit concatenation で 120文字以内に分割(ruff E501 修正、AC3 の挙動は変更なし) - anchor-comment-handling.md の新規見出しに日本語を追加して Japanese Check の閾値を満たす
敵対的レビュー結果Verdict: PR #2171 は現在 Draft で、head は 特に、以下の2件はマージブロッカーです。 FindingsP0-1: retrieval integrity 未確認時の |
| コメント内表現 | GFM上の扱い | 現行presence判定 |
|---|---|---|
> > \```yaml |
nested blockquote内のfence | false |
\````yaml |
4-backtick fence | false |
~~~yaml |
tilde fence | false |
- \```yaml |
list内fence | false |
\```YAML |
info stringの表記違い | false |
その結果、本文中に ANCHOR_SCOPE_REFRAME_V1 を意図した構造化ブロックが存在していても、
_parse_anchor_scope_reframe_body()→None_anchor_scope_reframe_fence_present()→False- genuine absence と誤分類
status: not_applicable_structured_anchor_payload_present_but_invalid()→False- 同じコメント本文が freeform authority として再解釈される
という fail-open が成立します。
これは #2053 の「structured payload が invalid/stale/wrong-target の場合、freeform への downgrade fallback を禁止する」というAC2に直接反します。
また、#2156のOutcome自身も「fenced block が存在する present-but-invalid は fail_closed に維持する」ことを求めています。
必要な修正
正規表現を2本並べるのではなく、単一の line-oriented scanner で以下の三値を生成すべきです。
absent
present_invalid
valid
最低限、scannerは次を処理する必要があります。
- backtick fence長 3以上
- tilde fence
- opening/closing fence長の整合
- 0〜3スペースのインデント
- blockquote markerとnested blockquote
- list indentation
- EOFまで閉じられないfence
- 複数fence
ANCHOR_SCOPE_REFRAME_V1marker/key family の存在
Markdown全体をレンダリングする必要はありません。リポジトリにはMarkdown parser依存がなく、現在の依存は PyYAML と jsonschema なので、この限定scannerを内部実装する方が変更範囲を抑えられます。
P1-3: AC8の「producer→consumer統合テスト」という主張が実際のテスト内容と一致しない
Issue #2156 AC8 は、実際の _classify_anchor_scope_reframe() の戻り値を次の順序で通す統合テストを要求しています。
_classify_anchor_scope_reframe()
→ _apply_multi_turn_candidate_route()
→ _project_scope_delta_decision_to_approval()
さらに4シナリオすべてを対象としています。
ところが test_producer_consumer_chain_classify_to_route_to_approval() は、名前に to_approval を含むにもかかわらず、実際には classifier と multi-turn route までしか呼んでいません。_project_scope_delta_decision_to_approval() は一度も実行していません。
projectionを確認する別テストはありますが、single-turn genuine absence の1ケースだけです。
したがってPR本文の以下の主張は過大です。
- AC8で classifier→route→projection の実結合を検証した
- 4シナリオすべてをカバーした
このリポジトリでは、PR #2096でも「E2Eと称したテストがdirect APIやhand-injected入力だけを使い、canonical entrypointを通っていない」ことが OWNER blocker として扱われています。今回も同じfalse-greenパターンです。
必要な修正
- 少なくとも、4シナリオそれぞれについて routed decision を projection に入力し、approvalの全フィールドを検証する。
- P0-1の修正と合わせ、可能なら
run_preflight()→ planner subprocess → final artifact/exit codeまで通す。 - テスト名とPR本文の「実結合」「E2E」という表現を、実際の到達範囲に合わせる。
P1-4: _project_scope_delta_decision_to_approval() の変更範囲が intended pair より広い
修正前は status == not_applicable ならbase resultを返していました。修正後は、すべてのdecision辞書について即座に次を実行します。
present = True- comment URL/hash/author/rerunをコピー
reason == no_anchor_scope_reframe_v1_payloadならmissing_marker- それ以外は
invalid_scope_delta_approval
しかし #2156 が対象としているのは、次の限定された組み合わせです。
status == not_applicable
reason == no_anchor_scope_reframe_v1_payload
trusted-author anchor evidenceあり
現状の実装では、将来または別producerが返す以下の入力まで意味変更されます。
{"status": "not_applicable"}{
"status": "not_applicable",
"reason": "some_other_not_applicable_reason"
}これらは従来の present: false / status: missing ではなく、present: true / invalid_scope_delta_approval へ変わります。さらに、URL/hash/authorが欠落していても present: true になります。
必要な修正
分岐を意図した組み合わせに限定してください。
if decision.get("status") == "not_applicable":
if decision.get("reason") != "no_anchor_scope_reframe_v1_payload":
return base
if not valid_required_provenance(decision):
return base # または明示的な integrity failure最低限、以下の回帰テストが必要です。
- bare
status: not_applicable - unrelated reason
- intended reasonだがURL/hash/association欠落
- intended reasonかつ完全なtrusted evidence
P2: 無関係なYAML例まで structured reframe attempt として扱う
逆方向の誤判定もあります。
_anchor_scope_reframe_fence_present() は ANCHOR_SCOPE_REFRAME_V1 の存在を見ず、任意の完全一致 ```yaml fence を present と判定します。
例えばOWNERが技術レビュー内に次のような無関係なYAML例を含めた場合です。
timeout: 90
retries: 3このコメントは、
- ANCHOR payload parserでは対象schemaでないため
None - presence helperではtrue
schema_invalid- freeform authority fallback禁止
となります。
#2086は、operator-selected human-context の自然言語directiveを、手書き ANCHOR_SCOPE_REFRAME_V1 なしで継続させるための仕組みです。無関係なYAMLスニペットが一つあるだけでそのlane全体を閉じるのは、既存設計との摩擦が大きい挙動です。
structured attempt のpresenceは、少なくとも以下のどちらかで判断すべきです。
ANCHOR_SCOPE_REFRAME_V1markerの存在schema_version、target、decision、allowed_path_deltas等のreframe key familyの組み合わせ
「任意のYAML fenceを意図的にfail-closedにする」という方針なら、Issue本文・reference・テストで明示する必要があります。
最低限のマージ条件
-
multi-turn integrity failureをcanonical blockerへ接続する
helper辞書のfail_closedだけではなく、finalSTATUS: blocked / exit 2を保証する。 -
freeform evidence生成より前にintegrity routeを確定する
blocking判定後にauthority evidenceが残らないようにする。 -
regex presence checkをtri-state scannerへ置換する
GFMの3+ backticks、tilde、indent、blockquote、list、unclosed fenceを扱う。 -
AC8テストを本当のproducer→route→projection、可能ならwrapper E2Eにする
最終artifact、blocker、status、exit codeまで確認する。 -
approval projectionを exact intended pair に限定する
他のnot_applicableproducerの意味を変更しない。
CI green は確認できますが、現在のテストは関数返却値を中心に確認しており、P0-1のcanonical enforcement gapとP0-2のGFM入力空間を通過していません。現状のままでは、PR本文のSafety Claim MatrixとAC6・AC8達成宣言は支持できません。
- P0-1: multi-turn integrity unconfirmed の fail_closed に専用 reason (multi_turn_anchor_context_retrieval_integrity_unconfirmed) を付与し、 ANCHOR_MULTI_TURN_FAIL_CLOSED_REASONS 集合でメンバーシップ判定するよう 呼び出し元を更新。blocking 確定時は先行構築済みの freeform scope_delta_authority_evidence を known_context から除去する。 - P0-2/P2: _anchor_scope_reframe_fence_present() を単一正規表現から line-oriented tri-state スキャナに置き換え、4+backtick/tilde fence/nested blockquote/大文字小文字を扱いつつ、無関係な yaml fence を 誤って present 判定しないよう内容の関連性も評価する。 - P1-3: producer(_classify_anchor_scope_reframe)→consumer (_apply_multi_turn_candidate_route)→projection (_project_scope_delta_decision_to_approval) の実結合を4シナリオ全てで 検証するようテストを拡張。 - P1-4: _project_scope_delta_decision_to_approval() の not_applicable evidence populate 分岐を、意図した reason (no_anchor_scope_reframe_v1_payload) のみに限定。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
OWNER adversarial review (#2171 comment 5294728549) fix_delta 完了報告head 「最低限のマージ条件」5件への対応1. P0-1(safety gap): multi-turn integrity 未確認時の fail_closed が canonical blocker に伝搬しない
2. P0-2(fail-open safety gap): fence presence 判定が GFM の妥当な fence 形式を取りこぼす
3. P2(逆方向の誤判定): 無関係な ```yaml fence まで structured reframe attempt として扱う
4. P1-3: AC8 の producer→consumer 統合テストが projection まで到達していない
5. P1-4:
検証結果
Allowed Paths 内の 7 ファイルのみを変更しています( |
Summary
_classify_anchor_scope_reframe()の genuine absence 分岐(本文に ```yaml fence 自体が存在しない)をstatus: fail_closedから `status: not_applicable` へ変更し、trusted author の freeform コメントが不要に hard stop されず、既存の freeform lane(実装: fix(issue-refinement-loop): bind freeform OWNER scope authority end-to-end and expose routing telemetry #2053/実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086)を継続利用できるようにしました。_anchor_scope_reframe_fence_present()で genuine absence と present-but-invalid(fence は存在するが malformed YAML / 誤ったschema_version、blockquote 埋め込み含む)を区別し、present-but-invalid は従来どおりfail_closed(schema_invalid:reason)を維持しました。_apply_multi_turn_candidate_route()を修正し、upstreamstatusがfail_closed/not_applicableいずれでもno_anchor_scope_reframe_v1_payloadreason を正しく認識するようにしました。retrieval integrity confirmed 時は advisory upgrade(warn)、unconfirmed 時は blocking 維持(not_applicableへの意味的降格を防止)を両立します。plan_refinement_loop.py::_project_scope_delta_decision_to_approval()を修正し、genuine-absence ケース(status: not_applicable)でも trusted author の anchor comment 証跡(comment_url/body_sha256/author_association/required_rerun)を失わないようにしました。最終的なapproval["status"](missing_marker)と_decide_scope_signal_route()のルートは変更していません。references/anchor-comment-handling.md/references/scope-signal-guard.mdを新しい tri-state 挙動に合わせて更新しました。Checks
以下の検証コマンドはすべて Issue #2156 の Verification Commands をそのまま実行し、全て合格したことを確認しました。
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py::TestGenuineAbsenceVsPresentInvalidTriState::test_genuine_absence_vs_present_invalid_tri_state -v— 合格しました(AC1 の検証)rg -n "no_anchor_scope_reframe_v1_payload" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py— 合格しました(AC2、baseline-expect: pass)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py::TestGenuineAbsenceVsPresentInvalidTriState::test_present_invalid_wrong_schema_version_stays_fail_closed -v— 合格しました(AC3 の検証)rg -n "wrong_repo" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py— 合格しました(AC4、baseline-expect: pass)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py::test_genuine_absence_integrity_confirmed_advisory_upgrade_via_classifier -v— 合格しました(AC5 の検証)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py::test_genuine_absence_integrity_unconfirmed_stays_blocking_via_classifier -v— 合格しました(AC6 の検証)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py::test_not_applicable_genuine_absence_preserves_anchor_evidence -v— 合格しました(AC7 の検証)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py::test_producer_consumer_chain_classify_to_route_to_approval -v— 合格しました(AC8。producer→consumer chain の実結合検証)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q— 1322 件すべて合格しました(AC9。既存テストへの regression はありません)Schema Change Applicability
not_schema_changescope_delta_decision.statusの値集合(approved_by_trusted_anchor | not_applicable | fail_closed)はreferences/scope-signal-guard.mdの既存 schema コメントに既にnot_applicableを含んでおり、新しい値・新しいキー・新しい型は導入していません。本 PR は「どの分岐がどの既存 status 値を返すか」という producer 側の内部ロジックのみを変更しており、cross-file consumer boundary となる schema 定義自体(キー集合・型・enum 値の追加削除)は変更していません。consumer 側(_project_scope_delta_decision_to_approval())は既存のnot_applicable分岐を維持したまま evidence 投影のタイミングのみを修正しました。Schema Consumer Inventory
対象外(
not_schema_changeのため)。Safety Claim Matrix
test_genuine_absence_vs_present_invalid_tri_state、test_no_yaml_block_genuine_absence_not_applicabletest_present_invalid_wrong_schema_version_stays_fail_closed、test_malformed_yaml_fail_closed、test_quoted_yaml_block_fail_closedtest_genuine_absence_integrity_confirmed_advisory_upgrade_via_classifiertest_genuine_absence_integrity_unconfirmed_stays_blocking_via_classifiertest_not_applicable_genuine_absence_preserves_anchor_evidenceclassify_scope_delta_authority()/_build_scope_delta_authority_evidence()自体は変更しないscope_signal_delta.pyを含まない(git diff で確認可能)Notes
issue-contract-reviewの contract snapshot はmissing_goでしたが、導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 Owner Decision により telemetry 扱いとし、着手判断には使用していません。Current Validated Scopeに明記された 4 関数(_parse_anchor_scope_reframe_body()/ 新設 presence ヘルパー、_classify_anchor_scope_reframe()、_apply_multi_turn_candidate_route()、_project_scope_delta_decision_to_approval())のみを変更し、classify_scope_delta_authority()/_build_scope_delta_authority_evidence()/scope_signal_delta.pyは変更していません(Out of Scope 遵守)。test_anchor_scope_reframe_preflight.py::test_no_yaml_block_fail_closed(AC2 の期待値変更に合わせてリネーム・更新)、test_anchor_scope_reframe_downgrade_safety.py::test_no_structured_payload_keeps_legitimate_freeform_lane_open(同様に期待値更新))を、genuine absence の新しいnot_applicable挙動に合わせて更新しました。それ以外の既存テスト(test_quoted_yaml_block_fail_closed/test_malformed_yaml_fail_closed含む)は無改変のまま green です。Runtime Verification Evidence(動作検証証跡)
## Runtime Verification Applicabilityのexecution_environment(uv run --locked pytest、リポジトリ内 in-process 実行、外部プロセス起動・ネットワーク通信なし)どおり、AC8 の統合テスト(test_producer_consumer_chain_classify_to_route_to_approval)は_classify_anchor_scope_reframe()の実際の戻り値を_apply_multi_turn_candidate_route()に通す実結合テストとして実装し、PASS しました(skip_conditions: なしのとおり SKIP なし)。.claude/skills/issue-refinement-loop/tests/全体(1322 tests)が green です(AC9 の pass 件数・fail 0 件の証跡)。受け入れ条件の達成状況
_anchor_scope_reframe_fence_present()が genuine absence と present-but-invalid を区別する。status: not_applicable、reason: no_anchor_scope_reframe_v1_payloadを維持。status: fail_closedのまま維持、not_applicableにならない。wrong_repo/wrong_issue_number/staleは引き続きfail_closed。warn/multi_turn_anchor_context_trusted_owner_advisoryへ昇格(upstream status が fail_closed / not_applicable いずれでも)。fail_closed、implementation_go: false)維持、not_applicableへの降格なし。_project_scope_delta_decision_to_approval()はnot_applicableでも anchor comment 証跡フィールドを populate する。_classify_anchor_scope_reframe()の実戻り値を_apply_multi_turn_candidate_route()/_project_scope_delta_decision_to_approval()に通す統合テストで 4 シナリオ全てをカバー。.claude/skills/issue-refinement-loop/tests/全体 green(1322 passed)。本 PR のマージにより Issue #2156 をクローズします。Closes #2156