Skip to content

fix: capability-preflight probe ordering, Spark validation, deadline test fidelity (#2401) - #2410

Merged
squne121 merged 2 commits into
mainfrom
worktree-issue-2401-capability-preflight-review-fixes
Aug 29, 2026
Merged

squne121 merged 2 commits into
mainfrom
worktree-issue-2401-capability-preflight-review-fixes

Conversation

@squne121

@squne121 squne121 commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • マージ済み PR feat: share capability preflight deadline #2394 のレビューコメントで指摘された 5 件の adopted findings を解消する、bounded な follow-up 実装です(Issue 実装: Address remaining capability preflight review findings #2401)。
  • scripts/claude-gpt/workflow_capability_preflight.py の assess() を再構成し、必須の GitHub プローブ(github_auth → github_repo_read(github_auth 完了時のみ)→ controlled_github_read(root auth の成否に関わらず独立実行))を、任意の spark_env_only プローブより 先に 実行するようにしました。共有の絶対 monotonic deadline はそのまま維持しています。
  • Spark JSON ペイロードの検証用ヘルパー _validate_spark_env_payload() を追加し、binary_available: bool / chatgpt_auth: object / chatgpt_auth.available: bool のみを検証します。chatgpt_auth が dict でない場合に .get("available") を呼び出して未捕捉の AttributeError が発生していた既存バグを、構造化された malformed-output 理由へ正規化することで解消しました。
  • 新規ファイル scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py を追加し、AC1(プローブ順序)、AC2(Spark starvation による degrade)、AC3(malformed Spark payload の非例外処理)、AC4(assess(deadline_ns=None) が単一の共有 deadline を全プローブへ不変のまま伝播すること)、AC5(実サブプロセス境界を横断する hermetic テスト。外部リーフ CLI である gh のみを PATH 経由の fake でスタブ化し、producer サブプロセスおよびその結果はスタブ化しない)を検証しています。
  • ファイル名ベースの timeout-ownership blacklist テスト(test_timeout_taxonomy_compat.py 内)を削除しました(AC6)。競合する timeout-ownership モジュールが存在しないことは、恒久的な filename blacklist ではなく PR レビュー時に一度確認する運用へ変更します。
  • 実サブプロセスを起動する既存テスト test_workflow_capability_returns_structured_result() に @pytest.mark.github_live マーカーを付与し、任意のライブカバレッジとして扱い、本 Issue の hermetic close evidence からは除外しました。
  • test_workflow_capability_preflight_deadline.py の既存アサーション(プローブ呼び出し順序)を、新しい順序 ["gh", "gh", "gh", "sh"] に更新しました(Issue 実装: Address remaining capability preflight review findings #2401 の Notes for Reviewer が明示する、AC1 実装に必須の破壊的変更です)。
  • fix_delta(OWNER REQUEST_CHANGES 対応、#2410 レビューコメント): AC5 のテストが「実の root-to-producer deadline transport を観測していない」「fake gh fixture が exact argv contract を強制していると PR 本文が誤って主張していた」という P1 指摘、および AC2/AC3 のテストが実際の境界を通っていなかったという P2 指摘を、テストファイルのみの変更で解消しました。詳細は下記 Runtime Verification Evidence を参照してください。

Checks

  • pnpm typecheck
  • pnpm lint
  • pnpm test
  • pnpm build
  • 本 PR は scripts/claude-gpt/ 配下の Python スクリプトと pytest のみを変更しており、TypeScript / JavaScript ファイルは一切変更していません。そのため上記 4 コマンドはこの diff に対して意味のある検証を行いません(フロントエンド toolchain が本 worktree に未インストールのため、実行コストに対して得られる signal がありません)。代わりに Issue 実装: Address remaining capability preflight review findings #2401 の Verification Commands(uv run --locked pytest ... / rg の 7 コマンド)を PR 本文下部の Runtime Verification Evidence セクションで全て実行・記録しています。
  • ruff check は変更ファイル全てで All checks passed! を確認済みです。

Schema Change Applicability

  • decision: not_schema_change
  • reason: CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 の producer/consumer 境界フィールド集合(schema / profile / decision / checks.{uv,spark,github} / actor_capabilities / reasons)は変更していません。変更したのは assess() 内部のプローブ実行順序と、Spark JSON payload の検証ロジックのみで、外部から観測可能なキー・型・意味は不変です。

Schema Consumer Inventory

N/A(not_schema_change のため)。

Safety Claim Matrix

本 PR は capability-preflight(workflow gate)のプローブ順序・deadline 共有・動作検証(Runtime Verification Applicability: immediate)に触れるため、本セクションを記載します。

Claim Implemented? Not controlled Evidence Follow-up
必須の GitHub プローブ(github_auth / github_repo_read / controlled_github_read)は、任意の spark_env_only プローブより常に先に実行され、Spark プローブの starvation が必須プローブの実行そのものを妨げることはない yes AC1/AC2 pytest(下記 Runtime Verification Evidence 参照) N/A
Spark JSON payload の不正形状(non-dict top level / non-bool binary_available / missing・non-dict chatgpt_auth / non-bool chatgpt_auth.available)は、未捕捉例外を発生させず既存の構造化 malformed-output reason へ正規化される yes AC3 pytest(6 parametrize ケース、下記参照) N/A
assess(deadline_ns=None) は _local_deadline_ns() を通じて厳密に 1 回だけ共有絶対 deadline を生成し、全ての適用対象プローブへ不変のまま渡す yes AC4 pytest(下記参照) N/A
この preflight モジュールは自身では GitHub の状態変更(write)を一切行わない(既存不変条件、AC12 相当、本 PR で変更なし) yes 既存テスト test_no_broker_dependency_reference / probe 実装は gh auth status / gh repo view / gh api ... --jq {name} の read-only 呼び出しのみ N/A

Runtime Verification Evidence(動作検証証跡)

Issue #2401 の ## Runtime Verification Applicability(decision: immediate)に基づき、artifact_requirements が指定する形式(focused pytest コマンド・exit status・pass count・producer argv / fake-CLI invocation trace の要約)で証跡を記載します。skip_conditions: none のため SKIP 経路はありません。

AC1: 必須プローブ順序

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_required_probes_run_before_optional_spark_and_starvation_degrades scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_controlled_github_read_runs_independently_of_root_auth_failure -q
..                                                                       [100%]
2 passed in 0.02s

Exit Code: 0 / Pass Count: 2/2

  • test_required_probes_run_before_optional_spark_and_starvation_degrades: 制御された monotonic clock 下で、observed argv 順序が ["gh", "gh", "gh", "sh"](必須3プローブが先に完了し、任意の spark(sh)プローブはその後に spawn される)であることを確認。
  • test_controlled_github_read_runs_independently_of_root_auth_failure: root github_auth を故意に失敗させ、observed argv 順序から ["gh", "auth"] は1回、["gh", "repo"](github_repo_read)は0回(正しくスキップ)、["gh", "api"](controlled_github_read)は実行済みであることを確認。

AC2: Spark starvation は degrade(block ではない)

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_required_probes_run_before_optional_spark_and_starvation_degrades -q
.                                                                        [100%]
1 passed in 0.02s

Exit Code: 0 / Pass Count: 1/1

  • fix_delta(P2-1): 修正前はこのテストが deadline 枯渇による spawn 前の starvation(spark(sh)が一切 spawn されないケース)のみを検証しており、AC2 が実際に述べる「spark プローブが正の残り timeout で spawn し TimeoutExpired を受ける」シナリオを検証していませんでした(spawn 前 no-spawn ケースは既存の test_expired_deadline_spawns_no_new_process(test_workflow_capability_preflight_deadline.py、AC7 の focused suite に含まれる)で別途カバー済み)。修正後は monotonic clock を、必須3プローブ完了後も正の残り timeout が spark プローブへ渡るよう調整し、subprocess.run の fake が sh argv に対して実際に subprocess.TimeoutExpired を送出するようにしました。sh が正の timeout(0 より大きい値)で spawn され timeout することを確認したうえで、spark_mode="preferred" / spark_fallback="allowed" で decision == degraded(blocked ではない)かつ checks.github.auth/repo_read == True、actor_capabilities.controlled_github_read.status == "ready" を確認。

AC3: malformed Spark payload は非例外・構造化 reason

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_malformed_spark_payload_returns_structured_reason scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_run_env_only_preflight_rejects_null_chatgpt_auth_via_real_function -q
.......                                                                  [100%]
7 passed in 0.02s

Exit Code: 0 / Pass Count: 7/7(既存 parametrize 6ケース: invalid_json / non_dict_top_level / non_bool_binary_available / missing_chatgpt_auth / non_dict_chatgpt_auth / non_bool_chatgpt_auth_available、+ fix_delta で追加した1ケース)

  • non_dict_chatgpt_auth(chatgpt_auth: "connected")ケースが、修正前は env_only_result.get("chatgpt_auth", {}).get("available") で未捕捉 AttributeError を発生させていたバグの直接的な回帰テストです。全6ケースで assess() は例外を送出せず、preferred/allowed → degraded、required/forbidden → blocked を確認。
  • fix_delta(P2-2): 既存6ケースは wcp._run_env_only_preflight 自体を monkeypatch して事前構築済み ProbeOutcome を assess() へ渡すため、_run_env_only_preflight() 自身の JSON パース + _validate_spark_env_payload() 境界は実際には経由していませんでした(assess() 内の重複パス経由のみ検証)。追加した test_run_env_only_preflight_rejects_null_chatgpt_auth_via_real_function は subprocess.run のみを fake 化し、{"binary_available": true, "chatgpt_auth": null} を実際の _run_env_only_preflight()(monkeypatch なし)へ通し、PROBE_MALFORMED_OUTPUT になることを確認しています。

AC4: 単一共有 deadline

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_assess_without_deadline_creates_one_shared_local_deadline -q
.                                                                        [100%]
1 passed in 0.02s

Exit Code: 0 / Pass Count: 1/1

  • _local_deadline_ns() の呼び出し回数が厳密に1回であること、かつ全4プローブ(github_auth / github_repo_read / controlled_github_read / spark_env_only)が観測した deadline 値が同一 sentinel 値であることを確認。assess() 自体は monkeypatch で置き換えていない実関数呼び出しです。

AC5: 実 root-to-producer サブプロセス境界(hermetic)

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_root_to_producer_transports_deadline_with_fake_external_clis scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_producer_zero_deadline_spawns_no_github_subprocess scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_root_to_producer_boundary_reports_blocked_on_fake_gh_auth_failure -q
...                                                                      [100%]
3 passed in 0.35s

Exit Code: 0 / Pass Count: 3/3
fix_delta(P1-1): 旧証跡は producer が正しい引数を受け取り fake gh から正しく応答されたことを直接観測しておらず(decision in ("ready", "degraded") という緩い比較のみ)、また「fake gh fixture が exact argv contract を強制する」という PR 本文の主張は、実際には _github_repo_read_probe() が発行する gh repo view <repo> --json name が fixture の --jq nameWithOwner 専用の厳密分岐に一致せず、stdout を検証しない permissive な互換分岐(--json はあるが nameWithOwner を含まないため何も出力せず exit 0 のみ)を通過していただけで誤りでした。この修正で以下をテスト自身が直接観測・検証するようにしました(fixture 自体・Allowed Paths 外は変更していません):

  • test_root_to_producer_transports_deadline_with_fake_external_clis: root_entry_router.subprocess.run の実体を保存したうえで記録用ラッパーに差し替え(実関数へ委譲、置き換えではない)、root が実際に構築した producer argv を記録。--deadline-monotonic-ns がちょうど1回、正の整数値付きで存在することを確認。さらに _install_fake_gh() の gh wrapper 自体(テストファイル内、fixture 本体は未変更)が FAKE_GH_CALL_LOG 環境変数経由で自分の sys.argv[1:] を JSON line として記録するようにし、実 producer が発行した3回の gh 呼び出しの exact argv と順序を auth status → repo view <repo> --json name → api --hostname github.com repos/<repo> --jq {name} として直接照合。spark_mode=None 固定条件で decision == "ready"(in ("ready", "degraded") ではなく厳密比較)に強化。
  • test_producer_zero_deadline_spawns_no_github_subprocess(新規、item e): 実 producer スクリプトを --deadline-monotonic-ns 0 で直接(root_entry_router を経由せず)起動し、fake gh の call log が空/未生成のまま(GitHub subprocess が一切 spawn されない)であること、および reasons に preflight_deadline_exhausted: 系の理由が含まれ decision == blocked であることを確認。
  • test_root_to_producer_boundary_reports_blocked_on_fake_gh_auth_failure(既存、変更なし): 同一境界を通じて producer 自身の decision: blocked verdict(transport レベルの synthetic failure ではない)が root consumer にそのまま届くことを確認済み。

なお、fake gh fixture(scripts/claude-gpt/tests/fixtures/fake_gh.py、Allowed Paths 外・未変更)自体は gh repo view <repo> --json name の shape を exact-argv 検証しません(--jq nameWithOwner 専用の厳密分岐のみ exact-argv、--json name は permissive 互換分岐です)。exact argv/order の保証は、この修正でテスト自身が追加した call-log ラッパーによるものであり、fixture の組み込み検証ではありません。

AC6: filename blacklist テストの削除

$ ! rg -q "test_no_new_competing_timeout_ownership_module_introduced" scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py

Exit Code: 0(rg 自体は該当文字列なしで exit 1、否定形の VC は exit 0)

AC7: focused suite 一括実行

$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py -q
.........................                                                [100%]
25 passed in 0.38s

Exit Code: 0 / Pass Count: 25/25(fix_delta で追加した2テストを含む: test_run_env_only_preflight_rejects_null_chatgpt_auth_via_real_function / test_producer_zero_deadline_spawns_no_github_subprocess)。ライブ GitHub アクセス・provider credential・ユーザー gh CLI 設定は一切不要(gh は _install_fake_gh の PATH wrapper で完全にスタブ化、その他のテストは wcp.subprocess.run の monkeypatch で完結)。test_expired_deadline_spawns_no_new_process(no-spawn-on-exhaustion 回帰)も含めて全 PASS。

$ uv run --locked pytest scripts/claude-gpt/tests/ -q
344 passed, 1 skipped, 2 deselected

追加の全体回帰確認として、scripts/claude-gpt/tests/ 配下の全テスト(test_actor_scoped_capability_probe.py / test_spark_fallback_route.py / test_workflow_capability_preflight.py(github_live マーカー付き1件は deselected)/ 本 Issue の Allowed Paths 外の既存テストを含む)も PASS することを確認しています。

Notes

…test fidelity (#2401)

Bounded follow-up for the merged PR #2394 review findings:
- Reorder capability-preflight probes so required GitHub probes
  (github_auth -> github_repo_read -> controlled_github_read) run before
  the optional spark_env_only probe, sharing one absolute deadline.
- Add a Spark JSON payload validator that normalizes malformed/invalid
  shapes (non-dict top level, non-bool binary_available, missing/non-dict
  chatgpt_auth, non-bool chatgpt_auth.available) into the existing
  structured malformed-output reason instead of risking an uncaught
  AttributeError.
- Add scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py
  covering probe ordering (AC1), spark-starvation degrade semantics (AC2),
  malformed Spark payload handling (AC3), the single shared absolute
  deadline (AC4), and a hermetic real root-to-producer subprocess boundary
  test faking only the external gh leaf CLI (AC5).
- Remove the filename-based timeout-ownership blacklist test (AC6).
- Mark the real-subprocess test_workflow_capability_returns_structured_result
  with @pytest.mark.github_live (optional live coverage, not part of this
  Issue's hermetic close evidence).
- Update the pre-existing shared-deadline probe-order assertion in
  test_workflow_capability_preflight_deadline.py to the new gh/gh/gh/sh
  order (required by implementing AC1).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2410 closed).

@squne121

Copy link
Copy Markdown
Owner Author

PR Review Verdict

Mergeability

  • mergeable: MERGEABLE
  • mergeStateStatus: BLOCKED (Draft PR のため。required checks は全green)
  • reviewed_head_sha: 9992649

Evidence Check

  • linked issue: Closes 実装: Address remaining capability preflight review findings #2401 確認
  • CI: required checks 5件(lint/test/build/typecheck/validate-generated-artifact)すべて SUCCESS、current head と一致
  • Allowed Paths gate: status ok、変更5ファイルすべて Issue 実装: Address remaining capability preflight review findings #2401 の Allowed Paths 内
  • AC coverage: AC1-AC7 全て独立再実行で PASS 確認(reviewer が worktree で PR head を checkout し自ら再実行、342 passed / 1 skipped(github_live) / 2 deselected / 0 failed の regression なし確認込み)
  • AC1 プローブ順序をコード読解で直接確認
  • fallback/SKIP 偽装マーカー検出なし

Blockers

なし

Non-blockers / Warnings

なし

verdict: APPROVE
reviewed_head_sha: "99926493fb1f46c67db3677d728798c44188dcbd"
blockers: []
warnings: []

@squne121

Copy link
Copy Markdown
Owner Author

判定

verdict: REQUEST_CHANGES
reviewed_head_sha: "99926493fb1f46c67db3677d728798c44188dcbd"
production_implementation: broadly_sound
blocking_findings:
  P0: 0
  P1: 1
non_blocking_findings:
  P2: 3
merge_condition:
  - "AC5で deadline の root→producer transport を実際に観測する"
  - "fake CLI trace の証跡を実テストと一致させる"
  - "AC2/AC3のテスト説明を実際に通る境界へ合わせる"

PR #2410 は現在も Draft・OPEN・mergeable で、対象 head は 99926493... です。現在 head の python-test や CI 集約チェックは成功しており、リポジトリ上のレビューコメントも「required checks は全green、AC1〜AC7 PASS」としています。ただし、その APPROVE は同じ所有者アカウントによるワークフローレビューであり、以下の false-green を検出できていません。

本番コードの方向性は正しいです。 github_auth → github_repo_read → controlled_github_read → spark_env_only への並べ替え、小さな Spark payload validator、filename blacklist の削除は妥当です。マージを止める理由は現在の production logic の破綻ではなく、Issue #2401 が特に重視した「deadline test fidelity」と「実境界の証跡」がまだ成立していないことです。Issue #2401 は、PR #2394 のレビューで見つかった五件を対象に、実 root→producer 境界、captured producer argv、fake CLI invocation trace を明示的に要求しています。


P1-1: AC5 は real subprocess を起動しているが、deadline transport を証明していない

test_root_to_producer_transports_deadline_with_fake_external_clis が実際の root_entry_router.capability_preflight_result() から実 producer を起動している点は改善です。しかしテスト本文が確認しているのは、最終的な GitHub capability と decision、および producer_* failure がないことだけです。root が組み立てた argv を捕捉せず、--deadline-monotonic-ns の存在・値を確認せず、用意した FAKE_GH_STATE も読み戻していません。

既存の test_root_transports_one_deadline_and_keeps_watchdog_grace は、root 側の subprocess.run を canned payload で置換し、argv に deadline があることを確認しています。一方、新しい integration test は producer を実行しますが、その producer が渡された deadline を受理・使用したことは確認していません。つまり証明が次の二つに分断されています。

unit test:
  root が deadline argv を組み立てた
  ただし producer は起動しない

integration test:
  producer は起動した
  ただし deadline argv を観測しない

実装上、root は deadline 引数を渡し、producer parser もそれを assess() に渡しているため、現時点のコード自体は正しく見えます。問題は、producer の main() が将来誤って常に deadline_ns=None を渡すようになっても、新しい integration test は producer がローカル deadline を生成して正常終了するため green のままになり得ることです。root 側 unit testも「argvを作った」ことしか見ないので、この handoff regression は検出できません。

さらに、PR 本文の AC5 証跡には事実と異なる説明があります。

fake gh fixture は三種類の呼び出しを exact argv contract としてのみ受理する

実際の producer は root repo probe として、

["gh", "repo", "view", repo, "--json", "name"]

を実行します。ところが fake fixture が厳密に検査しているのは別形式の、

gh repo view <repo> --json nameWithOwner --jq .nameWithOwner

です。現在の --json name は permissive な互換分岐へ流れます。fixture 自身のコメントも、calls[] は「正規化済みであり、exact argv・厳密順序・厳密回数を表さない」と明記しています。したがって、PR本文の「exact argv contract」「fake-CLI invocation trace を確認」という説明は、現在のテスト証跡より強すぎます。

最小修正

新しい共通ハーネスや production 変更は不要です。AC5 テスト内だけで次を行えば十分です。

  1. rer.subprocess.run の元関数を保存する。
  2. argv を記録した後、保存した本物の関数へ委譲する wrapper を設定する。
  3. --deadline-monotonic-ns が一度だけ存在し、整数値を伴うことを確認する。
  4. fake gh wrapper 自体で sys.argv[1:] を JSONL に一行ずつ記録し、テスト終了後に三コマンドの実 argv と順序を確認する。
  5. spark_mode=None の固定条件では decision in ("ready", "degraded") ではなく、decision == "ready" を要求する。
  6. producer CLI が明示 deadline を使用することについては、--deadline-monotonic-ns 0 で real producer を一度起動し、GitHub subprocess が一件も spawn されず deadline_exhausted になる小さな境界テストを追加する。

これで、「root が引数を作る」「子プロセスへ渡る」「producer parser が使用する」「leaf CLI は fake だけ」という連鎖を、重い基盤なしで固定できます。


P2-1: AC2 テストは「Spark timeout」ではなく「Spark 起動前の deadline exhaustion」を試している

PR #2394 の元 finding は、optional Spark probe が実際に開始され、その timeout によって残り共有予算を使い切るケースでした。Python の subprocess.run(timeout=...) は timeout 時に子プロセスを終了して待機した後に TimeoutExpired を送出するため、長い optional probe が実時間の共有予算を消費するという前提は正しいです。([Python documentation]1)

現在の新テストは、三つの GitHub probe が fake clock を 90 → 91 → 92 → 100秒 と進め、Spark が残り時間を確認した時点ですでに deadline と同値にしています。そのため sh は一度も spawn されず、期待 reason も、

preflight_deadline_exhausted:spark_env_only

です。これは有用な no-spawn-on-exhaustion テストですが、「Spark が正の timeout を受け取って開始され、TimeoutExpired になった」という AC2 の本来のシナリオではありません。

最小修正は、現在のテストを次の条件に変えることです。

github_auth             completed
github_repo_read        completed
controlled_github_read  completed
spark_env_only          正の remaining timeout で spawn
                        → TimeoutExpired

そして以下を確認します。

observed command order = gh, gh, gh, sh
spark timeout > 0
reason = preflight_probe_timeout:spark_env_only
github capabilities = ready
decision = degraded

既存の test_expired_deadline_spawns_no_new_process が no-spawn ケースをすでに保持しているので、新しい scheduler、budget reservation、sleep ベースの実時間テストは不要です。


P2-2: malformed payload テストは、新しく修正した _run_env_only_preflight() 境界を通っていない

production 側では _validate_spark_env_payload() が追加され、次の三フィールドを bool/dict として検証しています。

binary_available
chatgpt_auth
chatgpt_auth.available

これは適切です。文字列 "false" を truthy として扱うことや、chatgpt_auth: null に対する .get() 例外を防げています。

一方、test_malformed_spark_payload_returns_structured_reason は _run_env_only_preflight 自体を monkeypatch し、テスト内で作った ProbeOutcome(PROBE_COMPLETED, stdout=...) を直接 assess() に渡しています。そのため、新しく追加された _run_env_only_preflight() 内の JSON parse と validator はこのテストでは一度も実行されません。

現在は assess() 側でも再度 parse・validate しているため、今の production behavior に未捕捉例外が残っているとは判断しません。ただし、parse boundary の所有箇所が二重化され、テストも片方しか通らないので、将来の整理時に再び false-green になりやすい構造です。

修正は小さくて済みます。六ケースの policy mapping テストは残し、それとは別に代表ケース一件だけ、

{"binary_available": true, "chatgpt_auth": null}

を fake subprocess.run の sh stdout として返し、real _run_env_only_preflight() を通して PROBE_MALFORMED_OUTPUT になることを確認してください。JSON Schema packageや共通 validator frameworkは不要です。

また、既存の、

test_producer_cli_without_deadline_creates_local_deadline

は現在も assess() を丸ごと置換し、CLI が None を渡すことしか確認していません。新しい AC4 テストが実際のローカル deadline 生成を証明しているので、この旧テストは、

test_producer_cli_without_deadline_passes_none_to_assess

へ改名するだけで十分です。


P2-3: gh auth status の誤ブロックは本PR外だが、実用性のため次に処理すべき

現在の root probe は引き続き裸の、

gh auth status

です。GitHub CLI の公式仕様では、hostname を指定しない場合は既知の全 host・全 account を確認し、どれか一つに認証問題があると exit 1 になります。そのため、github.com の現在の account が正常でも、古い Enterprise host や非active account の不整合で preflight が block される可能性があります。(GitHub CLI)

これはすでに Issue #2404 として、次への変更が分離されています。

gh auth status --active --hostname github.com

Issue #2401 でも明示的に Out of Scope とされているため、PR #2410へ混ぜる必要はありません。ただし、個人開発の操作性に直接効く改善なので、PR #2410の後に優先して処理する価値があります。


妥当だった設計判断

Probe ordering

required GitHub probe を optional Spark より先に実行する修正は妥当です。Spark が最後なら、Spark timeout後に確認すべき required subprocess は残らず、preferred + allowed を安全に degraded へできます。新しい並列 scheduler や probe ごとの予約予算は不要です。

Absolute monotonic deadline

root が一つの絶対 monotonic_ns deadline を作り、producerへ整数で渡す方式は維持すべきです。Python の monotonic clock はシステム時計更新の影響を受けず、現在の対応環境ではプロセス間で同じ clock を使用します。relative timeout を階層ごとに再生成するより、現行方式の方が単純で正確です。([Python documentation]3)

not_schema_change

public field 集合と型は変わっておらず、actual root consumer は structured result を保持したうえで、最終的には ready/degraded を proceed、blocked を stop として扱っています。probe順序と理由の並びは観測可能な挙動変更ですが、wire schema の変更ではありません。Schema Consumer Inventory: N/A は妥当です。

Live test の分離と locked verification

github_live markerを既存の実環境 integration testへ付け、通常 suite から除外する方針も適切です。pytest は登録 marker を -m "not ..." で deselectでき、現在の pyproject.toml もその設定を持っています。uv run --locked も、lockfileが古い場合に自動更新せず失敗させるため、再現可能な verification commandとして正しい選択です。 ([pytestドキュメント]4)

配布・移行

変更対象は repository-internal な Python producer と pytest に限定され、公開package、plugin install、release artifact、schema migrationはありません。したがって install smoke、配布表、migration harnessを追加する必要はありません。PR #2410では、既存の subprocess 境界を一件正確に検証するだけで十分です。


推奨アクション

production の probe順序変更と validator はそのまま維持してください。修正対象はほぼ test_capability_preflight_review_fixes.py とPR本文だけです。

  1. AC5で root producer argv を記録し、deadline 引数を確認する。
  2. real producer が明示 deadline を使用する小さな expired-deadline ケースを加える。
  3. fake gh wrapperで実 argvを記録するか、PR本文の「exact argv trace」主張を撤回する。Issue契約上は記録する方を推奨します。
  4. AC2を sh が実際に spawnされて TimeoutExpired になるケースへ変更する。
  5. malformed payloadについて、real _run_env_only_preflight() を通る代表ケースを一件追加する。
  6. focused suiteとPython regressionを再実行し、実際に観測した内容だけで Runtime Verification Evidence を更新する。

この範囲なら、新しいセキュリティ層、汎用ハーネス、process supervisor、JSON Schema基盤を増やさずに、PR #2410の目的である「false-greenの解消」を完遂できます。

…指摘へ整合させる (#2401)

PR #2410 への OWNER REQUEST_CHANGES (P1-1/P2-1/P2-2) fix_delta。

- AC5 (test_root_to_producer_transports_deadline_with_fake_external_clis):
  実 subprocess.run をラップして root が構築した producer argv を記録し
  `--deadline-monotonic-ns` の一意存在と整数値を検証。fake `gh` wrapper
  自体が sys.argv[1:] を JSON line で記録するようにし、fixture の
  calls[] (非厳密トレース) に頼らず 3 回の gh 呼び出しの exact argv/order
  を照合。spark_mode=None 固定条件で decision=="ready" を厳密化。
  --deadline-monotonic-ns 0 で実 producer を直接起動し GitHub subprocess
  が一切 spawn しないことを確認する境界テストを追加。
- AC2 (test_required_probes_run_before_optional_spark_and_starvation_degrades):
  spawn 前 deadline 消費シナリオ(既存 test_expired_deadline_spawns_no_new_process
  でカバー済み)ではなく、spark probe が正の残り timeout で spawn し
  TimeoutExpired を受ける実シナリオへ変更。
- AC3: 実 _run_env_only_preflight() を直接呼び出し (assess() 経由の
  monkeypatch 迂回なし) chatgpt_auth: null の malformed 判定境界を検証
  する追加ケースを1件追加。既存6ケースは維持。
- test_producer_cli_without_deadline_creates_local_deadline を
  test_producer_cli_without_deadline_passes_none_to_assess へリネーム
  (挙動変更なし、AC4新規テストとの役割分担を明記)。

Allowed Paths内2ファイルのみ変更。focused suite 25 pass、full
scripts/claude-gpt/tests/ suite 344 pass, 1 skip。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

PR Review Verdict (iteration 1, fix_delta 対応)

OWNER の REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/2410#issuecomment-5465398027)で指摘された P1-1 / P2-1 / P2-2 が、実際のコード・テストを独立に読んで解消済みであることを確認しました。

Mergeability

  • mergeable: MERGEABLE
  • mergeStateStatus: CLEAN
  • reviewed_head_sha: fb3cdab

Evidence Check

  • fresh worktree で head fb3cdab を checkout し、focused suite (25 passed) + 全体 scripts/claude-gpt/tests/ suite (344 passed, 1 skipped, 2 deselected) を独立再実行し PR 本文の申告と一致確認
  • CI required checks(python-test/lint/typecheck/build/test/validate-generated-artifact)全て SUCCESS 確認
  • Allowed Paths gate: 変更5ファイル全て Issue 実装: Address remaining capability preflight review findings #2401 の Allowed Paths 内

P1-1(blocking, OWNER指摘)解消確認

  • producer argv 捕捉・--deadline-monotonic-ns 1回・整数値であることを assert
  • fake gh wrapper 自体が実 argv/順序を記録・assert(fixture の permissive normalization に非依存)
  • spark_mode=None で decision == "ready" の厳密一致
  • --deadline-monotonic-ns 0 の zero-spawn 境界テストを新規追加
  • PR本文の証跡記述は自己訂正済みで誇張なし

P2-1 / P2-2(OWNER指摘)解消確認

  • AC2: Spark probe が正の残り timeout で実際に spawn → 実 TimeoutExpired のシナリオに変更済み(gh,gh,gh,sh / preflight_probe_timeout:spark_env_only)
  • AC3: _run_env_only_preflight() を monkeypatch せず実関数経由で chatgpt_auth: null を検証する新規テスト追加

Blockers

なし

Non-blockers / Warnings

なし

verdict: APPROVE
reviewed_head_sha: "fb3cdabb8ccca41ddc138e3bd3a8afb0587c7f4c"
blockers: []
warnings: []

@squne121
squne121 marked this pull request as ready for review August 29, 2026 23:29
@squne121
squne121 merged commit df7edd6 into main Aug 29, 2026
53 of 62 checks passed
@squne121
squne121 deleted the worktree-issue-2401-capability-preflight-review-fixes branch August 29, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: Address remaining capability preflight review findings

1 participant