Skip to content

実装: capability_preflight_result() の nested timeout 構造を単一 deadline 共有方式へ改善する #2322

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2320(Issue #2311)の OWNER REQUEST_CHANGES レビューで指摘された non-blocking 推奨事項(P1-2)を反映し、capability_preflight_result() の timeout 構造を改善する"
change_kind: code

Parent Issue

none(単独改善)

Parent Goal Ref

Dependencies

Current Validated Scope

  • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py の capability_preflight_result() の外側 timeout 方式を、単一の absolute monotonic deadline を producer へ伝達する方式へ変更する
  • scripts/claude-gpt/workflow_capability_preflight.py 内の4つの subprocess probe(spark_env_only / github_auth / github_repo_read / controlled_github_read)へ、共有 deadline から算出した残り時間を配分する方式への変更
  • non-zero exit 時に stderr の bounded・redacted excerpt を reason へ保持する処理の追加
  • 内部 timeout / spawn error / deadline exhaustion を安定した reason code へ分離する処理の追加(従来の producer_invocation_failed:TimeoutExpired への一律縮退を廃止)

Remaining Parent Gaps

なし

Outcome

capability_preflight_result() が、time.monotonic_ns() から一度だけ作成した absolute monotonic deadline(--deadline-monotonic-ns)を producer(workflow_capability_preflight.py)へ optional CLI 引数として伝達し、producer 内部の4 probe(spark_env_only / github_auth / github_repo_read / controlled_github_read)がその共有 deadline から min(probe_cap_seconds, remaining_seconds) で各 timeout を算出する単一 deadline 共有方式に改善された状態。

親側の watchdog timeout は producer の cooperative deadline より WATCHDOG_GRACE_SECONDS だけ大きい値に固定され、producer が deadline を認識して終了した場合(preflight_deadline_exhausted:<probe_name>)、probe 自体が timeout した場合(preflight_probe_timeout:<probe_name>)、producer が協調終了しなかった場合(producer_watchdog_timeout)、producer が non-zero exit した場合(producer_invocation_failed:exit_<code>:<sanitized_excerpt>)が、それぞれ区別可能な reason code として保持される状態。

spark_mode is None のときは spark_env_only probe を実行せず、preferred(fallback allowed)の timeout は fallback_only、required(fallback forbidden)の timeout は blocked として扱われる状態。

non-zero exit 時の stderr は、redaction を truncation より先に行った上で最大500文字の excerpt として reason に保持され、raw credential・OAuth URL・ANSI escape・NUL が残らない状態。

CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 および capability_preflight_result() の public function signature・decision/checks/actor_capabilities/reasons のキー集合は変更されず、preflight.sh --workflow-profile からの既存直接起動経路(deadline 引数なし)も引き続き動作する状態。

対応する新規テスト(fake monotonic clock・monkeypatched subprocess.run による hermetic tests)が追加され、対象テストファイルに対する uv run --locked pytest が PASS している状態。

Runtime Verification Applicability

decision: immediate
auth_required: false
network_required: false
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
  - AC8
  - AC9
execution_environment: hermetic local pytest (fake monotonic clock, monkeypatched subprocess.run; no live GitHub API, no sleep)
skip_conditions:
  - none (all AC are exercised by the focused hermetic pytest command; no live network dependency requires skip handling)
fallback_policy: none required (decision is immediate and fully satisfiable by hermetic pytest; no degraded/deferred fallback path is defined)
artifact_requirements:
  - focused hermetic pytest output
  • reason: 変更対象は subprocess timeout、producer/consumer transport(CLI argument)、exit code、stderr capture という runtime behavior そのものである。live GitHub API 呼び出しは不要だが、fake monotonic clock と monkeypatched subprocess.run による hermetic pytest の実行結果を runtime artifact として要求する(not_applicable は分類として不正確だったため訂正する)。同じ拡張面を触る 実装: refactor: PR #2357由来のdead root-level AGY post-runtime override一式を削除する #2368 も同様に decision: immediate を宣言し、live external process や新規 harness を要求せず pytest のみを runtime artifact としている。

In Scope

  • root_entry_router.py::capability_preflight_result() が、time.monotonic_ns() から一度だけ absolute deadline(deadline_ns = time.monotonic_ns() + int(DEFAULT_BUDGET_SECONDS * 1_000_000_000))を作成し、producer へ --deadline-monotonic-ns として渡すよう変更する。public function signature に budget 引数を追加しない(module constant + producer 側 optional CLI 引数のみで実装する)
  • 親側 watchdog は parent_timeout = remaining_seconds + WATCHDOG_GRACE_SECONDS の関係を維持し、producer cooperative deadline < parent watchdog timeout を常に満たす
  • workflow_capability_preflight.py の --deadline-monotonic-ns は optional 引数とし、省略時(例: preflight.sh --workflow-profile からの直接起動)は producer 自身が同じ既定 budget(DEFAULT_BUDGET_SECONDS)から local deadline を作成する。preflight.sh --workflow-profile の既存直接起動経路の互換性を維持する
  • producer 内の以下4つの独立 subprocess probe すべてが、共有 deadline から算出した残り時間(min(probe_cap_seconds, remaining_seconds))を timeout として使用するよう変更する:
    1. spark_env_only(_run_env_only_preflight())
    2. github_auth(_github_auth_ok())
    3. github_repo_read(_github_repo_read_ok())
    4. controlled_github_read(_controlled_github_read_capability()、実装: Claude-GPT workflow の actor-scoped capability handoff を導入し issue-refinement-loop の auth/delegation parity を安定化する #2340 由来)
      remaining time が 0 以下の場合、新しい subprocess を起動しない
  • assess() の spark_mode 意味論を次に固定する: spark_mode is None の場合は _run_env_only_preflight() を実行しない(現在は spark_mode の判定より前に無条件実行されているため、この順序を修正する)。spark_mode == preferred かつ fallback allowed の timeout/budget exhaustion は fallback_only(workflow 全体を terminal block しない)。spark_mode == required かつ fallback forbidden の timeout/budget exhaustion は blocked
  • producer 内の timeout / deadline exhaustion / spawn error を、typed internal outcome(completed / nonzero_exit / probe_timeout / deadline_exhausted_before_spawn / spawn_error / malformed_output)へ分離し、最終出力の既存 reasons 配列へ安定した reason code(preflight_probe_timeout:<probe_name> 等)を追加する。probe timeout/deadline exhaustion は producer が処理できた operational result として扱い、producer 自体は引き続き exit 0 で既存の ready | degraded | blocked schema を返す(non-zero exit は invalid input/internal error 専用のまま維持する)
  • 親側の watchdog timeout(producer が協調終了しなかった場合)は producer_watchdog_timeout として、producer 自身が返す deadline 関連 reason と区別する
  • producer が non-zero exit した場合、stderr の bounded excerpt(MAX_STDERR_EXCERPT_CHARS = 500)を reason へ保持する処理を追加する。処理順序は固定する: (1) bytes の場合 UTF-8 errors="replace" で decode → (2) current environment に存在する既知 credential 値を置換 → (3) GitHub token/github_pat_/Bearer/sk-/OAuth URL・query parameter を置換 → (4) ANSI escape・NUL・不要な C0 control character を除去 → (5) CR/LF/連続空白を単一空白へ正規化 → (6) 最後に500文字へ truncate(redaction を truncation より必ず先に行う)
  • 上記変更を検証する新規/更新テストの追加(fake monotonic clock と monkeypatched subprocess.run を用いた hermetic tests。sleep や real GitHub 呼び出しは使わない)

Out of Scope

Acceptance Criteria

  • AC1: root_entry_router.capability_preflight_result() は time.monotonic_ns() から一度だけ absolute deadline を作成し、producer へ --deadline-monotonic-ns で渡す。public function signature と既存 result schema のキー集合は変更しない。
  • AC2: producer の --deadline-monotonic-ns は optional であり、省略時は producer 自身が同じ既定 budget から local deadline を作成する。preflight.sh --workflow-profile の既存直接起動が維持される。
  • AC3: 次の全 subprocess probe が同じ deadline から残り時間を算出する: spark_env_only / github_auth / github_repo_read / controlled_github_read。timeout は min(probe_cap, remaining) とし、remaining <= 0 の場合は subprocess を起動しない。
  • AC4: spark_mode=None の場合、spark_env_only probe は実行されない。preferred/allowed の timeout は fallback_only、required/forbidden の timeout は blocked となる。
  • AC5: probe timeout/deadline exhaustion/spawn error は producer の既存 reasons に stable reason code として保持され、well-formed assessment は exit 0 で返る。parent watchdog timeout とは区別される。
  • AC6: 親側 watchdog は cooperative deadline より大きい grace を持ち、producer が deadline 処理を行わない場合のみ producer_watchdog_timeout を返す。
  • AC7: producer の completed non-zero exit では、stderr を redaction-before-truncation した最大500文字の excerpt が reason に保持される。raw credential、OAuth URL、ANSI/NUL は残らない。
  • AC8: fake clock と fake subprocess による hermetic tests で、deadline transport、全probeのremaining timeout、no-spawn-after-expiry、optional Spark semantics、watchdog separation、stderr sanitization、standalone producer compatibility を検証する。
  • AC9: CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 および capability_preflight_result() の decision/checks/actor_capabilities/reasons のキー集合は変更しない。

Verification Commands

# AC1
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC2
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC3
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC4
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC5
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC6
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC7
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC8
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q
# AC9
$ uv run --locked pytest scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py -q

test_workflow_capability_preflight_deadline.py と test_timeout_taxonomy_compat.py は本 Issue の実装で新規追加するテストファイルである。既存の rg ベースの Verification Commands は削除した。全 AC は同一の focused pytest invocation で検証する。

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py
  • scripts/claude-gpt/workflow_capability_preflight.py
  • .claude/skills/issue-refinement-loop/scripts/tests/
  • scripts/claude-gpt/tests/

Stop Conditions

Required Skills

なし

Required Design References

  • docs/dev/secret-policy.md(stderr excerpt から token 等の機微情報を除去する方針の根拠)
  • .claude/skills/issue-refinement-loop/scripts/preflight_agy.py::_redact_output_sample()(stderr redaction の既存先例。import はせず挙動だけを合わせる)

Scope Delta(任意)

N/A

Source

Activity

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

    @squne121
    OwnerAuthor

    Scope Collision (C1) advisory (create-issue overlap preflight): related_issue=#2278, #2153, #2152, #1975, #1908, #1829, #1812, #1810, #1601, #1556, #1555, #1288, #1007, #1006, #998, #997, #944, #926, #917, #667, #666, #420, #205; overlapping_paths=.claude/skills/issue-refinement-loop/tests (directory-level), scripts/claude-gpt/tests (directory-level), scripts/claude-gpt/workflow_capability_preflight.py, .claude/skills/issue-refinement-loop/scripts/root_entry_router.py。

    non_conflict_reason: 上記候補群は同ディレクトリ配下の別ファイル・別テスト(例: test_command_registry.py 等)を指しており、本 Issue の対象ファイル(root_entry_router.py の capability_preflight_result / workflow_capability_preflight.py)とは非重複。ディレクトリ単位 Allowed Paths の記載による machine-detected overlap であり、実ファイル競合ではない。
    edit_intent: capability_preflight_result() の timeout budget 配分ロジックと workflow_capability_preflight.py の probe timeout / stderr excerpt 保持ロジックの追加のみ。既存関数のシグネチャ・他候補が扱うテストファイルには触れない。
    dependency ordering: 依存関係なし(並行実装可)。

  3. squne121 commented on Aug 25, 2026

    @squne121
    OwnerAuthor

    Retrospective evidence 追加(2026-08-24〜26 Claude-GPT #2330/#2332 実行分析)

    /agent-retrospective(current main, PR #2342 反映済み)で #2330 / #2332 を個別に retrospective 実行したところ、両方とも observer wave で typed operational failure(#2330: missing_structured_output、#2332: observer_run_id_mismatch)となり本 tool 自体からは AGY/timeout の直接証跡は得られなかった。以下は補助 read-only SubAgent(AGY/Spark/timeout forensic)による独立コード調査の所見。

    nested timeout の具体的構造(実測)

    • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py:451 — capability_preflight_result() は scripts/claude-gpt/workflow_capability_preflight.py を 単一 subprocess timeout=30 として呼び出す。
    • しかし workflow_capability_preflight.py 自身が内部で gh auth status 等を複数回、それぞれ timeout=30 で subprocess 実行している(L98 / L134 / L147 付近)。

    つまり親 30s の deadline の中に子 30s×複数回が入れ子になっており、本 Issue が指す「nested timeout / shared deadline」の欠如を実装レベルで裏付ける追加証拠となる。

    Issue #2332 の実運用ログでは「Step 1 の codebase-investigator は AGY OAuth の認証タイムアウトにより repository evidence を取得できませんでした」と記録されているが、これが preflight_agy.py の SMOKE_TIMEOUT_SECONDS=20 / GROUNDING_TIMEOUT_SECONDS=40 / 関数デフォルト timeout_sec=180.0(.claude/skills/gemini-cli-headless-delegation/scripts/preflight_agy.py)のどの段で発生したかは、生 stderr excerpt が確認できず unverified。

    advisory failure は terminal blocker になっていない(設計通りの degraded fallback)

    secret/credential 値はこのコメントに一切含めていない。

  4. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結果

    判定

    REQUEST_CHANGES

    レビュー基準は、2026年8月28日時点の main HEAD 97fd045ab36cbc57221c4527f5995854792a5d80 です。

    Issue が扱う問題は実在します。最新 main でも親側は producer 全体に timeout=30 を設定し、timeout を例外クラス名だけに縮退させ、non-zero exit の stderr を完全に破棄しています。producer 側はさらに複数の subprocess timeout を独立保持しています。したがって、PR #2320 の OWNER レビューで指摘された問題は未解消です。

    ただし、Issue 本文は「共有 deadline を渡す」という方向だけを定め、deadline の表現、standalone producer との互換性、probe の優先順位、内部 timeout の reason 化、親 watchdog の意味、stderr sanitization の具体契約、実際に証明するテスト境界を定義していません。このままでは、実装者がそれぞれ異なる妥当そうな設計を選べてしまいます。


    P0-1: 「deadline」と「budget」が混同され、親子間 transport が未定義

    AC1 は「単一の共有 deadline(budget)を producer プロセスへ伝達」としていますが、次が未定義です。

    • 秒数を渡すのか、絶対時刻を渡すのか
    • producer 起動に要した時間を budget に含めるのか
    • producer が直接起動された場合の deadline は誰が作るのか
    • 不正値・期限切れ値をどう扱うのか
    • 外側 timeout を削除するのか、watchdog として残すのか

    特に producer は root router 専用ではありません。preflight.sh --workflow-profile からも workflow_capability_preflight.py が直接起動されます。deadline 引数を必須化すると、この既存経路を破壊します。

    必須修正

    共有値は absolute monotonic deadline に固定するのが最も明確です。

    DEFAULT_BUDGET_SECONDS = 30.0
    WATCHDOG_GRACE_SECONDS = 2.0
    
    deadline_ns = time.monotonic_ns() + int(DEFAULT_BUDGET_SECONDS * 1_000_000_000)
    
    argv.extend([
        "--deadline-monotonic-ns",
        str(deadline_ns),
    ])

    producer の CLI では --deadline-monotonic-ns を任意引数とします。

    • root router 経由: 親が一度だけ作成した deadline を渡す
    • preflight.sh --workflow-profile などの直接起動: producer 自身が同じ既定 budget から deadline を作る
    • malformed: CLI input error として exit 2
    • 既に期限切れ: subprocess を起動せず、well-formed な decision: blocked を exit 0 で返す

    このリポジトリは Python 3.12 以上を要求しています。time.monotonic() はシステム時計変更の影響を受けず、system-wide であり、monotonic_ns() は整数ナノ秒なので、同一ホスト上の親子プロセスで絶対 deadline を共有する用途に適しています。 ([Python documentation]1)

    capability_preflight_result() の公開シグネチャに budget 引数を追加する必要はありません。 module constant と producer の optional CLI 引数だけで実装できます。これは既存 caller と #2368 の cleanup を最も乱しません。


    P0-2: 外側 timeout は削除してはいけないが、子 budget と同値でもいけない

    Issue 本文は「外側の固定30秒 timeout 方式変更」とだけ書いており、外側 timeout を完全撤去する実装も許してしまいます。これは不適切です。

    producer が deadline を無視する、JSON 出力前に無限ループする、deadline 処理自体が壊れる、といった場合に親側 watchdog が必要です。一方、子と親を同じ30秒にすると、現在と同様、producer が構造化 reason を出力する直前に親が kill する競合が残ります。

    Python の subprocess.run(timeout=...) は、期限到達時に child を kill して wait した後で TimeoutExpired を再送出します。また、process creation 自体は多くのプラットフォームで中断できないため、指定秒数ぴったりに例外が届く保証もありません。([Python documentation]2)

    必須修正

    親側は次の関係に固定すべきです。

    producer cooperative deadline < parent watchdog timeout
    

    具体的には次です。

    remaining_seconds = max(
        0.001,
        (deadline_ns - time.monotonic_ns()) / 1_000_000_000,
    )
    parent_timeout = remaining_seconds + WATCHDOG_GRACE_SECONDS

    reason も分離してください。

    • producer が deadline を認識して終了
      preflight_deadline_exhausted:<probe_name>
    • probe 自体が timeout
      preflight_probe_timeout:<probe_name>
    • producer が協調終了しなかった親 watchdog
      producer_watchdog_timeout
    • producer が non-zero 終了
      producer_invocation_failed:exit_<code>:<sanitized_excerpt>

    現在の producer_invocation_failed:TimeoutExpired は、協調 deadline の失敗なのか、producer の hang なのかを区別できないため廃止対象です。最新 main の親側は依然として全例外をクラス名だけに変換しています。


    P0-3: AC2 の probe inventory が古く、optional Spark probe が全 budget を消費できる

    Issue 本文は「gh auth status / gh repo view 等」としていますが、現在の producer には少なくとも次の4つの subprocess 境界があります。

    1. preflight.sh --env-only — 30秒
    2. root gh auth status — 30秒
    3. root gh repo view — 30秒
    4. controlled gh api --hostname github.com repos/{repo} — 15秒

    4番目は #2340 の実装後に追加されたため、Issue 起票時の「等」では検証漏れが起きます。

    さらに問題なのは、assess() が spark_mode の有無に関係なく、最初に _run_env_only_preflight() を実行していることです。_spark_capability() は spark_mode=None なら即座に not_required を返せるのに、その判定より前に最大30秒の shell subprocess を起動しています。単一30秒 budget に置き換えるだけでは、使わない Spark probe が全 budget を消費し、必須の GitHub probe を一度も実行できない構造になります。

    必須修正

    AC2 は「等」ではなく、上記4 probe を列挙してください。

    また Spark probe は次の意味論に固定すべきです。

    • spark_mode is None
      _run_env_only_preflight() を実行しない
    • spark_mode == preferred かつ fallback allowed
      timeout/budget exhaustion は fallback_only。workflow 全体を terminal block しない
    • spark_mode == required かつ fallback forbidden
      timeout/budget exhaustion は blocked
    • remaining time が0以下なら、新しい subprocess を起動しない
    • 各 subprocess timeout は min(probe_cap_seconds, remaining_seconds) とする

    実装は大規模な scheduler にせず、producer 内に一つだけ private helper を置けば十分です。

    def _run_probe_with_deadline(
        probe_name: str,
        argv: list[str],
        *,
        deadline_ns: int,
        cap_seconds: float,
        env: dict[str, str] | None = None,
    ) -> ProbeOutcome:
        ...

    並列化、process supervisor、専用 deadline package は不要です。


    P0-4: shared deadline を導入しても、現在の内部 reason collapse を残すと問題は半分しか直らない

    現状は、内部 timeout が次のように処理されます。

    • env-only timeout → 空 dict {} に変換
    • gh auth status timeout → False
    • gh repo view timeout → False
    • controlled gh api timeout → controlled_github_unavailable

    つまり、共有 deadline を導入しても、producer が「認証がない」「repository read が拒否された」「単に時間切れだった」を区別できないままなら、remediation は依然として不正確です。

    必須修正

    public schema のキー集合は変更せず、内部だけ typed outcome にしてください。

    completed
    nonzero_exit
    probe_timeout
    deadline_exhausted_before_spawn
    spawn_error
    malformed_output
    

    最終出力では既存の reasons 配列へ安定した reason code を追加します。

    preflight_probe_timeout:spark_env_only
    preflight_deadline_exhausted_before:github_auth
    preflight_probe_spawn_error:github_repo_read:FileNotFoundError
    

    probe timeout/deadline exhaustion は producer が処理できた operational result なので、producer 自体は exit 0 で既存の ready | degraded | blocked schema を返すべきです。non-zero exit は引き続き invalid input/internal error 専用とします。

    #2340 の timeout compatibility test も、shared deadline の所有者が #2322 であることを明示しています。これを単に削除するのではなく、新しい reason semantics に合わせて更新する必要があります。


    P1-1: Verification Commands が false-green

    現在の AC1〜AC3 はすべて rg です。

    rg "def capability_preflight_result"
    rg "timeout"
    rg "stderr"

    これは、次の誤実装でも PASS します。

    • deadline 引数を追加したが誰も渡していない
    • 4 probe のうち1つだけ remaining time を使う
    • parent timeout と child deadline が同値
    • stderr を sanitization 前に truncate する
    • optional Spark probe が budget を使い切る
    • timeout reason が依然として generic boolean に潰れる

    また AC4 の pytest は、.claude/skills/issue-refinement-loop/tests/ -k capability_preflight のみです。しかし実際の root producer/consumer 境界テストは .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py にあり、producer の主要テストは scripts/claude-gpt/tests/test_workflow_capability_preflight.py にあります。現行 command は双方を正しく対象にしていません。

    推奨 Verification Commands

    uv run --locked pytest \
      scripts/claude-gpt/tests/test_workflow_capability_preflight.py \
      scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py \
      scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py \
      .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py \
      -q

    新規テストでは、sleep や real GitHub を使わず、fake monotonic clock と monkeypatched subprocess.run で以下を証明してください。

    1. 親が一つの absolute deadline を producer argv に渡す
    2. producer が4 probe へ単調減少する remaining timeout を渡す
    3. deadline 経過後は次 probe を起動しない
    4. spark_mode=None では env-only subprocess を起動しない
    5. fallback-eligible Spark timeout は degraded になる
    6. child timeout は parent watchdog より先に structured reason になる
    7. producer 全体が協調しない場合だけ parent watchdog になる
    8. direct preflight.sh --workflow-profile は deadline 引数なしでも動く
    9. public schema のキー集合が変わらない
    10. non-zero stderr が bounded/redacted される

    pytest の既定設定は live GitHub/live Claude マーカーを除外しているため、この検証は既存の hermetic test 方針にも一致します。


    P1-2: stderr excerpt の契約が「token 等」だけでは弱すぎる

    Issue は「bounded excerpt」「token 等を除去」としか定義していません。これでは実装者によって次が変わります。

    • 最大長
    • byte と文字のどちらで数えるか
    • 改行・NUL・ANSI escape の扱い
    • redaction と truncation の順序
    • token prefix、OAuth URL、Bearer header の対象範囲
    • HOME やローカルパスを残すか

    既存 repository には preflight_agy.py::_redact_output_sample() という有用な先例があります。既知の secret 環境変数値、GitHub/OpenAI token pattern、OAuth URL・query parameter を削除し、redaction 後に500文字へ制限しています。

    推奨契約

    root_entry_router.py に小さな local helper を置いてください。

    MAX_STDERR_EXCERPT_CHARS = 500
    

    処理順序は固定します。

    1. bytes なら UTF-8 errors="replace" で decode
    2. current environment に存在する既知 credential 値を置換
    3. GitHub token/github_pat_/Bearer/sk-/OAuth URL・query を置換
    4. ANSI escape、NUL、不要な C0 control character を除去
    5. CR/LF/連続空白を単一空白へ正規化
    6. 最後に500文字へ truncate

    GitHub CLI は GH_DEBUG により詳細を stderr へ出力し、NO_COLOR/CLICOLOR=0 で ANSI color を無効化できます。したがって sanitizer 側で ANSI を除去しつつ、可能なら child env でも color を抑止するのが妥当です。(GitHub CLI)

    なお TimeoutExpired.stderr は、text=True でも取得時は bytes です。watchdog timeout の partial stderr を将来扱うなら、helper は str | bytes | None を受けられる必要があります。今回の最小実装では、watchdog timeout に partial stderr を付けず、completed non-zero process の stderr だけを excerpt 化すれば十分です。([Python documentation]2)

    既存の AGY private helper を import したり、新しい共通 secret-redaction package を作る必要はありません。挙動だけ合わせる方がスコープと依存を抑えられます。


    P1-3: Runtime Verification not_applicable は分類が不正確

    Issue 本文は「real API を呼ばない単体テストで完結するから not_applicable」としています。しかし変更対象は、subprocess timeout、producer/consumer transport、CLI argument、exit code、stderr capture という明確な runtime behavior です。

    ここで必要なのは live GitHub ではなく、次の宣言です。

    decision: immediate
    auth_required: false
    network_required: false
    artifact_requirements:
      - focused hermetic pytest output

    同じ拡張面を触る #2368 も、immediate を宣言しつつ、live external process や新規 harness を要求せず pytest のみを runtime artifact としています。この扱いが妥当です。


    P1-4: dependency ordering コメントが stale

    #2322 の作成時コメントは「依存関係なし、並行実装可」としています。

    しかし #2368 は同じ root_entry_router.py::capability_preflight_result() から AGY override 引数・関数・定数を削除する cleanup であり、Issue 本文で明示的に次の順序を推奨しています。

    #2368 を先にマージ
    → #2322 を main へ rebase
    → deadline 実装
    

    これは正しい順序です。#2322 を先に実装すると、deadline 変更と dead AGY control-plane 削除が同じ関数で衝突し、レビュー diff が無駄に複雑になります。

    また #2340 の実装により controlled_github_read probe が既に追加されています。#2322 は起票時の producer ではなく、現在の4-probe producer を基準に更新する必要があります。


    推奨する Acceptance Criteria 差し替え

    - [ ] AC1: root_entry_router.capability_preflight_result() は
          time.monotonic_ns() から一度だけ absolute deadline を作成し、
          producer へ --deadline-monotonic-ns で渡す。
          public function signature と既存 result schema のキー集合は変更しない。
    
    - [ ] AC2: producer の --deadline-monotonic-ns は optional であり、
          省略時は producer 自身が同じ既定 budget から local deadline を作成する。
          preflight.sh --workflow-profile の既存直接起動が維持される。
    
    - [ ] AC3: 次の全 subprocess probe が同じ deadline から残り時間を算出する。
          - spark_env_only
          - github_auth
          - github_repo_read
          - controlled_github_read
          timeout は min(probe_cap, remaining) とし、
          remaining <= 0 の場合は subprocess を起動しない。
    
    - [ ] AC4: spark_mode=None の場合、spark_env_only probe は実行されない。
          preferred/allowed の timeout は fallback_only、
          required/forbidden の timeout は blocked となる。
    
    - [ ] AC5: probe timeout / deadline exhaustion / spawn error は
          producer の既存 reasons に stable reason code として保持され、
          well-formed assessment は exit 0 で返る。
          parent watchdog timeout とは区別される。
    
    - [ ] AC6: 親側 watchdog は cooperative deadline より大きい grace を持ち、
          producer が deadline 処理を行わない場合のみ
          producer_watchdog_timeout を返す。
    
    - [ ] AC7: producer の completed non-zero exit では、
          stderr を redaction-before-truncation した最大500文字の excerpt が
          reason に保持される。raw credential、OAuth URL、ANSI/NUL は残らない。
    
    - [ ] AC8: fake clock と fake subprocess による hermetic tests で、
          deadline transport、全probeのremaining timeout、no-spawn-after-expiry、
          optional Spark semantics、watchdog separation、stderr sanitization、
          standalone producer compatibility を検証する。
    
    - [ ] AC9: CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 および
          capability_preflight_result() の
          decision/checks/actor_capabilities/reasons のキー集合は変更しない。

    最小かつ有用な実装範囲

    追加すべき production abstraction は、実質的に次の2つだけです。

    • producer 側: _run_probe_with_deadline() または同等の小さな helper
    • parent 側: _sanitize_stderr_excerpt()

    追加不要です。

    • 新規 daemon/broker
    • process-group supervisor
    • live GitHub canary
    • 新規 Bash sandbox
    • deadline 専用 package
    • schema version bump
    • authorization ledger
    • stderr sanitizer の全リポジトリ共通化
    • permanent security harness

    結論として、Issue の目的は有用で優先してよいものの、現在の契約は implementation-ready ではありません。#2368 後に本文を上記内容へ更新してから実装するのが最も小さく、誤診断を減らし、workflow を止めにくい設計です。

  5. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

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

    対象コメント: https://github.com/squne121/loop-protocol/issues/2322#issuecomment-5452129032(OWNER 敵対的レビュー、判定 REQUEST_CHANGES / 処置 reframe_in_place)に基づき、本文を全面改訂しました。

    実施内容(2 iteration)

    1. Iteration 1: deterministic review が 5 blocker(EXTSURF001 Runtime Verification Applicability 誤分類 + VC unexpected_pass ×3 false-green)を検出。OWNER レビューの推奨内容(absolute monotonic deadline 方式・AC1〜AC9 差し替え・4-probe 明示・Verification Commands を実 pytest へ差し替え・Issue 実装: refactor: PR #2357由来のdead root-level AGY post-runtime override一式を削除する #2368 依存関係の明記・stderr sanitization 契約)に基づき本文を全面改訂。
    2. Iteration 2: decision: immediate 昇格に伴い必須の <!-- runtime-verification: true --> タグが AC に欠落(1 blocker)。AC1〜AC9 全てにタグを追加し解消。

    検証

    • codebase-investigator: OWNER レビューの repository fact claim(timeout=30 固定・stderr 破棄・4 probe 構造・Spark probe 優先度・実装: refactor: PR #2357由来のdead root-level AGY post-runtime override一式を削除する #2368 状態・standalone 起動経路)を現在の main HEAD で全件確認、矛盾なし。
    • web-researcher: 外部技術主張(time.monotonic_ns() / subprocess.run(timeout=) / TimeoutExpired.stderr / gh 環境変数)を Python 3.12 公式ドキュメント等で fact-check、ほぼ正確(1点軽微な補足のみ)。

    最終状態

    VERDICT: approve(blockers: 0)、final review gate final_review_allowed: true。

    重要な留意事項(実装着手前提条件)

    本 Issue 本文には、Issue #2368(capability_preflight_result() の AGY override cleanup、現在 OPEN・未マージ)のマージと main への rebase が実装着手の前提条件として明記されています。#2368 がマージされるまで、本 Issue の実装(impl-review-loop)は着手しないでください。

  6. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  7. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  8. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  9. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  10. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-29)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2394"
      head_sha: "df2f78a8866dbd15c434ff3351e2c6b292f8b51b"
      issue_number: 2322
      termination_reason: approved
      merge_ready: true
      iteration: 1
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  11. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  12. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 更新後の完了 (2026-08-29)

    • iteration: 2
    • verdict: APPROVE
    • route: approved
    • PR: feat: share capability preflight deadline #2394
    • 次アクション: Draft PR の人間レビュー → マージ → post-merge-cleanup
    • 注記: 先行する完了報告の head を current head へ更新します。focused VC は 43 passed です。
    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2394"
      head_sha: "6e9bf568d4d00c07b37874758c74a73b6f234232"
      issue_number: 2322
      termination_reason: approved
      merge_ready: true
      iteration: 2
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "pr-2394-focused-vc-count"
          source_url: "https://github.com/squne121/loop-protocol/pull/2394"
          source_note_id: "pr-reviewer-warning"
          summary: "PR 本文の focused pytest 記載は 41 passed のままだが、current head の独立実行は 43 passed。"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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