Skip to content

実装: Address remaining capability preflight review findings #2401

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: Bounded follow-up for the merged PR #2394 capability-preflight review findings.
change_kind: code

Parent Issue

none

Parent Goal Ref

  • Goal: Close the bounded capability-preflight review findings identified in merged PR feat: share capability preflight deadline #2394.
  • Desired Destination: Capability preflight probe ordering, malformed-output handling, deadline test fidelity, and hermetic root-to-producer verification evidence.

Current Validated Scope

  • Correct bounded capability-preflight probe ordering so required GitHub probes run before the optional Spark probe, and so controlled_github_read runs independently of root github_auth success/failure.
  • Validate only the Spark JSON fields actually consumed by the capability decision, and normalize malformed shapes into the existing structured reason without an uncaught exception.
  • Make shared-deadline tests faithful to the producer/root-consumer contract and hermetic, including one test that crosses the real root-to-producer subprocess boundary.
  • Remove the filename-based timeout-ownership blacklist test.
  • Preserve structured reasons, the existing single absolute monotonic deadline, and fail-closed behavior.

Remaining Parent Gaps

  • None. A new scheduler, deadline package, or security sandbox work requires a separate Issue.

Outcome

Updated capability-preflight source and hermetic tests make the merged PR #2394 review comment's five adopted findings pass deterministic tests for probe ordering, malformed Spark output validation, deadline fidelity (including a real root-to-producer boundary test), and removal of the filename-based timeout-ownership blacklist test, while preserving the existing single absolute monotonic deadline and public result schema.

Runtime Verification Applicability

decision: immediate
reason: "This Issue changes probe ordering, subprocess-spawn conditions, and Spark JSON parsing in scripts/claude-gpt/workflow_capability_preflight.py, plus a root-to-producer subprocess boundary test; these are runtime behaviors of external process invocation that static analysis cannot verify."
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC6, AC7]
execution_environment: "Deterministic pytest with faked external leaf CLIs (gh, claude-code-proxy or fixture preflight.sh); no live GitHub network, credentials, or user CLI state required."
skip_conditions: "none"
fallback_policy: "Producer-level unit tests are valid evidence for AC1-AC4 and AC6-AC7. AC5 alone requires the real root-to-producer subprocess boundary; a test that bypasses that boundary is not PASS evidence for AC5. A hermetic fixture failure is an ordinary test failure to fix within this PR, not automatic human escalation."
artifact_requirements: "Attach the focused pytest command, exit status, pass count, and a summary of captured producer argv / fake-CLI invocation traces to the PR Runtime Verification Evidence section."

In Scope

  • Reorder capability-preflight probes so the required GitHub probes (github_auth, then github_repo_read only when github_auth completed) run before the optional spark_env_only probe, and run controlled_github_read independently of root github_auth success/failure, all within the existing shared absolute monotonic deadline.
  • Preserve no-spawn behavior once the shared deadline is exhausted.
  • Add a small helper that validates only the Spark JSON fields consumed by the capability decision (binary_available: bool, chatgpt_auth: object, chatgpt_auth.available: bool) and normalizes malformed/invalid shapes into the existing structured malformed-output reason without an uncaught exception.
  • Strengthen shared-deadline tests to assert observed probe arguments and remaining timeout budgets from a controlled monotonic clock, and to prove assess() (not a monkeypatched replacement of assess()) creates exactly one local absolute deadline shared unchanged by all applicable probes.
  • Add one hermetic test that exercises the real root-to-producer subprocess boundary by reusing the existing skill_runtime_exec → workflow_start_entry → root_entry_router → workflow_capability_preflight.py fixture pattern already used by test_real_producer_blocked_on_fake_gh_auth_failure_posts_no_comment (the _install_fake_gh/_FAKE_GH_FIXTURE PATH-wrapper pattern, labeled "P1-4: real producer/consumer integration via a fake gh on PATH" in test_root_entry_router_workflow_capability.py); only external leaf CLIs (gh, claude-code-proxy or fixture preflight.sh) are faked, and the producer subprocess/result itself is not replaced with a fixture payload.
  • Add these new probe-ordering, malformed-output, deadline-fidelity, and root-to-producer tests to a new file, scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py, rather than as new test functions appended to an existing test file (Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305 canonical VC shape: a not-yet-created test file, not a new node-id on an existing file).
  • Remove the filename-based test_no_new_competing_timeout_ownership_module_introduced blacklist test from test_timeout_taxonomy_compat.py; absence of a competing timeout-ownership module is confirmed once during PR review instead of enforced by a permanent filename blacklist.
  • Mark the existing real-subprocess integration test test_workflow_capability_returns_structured_result() in test_workflow_capability_preflight.py with the already-defined @pytest.mark.github_live marker (pyproject.toml); it remains as optional live coverage and is not part of this Issue's hermetic close evidence.
  • Update this Issue's Verification Commands to uv run --locked pytest ... instead of uv run --with pytest python -m pytest ..., matching the project's pinned uv==0.11.29 and declared pytest dev dependency.

Out of Scope

  • A new scheduler or general-purpose probe orchestrator.
  • A new deadline package or cross-repository deadline framework.
  • Security sandbox, credential, or permission-model redesign.
  • Unrelated capability expansion or workflow remediation.
  • Scoping gh auth status to a specific host (--active --hostname); tracked as a separate small follow-up, not part of this Issue's PR feat: share capability preflight deadline #2394 review deltas.

Acceptance Criteria

  • AC1: Required probes run in the exact order defined above (github_auth → github_repo_read when github_auth completed → controlled_github_read independently of root auth outcome → spark_env_only last), verified by a new test in test_capability_preflight_review_fixes.py. A failed root github_auth skips root github_repo_read but does not skip controlled_github_read, verified by a second new test in the same file.
  • AC2: When required GitHub probes complete and the optional Spark probe consumes the remaining shared deadline, preferred/allowed returns degraded rather than blocked, and the GitHub probe results remain ready.
  • AC3: Invalid JSON and structurally invalid Spark payloads (non-dict top level, non-bool binary_available, missing/non-dict chatgpt_auth, non-bool chatgpt_auth.available) return a structured malformed-output reason without an uncaught exception. preferred/allowed degrades; required/forbidden blocks.
  • AC4: assess(deadline_ns=None) creates exactly one local absolute deadline via _local_deadline_ns() and passes it unchanged to all applicable probes.
  • AC5: A hermetic test invokes the real root consumer (root_entry_router.capability_preflight_result()) and the real producer child process (workflow_capability_preflight.py). Only external leaf CLIs are faked; the producer subprocess and its result are not replaced with a fixture payload.
  • AC6: test_no_new_competing_timeout_ownership_module_introduced is removed from test_timeout_taxonomy_compat.py. Absence of a competing timeout-ownership module is reviewed once in the PR and is no longer enforced by a permanent filename blacklist.
  • AC7: The focused, locked pytest suite (test_capability_preflight_review_fixes.py, test_timeout_taxonomy_compat.py, and the existing test_workflow_capability_preflight_deadline.py, including its existing test_expired_deadline_spawns_no_new_process no-spawn-on-exhaustion regression) passes without live GitHub access, provider credentials, or user gh CLI configuration.

Verification Commands

# 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

# AC2
$ 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

# AC3
$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_malformed_spark_payload_returns_structured_reason -q

# AC4
$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_assess_without_deadline_creates_one_shared_local_deadline -q

# AC5
$ uv run --locked pytest scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py::test_root_to_producer_transports_deadline_with_fake_external_clis -q

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

# AC7
$ 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

Allowed Paths

  • scripts/claude-gpt/workflow_capability_preflight.py
  • scripts/claude-gpt/tests/test_actor_scoped_capability_probe.py
  • scripts/claude-gpt/tests/test_spark_fallback_route.py
  • scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py
  • scripts/claude-gpt/tests/test_workflow_capability_preflight.py
  • scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py
  • scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py

Stop Conditions

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

Required Skills

  • Python subprocess and pytest

Required Design References

  • docs/dev/runtime-verification-policy.md
  • docs/dev/extension-surface-runtime-policy.yaml
  • docs/dev/agent-skill-boundaries.md

Scope Delta(任意)

N/A

Delivery Rule

1 Issue = 1 PR. Create a dedicated worktree and open a Draft PR by default. Do not split these bounded review findings across multiple PRs.

Source

Scope Overlap Note

Notes for Reviewer

  • Deterministic code and test-fixture improvements are the adopted remedy; a prompt or operator workaround does not correct probe ordering, parsing, deadline semantics, or reproducible evidence.
  • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py was removed from Allowed Paths: the AC5 root-to-producer test reuses the existing test_real_producer_blocked_on_fake_gh_auth_failure_posts_no_comment fixture pattern (real subprocess, fake gh on PATH) without modifying that file. Note: test_root_entry_router_advances_once_on_positive_fixture in the same file is NOT the right precedent to copy -- it monkeypatches subprocess.run to return a canned JSON payload instead of spawning the real producer, which is exactly what AC5 forbids.
  • Scoping gh auth status to a specific host is intentionally deferred to a separate small follow-up Issue rather than mixed into this bounded PR feat: share capability preflight deadline #2394 review-deltas Issue.
  • AC1-AC5's new tests live in a new file, test_capability_preflight_review_fixes.py, instead of new node-ids on the existing test_workflow_capability_preflight_deadline.py: the VC baseline preflight rejects existing_file.py::new_test_name as a non-canonical shape (Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305) and requires a not-yet-created file instead.
  • AC6's Verification Command uses a negated rg existence check (! rg -q ...) rather than running the whole test_timeout_taxonomy_compat.py file, since the target test currently exists and passes; the negated form fails at baseline (test still present) and passes once the test is removed.
  • Implementing AC1's new probe order will break the pre-existing, currently-passing assertion assert [call[0][0] for call in calls] == ["sh", "gh", "gh", "gh"] in test_all_four_probes_share_decreasing_remaining_timeout (test_workflow_capability_preflight_deadline.py, included in AC7's focused suite). Updating that assertion to the new order (["gh", "gh", "gh", "sh"]) is a required part of implementing AC1, not an optional strengthening.

Activity

  1. added
    triage-required
    on Aug 29, 2026
  2. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    判定

    verdict: REQUEST_CHANGES
    issue_readiness: not_ready
    direction: sound
    blocking_findings:
      P0: 1
      P1: 6
    non_blocking_findings:
      P2: 2
    recommended_scope:
      production: "probe順序変更 + 小さなSpark JSON validator"
      tests: "deadline忠実性 + 真のroot→producer境界 + 既存ブラックリスト削除"
      rejected_expansion:
        - new scheduler
        - deadline package
        - process supervisor
        - JSON Schema framework
        - security sandbox
        - permanent filename guard

    Issue #2401の方向性自体は正しいです。PR #2394の残存不具合を、共有monotonic deadlineを維持したまま小さく直す方針は妥当です。

    ただし、現状のIssue契約には誤った実装でもACを満たせるfalse-green経路が残っています。また、元レビューの5項目のうち1項目が、採否判断なしに消えています。着手前にIssue本文を修正すべきです。


    P0-1: AC4の「root→producer証跡」は、現在の検証方法では証明できない

    Issue #2401はAC4で、root consumerから実producerまでを通り、GitHubネットワーク・token・ユーザーCLI状態に依存しない再現可能な証跡を要求しています。さらに、producer/consumer経路を迂回するテストをPASS証跡として認めないと明記しています。

    しかし現在の対応テストであるtest_root_transports_one_deadline_and_keeps_watchdog_graceは、次の形です。

    • root_entry_router.subprocess.runを置換
    • 実producerを起動せず、テスト内で作ったJSON payloadを直接返す
    • rootが組み立てたargvとwatchdog timeoutだけを確認する

    つまりこれはrootからproducerへの引数組み立てテストであって、root→producerの実境界テストではありません。現在のAC4コマンドでdeadlineテストファイル全体を通しても、producerが一度も起動されないままPASSできます。

    必要な修正

    1件だけ、次の性質を持つテストを追加してください。

    test_root_to_producer_transports_deadline_with_fake_external_clis
    

    このテストでは以下を固定します。

    • 実物のroot_entry_router.capability_preflight_result()を呼ぶ

    • rootが呼ぶsubprocess.runは、argvを記録した後、保存した本物のsubprocess.runへ委譲する

    • 実物のworkflow_capability_preflight.pyを子プロセスとして起動する

    • fakeにするのは外部leafだけ

      • gh
      • claude-code-proxy、またはfixture用preflight.sh
    • producer subprocess自体やproducer返却payloadはfakeにしない

    • fake CLIの呼び出しを一時ファイルへ記録し、live GitHubへ到達していないことを確認する

    • rootが渡した--deadline-monotonic-nsとproducerのstructured resultを確認する

    リポジトリには既に、実際の

    skill_runtime_exec
      → workflow_start_entry
      → root_entry_router
      → workflow_capability_preflight.py
    

    を通すfixture設計があります。新しい共通ハーネスは作らず、この既存パターンをdeadlineテスト内で小さく流用すれば十分です。


    P1-1: 元レビューは5項目なのに、Issueは「4 findings」として1項目を黙って落としている

    PR #2394への元レビューは、次の5項目です。

    1. optional Spark probeがrequired GitHub probeより先に予算を消費する
    2. Spark成功JSONのshape不正が未捕捉例外になる
    3. local deadlineテストが名前どおりのことを証明していない
    4. focused suiteがhermeticではない
    5. ファイル名ブラックリストテストを削除すべき

    Issue #2401は「four identified findings」と書き、5番目をIn ScopeにもACにも入れていません。Issueにはコメントがなく、P3を意図的に却下したowner decisionも記録されていません。したがって、少なくとも記録上は採否判断なしの取りこぼしです。

    採用すべき修正

    test_no_new_competing_timeout_ownership_module_introduced()を削除対象に加えてください。

    現在のテストは、次の3ファイル名だけを禁止しています。

    "shared_deadline"
    "nested_timeout_manager"
    "timeout_ownership"

    この方式では、

    • 正当な将来実装でも、その名前なら失敗する
    • 同じ重複実装をdeadline_budget.pyという名前で作れば通る
    • IssueのOut of Scopeを、意味ではなく文字列で永久固定する

    という問題があります。個人趣味開発では変更自由度を下げるだけで、実装品質をほぼ保証しません。

    同リポジトリでは直近のPR #2372で、dead-code不在確認を恒久pytestにせず、PRレビュー時の一回限り確認へ戻した先例があります。今回も同じ方針が整合的です。

    Issue本文は、次のいずれかにする必要があります。

    • 推奨: 「5 findings」に直し、ブラックリストテスト削除をACへ追加
    • 代替: 「4 adopted findings」と明記し、P3を却下した理由をRejected Findingsに記録

    ワークフロー有用性を優先するなら、削除を採用する方がよいです。


    P1-2: 「review-required order」だけでは、actor-scoped契約を壊す実装を防げない

    現在の実装順は概ね次のとおりです。

    trusted uv
    spark_env_only
    github_auth
    github_repo_read
    controlled_github_read
    

    Sparkのprobe capとworkflow全体budgetがどちらも30秒なので、Sparkが先に30秒消費すると、GitHub必須probeが起動されないままworkflowがblockedになります。現在の実装とテストは、この誤ったsh → gh → gh → gh順を固定しています。

    必要な順序は明記すべきです。

    1. trusted uv
    2. github_auth
    3. github_repo_read
       - github_authが成功した場合だけ実行
    4. controlled_github_read
       - root github_authの成否とは独立して実行
    5. spark_env_only
       - spark_modeが指定された場合だけ実行
    

    特に重要なのは、controlled_github_readをroot側のgithub_auth成功に従属させないことです。

    Issue #2340は、root shellとcontrolled executorを別のexecution substrateとして扱い、controlled側のsanitized environmentを独立検証する契約です。root authが失敗したからといってcontrolled probeまで省略すると、actor-scoped capabilityを再び一つのroot判定へ潰すことになります。

    必須の回帰ケース

    最低限、次の2ケースが必要です。

    ケースA: optional Sparkが残り予算を使い切る

    github_auth        completed
    github_repo_read   completed
    controlled_read    completed
    spark_env_only     timeoutし、fake clockをdeadlineまで進める
    
    preferred + allowed
    → decision = degraded
    → GitHub結果はreadyのまま
    

    ケースB: root auth失敗時もcontrolled probeは実行される

    github_auth        nonzero
    github_repo_read   skipped
    controlled_read    executed independently
    spark_env_only     last
    

    単にargvの先頭要素を並べるだけでなく、最終decisionとactor capabilityまで確認すべきです。


    P1-3: malformed-outputのテストが、修正すべきparse境界を迂回している

    現在の_run_env_only_preflight()は、JSONをparseした後、トップレベルがdictであることしか確認していません。その後の_spark_capability()は次に相当する処理を行います。

    env_only_result.get("chatgpt_auth", {}).get("available")

    したがって、次のような構造はJSONとしては成功しますが、後段でAttributeErrorになります。

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

    また、文字列を受理した場合はbool("false") == Trueなので、次の不正値を「利用可能」と誤判定し得ます。

    {
      "binary_available": "false",
      "chatgpt_auth": {
        "available": "false"
      }
    }

    現在のコードはトップレベルdictしか確認せず、後段でbool coercionしています。

    さらに現在のtest_successful_malformed_spark_output_returns_structured_reasonは、_run_env_only_preflight()自体をmonkeypatchしてProbeOutcome(PROBE_COMPLETED)を返しています。つまり、実際に壊れているparse境界を通りません。このテストは、parse境界が未修正でも別の場所で例外を握りつぶせばPASSします。

    最小実装

    JSON Schemaや共通validation packageは不要です。消費する3フィールドだけを小さなhelperで検査してください。

    def _parse_spark_env_only_payload(stdout: str) -> dict | None:
        try:
            payload = json.loads(stdout)
        except (json.JSONDecodeError, TypeError, ValueError):
            return None
    
        if not isinstance(payload, dict):
            return None
    
        if type(payload.get("binary_available")) is not bool:
            return None
    
        chatgpt_auth = payload.get("chatgpt_auth")
        if not isinstance(chatgpt_auth, dict):
            return None
    
        if type(chatgpt_auth.get("available")) is not bool:
            return None
    
        return payload

    preflight.sh --env-onlyが実際に生成する値も、この3フィールドはboolean/object/booleanです。外部proxyの生出力をPython側で再解釈せず、リポジトリ所有のJSON境界だけを検証するのが適切です。

    テストでは_run_env_only_preflight()を置換せず、subprocess.runのsh呼び出しだけにmalformed stdoutを返してください。

    最低限の入力集合は以下です。

    not-json
    []
    {}
    {"binary_available": 1, "chatgpt_auth": {"available": true}}
    {"binary_available": true, "chatgpt_auth": null}
    {"binary_available": true, "chatgpt_auth": {"available": "true"}}
    

    全ケースについて、

    preferred + allowed   → fallback_only / degraded
    required + forbidden  → unavailable / blocked
    producer exit          → 0
    malformed reason       → 1回だけ含む
    

    を固定すべきです。


    P1-4: local deadlineテストは依然として名前と証明内容が一致していない

    現在のテスト名は、

    test_producer_cli_without_deadline_creates_local_deadline
    

    ですが、テストはassess()全体をfakeへ置換し、main()がdeadline_ns=Noneを渡したことだけを確認しています。

    つまり証明しているのは、

    CLI引数省略
    → main()がassess(deadline_ns=None)を呼ぶ
    

    だけです。

    実際の、

    deadline_ns = _local_deadline_ns() if deadline_ns is None else deadline_ns

    が削除されても、このテストは通ります。

    必要な修正

    既存テストは正直な名前へ変更します。

    test_producer_cli_without_deadline_passes_none_to_assess
    

    別途、実物のassess()を使うテストを追加します。

    test_assess_without_deadline_creates_one_shared_local_deadline
    

    このテストでは、

    • _local_deadline_ns()をsentinel値へmonkeypatch
    • 呼び出し回数が1回
    • github_auth
    • github_repo_read
    • controlled_github_read
    • spark_env_only

    の全probeが同じsentinelを受け取ることを確認します。

    AC1とAC3の現在の対応も入れ替わっています。

    • AC1は「順序 + no-spawn」だが、指定コマンドは順序だけ
    • AC3は「observed arguments + remaining budgets」だが、指定コマンドはdeadline直後のno-spawnだけ

    ACとnode-idを一対一に対応させるべきです。

    なお、Pythonのsubprocess.run(timeout=...)はtimeout後に子を終了して待機してから例外を返し、process creation自体は即時中断できない場合があります。そのため、テストすべきなのは渡された残りbudgetとdeadline後のno-spawnであり、実時間が厳密に30.000秒以内かどうかではありません。absolute monotonic_ns()を共有する設計自体は妥当です。 ([Python documentation]1)


    P1-5: Runtime Verificationのapplicable_acs: AC4は自己矛盾している

    Issueは変更理由として、

    • external process invocation
    • output parsing
    • deadline semantics

    を挙げています。

    それにもかかわらず、Runtime Verificationの対象はAC4だけです。しかし実際には、

    • AC1: probe invocation/order
    • AC2: malformed subprocess output
    • AC3: timeout budget/no-spawn
    • AC4: root→producer boundary
    • AC5: regression

    の全てがruntime behaviorです。元のIssue #2322も、fake clockとfake subprocessで全ACをimmediate runtime verification対象としていました。

    また、

    hermetic fixture cannot execute
    → STOPしてIssue comment
    

    というskip conditionは過剰です。

    fixtureが壊れた場合は通常のtest failureとして、同じPR内で修正すればよいだけです。fixture実行失敗のたびに人間停止・Issue commentを要求すると、今回のような小さなfollow-upが運用ゲートになります。

    推奨契約

    decision: immediate
    applicable_acs:
      - AC1
      - AC2
      - AC3
      - AC4
      - AC5
    
    execution_environment:
      deterministic pytest;
      no live GitHub or proxy-provider access;
      project-pinned Python/uv toolchain may be used
    
    skip_conditions: none
    
    fallback_policy:
      - producer-level tests are valid evidence for producer ordering/parsing/deadline behavior
      - AC4 alone requires the real root-to-producer subprocess boundary
      - fixture failure is FAIL, not automatic human escalation
      - stop only when repair requires an Out-of-Scope production change

    「producerを直接呼ぶテストは一切PASS証跡にならない」と広く解釈すると、AC1~AC3まで重いE2Eへ寄せることになります。境界証明が必要なのはAC4だけ、と明確に分けるべきです。


    P1-6: focused verificationがhermeticではなく、uv --with pytestも再現性を下げている

    IssueのAC5はtest_workflow_capability_preflight.pyファイル全体を実行します。しかし同ファイルのtest_workflow_capability_returns_structured_result()は、実物の、

    sh preflight.sh --workflow-profile issue-to-impl
    

    を起動します。その先で実際の、

    gh auth status
    gh repo view
    gh api
    

    へ到達し得ます。これはGitHub認証・CLI状態に依存しないhermetic close gateではありません。

    このintegration test自体には価値があるので、削除する必要はありません。

    推奨は次の分離です。

    • 新しいroot→producer fixtureをmerge必須のhermetic testにする
    • 既存の実環境integration testは@pytest.mark.github_liveを付けて保持
    • live smokeは任意実行とし、Issue close条件にはしない

    リポジトリのpyproject.tomlには既にgithub_live markerがあり、通常pytestでは除外する方針が定義されています。新しい分類やハーネスは不要です。

    また、Issueの全Verification Commandsが使っている、

    uv run --with pytest python -m pytest ...

    も変更すべきです。

    このリポジトリは既にdev dependencyとしてpytestを宣言し、uvのバージョンを==0.11.29へ固定しています。--with pytestはpytestを別のephemeral layerとして追加でき、project lockと競合する版も許容し得ます。ここでは再現性を下げるだけです。--lockedはlockfileを変更せず、古いlockなら失敗させるため、Issue検証にはこちらが適切です。 ([Astral Docs]2)

    使用すべき形は次です。

    uv run --locked python -m pytest ...

    --offlineは追加しない方がよいです。テスト本体はGitHub/proxyへ接続しない一方、初回環境ではuvがlocked dependencyを取得する可能性があります。依存cacheまでmerge条件にすると、個人環境で不要な失敗を増やします。


    P2-1: Scope Collision欄は実質的に誤検出で、調整判断に使えない

    Scope Collisionとして挙げられているIssueは、実際には次の内容です。

    これらは、#2401が変更するcapability preflightのprobe ordering、Spark JSON parsing、shared deadline testsとは実質的に別スコープです。広いallowed_paths: scripts/や.claude/.../scripts/が一致しただけのpath-prefix overlapに見えます。

    この列挙をC1として残すと、scope guardや実装Agentが無駄に停止・調整・人間エスカレーションする可能性があります。

    次の形へ置き換えるのが適切です。

    Implementation dependency: none
    
    Historical contract references:
    - #2322: single absolute monotonic deadline
    - #2340: actor-scoped controlled GitHub capability
    - PR #2394 review comment: source of the five follow-up findings
    
    Scope collision:
    - no validated exact-file/line collision known
    - broad path-prefix matches are non-blocking
    

    P2-2: 裸のgh auth statusは別Issueで対象hostへ絞る価値がある

    現在のroot auth probeは、

    gh auth status

    を実行しています。

    GitHub CLIの公式仕様では、hostを指定しない場合、既知の全host・accountを調べ、いずれかに問題があるとexit 1になり得ます。そのため、今回のGitHub.comリポジトリへ正常にアクセスできても、古いEnterprise hostや非active accountの不整合でworkflowをblockする可能性があります。 ([GitHub CLI]3)

    最小改善は次です。

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

    ただしこれはPR #2394レビューの残存差分ではないため、#2401には混ぜず、別の小さなfollow-upにするのがよいです。


    外部実装との照合結果

    absolute monotonic deadlineは維持すべき

    time.monotonic_ns()はシステム時計変更の影響を受けず、後退せず、プロセス間で同じclock domainを利用できます。rootがabsolute deadlineを整数で渡し、producerが残り時間を再計算する方式は、relative timeoutを段階ごとに作り直すより妥当です。新しいschedulerやdeadline managerは不要です。 ([Python documentation]4)

    subprocess.run(timeout=…)の現在の使い方も基本的に妥当

    timeout時には子を終了・waitした後にTimeoutExpiredが返るため、optional probeが共有予算を実時間で使い切るという元レビューの前提は正しいです。一方で厳密なwall-clock upper boundまでは保証されないため、process supervisorやsleepベーステストを追加する必要はありません。 ([Python documentation]1)

    claude-code-proxy codex auth statusはproduction probeとしては妥当

    proxyは保存された認証情報・account・expiryを確認するcodex auth statusを提供しています。productionでは現行probeを維持し、テストではfake executableでCLI契約だけを再現するのが適切です。実OAuth/keychainをhermetic testへ持ち込む必要はありません。 ([GitHub]5)


    Issue本文の推奨差し替え要点

    ## Goal
    
    Close the five adopted post-merge findings from PR #2394 while preserving
    the existing single absolute monotonic deadline and public result schema.
    
    ## In Scope
    
    - Execute required GitHub probes before optional Spark probing:
      1. trusted uv
      2. github_auth
      3. github_repo_read when root auth completed
      4. controlled_github_read independently of root auth
      5. spark_env_only when Spark was requested
    - Preserve no-spawn behavior after shared-deadline exhaustion.
    - Validate only the Spark JSON fields consumed by the capability decision:
      - binary_available: bool
      - chatgpt_auth: object
      - chatgpt_auth.available: bool
    - Preserve malformed-output typed reasons and existing degraded/blocked semantics.
    - Prove that assess() creates one local deadline and passes the same value
      to all applicable probes.
    - Add one real root-to-producer subprocess test with fake external leaf CLIs.
    - Delete the filename-based timeout-ownership blacklist test.
    - Preserve the existing live integration test as optional github_live coverage.
    
    ## Acceptance Criteria
    
    - [ ] AC1: Required probes run in the exact order defined above. A failed
          root auth skips root repo-read but does not skip controlled_github_read.
    - [ ] AC2: When required GitHub probes complete and optional Spark consumes
          the remaining deadline, preferred/allowed returns degraded rather than
          blocked.
    - [ ] AC3: Invalid JSON and structurally invalid Spark payloads return
          preflight_probe_malformed_output:spark_env_only without an uncaught
          exception. preferred/allowed degrades; required/forbidden blocks.
    - [ ] AC4: assess(deadline_ns=None) creates exactly one local absolute
          deadline and passes it unchanged to all applicable probes. A probe is
          not spawned when remaining time is non-positive.
    - [ ] AC5: A hermetic test invokes the real root consumer and real producer
          child process. Only external leaf CLIs are faked; the producer result
          is not replaced with a fixture payload.
    - [ ] AC6: test_no_new_competing_timeout_ownership_module_introduced is
          removed. Out-of-scope absence is reviewed once in the PR and is not
          enforced by a permanent filename blacklist.
    - [ ] AC7: The focused locked pytest suite passes without live GitHub,
          provider credentials, or user gh configuration.
    
    ## Runtime Verification Applicability
    
    - decision: immediate
    - applicable_acs: AC1, AC2, AC3, AC4, AC5, AC6, AC7
    - execution_environment: deterministic pytest with fake GitHub/proxy leaf CLIs
    - skip_conditions: none
    - fallback_policy:
      - producer unit tests are valid for AC1-AC4
      - AC5 requires the real root-to-producer subprocess boundary
      - fixture failure is a test failure, not automatic human escalation
    - artifact_requirements:
      - command
      - exit status and pass count
      - summary of captured producer argv and fake-CLI trace assertions
    
    ## Scope Collision
    
    - implementation dependencies: none
    - historical contract references: #2322, #2340
    - source: PR #2394 post-merge review
    - no validated exact-file or line-level collision is known

    推奨Verification Commands

    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py::test_required_github_probes_finish_before_optional_spark_timeout -q
    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py::test_malformed_spark_payload_returns_structured_reason -q
    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py::test_assess_without_deadline_creates_one_shared_local_deadline -q
    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py::test_expired_deadline_spawns_no_new_process -q
    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py::test_root_to_producer_transports_deadline_with_fake_external_clis -q
    uv run --locked python -m pytest scripts/claude-gpt/tests/test_workflow_capability_preflight_deadline.py scripts/claude-gpt/tests/test_timeout_taxonomy_compat.py -q

    より広いscripts/claude-gpt/tests回帰は実行してよいですが、#2401のclose根拠は上記focused suiteに置くべきです。


    最終評価

    Issue #2401は修正後なら価値の高い小規模follow-upです。実装規模も、本来は次の範囲で収まります。

    workflow_capability_preflight.py
      - GitHub probesを前へ移動
      - 小さなSpark payload validatorを追加
    
    test_workflow_capability_preflight_deadline.py
      - starvation/order test
      - malformed shape test
      - local deadline fidelity test
      - real root→producer test
    
    test_timeout_taxonomy_compat.py
      - filename blacklist testを削除
    
    test_workflow_capability_preflight.py
      - real GitHub経路のtestをgithub_liveへ分類
    

    新しいscheduler、共通schema、sandbox、process supervisor、永続artifact pipelineは不要です。上記の契約修正を入れれば、品質を上げながら個人開発のワークフローを重くしない形でAPPROVE相当になります。

  3. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

    OWNERのREQUEST_CHANGESレビュー(https://github.com/squne121/loop-protocol/issues/2401#issuecomment-5463051460)を受け、Issue契約を全面改訂しました。

    実施した修正(Step 4 rewrite、3 iteration + Step 2.5 semantic review、2 iteration)

    1. iteration 1: Runtime Verification Applicability を箇条書きから fenced YAML ブロックへ修正(checker の ^\s*field\s*: 正規表現が - field: 箇条書きにマッチしないバグを回避)。AC を AC1〜AC7 へ再構成し probe 順序・malformed JSON 検証・deadline 忠実性・root-to-producer 境界テスト・blacklist test 削除・hermetic focused suite を反映。Allowed Paths から未使用の root_entry_router.py を除去(scope_signal_guard の new_allowed_path_layer 誤検知も解消)。Scope Overlap Note の無関係 Issue 列挙を削除。
    2. iteration 2: Verification Commands を uv run --locked python -m pytest ... から uv run --locked pytest ... へ修正(--locked と python -m の組み合わせが VC preflight allowlist でブロックされるため)。
    3. iteration 3: AC1-AC5 の新規テストを既存ファイルへの新規 node-id 参照から、未作成の新規ファイル test_capability_preflight_review_fixes.py への参照へ変更(Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305 の非canonical VC shape 検出)。AC6 を否定 rg 形式に変更。
    4. Step 2.5 semantic review(1回目、medium finding): AC1 実装後に既存テスト test_all_four_probes_share_decreasing_remaining_timeout のハードコード済みアサーション(["sh","gh","gh","gh"])が壊れる懸念を検出・検証し、Notes for Reviewer に明記。
    5. Step 2.5 semantic review(2回目、high finding): AC5 の In Scope/Notes が誤った既存フィクスチャ(test_root_entry_router_advances_once_on_positive_fixture、実際は canned JSON を返す monkeypatch)を参照していたことを検出・検証し、正しい precedent(test_real_producer_blocked_on_fake_gh_auth_failure_posts_no_comment、実 subprocess + fake gh on PATH)へ訂正。
    6. Step 2.5 semantic review(3回目): assessment: clear、追加 finding なし。

    外部仕様 claim(time.monotonic_ns()、subprocess.run(timeout=)、gh auth status、uv run --locked 等)は web-researcher で一次資料照合済み。リポジトリ内 fact claim(probe 順序・JSON parse バグ・既存テスト実装・関連 Issue の実在性等)は codebase-investigator で全 13 件検証済み。

    Follow-up

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issue/2401#issuecomment-5463051460:P2-2"
          status: created
          issue:
            number: 2404
            url: "https://github.com/squne121/loop-protocol/issues/2404"
          reason: null
      note_only_observations: []

    OWNERレビューのP2-2(gh auth status の host 絞り込み)は本Issueのスコープ外として分離し、#2404 として起票済みです。

    Handoff

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: null
        generated_at: "2026-08-29T15:34:00Z"
        body_sha256: "sha256:4c4b16e249a2856474b174beeb30c0c0e3dab84063380df1f2b1b520d634a0a8"
      metadata:
        title_prefix_ready: false
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "label sync not attempted in this run"
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-08-29T15:34:00Z"
      checked_body_sha256: "sha256:4c4b16e249a2856474b174beeb30c0c0e3dab84063380df1f2b1b520d634a0a8"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    root_entry_router.py::run_root_transition() による同一ターン内 fresh review(capability preflight → live fetch → current-run issue-contract-review → live 再取得)の結果、route: invoke_impl_review_loop(reason: fresh_review_go_live_equality、reviewed_body_sha256 と observed_live_body_sha256 が一致、reviewed_base_sha と observed_base_sha が一致)を確認しました。ただし今回の依頼スコープは issue-refinement-loop 単体のため、impl-review-loop の実起動はこのターンでは行っていません。実装に進む場合は改めて指示してください。

  4. changed the title [-]Address remaining capability preflight review findings[/-] [+]実装: Address remaining capability preflight review findings[/+] on Aug 29, 2026
  5. removed
    triage-required
    on Aug 29, 2026
  6. self-assigned this
    on Aug 29, 2026
  7. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-29T22:15:31Z)

  8. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-29T22:20:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2410"
      head_sha: "99926493fb1f46c67db3677d728798c44188dcbd"
      issue_number: 2401
      termination_reason: approved
      merge_ready: false
      iteration: 0
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  9. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-29T23:30:00Z)

    OWNER の REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/2410#issuecomment-5465398027、P1:1/P2:3)を fix_delta として反映し、独立 pr-review-judge が再検証の上 APPROVE しました。

    • 次アクション: 人間レビュー → マージ → post-merge-cleanup
    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2410"
      head_sha: "fb3cdabb8ccca41ddc138e3bd3a8afb0587c7f4c"
      issue_number: 2401
      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: []
  10. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-08-30T00:00:00Z)

    • status: ok
    • 次アクション: なし(follow-up候補なし、parent issueなし、superseded PRなし)
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues: []
      note_only_observations: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

phase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions