Skip to content

実装: NESTED_DELEGATION_001 drift 判定の advisory-only 化に test_agent_parity.py を追従させる #1948

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #1879 (af511e17) が advisory-only 化した delegation drift 判定に tests/test_agent_parity.py を追従させ、main の regression gate を green に戻し、tests/test_agent_parity.py を required Python CI gate に登録する"
change_kind: mixed

Parent Issue

なし(単独改善)

Parent Goal Ref

N/A(親 Issue なし)

Current Validated Scope

N/A(親 Issue なし)

Remaining Parent Gaps

N/A(親 Issue なし)

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue は tests/test_agent_parity.py の pytest アサーションと .github/ci/python-test-plan.json の CI 登録のみを変更する静的テスト修正であり、プロセス起動・UI 操作・実行時挙動観測を伴わない。uv run --locked pytest による静的検証のみで完結する。

Outcome

tests/test_agent_parity.py の TestNestedDelegation / TestStatusOutput / TestFixtureFiles / TestB3DriftIsFail 配下にある、削除済みの NESTED_DELEGATION_001 strict drift 判定を前提とした 6 テストと、それ以外に残る strict-drift 前提の stale なテスト名・fixture 名・docstring・変数名が、PR #1879(af511e17)で導入された delegation_intent_hint(advisory-only ヒント、scripts/check_claude_codex_agent_parity.py の classify_delegation_intent_hint() / extract_claude_facts() / extract_codex_facts() / compare_parity())の設計に整合する形へ更新され、advisory semantics(hint 不一致でも drift を生成しない・STATUS/exit code に影響しない)を behavioral に固定するアサーションが追加され、tests/test_agent_parity.py が .github/ci/python-test-plan.json の required Python unit lane に登録され、uv run --locked pytest tests/test_agent_parity.py tests/test_codex_agent_bridge_contract.py が baseline で green になっている状態。

In Scope

  • tests/test_agent_parity.py の以下 6 テストを、delegation_intent_hint("blocked" | "allowed" | "unknown")を用いた advisory 判定に整合するアサーションへ書き換える:
    • TestNestedDelegation::test_delegation_mismatch_produces_drift
    • TestNestedDelegation::test_codex_delegation_from_max_depth
    • TestNestedDelegation::test_delegation_report_in_output
    • TestStatusOutput::test_delegation_drift_status_warn
    • TestFixtureFiles::test_drift_delegation_mismatch_fixture
    • TestB3DriftIsFail::test_delegation_drift_produces_fail
  • tests/test_agent_parity.py 内に残る、上記6テスト以外の strict-drift 前提の stale な記述を advisory-only 設計へ整合させる(新規テスト追加ではなく、既存の記述の是正・改名を指す):
    • test_delegation_blocked_both_no_drift(関数名・アサーションが strict drift 前提のまま)
    • TestB4RealRepoParity の docstring(strict drift を前提とした説明)
    • deleg_drifts 変数を用いた NESTED_DELEGATION_001 抽出ロジック(advisory report 参照へ置換、または不要なら削除)
    • drift_delegation_mismatch fixture 名(fixture の内容が advisory report 前提になった場合、名前と内容の不整合を解消)
  • tests/test_agent_parity.py に新規クラス TestAdvisoryDelegationSemantics を追加し、以下の advisory semantics を behavioral に固定するアサーションを実装する:
    • test_intent_hint_mismatch_no_drift: Claude/Codex の delegation_intent_hint が不一致でも NESTED_DELEGATION_001 drift が all_drifts に生成されず、STATUS == "ok" かつ --strict でも exit code が 0 であること
    • test_nested_delegation_report_fields: nested_delegation_report の各要素が agent / claude_intent_hint / claude_evidence / codex_intent_hint / codex_evidence を持つこと
    • test_classify_delegation_intent_hint_precedence: blocked | allowed | unknown の三値分類、および blocked 表現と allowed keyword が共存する場合に blocked が優先されることを classify_delegation_intent_hint() の unit test で固定する
  • .github/ci/python-test-plan.json の targets に tests/test_agent_parity.py を追加し、required Python unit lane の一部として CI gate 化する
  • 上記書き換えにあたり、scripts/check_claude_codex_agent_parity.py の compare_parity() / classify_delegation_intent_hint() の現在の実装、および PR feat(codex): enable multi-agent v2 config #1879 の設計判断(advisory-only 化は意図的であり、V2 有効時に strict な delegation 判定を要求しない)を前提にする

Out of Scope

  • .codex/config.toml の [features.multi_agent_v2] 設定自体の変更
  • scripts/check_claude_codex_agent_parity.py の delegation_intent_hint ロジック自体の再設計(advisory heuristic の精度向上は別 Issue)
  • Issue 実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943(bounded read-only delegation parity)が要求する READONLY_DELEGATION_POLICY の実装
  • NESTED_DELEGATION_001 rule_id の再導入(strict 判定を復元する設計変更は別 Issue とする)
  • .github/ci/python-test-plan.json の tests/test_agent_parity.py 以外の既存エントリの変更

Acceptance Criteria

  • AC1: tests/test_agent_parity.py と tests/test_codex_agent_bridge_contract.py が pytest で全件 PASS する(AC2-AC4 で追加する新規テストの PASS も本 AC が担保する)
  • AC2: TestAdvisoryDelegationSemantics::test_intent_hint_mismatch_no_drift が存在する。Claude/Codex の delegation_intent_hint が不一致でも NESTED_DELEGATION_001 drift が生成されず、STATUS == "ok" かつ --strict の終了コードが 0 であることを検証する(PASS すること自体は AC1 で検証する)
  • AC3: TestAdvisoryDelegationSemantics::test_nested_delegation_report_fields が存在する。nested_delegation_report の各要素が claude_intent_hint / claude_evidence / codex_intent_hint / codex_evidence を持つことを検証する(PASS すること自体は AC1 で検証する)
  • AC4: TestAdvisoryDelegationSemantics::test_classify_delegation_intent_hint_precedence が存在する。blocked | allowed | unknown の三値分類、および blocked 表現と allowed keyword 共存時に blocked が優先されることを検証する(PASS すること自体は AC1 で検証する)
  • AC5: .github/ci/python-test-plan.json の targets に tests/test_agent_parity.py が含まれる
  • AC6: tests/test_agent_parity.py に NESTED_DELEGATION_001 という strict-drift 前提の文字列が、advisory report の後方互換コメント等を除き、drift 生成を主張する形では残っていない

Verification Commands

# AC1
# vc-role: regression_gate
# baseline-expect: fail
$ uv run --locked pytest tests/test_agent_parity.py tests/test_codex_agent_bridge_contract.py -q

# AC2
# vc-role: behavioral_contract
# baseline-expect: fail
$ rg -n "def test_intent_hint_mismatch_no_drift" tests/test_agent_parity.py

# AC3
# vc-role: behavioral_contract
# baseline-expect: fail
$ rg -n "def test_nested_delegation_report_fields" tests/test_agent_parity.py

# AC4
# vc-role: behavioral_contract
# baseline-expect: fail
$ rg -n "def test_classify_delegation_intent_hint_precedence" tests/test_agent_parity.py

# AC5
# vc-role: ci_selection
# baseline-expect: fail
$ rg -n "tests/test_agent_parity.py" .github/ci/python-test-plan.json

# AC6
# vc-role: regression_gate
# baseline-expect: pass
$ rg -n "NESTED_DELEGATION_001" tests/test_agent_parity.py

Allowed Paths

  • tests/test_agent_parity.py
  • .github/ci/python-test-plan.json

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • scripts/check_claude_codex_agent_parity.py の compare_parity() / classify_delegation_intent_hint() / extract_claude_facts() / extract_codex_facts() 実装(advisory-only 化の直接の正本)
  • PR feat(codex): enable multi-agent v2 config #1879(af511e17、「feat(codex): enable multi-agent v2 config」)の設計判断と consumer inventory
  • docs/dev/workflow.md「Multi-Agent V2 の V1 rollback」節(V2 有効時に strict な delegation 判定を要求しない背景説明。advisory-only 化の直接規範ではなく補助的な文脈情報として扱う)

Scope Delta(任意)

N/A

Notes for Reviewer

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 2, 2026
  2. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    この問題の再発防止策ってなに?
    #1933 が導入されていたら未然に防げた?

  3. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。現状の #1948 は不具合を直せますが、再発防止にはなっていません。

    最大の問題は、tests/test_agent_parity.py を修正してローカルで PASS させても、そのファイルが required Python CI の test-plan に含まれないままな点です。現在の .github/ci/python-test-plan.json には tests/test_codex_agent_bridge_contract.py などはありますが、tests/test_agent_parity.py はありません。

    指定コメントへの回答

    #1933 が導入されていたら未然に防げた?

    現在の #1933 の設計では防げません。

    #1933 は pnpm typecheck / pnpm lint / pnpm test / pnpm build を中心としたローカル hook の調査 Issue です。ところが、このリポジトリの pnpm test は Vitest であり、Python の tests/test_agent_parity.py は実行しません。

    さらに、仮に #1933 で専用 pytest を pre-push に追加しても、それだけでは強制力がありません。

    • Git の client-side hook は clone 時に自動配布されません。
    • git push --no-verify で pre-push hook を迂回できます。
    • prek で全体テストを確実に動かすには、少なくとも stages: [pre-push]、always_run: true、pass_filenames: false の明示が必要です。 ([Git]1)

    したがって、#1933 は早期フィードバック用の補助策です。強制的な再発防止策は required CI 側に置く必要があります。


    P0: required CI への登録が #1948 のスコープ外

    #1948 の Allowed Paths は tests/test_agent_parity.py だけです。つまり、現在欠落している .github/ci/python-test-plan.json を修正できません。

    PR #1879 は parity checker を strict drift から advisory hint に変更し、consumer inventory も記載していましたが、そこに tests/test_agent_parity.py がありませんでした。登録されたのは別の専用テストです。

    これは元の #799 で明示的に未解決とされた、

    parity チェックの CI required gate 化の要否判断

    という負債の顕在化です。

    必須修正

    Allowed Paths に次を追加してください。

    - tests/test_agent_parity.py
    - .github/ci/python-test-plan.json
    

    python-test-plan.json の targets に次を追加します。

    "tests/test_agent_parity.py"

    このリポジトリでは同ファイルが Python unit lane の SSOT であり、Python スクリプト変更は Python unit lane 必須という方針になっています。

    GitHub required check は実際に対象テストを実行する job でなければ意味がありません。条件付きで job 自体が skip された場合、成功扱いになるケースもあるため、常設 test-plan への追加が適切です。 ([GitHub Docs]2)


    P0: 「6テストだけ」の固定スコープは不完全

    #1948 は六つの失敗テストだけを列挙していますが、現在のファイルにはそれ以外にも strict delegation drift を前提とした記述があります。

    例えば以下です。

    • test_delegation_blocked_both_no_drift

    • TestB4RealRepoParity の docstring

    • NESTED_DELEGATION_001 を抽出する deleg_drifts

    • fixture 名・説明に残る drift_delegation_mismatch

    • max_depth を Codex delegation authority とする helper/test vocabulary

    本番 checker は現在、delegation を drift に追加せず、claude_intent_hint / codex_intent_hint を advisory report に出すだけです。異なる hint であっても all_drifts に入らないため、STATUS や --strict の終了コードには影響しません。

    必須修正

    「指定された六テストだけを書き換える」ではなく、次のように変更すべきです。

    tests/test_agent_parity.py 内の delegation strict-drift 契約を全件 inventory し、構造判定テストと advisory report テストを明確に分離する。

    最低限、次の挙動を固定してください。

    1. Claude/Codex の hint が異なっても NESTED_DELEGATION_001 は生成されない。
    2. STATUS == "ok"。
    3. --strict でも exit 0。
    4. nested_delegation_report に両 launcher の hint と evidence が出る。
    5. blocked | allowed | unknown の三値分類を検証する。
    6. blocked 表現と allowed keyword が共存した場合、現実装どおり blocked が優先される。

    P0: AC2 が trivially-pass に近い

    現在の AC2 は次だけです。

    rg -n "delegation_intent_hint" tests/test_agent_parity.py

    これはコメント、import、未実行コードに文字列を一つ置くだけでも PASS します。advisory-only の意味、STATUS、exit code、JSON schema のいずれも証明しません。#1948 の目的に対する検証として弱すぎます。

    置き換えるべき AC

    AC2:
    Claude/Codex の delegation intent hint が不一致でも、
    NESTED_DELEGATION_001 drift が生成されず、
    STATUS=ok かつ --strict の終了コードが 0 である。
    
    AC3:
    nested_delegation_report の各要素が
    agent / claude_intent_hint / claude_evidence /
    codex_intent_hint / codex_evidence を持つ。
    
    AC4:
    blocked / allowed / unknown と blocked precedence が
    classifier unit test で固定されている。
    
    AC5:
    tests/test_agent_parity.py が python-test-plan SSOT の targets に含まれる。
    

    P1: Required Design Reference が根拠になっていない

    #1948 は docs/dev/workflow.md の「Multi-Agent V2 の V1 rollback」を advisory-only 化の根拠としています。しかし、その節が定義しているのは、

    • V2 を無効化する
    • max_depth = 1 を戻す
    • V1 config assertion を実行する

    という rollback 手順だけです。delegation parity を advisory にする規範は書かれていません。

    advisory-only の直接的な正本は以下です。

    • PR feat(codex): enable multi-agent v2 config #1879 の設計判断と consumer inventory
    • scripts/check_claude_codex_agent_parity.py のコメント
    • compare_parity() が delegation comparison を行わない現実装
    • nested_delegation_report の report schema

    Required Design References はこれらへ差し替えるべきです。


    P1: Verification Commands が DoR 契約を満たしていない

    リポジトリの DoR は、VC ごとに # baseline-expect: pass|fail|deferred を直前に記載することを要求しています。また、baseline で既に PASS する単なる文字列検索は differential VC として不適切です。

    #1948 の両 VC には annotation がありません。

    推奨 VC

    # AC1
    # vc-role: regression_gate
    # baseline-expect: fail
    $ uv run --locked pytest tests/test_agent_parity.py tests/test_codex_agent_bridge_contract.py -q
    
    # AC2-AC4
    # vc-role: behavioral_contract
    # baseline-expect: fail
    $ uv run --locked pytest tests/test_agent_parity.py -q -k "delegation"
    
    # AC5
    # vc-role: ci_selection
    # baseline-expect: fail
    $ rg -n '"tests/test_agent_parity.py"' .github/ci/python-test-plan.json

    加えて PR review gate として、current head の python-test および ci-verdict-summary 成功を要求してください。


    再発防止策の適切な分担

    #1948: 今回の直接修正

    • stale test 契約の全面更新
    • behavioral assertion 化
    • tests/test_agent_parity.py の required Python test-plan 登録

    #1933: ローカル早期検出

    採用する場合は、例えば次の専用 pre-push hook を追加します。

    - id: agent-parity-regression
      name: agent parity regression
      language: system
      entry: uv run --locked pytest tests/test_agent_parity.py tests/test_codex_agent_bridge_contract.py -q
      stages: [pre-push]
      always_run: true
      pass_filenames: false

    ただし、これは bypass 可能な補助線であり、merge authority にしてはいけません。

    #1934: 変更影響分析の再発防止

    今回の根本原因は「テストを弱体化した」ことではなく、producer の契約変更時に unchanged consumer を inventory から漏らしたことです。#1934 は現在、テスト削除・assertion 弱体化・CI 空実装などを対象にしていますが、consumer inventory 漏れは明示されていません。

    次のレビュー規則を #1934 に追加すべきです。

    checker の rule ID、output key、status/exit semantics を変更する PR は、旧 symbol または rule ID を repository-wide に検索し、全 consumer test と CI lane 登録状況を Schema Consumer Inventory に列挙する。未更新 consumer がある場合は merge 不可。

    新しい巨大な control-plane は不要です。既存の inventory、rg、required test-plan、PR review の組み合わせで十分です。

    最終結論

    #1948 の方向性自体、つまり strict drift テストを advisory semantics に追従させる判断は妥当です。しかし、現状のままでは次の三点で不十分です。

    1. required CI に登録されない。
    2. 六テスト以外の stale contract が残る。
    3. AC2 が advisory semantics を検証していない。

    .github/ci/python-test-plan.json をスコープに追加し、behavioral contract と consumer inventory を AC 化するまで実装着手不可と判断します。

  4. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(human_judgment_required)

    anchor comment(https://github.com/squne121/loop-protocol/issues/1948#issuecomment-5154602439)を起点に、以下の改善を Issue 本文へ反映しました(3 iteration)。

    反映内容

    1. ## Runtime Verification Applicability セクションを追加(decision: not_applicable。静的テスト修正のみで完結するため)
    2. Allowed Paths に .github/ci/python-test-plan.json を追加
    3. In Scope を拡張し、6テストの書き換えに加えて test_delegation_blocked_both_no_drift / TestB4RealRepoParity docstring / deleg_drifts / drift_delegation_mismatch fixture 名等の stale な strict-drift 前提記述の是正、および tests/test_agent_parity.py の required Python test-plan 登録を追加
    4. Acceptance Criteria を AC1-AC6 に拡張し、advisory semantics(drift 非生成・STATUS/exit code・nested_delegation_report schema・blocked/allowed/unknown 分類と優先順位)を behavioral に固定
    5. Verification Commands に # vc-role: / # baseline-expect: を per-command で付与
    6. Required Design References を是正(scripts/check_claude_codex_agent_parity.py の実装・PR feat(codex): enable multi-agent v2 config #1879 を直接の正本とし、docs/dev/workflow.md は補助的文脈情報として位置づけ)

    これらの変更は codebase investigation(Step 1)により、anchor comment の4指摘(CI 未登録・stale 記述残存・AC2 trivially-pass・Required Design References の是正要否)すべてが実コードで事実確認された上で行っています。

    現在の状態と停止理由

    decide_next_loop_action.py が scope_signal_guard.triggered=true(reason_code: new_in_scope_area、excluded_by_anchor_reframe: false)を検出し、hard-stop しました。

    • ## In Scope に新規の機能領域(stale 記述の是正、CI test-plan 登録という追加の変更対象領域)が追加されたため、loop policy 上の scope 変更停止条件に該当します。
    • この signal は anchor comment(OWNER のレビューコメント)由来の正当な指摘ですが、ANCHOR_SCOPE_REFRAME_V1 形式の明示的な Scope Delta 承認ペイロードが付与されていないため、loop は自動的に scope 拡張を承認しません。

    review-issue による直近レビューでは、本文構造上の欠陥(C1-C11)はすべて pass しており、残る唯一の blocker(AC1 の regression_gate VC が baseline で FAIL する)は本 Issue の性質上(PR #1879 が導入した regression を修正する Issue のため)構造的なものであり、本文修正では解消できないことも確認済みです。

    人間への確認事項

    1. In Scope の拡張(stale 記述是正・.github/ci/python-test-plan.json 登録の追加)を承認するか
    2. 承認する場合、実装着手(issue-contract-review → impl-review-loop)へ進めてよいか
    3. AC1 の regression_gate blocked 状態(baseline FAIL)は本 Issue の前提として許容されるか(実装完了により解消される想定)

    TERMINATION_CAUSE: human_judgment_required
    BLOCKERS: scope_signal_guard_triggered, scope_signal_guard_reason_code:new_in_scope_area

  5. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    ANCHOR_SCOPE_REFRAME_V1 — Scope Delta Approval

    前回の issue-refinement-loop 終了報告(scope_signal_guard.triggered: true, reason_code: new_in_scope_area)に対する human 判断を記録する。

    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1948
    decision: approve_scope_delta
    allowed_path_deltas:
      - ".github/ci/python-test-plan.json"
    rationale: "OWNER の anchor comment(#1948 issuecomment-5154602439)で指摘された stale test 記述の是正・required Python CI gate 登録は codebase investigation で事実確認済みであり、Issue #1948 の In Scope 拡張として承認する。"
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate

    追加の human 判断

    • 実装着手(issue-contract-review → impl-review-loop)へは、本コメント時点では進めない。着手判断は別途行う。
    • AC1(vc-role: regression_gate)の baseline FAIL(blocked 判定)は、本 Issue が PR feat(codex): enable multi-agent v2 config #1879 の regression を修正する Issue である以上の前提として許容する。実装完了によって解消される想定であり、これ以上の Issue 本文修正は不要と判断する。
  6. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-02T03:01:39Z)

  7. added 2 commits that reference this issue on Aug 2, 2026
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