Skip to content

実装: RDR001/command_not_allowed taxonomy と readiness semantics の split-brain を解消する #1564

Closed as not planned

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "reviewer_claim_replay.py と contract_readiness_check.py の RDR001 / command_not_allowed taxonomy を実 readiness/preflight producer から deterministic backing させ、readiness authority(human_judgment)と replay authority(proceed_to_rewrite)の split-brain を解消する"
change_kind: code

Parent Issue

none(単独改善)

Background

Parent Goal Ref

Current Validated Scope

  • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py の _PREFLIGHT_CATEGORY_TO_READINESS マッピングに command_not_allowed エントリを追加する
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 に command_not_allowed と RDR001(required_design_references_missing_or_empty)の taxonomy entry を追加し、両者について rule_id と category の AND semantics(OR ではない)による producer-shape 検証を行う
  • 上記変更に対応するテストを既存の taxonomy parity/producer-shape テストファイルに追加・更新する

Remaining Parent Gaps

Outcome

.claude/skills/issue-contract-review/scripts/contract_readiness_check.py の _PREFLIGHT_CATEGORY_TO_READINESS に "command_not_allowed": "needs_fix" が追加され、かつ .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 に command_not_allowed と RDR001(required_design_references_missing_or_empty)の taxonomy entry が追加されて、両エントリの evidence 判定が rule_id と category の AND semantics + broad_search_path_unbounded と同水準の producer-shape 検証(baseline_vc_preflight/v1 schema、classification/category/decision/scope_class の完全一致)で行われ、wrong source/wrong category/wrong rule/stale body_sha256 の evidence がすべて reject される状態。対応する新規テストが .claude/skills/issue-contract-review/tests/test_contract_readiness_check_broad_search_path.py と .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py / .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py に追加され、全 AC が PASS している。

In Scope

  • contract_readiness_check.py の _PREFLIGHT_CATEGORY_TO_READINESS に "command_not_allowed": "needs_fix" を追加する(VC body の再構成で解消可能な body-author-fixable な問題として扱う。compound_command_disallowed / broad_search_path_unbounded と同じ扱い)
  • reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 に以下 2 エントリを追加する:
    • command_not_allowed: readiness_rule_ids == ["VCP_COMMAND_NOT_ALLOWED"]/readiness_rule_id_source_check == "baseline_vc_preflight"/readiness_categories == ["command_not_allowed"]/readiness_category_source_check == "baseline_vc_preflight"
    • rdr001(entry_id は rdr001 または required_design_references_missing_or_empty のいずれか実装判断で確定してよい): readiness_rule_ids == ["RDR001"]/readiness_rule_id_source_check == "contract_readiness_check"/readiness_categories == ["required_design_references_missing_or_empty"]/readiness_category_source_check == "contract_readiness_check"
  • 上記 2 エントリを _STRICT_READINESS_SOURCE_PAYLOAD_KINDS 相当(rule_id かつ category の AND 一致、source_check 一致、加えて wrong source/wrong category/wrong rule の reject)の対象に加える
  • command_not_allowed エントリについては broad_search_path_unbounded と同様、direct vc_preflight_result を評価する経路(_matching_vc_preflight() 相当)でも vc_preflight_result.schema == "baseline_vc_preflight/v1"/該当 item の classification == "blocked"/category == "command_not_allowed"/decision == "blocked"/scope_class == "baseline_fail_expected" を全て満たす場合のみ evidence として受理する producer-shape 検証を追加する(_STRICT_VC_PREFLIGHT_PRODUCER_SHAPE_KINDS 相当への追加)
  • body_sha256 が review/readiness 間で不一致(stale evidence)の場合、command_not_allowed / RDR001 いずれの taxonomy entry も evidence として受理しないことを保証する(既存の analyze() の body hash fail-closed 挙動を両エントリにも適用する)
  • 上記すべてを検証する新規テストケースを以下のファイルに追加する:
    • .claude/skills/issue-contract-review/tests/test_contract_readiness_check_broad_search_path.py(readiness mapping 側: command_not_allowed → needs_fix の producer-shape テスト)
    • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py(taxonomy entry のフィールド形状テスト)
    • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py(producer-shape 検証 + wrong source/category/rule/stale body の reject テスト + readiness/replay authority 一致テスト)

Out of Scope

Acceptance Criteria

  • AC1: contract_readiness_check.py の _PREFLIGHT_CATEGORY_TO_READINESS に "command_not_allowed": "needs_fix" が追加され、schema: "baseline_vc_preflight/v1"/status: "blocked"/results[0] が classification: "blocked"、category: "command_not_allowed"、decision: "blocked"、scope_class: "baseline_fail_expected" を持つ preflight result を readiness 変換関数に渡すと、生成される readiness error が rule_id: "VCP_COMMAND_NOT_ALLOWED"/category: "command_not_allowed"/source_check: "baseline_vc_preflight" を持ち、overall status が "human_judgment" ではなく "needs_fix" になる
  • AC2: reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 に command_not_allowed エントリが存在し、readiness_rule_ids == ["VCP_COMMAND_NOT_ALLOWED"]/readiness_categories == ["command_not_allowed"]/readiness_category_source_check == "baseline_vc_preflight" を持つ
  • AC3: command_not_allowed の evidence 判定は rule_id と category の AND(rule_id だけ一致・category だけ一致のどちらの片側一致でも reject)で行われ、かつ direct vc_preflight_result を評価する場合は vc_preflight_result.schema != "baseline_vc_preflight/v1"、または該当 item の classification/category/decision/scope_class のいずれか 1 つでも broad_search_path_unbounded 相当の期待値と異なる場合は evidence として reject される
  • AC4: command_not_allowed エントリについて、wrong source_check(例: "validate_issue_body")を持つ readiness error、または review_result.body_sha256 と readiness_result.body_sha256 が不一致(stale body)の場合、evidence が reject され deterministic_backed が True にならない
  • AC5: reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 に RDR001(required_design_references_missing_or_empty)エントリが存在し、readiness_rule_ids == ["RDR001"]/readiness_rule_id_source_check == "contract_readiness_check"/readiness_categories == ["required_design_references_missing_or_empty"]/readiness_category_source_check == "contract_readiness_check" を持つ
  • AC6: RDR001 エントリについても AC3・AC4 と同様の AND semantics + wrong source/wrong category/wrong rule/stale body_sha256 の reject が成立する
  • AC7: 同一の command_not_allowed preflight evidence を (a) contract_readiness_check.py の readiness 変換関数に通した場合の readiness status("needs_fix")と、(b) 同じ evidence を reviewer_claim_replay.analyze() に command_not_allowed 相当の reviewer blocker code と共に渡した場合の deterministic_backed(True)/normalized_kind("command_not_allowed")の結果が矛盾しないこと(readiness が needs_fix を返しているのに replay が checker_gap/unbacked に倒れないこと)を新規テストが検証する

Verification Commands

# AC1
$ uv run --locked python3 -m pytest .claude/skills/issue-contract-review/tests/test_contract_readiness_check_broad_search_path.py -k test_command_not_allowed_maps_to_needs_fix -q
# AC2
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -k test_command_not_allowed_taxonomy_entry_fields -q
# AC3
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py -k test_command_not_allowed_producer_shape_and_semantics -q
# AC4
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py -k test_command_not_allowed_rejects_wrong_source_category_rule_stale_body -q
# AC5
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -k test_rdr001_taxonomy_entry_fields -q
# AC6
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -k test_rdr001_rejects_wrong_source_category_rule_stale_body -q
# AC7
$ uv run --locked python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py -k test_readiness_and_replay_authority_agree_for_command_not_allowed -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
  • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_broad_search_path.py
  • .claude/skills/issue-contract-review/tests/test_contract_readiness_check_broad_search_path.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • command_not_allowed を needs_fix ではなく human_judgment として扱うべきという判断が必要になった場合: 変更せず Issue comment で報告し、人間の判断を待つ
  • broad_search_path_unbounded の producer-shape 検証パターンが command_not_allowed / RDR001 にそのまま適用できない構造上の理由が判明した場合: 変更せず Issue comment で報告し、人間の判断を待つ

Required Skills

  • Python(辞書ベース taxonomy テーブル駆動設計 / jsonschema validation)

Required Design References

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-contract-review/SKILL.md
  • .claude/skills/issue-contract-review/references/vc-preflight.md

Scope Delta(任意)

N/A

Notes for Reviewer

Runtime Verification Applicability

本 Issue の変更対象は reviewer_claim_replay.py / contract_readiness_check.py という readiness/preflight producer の unit-level なロジック修正と、それに対応する pytest ベースの決定論的テストのみです。ゲームの実行時動作には影響しません。

decision: not_applicable
reason: "Unit-level readiness/preflight producer logic and pytest-only verification. No runtime game behavior changed."

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 18, 2026
  2. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 現状の Issue 契約では実装開始不可です。

    問題設定自体は妥当です。前提の #1554 は PR #1581 でマージ済みで、structured_blockers[].code が child claim に保全されるようになっています。一方、#1564 は「実際の blocker code の正規化」「producer-shape 検証の実装方式」「自動修復してよい範囲」を固定できていません。さらに、後発の #1810 が taxonomy を唯一の SSOT にする設計を要求しており、#1564 の局所的な special-case 追加と衝突します。

    Blocker 1 — Verification Commands が全件自己違反している

    #1564 の全 VC は、既存テストファイルに対する次の形式です。

    uv run --locked python3 -m pytest <existing-file> -k <new-test> -q

    現行 baseline_vc_preflight.py は、uv run に --locked 等が付いた状態で python3 -m を使用する形を runtime-smoke 専用形との衝突として command_not_allowed に分類します。直接 pytest を呼ぶ形だけが許可されます。

    さらに -k <未作成テスト名> を既存ファイルへ向ける形式も禁止されています。リポジトリの正規形は「まだ存在しない新規テストファイルへの node-id」であり、既存ファイルへの -k は pytest exit 5 による hard block 対象です。

    したがって、単に python3 -m を消すだけでは不十分です。専用テストファイルを新設して Allowed Paths に追加し、例えば次の形へ変更する必要があります。

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_command_not_allowed.py::test_taxonomy_entry -q

    --locked 自体は uv の正式なオプションであり、lockfile が最新であることと変更されないことを検証します。今回の拒否は uv の制約ではなく、このリポジトリ独自の VC allowlist 境界です。([Astral Docs]1)

    Blocker 2 — 実際の blocker code が taxonomy に解決される保証がない

    現在の taxonomy lookup が登録するのは次の値だけです。

    • reviewer_codes
    • deterministic_checks
    • domain_keys
    • entry_id

    readiness_rule_ids と readiness_categories は lookup に入りません。したがって、AC2/AC5 のとおり readiness fields だけを正しく設定しても、child claim の VCP_COMMAND_NOT_ALLOWED や RDR001 が unknown_blocker_type のまま残る実装が成立します。

    最低限、以下を AC で固定すべきです。

    command_not_allowed:
      entry_id: command_not_allowed
      reviewer_codes:
        - VCP_COMMAND_NOT_ALLOWED
        - command_not_allowed
      readiness_rule_ids:
        - VCP_COMMAND_NOT_ALLOWED
      readiness_categories:
        - command_not_allowed
    
    rdr:
      entry_id: <1つに固定する>
      reviewer_codes:
        - RDR001
        - required_design_references_missing_or_empty
      readiness_rule_ids:
        - RDR001
      readiness_categories:
        - required_design_references_missing_or_empty

    加えて、次を直接検証する AC が必要です。

    assert normalize_taxonomy_key("VCP_COMMAND_NOT_ALLOWED") == "command_not_allowed"
    assert normalize_taxonomy_key("RDR001") == "<固定したentry_id>"

    #1564 は RDR の entry_id を実装者判断に委ねていますが、後続の #1810 は entry_id と deterministic_domain_key の格納先を固定する前提です。domain_keys も含め、#1564 で値を確定させる必要があります。

    Blocker 3 — strict producer-shape の追加方法が現行コードと整合しない

    readiness 側の strict 処理は、名前だけが汎用的で、実装は完全に broad_search_path_unbounded 専用です。

    _STRICT_READINESS_SOURCE_PAYLOAD_KINDS = {
        "broad_search_path_unbounded"
    }
    
    def _has_valid_broad_search_source_payload(...):
        ...

    この集合へ RDR を追加すると、RDR evidence に存在しない broad-search 用 source_payload を要求するため、正しい RDR evidence まで全件 reject されます。RDR producer は rule_id/category/source_check を生成しますが、source_payload は生成していません。

    direct VC preflight 側も、集合へ command_not_allowed を追加しただけでは top-level schema しか検証されません。item 単位の classification/category/decision/scope_class 検証は、次の hardcoded 分岐に残っています。

    if kind == "broad_search_path_unbounded":
        ...

    そのため #1564 の「_STRICT_* 相当へ追加」という指示では、必要な安全性を満たす実装方式が一意になりません。

    一方、後発の #1810 は taxonomy を唯一の SSOT とし、第二の hardcoded dict・mapping・match 分岐を禁止しています。#1564 で if kind == "command_not_allowed" と if kind == "rdr001" を増やすと、#1810 の設計目的を先に破壊します。

    必要なのは、entry ごとの producer contract をデータとして表現する方式です。例えば概念的には以下です。

    {
        "entry_id": "command_not_allowed",
        "producer_contract": {
            "source_check": "baseline_vc_preflight",
            "schema": "baseline_vc_preflight/v1",
            "require_source_payload": True,
            "classification": "blocked",
            "category": "command_not_allowed",
            "decision": "blocked",
            "scope_class": "baseline_fail_expected",
        },
    }

    ただし taxonomy のキー集合変更は #1564 の Stop Conditions に抵触します。したがって、以下のどちらかを人間判断で確定するまで停止すべきです。

    1. 実装: RDR001/command_not_allowed taxonomy と readiness semantics の split-brain を解消する #1564 を 実装: fix(replay-taxonomy): readiness rule_id/category を deterministic_domain_key taxonomy に正規化する #1810 へ統合する
    2. 実装: RDR001/command_not_allowed taxonomy と readiness semantics の split-brain を解消する #1564 の契約を更新し、後続 resolver が消費できる producer metadata を taxonomy に追加する

    Blocker 4 — command_not_allowed 全体を needs_fix にする根拠が不足している

    command_not_allowed は一種類の本文ミスではありません。現行実装では、少なくとも以下が同じカテゴリになります。

    • 未知のコマンド

    • git commit、git push

    • gh api、gh issue edit

    • pnpm add

    • 許可されない uv run

    • env をコマンド wrapper として使う形

    明らかな危険コマンドは Issue 本文の書き換えで解消できます。しかし「未知コマンド」には、本来 first-class checker または allowlist 拡張が必要な tooling gap も含まれ得ます。現在の artifact には両者を機械的に区別する reason code がありません。

    その状態でカテゴリ全体を needs_fix にすると、正しい挙動が次のいずれなのか判断できません。

    • VC を安全な既存コマンドへ書き換える
    • 新しい first-class checker を実装する
    • allowlist policy owner へ送る
    • 危険な要求として拒否する

    command_not_allowed の producer に、例えば次の分類を追加してから readiness mapping を決めるべきです。

    reason_class:
      - body_author_fixable
      - tooling_gap
      - policy_violation
      - unsafe_mutation

    少なくとも body_author_fixable と明示されたものだけを needs_fix にし、それ以外は human_judgment または fix_checker_artifact に送る必要があります。これが #1564 の範囲外なら、本文にある Stop Condition を発火させるべきケースです。

    Blocker 5 — RDR001 は検出可能でも自動修復可能ではない

    RDR checker 自身が、正しい設計文書の選択には人間判断が必要であるため autofixable: False と明記しています。

    一方、replay が deterministic_fail_confirmed になると、現行フローは Step 4 の自動 rewrite へ進みます。

    つまり #1564 を実装すると、次の危険な経路が開きます。

    1. RDR001 の検出は決定論的に成功
    2. replay が deterministic-backed と判定
    3. issue-author が自動修正
    4. 単に存在するだけの無関係な文書を Required Design References に追加
    5. checker は PASS するが、意味的契約は悪化

    「検出が決定論的」と「修復対象を決定論的に選べる」は別です。次のいずれかが必要です。

    • RDR001 を自動 rewrite に送らず、人間判断経路へ分離する
    • investigation が選定した具体的な design reference 候補を署名済み入力として issue-author に渡す
    • issue-author が任意の既存文書を選べないことを E2E で検証する

    現行 Allowed Paths では routing 変更や author input 契約の修正ができないため、別 Issue への分割が妥当です。

    High — readiness artifact 自体の schema spoof を拒否できない

    現在の CLI は readiness artifact に対して body_sha256 と errors の存在しか検査していません。

    _validate_minimal_schema(
        readiness_result,
        "readiness-result-file",
        ("body_sha256", "errors"),
    )

    schema の固定値、各フィールドの型、未知フィールド、error item の形状は検証されません。したがって、body hash だけ一致させた手書き artifact が evidence として採用される余地があります。

    #1564 は malformed/spoofed evidence の fail-closed を Outcome に掲げていますが、AC3は direct VC preflight の schema しか対象にしていません。readiness 側にも以下が必要です。

    • schema の const
    • body_sha256、errors の required
    • object/array/string の型検査
    • error item の required fields
    • 未知フィールドを許可するか否かの明示
    • wrong schema/missing schema/wrong type の負テスト

    JSON Schema は、required を指定しなければ property の欠落を許し、additionalProperties を制限しなければ未知フィールドも許します。const、required、型、追加プロパティ方針を明示して初めて fail-closed 契約になります。(JSON Schema)

    High — AC7 は production chain を検証していない

    AC7 は readiness 変換関数と analyze() を同じ fixture で呼ぶだけです。これでは、途中のどこかで code が変換・欠落しても検出できません。

    #1554 完了後の実経路を使う必要があります。

    baseline_vc_preflight
    → contract_readiness_check
    → check_issue_contract --mode merge_readiness
    → compact_review_result
    → REVIEWER_BLOCKER_CLAIM_V1
    → parent_replay_binding
    → reviewer_claim_replay.analyze
    

    この経路で、少なくとも以下を検証すべきです。

    reviewer_blocker_code: VCP_COMMAND_NOT_ALLOWED | RDR001
    normalized_kind: <expected entry_id>
    deterministic_backed: true
    verdict_detail_v1: deterministic_fail_confirmed
    routing: proceed_to_rewrite または明示した別経路
    checker_gap: false
    

    後発の #1810 も、単体 adapter が存在するだけで production wiring されない失敗を防ぐため、同様の end-to-end chain を要求しています。

    修正後に必要な契約

    #1564 を維持する場合、最低限以下を本文へ反映すべきです。

    1. VC を dedicated new test files の node-id 形式へ変更し、Allowed Paths に追加する。
    2. entry_id、reviewer_codes、domain_keys を実装判断ではなく固定する。
    3. VCP_COMMAND_NOT_ALLOWED と RDR001 の実 code 正規化を AC に追加する。
    4. per-entry hardcoded 分岐ではなく、実装: fix(replay-taxonomy): readiness rule_id/category を deterministic_domain_key taxonomy に正規化する #1810 と整合する taxonomy-driven producer contract を採用する。
    5. command_not_allowed を reason class に分割し、自動修復可能なものだけ needs_fix にする。
    6. RDR001 の「検出」と「修復権限」を分離する。
    7. readiness artifact に strict schema validation を適用する。
    8. 実装: reviewer checker taxonomy の最小 SSOT foundation と既存ファイル未登録node-id resolver #1549/実装: RDR001/command_not_allowed taxonomy と readiness semantics の split-brain を解消する #1564 → 実装: fix(replay-taxonomy): readiness rule_id/category を deterministic_domain_key taxonomy に正規化する #1810 → 実装: reviewer_claim_replay.py の taxonomy に RDR001 / VCP_COMMAND_NOT_ALLOWED を追加し parent_replay_binding.py に C9 evidence 経路を追加する #1555 の依存順序を 実装: RDR001/command_not_allowed taxonomy と readiness semantics の split-brain を解消する #1564 と 実装: reviewer_claim_replay.py の taxonomy に RDR001 / VCP_COMMAND_NOT_ALLOWED を追加し parent_replay_binding.py に C9 evidence 経路を追加する #1555 双方へ同期する。
    9. hand-written fixture ではなく、実装: compact_review_result.py の REVIEWER_BLOCKER_CLAIM が structured_blockers ではなく blocking_issues の prose から code を構築している問題を修正する #1554 後の production chain E2E を追加する。

    現状評価

  3. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "review_compact_intermediate_validation_invalid: artifact_absolute_path_rejected"
    
    "anchor_requires_scope_and_policy_decisions: taxonomy SSOT, command_not_allowed reason class, and RDR001 rewrite authority"
    
  4. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    #1564 の要件は #1810 に統合しました。taxonomy SSOT、VCP_COMMAND_NOT_ALLOWED / RDR001 の source-qualified producer contract、reason_class routing、RDR001 の human-judgment guard、strict artifact validation、および production-chain E2E は #1810 の本文を正本として実施します。以後は #1810 を追跡してください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions