Skip to content

test: external manifest publish の Stop/SubagentStop stderr 契約と scope-rollup 環境分離を修正する #1828

Closed as not planned

Description

@squne121

Parent Issue

none

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Stop/SubagentStop の external manifest publish テストを、イベント固有の stderr 契約と scope-rollup 環境分離を用いて決定論的に検証できる状態にする"
change_kind: code

Parent Goal Ref

  • Goal: なし(単独改善)
  • Desired Destination: なし

Current Validated Scope

  • Stop は scope-rollup capture gate の対象外で stderr は空、SubagentStop は source-bound eligibility artifact が存在しないときに stderr へ固定の eligibility_missing 診断を出しつつ manifest flow を継続する。
  • 現在のテストは両イベントに Stop 用 fixture と空 stderr 期待を使い、scope-rollup/test seam の環境変数を継承するため、上記契約を決定論的に再現していない。

Remaining Parent Gaps

なし

Outcome

tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta が、イベント固有 fixture、固定された missing eligibility/readiness/capture path、およびイベント別の stdout/stderr 完全一致によって Stop/SubagentStop の external manifest publish 契約を検証する状態にする。

In Scope

  • _isolated_env() を拡張し、SCOPE_ROLLUP_ELIGIBILITY_ARTIFACT_PATH、SCOPE_ROLLUP_READINESS_ARTIFACT_PATH、SCOPE_ROLLUP_CAPTURE_DIR、SCOPE_ROLLUP_REQUIRE_SOURCE_BOUND_ELIGIBILITY、SCOPE_ROLLUP_REPO_ROOT、CODEX_SCOPE_ROLLUP_CAPTURE_SCRIPT、CODEX_SESSION_RECORDING_PRODUCER、NODE_ENV を継承しない。テストごとに tmp_path 配下の存在しない eligibility/readiness path と capture directory を明示する。
  • 対象テストを event 固有の payload で実行する。Stop には tests/fixtures/codex/positive_fixture.json、SubagentStop には tests/fixtures/hooks/codex-subagent-stop-allow.json を使い、CLI event と payload の hook_event_name を一致させる。
  • stdout は各 event で {"continue":true} と完全一致、stderr は Stop で空文字列、SubagentStop で [codex-hook-adapter] info: scope-rollup capture skipped (eligibility_missing)\n と完全一致させる。
  • 各 event で return code 0、Git porcelain status の before/after 一致、external manifest が Stop/SubagentStop 各1件、capture directory が未作成または空、missing eligibility/readiness path が未作成であることを検証する。
  • tests/hooks/codex-scope-rollup-capture.test.ts の eligibility_missing 正常系期待を維持する。PR 本文には、adapter の診断仕様を変更せずテストのみを修正した根拠を記録する。

Out of Scope

Acceptance Criteria

  • AC1: Stop payload を Stop event で実行し、return code 0、stdout {"continue":true}、stderr 空文字列を完全一致で検証する。
  • AC2: SubagentStop payload を SubagentStop event で実行し、return code 0、stdout {"continue":true}、stderr の eligibility_missing 診断一行を完全一致で検証する。
  • AC3: 各 event の payload の hook_event_name と CLI event を一致させ、scope-rollup/test seam の継承環境を除去した tmp_path 配下の missing eligibility/readiness/capture path を使用する。
  • AC4: 各 event 後に Git porcelain status が不変で、external manifest が Stop/SubagentStop 各1件、capture directory が未作成または空、missing eligibility/readiness path が未作成であることを検証する。
  • AC5: tests/session_recording/codex/test_external_manifest_publish.py の全テストが PASS する。
  • AC6: tests/hooks/codex-scope-rollup-capture.test.ts が PASS し、eligibility_missing を正常な capture-skip 診断として扱う既存契約を維持する。
  • AC7: PR 本文に、adapter の診断仕様を変更せず test-only で修正した選定根拠を記録する。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue は既存の Python/Vitest regression test の期待値・fixture・環境分離を修正する test-only 変更であり、別途の実行時統合検証 AC を追加しない。

Verification Commands

# AC1
# preflight-scope: pr_review_only
$ uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist

# AC2
# preflight-scope: pr_review_only
$ uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist

# AC3
# preflight-scope: pr_review_only
$ uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist

# AC4
# preflight-scope: pr_review_only
$ uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist

# AC5
# preflight-scope: pr_review_only
$ uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py -p no:xdist

# AC6
# preflight-scope: pr_review_only
$ pnpm test -- tests/hooks/codex-scope-rollup-capture.test.ts

# AC7
# preflight-scope: pr_review_only
$ gh pr view --json body --jq .body

Allowed Paths

  • tests/session_recording/codex/test_external_manifest_publish.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • adapter の scope-rollup capture 判定、skip 診断、ログレベル、reason code の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • tests/hooks/codex-scope-rollup-capture.test.ts の変更が必要と判明した場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • なし

Required Design References

  • docs/dev/session-recording-policy.md
  • .claude/skills/session-recording-policy/SKILL.md

Scope Delta(任意)

  • Anchor comment issuecomment-5107189019 に従い、adapter 修正選択肢と adapter の Allowed Path を除外し、test-only の event-specific contract に置換する。

Depends On

なし

Blocks

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jul 27, 2026
  2. squne121 commented on Jul 27, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #1828
    Failure stage: issue-ids
    Message: issue-ids failed

    Requested:

    • labels: enhancement, phase/implementation, triage-required, agent/implementer
    • parent: (none)
    • dependencies: #0
      Completed steps: create, label, label-readback

    Failure context: command=gh api graphql -f query=
    query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){issue(number:$number){id databaseId}}} -F owner=squne121 -F name=loop-protocol -F number=0
    output=gh: Could not resolve to an Issue with the number of 0.
    matching_issue_numbers=[1828]
    issue_number=1828

    Recovery hint: stage 'issue-ids' encountered an unexpected failure.
    Generic guidance: verify the issue state manually and re-run the transaction if safe.
    gh issue view 1828 --repo squne121/loop-protocol --json number,title,labels,state
    idempotent re-run: depends on the specific failure

    Please recover deterministically before re-running the create issue transaction.

  3. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 問題の発見自体は正しいですが、現状の Issue 契約では実装に着手すべきではありません。

    原因はほぼ テスト側の stale expectation と環境分離不足です。codex-hook-adapter.mjs を修正候補として残すと、Issue #1527 で意図的に導入した fail-closed capture gate の診断を消す誤修正へ誘導します。

    P0-1. 「テスト修正か adapter 修正か」という二択が不適切

    adapter は「empty repo delta」を見て診断を出しているわけではありません。

    実際の条件は次のとおりです。

    • Stop は scope-rollup gate の対象外
    • SubagentStop だけが gate の対象
    • 固定 location の eligibility artifact がなければ、eligibility_missing を stderr に出す
    • その後、通常の manifest flow は継続する

    この分岐は明示的に実装されています。

    さらに Issue #1527 は、eligibility/readiness が missing・invalid・stale の場合に producer を起動せず、固定 reason code で skip することを要求しています。 専用 Vitest も eligibility_missing を正常系として検証しています。

    したがって、Issue 本文の次の表現は誤っています。

    empty repo delta 時に info 診断を出す条件

    repo delta は adapter の入力でも判定材料でもありません。正しくは次です。

    SubagentStop において source-bound eligibility artifact が存在しない場合の、意図された capture-skip 診断

    必要な修正

    • adapter 側修正という選択肢を削除する
    • Allowed Paths から scripts/session-recording/codex-hook-adapter.mjs を外す
    • Out of Scope に「scope-rollup skip 診断の抑制・ログレベル変更」を追加する
    • 通常の missing eligibility を無音化したい場合は、実装: Codex の SubagentStop scope-rollup capture を復旧する #1527 の契約・policy・専用テストを変更する別 Issue とする

    stdout と stderr は独立したストリームです。stderr に診断を出しても、stdout の {"continue":true} プロトコルは壊れません。Node.js も subprocess の stdout/stderr を別々の pipe として扱います。(Node.js)

    P0-2. _isolated_env が実際には isolation になっていない

    現在の _isolated_env() は親プロセスの環境をコピーし、削除するのは CODEX_HOOK_MANIFEST_ROOT だけです。

    次の値を継承してしまいます。

    • SCOPE_ROLLUP_ELIGIBILITY_ARTIFACT_PATH
    • SCOPE_ROLLUP_READINESS_ARTIFACT_PATH
    • SCOPE_ROLLUP_CAPTURE_DIR
    • SCOPE_ROLLUP_REQUIRE_SOURCE_BOUND_ELIGIBILITY
    • SCOPE_ROLLUP_REPO_ROOT
    • CODEX_SCOPE_ROLLUP_CAPTURE_SCRIPT
    • CODEX_SESSION_RECORDING_PRODUCER
    • NODE_ENV

    override がなければ、adapter は repo 内の .claude/tmp/session-recording/ にある固定 artifact を参照します。

    その結果、開発環境の状態によって挙動が変わります。

    • artifact 不在: eligibility_missing を出して producer を起動しない
    • valid artifact あり: capture producer を実際に起動する
    • stale/invalid artifact あり: 別の reason code を出す
    • NODE_ENV=test 等を継承: test-only seam が有効になる可能性がある

    専用 Vitest はこの問題を避けるため、eligibility・readiness・capture directory をすべて一時ディレクトリへ明示的に向けています。

    この非決定性の解消が #1828 の本質です。 単に stderr assertion を緩めるだけでは不十分です。

    P0-3. SubagentStop に Stop 用 fixture を渡している

    対象テストは同じ payload を使い、CLI の --event だけを Stop / SubagentStop に切り替えています。

    しかし fixture 内の hook_event_name は常に Stop です。

    つまり現在のテストは、docstring が主張する「real SubagentStop entrypoint」を再現していません。既に SubagentStop 用 fixture が存在し、session_id、agent_id、agent_type、last_assistant_message を含んでいます。

    修正後はイベントごとに payload を分けるべきです。

    外部調査でも、Codex の root agent と subagent の hook identity は現在も仕様整備中で、公式リポジトリでは SubagentStop parity が未完成として扱われています。したがって、曖昧な疑似 payload ではなく、このリポジトリ自身の #1527 契約と official-wire fixture を正本にすべきです。([GitHub]2)

    P1-1. stderr はイベント別に完全一致させる

    推奨する期待値は次です。

    expected_stderr = {
        "Stop": "",
        "SubagentStop": (
            "[codex-hook-adapter] info: "
            "scope-rollup capture skipped (eligibility_missing)\n"
        ),
    }

    "eligibility_missing" in result.stderr のような部分一致では不十分です。別の warning や複数診断が混入しても PASS してしまいます。

    同じリポジトリでも、PR #1741 のレビュー対応で scope-rollup transport 診断を「部分一致」から「固定された単一行の完全一致」へ強化しています。

    同時に以下も維持すべきです。

    assert result.stdout == '{"continue":true}'
    assert result.returncode == 0

    JSON decode だけでは、余分な stdout や trailing garbage の混入を検出できません。

    P1-2. 「empty repo delta」という証跡は過大主張

    現在の _git_status() は次を比較しています。

    git status --porcelain=v1 --untracked-files=all --ignored=matching

    しかし .claude/tmp/ は ignore 対象です。 Git の --ignored=matching は、ディレクトリ自体が ignore pattern に一致すると、そのディレクトリを表示するだけで内部ファイルを列挙しません。(Git)

    さらに capture producer の既定出力先は /tmp であり、semantic rejection でも .capture.yaml sidecar を書けます。 これらは Git status には一切現れません。

    したがって、現在の比較が証明するのは厳密には次だけです。

    Git porcelain status の表示集合が変化しなかった

    「repository filesystem への書き込みが一切なかった」や「capture side effect がなかった」ことは証明していません。

    修正後は、少なくとも次を別々に検証すべきです。

    • Git working-tree status が不変
    • external manifest が Stop/SubagentStop 各1件生成された
    • isolated scope-rollup capture directory が作成されない、または完全に空
    • missing eligibility/readiness path にファイルが生成されていない

    P1-3. Acceptance Criteria が原因ではなく結果しか固定していない

    現在の AC1~AC3 は主に「テストが PASS する」ことを要求しており、どの契約で PASS すべきかが不足しています。

    最低限、次に置き換えるべきです。

    1. Stop は stdout exact JSON、stderr exact empty。
    2. SubagentStop は stdout exact JSON、stderr は eligibility_missing の単一固定行。
    3. CLI event と payload の hook_event_name が一致する。
    4. eligibility/readiness path は tmp_path 配下の存在しない固定 path に強制する。
    5. inherited scope-rollup/test seam 環境変数を除去または上書きする。
    6. scope-rollup capture directory に canonical capture・sidecar・partial artifact が一件もない。
    7. Git status before/after が一致する。
    8. 専用 codex-scope-rollup-capture.test.ts が引き続き PASS する。

    推奨する実装骨子

    SCOPE_ROLLUP_ENV_KEYS = (
        "CODEX_SCOPE_ROLLUP_CAPTURE_SCRIPT",
        "CODEX_SESSION_RECORDING_PRODUCER",
        "NODE_ENV",
        "SCOPE_ROLLUP_ELIGIBILITY_ARTIFACT_PATH",
        "SCOPE_ROLLUP_READINESS_ARTIFACT_PATH",
        "SCOPE_ROLLUP_CAPTURE_DIR",
        "SCOPE_ROLLUP_REQUIRE_SOURCE_BOUND_ELIGIBILITY",
        "SCOPE_ROLLUP_REPO_ROOT",
    )
    
    
    def _isolated_env(state_home: Path, scope_root: Path) -> dict[str, str]:
        env = os.environ.copy()
        env.pop("CODEX_HOOK_MANIFEST_ROOT", None)
    
        for key in SCOPE_ROLLUP_ENV_KEYS:
            env.pop(key, None)
    
        env["XDG_STATE_HOME"] = str(state_home)
        env["SCOPE_ROLLUP_ELIGIBILITY_ARTIFACT_PATH"] = str(
            scope_root / "missing-eligibility.json"
        )
        env["SCOPE_ROLLUP_READINESS_ARTIFACT_PATH"] = str(
            scope_root / "missing-readiness.json"
        )
        env["SCOPE_ROLLUP_CAPTURE_DIR"] = str(scope_root / "capture")
        return env

    テスト本体は概ね次の構造が妥当です。

    payloads = {
        "Stop": json.loads(
            (FIXTURES / "positive_fixture.json").read_text()
        ),
        "SubagentStop": json.loads(
            (
                REPO_ROOT
                / "tests"
                / "fixtures"
                / "hooks"
                / "codex-subagent-stop-allow.json"
            ).read_text()
        ),
    }
    
    expected_stderr = {
        "Stop": "",
        "SubagentStop": (
            "[codex-hook-adapter] info: "
            "scope-rollup capture skipped (eligibility_missing)\n"
        ),
    }
    
    for event, payload in payloads.items():
        before = _git_status(REPO_ROOT)
        result = run_adapter(event, payload, env=env)
    
        assert result.returncode == 0
        assert result.stdout == '{"continue":true}'
        assert result.stderr == expected_stderr[event]
        assert _git_status(REPO_ROOT) == before
    
    capture_dir = scope_root / "capture"
    assert not capture_dir.exists() or list(capture_dir.iterdir()) == []

    XDG_STATE_HOME を tmp_path 配下へ向ける現在の方針自体は妥当です。XDG Base Directory Specification でも state data は $XDG_STATE_HOME 配下とし、相対 path は無効として扱うよう定めています。([Freedesktop.org Specifications]4)

    関連 Issue・運用上の問題

    推奨する Issue の最終形

    タイトル

    test: external manifest publish の Stop/SubagentStop stderr 契約と scope-rollup 環境分離を修正する

    Allowed Paths

    tests/session_recording/codex/test_external_manifest_publish.py
    

    実装方針

    • test-only
    • adapter の診断仕様は変更しない
    • event-specific fixture を使う
    • scope-rollup artifact/capture/test seam 環境を完全分離する
    • event-specific stderr を完全一致で検証する
    • capture side effect 不在を明示的に検証する

    この形なら小規模かつ低リスクです。現契約のままでは、実装エージェントが adapter の正常な診断を抑制して #1527 を回帰させる可能性があるため、triage-required を外すべきではありません。

    なお、今回は GitHub connector で current main のファイル・Issue・PR・コメントを確認しましたが、この実行環境にはリポジトリのローカル checkout がないため、記載された pytest/Vitest コマンド自体の再実行は行っていません。

  4. changed the title [-]実装: test_external_manifest_publish.py の empty repo delta テストを scope-rollup capture skip 診断出力に対応させる[/-] [+]test: external manifest publish の Stop/SubagentStop stderr 契約と scope-rollup 環境分離を修正する[/+] on Jul 28, 2026
  5. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-28T17:08:10Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1828
      body_sha256: "sha256:97aac7978658f05545b4c577c60217b3b52103ad2fd259006ce23d89128da224"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:97aac7978658f05545b4c577c60217b3b52103ad2fd259006ce23d89128da224","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":3,"raw_command":"uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist","command_hash":"sha256:ec696e616a61c370c5999fc427830cb2792c63fc524594d2fbe1656ffa544aa9","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC2","line":7,"raw_command":"uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist","command_hash":"sha256:ec696e616a61c370c5999fc427830cb2792c63fc524594d2fbe1656ffa544aa9","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC3","line":11,"raw_command":"uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist","command_hash":"sha256:ec696e616a61c370c5999fc427830cb2792c63fc524594d2fbe1656ffa544aa9","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC4","line":15,"raw_command":"uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py::test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta -p no:xdist","command_hash":"sha256:ec696e616a61c370c5999fc427830cb2792c63fc524594d2fbe1656ffa544aa9","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC5","line":19,"raw_command":"uv run --locked pytest -q tests/session_recording/codex/test_external_manifest_publish.py -p no:xdist","command_hash":"sha256:5c0141ab580714ddb016ed4c336bf2f03fa7ccb69c244a1c81be075d9430db80","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC6","line":23,"raw_command":"pnpm test -- tests/hooks/codex-scope-rollup-capture.test.ts","command_hash":"sha256:1a59e4d54856a369d252fedda197acd7963207a53a74b5482512da00769d4c22","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false},{"ac":"AC7","line":27,"raw_command":"gh pr view --json body --jq .body","command_hash":"sha256:d8c4a4452904a80514017919435dd49a6f4e4c2d7acfe73df53ec5757844308a","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"bc703b449818d858d694040156aed08c6d7c3c69","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":1817,"title":"test: CLOSED predecessor の候補外 readback を固定 (#1766)","base_ref_name":"main","head_ref_name":"worktree-issue-1766-closed-native-predecessor-regression-v2","head_ref_oid":"5e39ca27825d76873b285de39a195a8d8f2311fd","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1817","changed_files_count_graphql":1},{"number":1819,"title":"実装:#1797_C2a-successor-structural-collisionのhuman-review-route修正","base_ref_name":"main","head_ref_name":"worktree-issue-1797-c2a-successor-collision","head_ref_oid":"e1bb2480b8cc6968496e53660d17b25993864a2d","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1819","changed_files_count_graphql":5}],"fetched_count":3,"totalCount":3,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:d46a62601e0191675a8f412707ff6bd1d55c3e619bacbc9230e3dcb98e892e00","errors":[]},"inventory_digest_extended":"sha256:4c754fb284e0555e3cf6e8ba4b7c53b7411dc02e755e378a65a4bd083f18a3bc","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1828,"contract_source_kind":"issue_comment","contract_source_id":"5107305363","contract_body_sha256":"sha256:97aac7978658f05545b4c577c60217b3b52103ad2fd259006ce23d89128da224","allowed_paths_normalized_sha256":"8393c22bf0ad3b66fa6c810f8e59347a4111981ea18c5821a06ed0582e8a2514","base_ref":"main","base_sha_at_snapshot":"bc703b449818d858d694040156aed08c6d7c3c69"}
  6. squne121 commented on Jul 28, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1828#issuecomment-5107305363
        generated_at: '2026-07-28T17:08:10Z'
        body_sha256: sha256:97aac7978658f05545b4c577c60217b3b52103ad2fd259006ce23d89128da224
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: '2026-07-28T17:09:39Z'
      checked_body_sha256: sha256:97aac7978658f05545b4c577c60217b3b52103ad2fd259006ce23d89128da224
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  7. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    disposition 確認: KEEP(現状維持)

    #1782 の OWNER 敵対的レビュー(https://github.com/squne121/loop-protocol/issues/1782#issuecomment-5266277591)を確認した。本 Issue は #1725 が対象とする test(test_external_manifest_publish.py)の Stop/SubagentStop stderr 契約・環境分離という実 test defect を扱う具体的な修正であり、KEEP(変更なし)と判定された。本文・スコープの変更は行わない。

  8. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    これはhooksの導入に関わるテストでhooksは基本実装しないのであれば不要では?

  9. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    結論

    Issue #1828 は、現行 main に対しては CLOSE / not_planned が妥当です。指定コメントの「この Hook 系テストは不要では?」という方向性は正しいです。ただし理由は「Hooks を基本実装しないから」ではなく、#1828 が対象としている enforcing/scope-rollup 時代の Stop / SubagentStop 契約が、#1830 / PR #1849 によって既に quarantine・削除され、Issue の前提そのものが消滅したからです。

    一方、Codex Hook 自体は不要になっていません。現行リポジトリでは [features].hooks = true のまま、project-local hook として SessionEnd と SubagentStop の passive recorder を明示的に維持しています。OpenAI Codex の現行実装にも SessionEnd / SubagentStop / Stop は存在し、root turn と thread-spawn subagent で Stop/SubagentStop を分離しています。したがって、現行 passive Hook の最小テストは残すべきです。 (GitHub)

    敵対的レビュー結果

    Severity | 判定 -- | -- P0 | #1828 の Current Validated Scope / AC / VC が live repository と不整合です。 Issue は test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta、scope-rollup の eligibility_missing stderr、eligibility/readiness 環境変数を修正対象にしていますが、現行 test_external_manifest_publish.py は passive recorder の2テストだけです。現行 adapter も SessionEnd / SubagentStop のみで、scope-rollup・eligibility/readiness・Stop warning path はありません。 P0 | 直前の KEEP 判定は撤回すべきです。 #1782 のレビューは「#1828 は Stop/SubagentStop fixture / stderr / env isolation の実在する defect」と判定し、そのまま #1828 に KEEP コメントが転記されています。しかし live main にはそのテスト・stderr path がありません。これは典型的な stale-snapshot review です。 P1 | #1725 は #1828 と一緒に閉じてはいけません。reframe が必要です。 python-test-plan.json は現在も test_external_manifest_publish.py を node-backed-hook-tests が提供すると宣言していますが、workflow の実行部分は test_hook_adapter.py と test_initial_branch_create_lane.py までで、対象ファイルの execution step が見当たりません。pytest の --collect-only は文字通り「収集のみで実行しない」ため、この false-green は独立した実 defect です。 (pytest) P1 | ドキュメントの historical/current 境界が弱く、今回の stale review を再発させます。 session-recording-policy.md 冒頭では #1830 以降の scope-rollup/Stop 等を「履歴・再導入時の設計資料」と明記している一方、その直後には eligibility/readiness、固定 private location、capture transport 等が現在形の normative text として大量に残っています。機械的・LLM 的 review では active contract と誤認しやすい構造です。 P2 | 現行 passive recorder 側には別の低コスト hardening 候補がありますが、#1828 に混ぜるべきではありません。 appendFile(..., mode: 0o600) の mode は新規作成時しか効かず、既存ファイルの権限を修正しません。また Node は promise-based FS の同一ファイルへの並行変更について同期されない点を注意しています。複数 SubagentStop が同じ JSONL に並行 append する test は現状確認できません。telemetry が advisory の間は P2 ですが、後に evidence として使うなら重要になります。 (Node.js)

    #1849 が #1828 を実質的に supersede している

    PR #1849 の契約はかなり明確です。active hook を SessionEnd と任意の SubagentStop に限定し、SubagentStop stdout を {"continue":true} に固定し、recorder から decision・通信・Git 操作・transcript 解析を除去しています。さらに enforcement 再導入には別 Issue が必要と明記しています。

    現行テストもこの設計に既に追随しています。test_hook_adapter.py は SessionEnd の no-transcript、SubagentStop の exact continuation JSON、malformed/EACCES の fail-open、quarantined event の no-op を検証しています。Vitest 側にも allowlist、fail-open、recorder boundary があり、旧 #1828 が要求する scope-rollup stderr helper を追加する余地はありません。

    したがって #1828 を今実装すると「壊れたテストを直す」のではなく、quarantine 済みの scope-rollup/Stop contract をテストコードへ再導入する危険がある、というのが最大の blocker です。

    WEB調査を踏まえた現行 Hook 方針

    OpenAI Codex 本体では Hook は現在も正式な実装面です。現行 source は root turn では Stop、thread-spawn subagent では SubagentStop を dispatch し、SessionEnd は root-only としています。output parser も Stop/SubagentStop の command output と universal continue field を処理します。したがって loop-protocol が main thread の「毎 turn Stop」ではなく「session 終了時 SessionEnd」を passive telemetry に使い、subagent だけ SubagentStop にする設計は合理的です。(GitHub)

    ただし OpenAI の公式 repository には、2026年6〜7月時点で codex exec や linked worktree で project-local hooks が dispatch されないという報告も残っています。これは確定仕様ではなく未解決のバグ報告ですが、direct adapter test の成功を live Codex hook delivery の証明にしてはいけないという現在の loop-protocol documentation の判断を補強します。passive telemetry なので、ここを required gate に戻す必要はありません。(GitHub)

    推奨 disposition

    #1828: CLOSE / not_planned を推奨します。close reason は「Hooks 全廃」ではなく、superseded by #1830 / PR #1849; referenced Stop/scope-rollup test and stderr/env contract no longer exist on current main とするのが正確です。直前の KEEP コメントも stale と明示すると、後続 agent が再び拾いません。

    #1725 は KEEP / reframe が妥当です。#1828 dependency、旧 Stop failure、eligibility warning の説明を削除し、「現行 test_external_manifest_publish.py の passive-recorder tests を node-backed-hook-tests で実際に execution する」という1点だけに縮小すべきです。これなら minimal harness 方針とも矛盾しません。

    さらに別途、session-recording-policy.md の旧 scope-rollup 部分を Historical / Quarantined と視覚的・構造的に隔離する価値があります。今回の誤判定は単なる Issue 放置ではなく、「削除済み production path の詳細な契約文が SSOT 内に現役風に残り、reviewer が live symbol existence を確認せず KEEP した」ことが再発要因です。

    最終判定は REQUEST_CHANGES(既存 KEEP 判定に対して)です。#1828 は実装せず閉じ、#1725 だけ現行 passive test coverage に reframe するのが最小かつ整合的です。

    ## 結論

    Issue #1828 は、現行 main に対しては CLOSE / not_planned が妥当です。指定コメントの「この Hook 系テストは不要では?」という方向性は正しいです。ただし理由は「Hooks を基本実装しないから」ではなく、#1828 が対象としている enforcing/scope-rollup 時代の Stop / SubagentStop 契約が、#1830 / PR #1849 によって既に quarantine・削除され、Issue の前提そのものが消滅したからです。

    一方、Codex Hook 自体は不要になっていません。現行リポジトリでは [features].hooks = true のまま、project-local hook として SessionEnd と SubagentStop の passive recorder を明示的に維持しています。OpenAI Codex の現行実装にも SessionEnd / SubagentStop / Stop は存在し、root turn と thread-spawn subagent で Stop/SubagentStop を分離しています。したがって、現行 passive Hook の最小テストは残すべきです。 ([GitHub]1)

    敵対的レビュー結果

    Severity 判定
    P0 #1828 の Current Validated Scope / AC / VC が live repository と不整合です。 Issue は test_stop_and_subagentstop_hooks_write_external_manifest_with_empty_repo_delta、scope-rollup の eligibility_missing stderr、eligibility/readiness 環境変数を修正対象にしていますが、現行 test_external_manifest_publish.py は passive recorder の2テストだけです。現行 adapter も SessionEnd / SubagentStop のみで、scope-rollup・eligibility/readiness・Stop warning path はありません。
    P0 直前の KEEP 判定は撤回すべきです。 #1782 のレビューは「#1828 は Stop/SubagentStop fixture / stderr / env isolation の実在する defect」と判定し、そのまま #1828 に KEEP コメントが転記されています。しかし live main にはそのテスト・stderr path がありません。これは典型的な stale-snapshot review です。
    P1 #1725 は #1828 と一緒に閉じてはいけません。reframe が必要です。 python-test-plan.json は現在も test_external_manifest_publish.py を node-backed-hook-tests が提供すると宣言していますが、workflow の実行部分は test_hook_adapter.py と test_initial_branch_create_lane.py までで、対象ファイルの execution step が見当たりません。pytest の --collect-only は文字通り「収集のみで実行しない」ため、この false-green は独立した実 defect です。 (pytest)
    P1 ドキュメントの historical/current 境界が弱く、今回の stale review を再発させます。 session-recording-policy.md 冒頭では #1830 以降の scope-rollup/Stop 等を「履歴・再導入時の設計資料」と明記している一方、その直後には eligibility/readiness、固定 private location、capture transport 等が現在形の normative text として大量に残っています。機械的・LLM 的 review では active contract と誤認しやすい構造です。
    P2 現行 passive recorder 側には別の低コスト hardening 候補がありますが、#1828 に混ぜるべきではありません。 appendFile(..., mode: 0o600) の mode は新規作成時しか効かず、既存ファイルの権限を修正しません。また Node は promise-based FS の同一ファイルへの並行変更について同期されない点を注意しています。複数 SubagentStop が同じ JSONL に並行 append する test は現状確認できません。telemetry が advisory の間は P2 ですが、後に evidence として使うなら重要になります。 ([Node.js]3)

    #1849 が #1828 を実質的に supersede している

    PR #1849 の契約はかなり明確です。active hook を SessionEnd と任意の SubagentStop に限定し、SubagentStop stdout を {"continue":true} に固定し、recorder から decision・通信・Git 操作・transcript 解析を除去しています。さらに enforcement 再導入には別 Issue が必要と明記しています。

    現行テストもこの設計に既に追随しています。test_hook_adapter.py は SessionEnd の no-transcript、SubagentStop の exact continuation JSON、malformed/EACCES の fail-open、quarantined event の no-op を検証しています。Vitest 側にも allowlist、fail-open、recorder boundary があり、旧 #1828 が要求する scope-rollup stderr helper を追加する余地はありません。

    したがって #1828 を今実装すると「壊れたテストを直す」のではなく、quarantine 済みの scope-rollup/Stop contract をテストコードへ再導入する危険がある、というのが最大の blocker です。

    WEB調査を踏まえた現行 Hook 方針

    OpenAI Codex 本体では Hook は現在も正式な実装面です。現行 source は root turn では Stop、thread-spawn subagent では SubagentStop を dispatch し、SessionEnd は root-only としています。output parser も Stop/SubagentStop の command output と universal continue field を処理します。したがって loop-protocol が main thread の「毎 turn Stop」ではなく「session 終了時 SessionEnd」を passive telemetry に使い、subagent だけ SubagentStop にする設計は合理的です。([GitHub]1)

    ただし OpenAI の公式 repository には、2026年6〜7月時点で codex exec や linked worktree で project-local hooks が dispatch されないという報告も残っています。これは確定仕様ではなく未解決のバグ報告ですが、direct adapter test の成功を live Codex hook delivery の証明にしてはいけないという現在の loop-protocol documentation の判断を補強します。passive telemetry なので、ここを required gate に戻す必要はありません。([GitHub]4)

    推奨 disposition

    #1828: CLOSE / not_planned を推奨します。close reason は「Hooks 全廃」ではなく、superseded by #1830 / PR #1849; referenced Stop/scope-rollup test and stderr/env contract no longer exist on current main とするのが正確です。直前の KEEP コメントも stale と明示すると、後続 agent が再び拾いません。

    #1725 は KEEP / reframe が妥当です。#1828 dependency、旧 Stop failure、eligibility warning の説明を削除し、「現行 test_external_manifest_publish.py の passive-recorder tests を node-backed-hook-tests で実際に execution する」という1点だけに縮小すべきです。これなら minimal harness 方針とも矛盾しません。

    さらに別途、session-recording-policy.md の旧 scope-rollup 部分を Historical / Quarantined と視覚的・構造的に隔離する価値があります。今回の誤判定は単なる Issue 放置ではなく、「削除済み production path の詳細な契約文が SSOT 内に現役風に残り、reviewer が live symbol existence を確認せず KEEP した」ことが再発要因です。

    最終判定は REQUEST_CHANGES(既存 KEEP 判定に対して)です。#1828 は実装せず閉じ、#1725 だけ現行 passive test coverage に reframe するのが最小かつ整合的です。

  10. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 停止記録

    指定された OWNER コメントを human-context anchor として、canonical main から preflight.run.with_human_context を実行しましたが、preflight は次の fail-closed postcondition で停止しました。

    • reason_code: unauthorized_write_path
    • 検出対象: tmp/session-manifests/codex/stop/baseline-manifest.json
    • executor の指示: do_not_write_outside_allowed_root

    このパスは Issue-scoped artifact root の外であり、現行ポリシーでも Codex session manifest の正規出力先は repository 外の XDG state root です。repo-local tmp/session-manifests/** への新規 write は許容・抑制できません。

    したがって、executor の迂回、allowlist の拡張、または repo-local manifest の削除・変更は行っていません。再開には、runtime の manifest writer を正規の external state root へ戻したうえで、同じ human-context preflight を canonical main から fresh に再実行する必要があります。

    指定コメント自体が示す #1828 の CLOSE / not_planned disposition は、この環境ブロッカーにより planner/review/writeback まで到達できていないため、今回の loop では確定・適用していません。

    根拠: docs/dev/agent-skill-boundaries.md の Codex session manifest output boundary、scripts/session-recording/resolve-codex-session-manifest-root.mjs、scripts/agent-guards/skill_runtime_exec.py。

  11. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 停止記録(再開後)

    指定 OWNER コメントを human-context anchor とする preflight は再実行で STATUS: pass となり、必須の repository 調査と external web research を完了まで実施しました。

    repository 調査結果

    現行 main では #1828 が参照する Stop / scope-rollup の test・stderr・環境分離契約は存在しません。active Codex hook は passive な SessionEnd / SubagentStop に限定され、対象テストも passive recorder の 2 テストです。したがって、指定コメントの #1828 を CLOSE / not_planned とする repository-side 根拠は確認できました。#1725 の node-backed-hook-tests 実行不足は別問題として維持・reframe が必要です。

    fail-closed blocker

    planner が必須とした external web research は agy_web_grounding_tool_call_missing で停止しました。critical external claims(Codex の Stop/SubagentStop/SessionEnd event behavior と {"continue":true} output)について、認識可能な grounded tool trace を得られなかったため未検証です。

    この loop は critical external claim の未検証時に human escalation へ倒す契約のため、Issue 本文の rewrite、CLOSE / not_planned への state mutation、#1725 の更新は実行していません。executor の迂回や direct web-search fallback も行っていません。

    再開条件は、grounded external research が machine-verifiable な tool trace と sources を返せること、または当該 external claim を close disposition の根拠から除外することです。

  12. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    はい。今回のケースは、Codex CLI 自体より loop-protocol の issue-refinement-loop / web-researcher の設計に主因があります。

    今回の #1828 は特に分かりやすいです。repository-side の調査だけで「現行 main に対象契約が存在しない → #1828 は not_planned が妥当」という disposition までほぼ確定しているのに、その結論に必須ではない外部仕様確認が失敗したため、mutation 全体まで止まっています。

    何が設計上まずいか

    現在の web-research-routing.md はかなり機械的で、critical_external_claims がある状態で web research が failed / inconclusive なら、そのまま human escalation に送ります。「その external claim が最終判断に本当に必要か」という decision dependency がありません。

    さらに web-researcher は AGY-only、Gemini fallback 禁止、direct WebSearch/WebFetch fallback 禁止という single-path 構成です。それ自体は provenance を厳格にしたいなら成立しますが、citation_count == 0、critical claim の evidence 不足、grounding failure まで fail-closed にしているため、AGY の観測能力が一時的に欠けただけで上位 workflow 全体が止まりやすい構造です。

    しかも、この問題はリポジトリ内ですでに認識されています。#2059 は現在、AGY 内部の search_web / read_url_content event や provider provenance、grounding trace を completion gate にせず、正常終了した parseable / non-empty final result を caller に返せればよいという契約へ縮小されています。canonical web event/source record が 0 件というだけで delegation を失敗にしてはいけない、と明示されています。

    また #2054 では、reviewer についてすでに「transport failure と semantic judgment は別物」と設計されています。spawn/timeout/malformed output 等は environment_failure / semantic_verdict: null にし、human_judgment_required と混同しない方針です。同じ原則を web-research routing に適用すべきです。

    これは #1860 の「live Issue/PR、実 diff、実 test、current-head CI、独立 review を authority にし、過剰な control-plane を減らす」という方針にも合います。現状はむしろ、補助的な evidence transport が live repository state より強い completion gate になっており、minimal-harness 方針と逆転しています。

    OpenAI が公開している Codex の運用方針も、技術的境界を明確にしつつ低リスク操作は迅速に進め、高リスク操作を明示的に扱うという risk-based な考え方です。「観測証拠が1種類欠けたら常に人間へ」という設計である必要はありません。 (OpenAI)

    改善案

    優先順位はこうします。

    優先度 | 改善 | 期待効果 -- | -- | -- P0 | #2059 を完了し、grounding trace を AGY delegation 成功条件から外す | agy_web_grounding_tool_call_missing 系停止を直接減らす P0 | external claim に dispositive / corroborative を導入 | 結論に不要な外部調査失敗で mutation が止まらない P0 | transport/evidence failure と semantic ambiguity を分離 | tooling 障害を human_judgment_required にしない P0 | #1828 相当の regression test を追加 | 今回と同じ停止を再発させない P1 | human escalation 条件を限定 | owner conflict / security / irreversible action / disposition に必須な証拠不足だけ人間へ P1 | bounded retry 後は non-dispositive failure を note 化 | AGY 一時障害で作業全体が失敗しない P2 | termination comment を「本当に人間入力が必要な場合」に限定 | GitHub に停止報告ばかり蓄積する状態を減らす

    重要なのは WebSearch fallback を安易に再有効化しないこと です。#2059 も fallback prohibition 自体は維持しています。
    問題は fallback がないことではなく、唯一の調査経路の失敗を、関係のない semantic decision までブロックさせていることです。

    #1828 なら、理想的な routing は次です。

    current main に対象実装なし → repository evidence が disposition を独立に決定 → external Codex hook semantics は corroborative/non-dispositive → AGY grounding failure は unresolved note として保存 → CLOSE / not_planned を続行 → #1725 は別 concern として維持。

    逆に、「現行 Codex がその hook contract を本当にサポートするか」が Issue の実装可否そのものを決めるケースなら dispositive とし、その調査に失敗したときだけ human escalation を許します。

    つまり、fail-closed を捨てるのではなく、fail-closed の適用範囲を正しく狭めるのが適切です。

    以下を Codex CLI に渡すのを推奨します。#2059 と重複する AGY provider 修正を再実装せず、issue-refinement-loop 側に残る routing gap を独立して直すようにしています。

    CodexCLI 作業プロンプト — issue-refinement-loop の過剰 human escalation を解消する

    Repository:

    squne121/loop-protocol

    背景

    以下の停止事例を起点に、issue-refinement-loop の過剰な human escalation を改善してください。

    Target incident:

    https://github.com/squne121/loop-protocol/issues/1828#issuecomment-5267301558

    この停止では repository 調査により、

    という状態まで確定していた。

    しかし external web research が agy_web_grounding_tool_call_missing になり、Codex hook の historical/current external semantics を machine-grounded trace として検証できなかったことだけを理由に、Issue rewrite / close / related update の全 mutation が停止し human_judgment_required になった。

    これは改善対象とする。

    関連 authority / precedent

    必ず live state を再取得して確認すること。

    特に以下を設計上の precedent として扱うこと。

    1. 実装: web-researcher を AGY-first + native Web fallback にする #2059:
      provider 内部の web-tool provenance / grounding trace を AGY final-result handoff の completion condition にしない方向。

    2. implement: recover reviewer transport failures and cryptographically bind compact verdicts to artifacts #2054:
      transport failure と semantic judgment を分離し、transport failure を human_judgment_required と混同しない方向。

    3. 導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860:
      live Issue/PR、current repository state、実 diff、実 test、current-head CI、独立 review を authority とする minimal harness 方針。
      新しい巨大な control-plane、ledger、digest/state-machine を安易に追加しない。

    Objective

    issue-refinement-loop において、

    external research の transport / grounding / evidence materialization failure が、最終 semantic decision に必須でない場合は human escalation を発生させない

    ようにする。

    fail-open 化は禁止する。

    security boundary、authority boundary、external fact verification 自体を弱めるのではなく、

    • evidence acquisition failure

    • semantic uncertainty

    • decision dependency

    を分離する。

    Required semantics

    external claim を少なくとも semantic 上、次の2クラスへ分類できるようにすること。

    dispositive
    : この claim の真偽が Outcome / disposition / In Scope / AC / VC / safety decision を変えるため、検証不能なら自律判断できない。

    corroborative または non_dispositive
    : 補強・背景説明には有用だが、repository-owned evidence 等によって requested decision が独立に確定できる。

    新しい大規模 schema を追加することを前提にしない。
    既存 planner/result に最小の field / decision information を追加する方式を優先する。

    Routing

    以下を成立させること。

    repository evidence が decision を独立に決定できる
    +
    external claim が non-dispositive
    +
    web research が failed / inconclusive / grounding_failure

    human_judgment_required にしない。

    unresolved external evidence を note / risk として保存し、通常 routing を続行する。

    一方、

    repository evidence だけでは decision を確定できない
    +
    dispositive external claim が failed / inconclusive

    human_judgment_required を許可する。

    Transport failure

    AGY / web-researcher の以下のような失敗を semantic disagreement と混同しないこと。

    • timeout

    • auth/capability unavailable

    • malformed/empty transport result

    • agy_web_grounding_tool_call_missing

    • citation/source materialization failure

    • provider provenance unavailable

    既存 repository に environment_failure / transport-failure convention がある場合は再利用する。

    新しい route/schemaを追加しなければならない場合は、まず既存の #2054 等の convention を再利用できない理由を確認すること。

    Retry

    transient transport failure について bounded retry が既存 consumer に存在する場合は再利用する。

    無制限 retry は禁止。

    retry budget 消費後も、claim が non-dispositive なら human escalation に変換しない。

    #2059 との境界

    #2059 が所有する AGY provider / final-result handoff 修正を重複実装しないこと。

    #2059 が未完了の場合でも、

    「AGY 内部 trace が取得不能だった場合に、issue-refinement-loop がどう routing するか」

    という consumer-side concern は独立して評価する。

    同一 concern を所有する既存 OPEN Issue があるなら新規 Issue を作らず、その Issue を current authority とする。

    存在しない場合、このセッションでは root/main thread に exactly one implementation Issue の起票を明示的に許可する。

    新規 Issue が必要であること自体を human escalation / stop reason にしてはならない。

    Issue を作成する場合は少なくとも #1828、#2059、#2054、#1860 を Related / precedent として記録する。

    1 Issue = 1 PR を維持する。

    Regression requirement

    #1828 を抽象化した regression fixture/test を必ず追加する。

    Case A:

    • current repository investigation: requested legacy contract no longer exists

    • repository evidence alone: close / not_planned が deterministic

    • external claim: historical/current CLI hook semantics

    • external research result: failed または grounding_failure

    • external claim role: non-dispositive

    Expected:

    • human_judgment_required にならない

    • close/not-planned disposition に向けた routing を維持する

    • external evidence unavailable を note/risk として保持する

    Case B:

    • repository evidence: inconclusive

    • external specification が implementation/disposition を決定する唯一の authority

    • external research: failed/inconclusive

    • claim role: dispositive

    Expected:

    • fail-closed

    • human_judgment_required

    Case C:

    • external transport failure

    • semantic reviewer resultは存在しない

    Expected:

    • transport/environment failure と semantic judgment を混同しない

    Human escalation policy

    以下のみを原則的な human escalation 候補とする。

    • trusted OWNER directives が実質的に矛盾する

    • requested decision を決める dispositive evidence が取得不能

    • security / credential / permission boundary の変更判断が必要

    • destructive または回復不能な mutation が必要

    • semantic scope が複数の妥当な選択肢に分岐し repository authority だけでは解消不能

    • authorization が本当に不足している

    以下だけでは停止しない。

    • AGY transport failure

    • grounding trace 不足

    • citation materialization 不足

    • transient provider failure

    • non-dispositive external claim の未検証

    • 今回明示的に許可した implementation Issue の起票

    • separate follow-up concern が発見されたこと

    • merely overlapping paths / related Issue の存在

    External research policy

    direct WebSearch/WebFetch fallback を無断で再有効化しない。

    Gemini fallback prohibition も勝手に解除しない。

    今回の目的は fallback を増やすことではなく、

    external evidence provider の失敗を unrelated semantic decision の global blocker にしないこと

    である。

    Implementation workflow

    サブエージェントを使用してよい。

    必要な read-only investigation は並列化してよいが、全 SubAgent の terminal completion を待ち、dangling agent を残さないこと。

    推奨 investigation roles:

    SubAgent は read-only investigation に限定し、root/main thread が routing、GitHub mutation、Issue/PR作成、最終判断を所有する。

    調査完了後:

    1. current main を authority として再確認

    2. concern owner Issue の有無を検索

    3. 必要なら authorized implementation Issue を起票

    4. worktree を作成

    5. implementation

    6. targeted tests

    7. relevant issue-refinement-loop regression suite

    8. lint/static checks

    9. Draft PR 作成

    10. adversarial review

    11. blocker が実装修正可能なら承認不要で修正

    12. CI / review を merge 直前まで収束

    merge 自体は実行しない。

    Stop policy

    今回の目的は autonomous recovery なので、単なる tooling inconvenience を human escalation に変換しないこと。

    本当に停止してよいのは以下。

    • destructive operation が必要

    • credential / secret の取得・露出が必要

    • repository authorization がなく代替の許可済み経路もない

    • trusted OWNER authority が矛盾し機械的に解消不能

    • security boundary を弱めなければ実装不能

    • current repository contract と本指示が実質的に矛盾し、自律的な narrow interpretation が不可能

    それ以外の recoverable error は、bounded retry、alternate existing repository path、scope-preserving fix、または explicit unresolved note により継続する。

    「安全側だから」という理由だけで human_judgment_required にしない。

    Final report

    最後に以下を報告する。

    remaining genuine human decisions が空なら none と明記する。

    この修正を入れたあとに #1828 を fresh rerun するのが順序として適切です。#1828 を個別に「今回は例外として進める」だけでは、別 Issue で同じ failed external research → human escalation が再発します。 #2059 の完了だけでも停止頻度は下がりますが、web-research-routing.md 自体が現在 failed + critical_external_claims → human escalation なので、consumer-side の routing 修正も必要です。

    はい。今回のケースは、**Codex CLI 自体より `loop-protocol` の `issue-refinement-loop` / `web-researcher` の設計に主因があります**。

    今回の #1828 は特に分かりやすいです。repository-side の調査だけで「現行 main に対象契約が存在しない → #1828 は not_planned が妥当」という disposition までほぼ確定しているのに、その結論に必須ではない外部仕様確認が失敗したため、mutation 全体まで止まっています。

    何が設計上まずいか

    現在の web-research-routing.md はかなり機械的で、critical_external_claims がある状態で web research が failed / inconclusive なら、そのまま human escalation に送ります。「その external claim が最終判断に本当に必要か」という decision dependency がありません。

    さらに web-researcher は AGY-only、Gemini fallback 禁止、direct WebSearch/WebFetch fallback 禁止という single-path 構成です。それ自体は provenance を厳格にしたいなら成立しますが、citation_count == 0、critical claim の evidence 不足、grounding failure まで fail-closed にしているため、AGY の観測能力が一時的に欠けただけで上位 workflow 全体が止まりやすい構造です。

    しかも、この問題はリポジトリ内ですでに認識されています。#2059 は現在、AGY 内部の search_web / read_url_content event や provider provenance、grounding trace を completion gate にせず、正常終了した parseable / non-empty final result を caller に返せればよいという契約へ縮小されています。canonical web event/source record が 0 件というだけで delegation を失敗にしてはいけない、と明示されています。

    また #2054 では、reviewer についてすでに「transport failure と semantic judgment は別物」と設計されています。spawn/timeout/malformed output 等は environment_failure / semantic_verdict: null にし、human_judgment_required と混同しない方針です。同じ原則を web-research routing に適用すべきです。

    これは #1860 の「live Issue/PR、実 diff、実 test、current-head CI、独立 review を authority にし、過剰な control-plane を減らす」という方針にも合います。現状はむしろ、補助的な evidence transport が live repository state より強い completion gate になっており、minimal-harness 方針と逆転しています。

    OpenAI が公開している Codex の運用方針も、技術的境界を明確にしつつ低リスク操作は迅速に進め、高リスク操作を明示的に扱うという risk-based な考え方です。「観測証拠が1種類欠けたら常に人間へ」という設計である必要はありません。 ([OpenAI]1)

    改善案

    優先順位はこうします。

    優先度 改善 期待効果
    P0 #2059 を完了し、grounding trace を AGY delegation 成功条件から外す agy_web_grounding_tool_call_missing 系停止を直接減らす
    P0 external claim に dispositive / corroborative を導入 結論に不要な外部調査失敗で mutation が止まらない
    P0 transport/evidence failure と semantic ambiguity を分離 tooling 障害を human_judgment_required にしない
    P0 #1828 相当の regression test を追加 今回と同じ停止を再発させない
    P1 human escalation 条件を限定 owner conflict / security / irreversible action / disposition に必須な証拠不足だけ人間へ
    P1 bounded retry 後は non-dispositive failure を note 化 AGY 一時障害で作業全体が失敗しない
    P2 termination comment を「本当に人間入力が必要な場合」に限定 GitHub に停止報告ばかり蓄積する状態を減らす

    重要なのは WebSearch fallback を安易に再有効化しないこと です。#2059 も fallback prohibition 自体は維持しています。
    問題は fallback がないことではなく、唯一の調査経路の失敗を、関係のない semantic decision までブロックさせていることです。

    #1828 なら、理想的な routing は次です。

    current main に対象実装なし → repository evidence が disposition を独立に決定 → external Codex hook semantics は corroborative/non-dispositive → AGY grounding failure は unresolved note として保存 → CLOSE / not_planned を続行 → #1725 は別 concern として維持。

    逆に、「現行 Codex がその hook contract を本当にサポートするか」が Issue の実装可否そのものを決めるケースなら dispositive とし、その調査に失敗したときだけ human escalation を許します。

    つまり、fail-closed を捨てるのではなく、fail-closed の適用範囲を正しく狭めるのが適切です。

    以下を Codex CLI に渡すのを推奨します。#2059 と重複する AGY provider 修正を再実装せず、issue-refinement-loop 側に残る routing gap を独立して直すようにしています。

    CodexCLI 作業プロンプト — issue-refinement-loop の過剰 human escalation を解消する

    Repository:

    squne121/loop-protocol

    背景

    以下の停止事例を起点に、issue-refinement-loop の過剰な human escalation を改善してください。

    Target incident:

    https://github.com/squne121/loop-protocol/issues/1828#issuecomment-5267301558

    この停止では repository 調査により、

    という状態まで確定していた。

    しかし external web research が agy_web_grounding_tool_call_missing になり、Codex hook の historical/current external semantics を machine-grounded trace として検証できなかったことだけを理由に、Issue rewrite / close / related update の全 mutation が停止し human_judgment_required になった。

    これは改善対象とする。

    関連 authority / precedent

    必ず live state を再取得して確認すること。

    特に以下を設計上の precedent として扱うこと。

    1. 実装: web-researcher を AGY-first + native Web fallback にする #2059:
      provider 内部の web-tool provenance / grounding trace を AGY final-result handoff の completion condition にしない方向。

    2. implement: recover reviewer transport failures and cryptographically bind compact verdicts to artifacts #2054:
      transport failure と semantic judgment を分離し、transport failure を human_judgment_required と混同しない方向。

    3. 導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860:
      live Issue/PR、current repository state、実 diff、実 test、current-head CI、独立 review を authority とする minimal harness 方針。
      新しい巨大な control-plane、ledger、digest/state-machine を安易に追加しない。

    Objective

    issue-refinement-loop において、

    external research の transport / grounding / evidence materialization failure が、最終 semantic decision に必須でない場合は human escalation を発生させない

    ようにする。

    fail-open 化は禁止する。

    security boundary、authority boundary、external fact verification 自体を弱めるのではなく、

    • evidence acquisition failure
    • semantic uncertainty
    • decision dependency

    を分離する。

    Required semantics

    external claim を少なくとも semantic 上、次の2クラスへ分類できるようにすること。

    dispositive
    : この claim の真偽が Outcome / disposition / In Scope / AC / VC / safety decision を変えるため、検証不能なら自律判断できない。

    corroborative または non_dispositive
    : 補強・背景説明には有用だが、repository-owned evidence 等によって requested decision が独立に確定できる。

    新しい大規模 schema を追加することを前提にしない。
    既存 planner/result に最小の field / decision information を追加する方式を優先する。

    Routing

    以下を成立させること。

    repository evidence が decision を独立に決定できる
    +
    external claim が non-dispositive
    +
    web research が failed / inconclusive / grounding_failure

    human_judgment_required にしない。

    unresolved external evidence を note / risk として保存し、通常 routing を続行する。

    一方、

    repository evidence だけでは decision を確定できない
    +
    dispositive external claim が failed / inconclusive

    human_judgment_required を許可する。

    Transport failure

    AGY / web-researcher の以下のような失敗を semantic disagreement と混同しないこと。

    • timeout
    • auth/capability unavailable
    • malformed/empty transport result
    • agy_web_grounding_tool_call_missing
    • citation/source materialization failure
    • provider provenance unavailable

    既存 repository に environment_failure / transport-failure convention がある場合は再利用する。

    新しい route/schemaを追加しなければならない場合は、まず既存の #2054 等の convention を再利用できない理由を確認すること。

    Retry

    transient transport failure について bounded retry が既存 consumer に存在する場合は再利用する。

    無制限 retry は禁止。

    retry budget 消費後も、claim が non-dispositive なら human escalation に変換しない。

    #2059 との境界

    #2059 が所有する AGY provider / final-result handoff 修正を重複実装しないこと。

    #2059 が未完了の場合でも、

    「AGY 内部 trace が取得不能だった場合に、issue-refinement-loop がどう routing するか」

    という consumer-side concern は独立して評価する。

    同一 concern を所有する既存 OPEN Issue があるなら新規 Issue を作らず、その Issue を current authority とする。

    存在しない場合、このセッションでは root/main thread に exactly one implementation Issue の起票を明示的に許可する。

    新規 Issue が必要であること自体を human escalation / stop reason にしてはならない。

    Issue を作成する場合は少なくとも #1828、#2059、#2054、#1860 を Related / precedent として記録する。

    1 Issue = 1 PR を維持する。

    Regression requirement

    #1828 を抽象化した regression fixture/test を必ず追加する。

    Case A:

    • current repository investigation: requested legacy contract no longer exists
    • repository evidence alone: close / not_planned が deterministic
    • external claim: historical/current CLI hook semantics
    • external research result: failed または grounding_failure
    • external claim role: non-dispositive

    Expected:

    • human_judgment_required にならない
    • close/not-planned disposition に向けた routing を維持する
    • external evidence unavailable を note/risk として保持する

    Case B:

    • repository evidence: inconclusive
    • external specification が implementation/disposition を決定する唯一の authority
    • external research: failed/inconclusive
    • claim role: dispositive

    Expected:

    • fail-closed
    • human_judgment_required

    Case C:

    • external transport failure
    • semantic reviewer resultは存在しない

    Expected:

    • transport/environment failure と semantic judgment を混同しない

    Human escalation policy

    以下のみを原則的な human escalation 候補とする。

    • trusted OWNER directives が実質的に矛盾する
    • requested decision を決める dispositive evidence が取得不能
    • security / credential / permission boundary の変更判断が必要
    • destructive または回復不能な mutation が必要
    • semantic scope が複数の妥当な選択肢に分岐し repository authority だけでは解消不能
    • authorization が本当に不足している

    以下だけでは停止しない。

    • AGY transport failure
    • grounding trace 不足
    • citation materialization 不足
    • transient provider failure
    • non-dispositive external claim の未検証
    • 今回明示的に許可した implementation Issue の起票
    • separate follow-up concern が発見されたこと
    • merely overlapping paths / related Issue の存在

    External research policy

    direct WebSearch/WebFetch fallback を無断で再有効化しない。

    Gemini fallback prohibition も勝手に解除しない。

    今回の目的は fallback を増やすことではなく、

    external evidence provider の失敗を unrelated semantic decision の global blocker にしないこと

    である。

    Implementation workflow

    サブエージェントを使用してよい。

    必要な read-only investigation は並列化してよいが、全 SubAgent の terminal completion を待ち、dangling agent を残さないこと。

    推奨 investigation roles:

    SubAgent は read-only investigation に限定し、root/main thread が routing、GitHub mutation、Issue/PR作成、最終判断を所有する。

    調査完了後:

    1. current main を authority として再確認
    2. concern owner Issue の有無を検索
    3. 必要なら authorized implementation Issue を起票
    4. worktree を作成
    5. implementation
    6. targeted tests
    7. relevant issue-refinement-loop regression suite
    8. lint/static checks
    9. Draft PR 作成
    10. adversarial review
    11. blocker が実装修正可能なら承認不要で修正
    12. CI / review を merge 直前まで収束

    merge 自体は実行しない。

    Stop policy

    今回の目的は autonomous recovery なので、単なる tooling inconvenience を human escalation に変換しないこと。

    本当に停止してよいのは以下。

    • destructive operation が必要
    • credential / secret の取得・露出が必要
    • repository authorization がなく代替の許可済み経路もない
    • trusted OWNER authority が矛盾し機械的に解消不能
    • security boundary を弱めなければ実装不能
    • current repository contract と本指示が実質的に矛盾し、自律的な narrow interpretation が不可能

    それ以外の recoverable error は、bounded retry、alternate existing repository path、scope-preserving fix、または explicit unresolved note により継続する。

    「安全側だから」という理由だけで human_judgment_required にしない。

    Final report

    最後に以下を報告する。

    remaining genuine human decisions が空なら none と明記する。

    この修正を入れたあとに #1828 を fresh rerun するのが順序として適切です。#1828 を個別に「今回は例外として進める」だけでは、別 Issue で同じ failed external research → human escalation が再発します。 #2059 の完了だけでも停止頻度は下がりますが、web-research-routing.md 自体が現在 failed + critical_external_claims → human escalation なので、consumer-side の routing 修正も必要です。

  13. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    Backlog audit (2026-10-02): close as not planned / superseded. The Issue's Stop/scope-rollup test and stderr/environment contract belonged to the enforcing-harness design that was quarantined by #1830 and merged PR #1849 (merged 2026-07-29). The Issue thread already records that current main no longer contains the referenced contract and recommends CLOSE / not_planned. Current passive hook coverage is separate scope and should not revive #1828.

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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions