Repository navigation
fix(agent-ops): capability 判定を claude --help ではなく実 runtime 挙動で行う - #1976
Conversation
`run_worktree_agent_runtime_smoke.py` の Claude capability preflight を `claude --help` の文字列検索から実際の fixed-argv invocation 結果に基づく 判定へ置き換える。help への非掲載は capability 不足を意味せず、 `--max-turns` は Claude Code 2.1.220 の `--help` から欠落していても 実際には受理される documented print-mode flag であるため、false SKIP を 引き起こしていた。 - unknown/unrecognized option 診断のみを capability SKIP(exit 77)へ 分類し、任意の non-zero exit を capability 不足として扱わない - `--max-turns` の bound 到達は flag 受理の証拠として bounded turn failure(FAIL 1)とし capability SKIP に昇格させない - interactive lane は structured-only flag(`--output-format` / `--include-hook-events` / `--no-session-persistence` / `--max-turns`)を forward しない - `--max-turns` を 1 以上の整数のみ受理するよう argparse type を追加 - SKILL.md / references/claude-code.md の capability 判定説明を 実 runtime 挙動ベースへ更新(AC8) - 実 Claude Code 2.1.220 による structured smoke で false SKIP せず 実 invocation まで到達する evidence を確認(AC9) - #1734 の runtime AC 再実行可能性を回帰テストへ反映(AC10) Closes #1960
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1976/ The preview will be removed when this PR is closed. |
判定REQUEST_CHANGES
ただし、現在の実装は Issue #1960 の契約を複数箇所で満たしていません。 ブロッカーP1-1. command-not-found 等の exit 77 では、依然として
|
…dence 欠落・resolved executable 未共有・capability 判定の stdout 誤混入を修正) - preflight_herdr / preflight_claude_available / preflight_codex_flags の SKIP 77 経路が schema_summary 構築前に早期 return しており summary.md が 一切書かれていなかった欠陥を修正し、全 controlled exit を単一の write_evidence finalizer 経由にした(Issue #1960 AC7) - preflight_claude_available / preflight_codex_flags を shutil.which() で resolved executable を一度だけ返す設計に変更し、version capture と structured invocation へ同一の絶対パスを共有させ、evidence に resolved_executable を追加した(Design Decision 5)。interactive lane は herdr 側で再解決されるため同一バイナリを保証できない旨を resolved_executable_binding_note として正直に記録する - classify_claude_structured_outcome のテキストベース分類を stderr のみへ 限定し、fixed-argv flag 名を明示するパーサーエラー行のみを狭く一致させ、 stdout に有効な JSON stream-json event が既に観測されている場合は parser-rejection と判定しないガードを追加した(Issue #1960 P1-3) - 上記の regression test を追加し、既存 AC1-AC10 の pass を維持したまま 74 tests green を確認した - PR body の Schema Change Applicability を、フィールド集合は変更するが versioned producer-consumer contract ではないため not_schema_change、と 正しい理由に訂正した Ref: #1976 (comment) Closes #1960
…fication # Conflicts: # scripts/agent-ops/run_worktree_agent_runtime_smoke.py
* feat(agy): add capability gate for AGY headless capabilities (#1941) `preflight_agy.py` becomes the single implementation SSOT for AGY capability detection. Adds a version parser (parse_agy_version_string), a fixed-argv parser-acceptance classifier for `--disable-slash-commands`, a runtime probe for leading-slash literal treatment, binary identity fingerprinting + drift detection, an in-process-only memoization cache, and a single finalizer that always persists a sanitized JSON artifact under `.claude/tmp/`. The capability matrix decomposes headless_permission_policy / hooks / disable_slash_commands into predicate-level supported / unsupported / unavailable / inconclusive / evidence_invalid results — evidence-source prioritized runtime_semantic_observation > parser_acceptance > changelog > help > version, so help/version alone never confirm `supported`. `pre_invocation_injected_tool_call` is pinned `unsupported` while upstream google-antigravity/antigravity-cli#728 is open. Predicates whose live enforcement verification is Issue #1979's responsibility are classified `inconclusive`, never fabricated as `supported`. Also fixes the existing early cli_incompatible exit on missing --help flags so it defers to the runtime smoke check (help absence is supporting evidence only, per PR #1976 design) — this was explicitly the bug #1941 asked to fix, and the pre-existing test asserting the old behavior is updated accordingly. `--require-capability` adds an additive 0/1/77 exit-code mode without touching the default invocation's existing ok-boolean exit 0/1. setup_check.py surfaces the additive `agy_capabilities` field without adding its own version/help parser or changing its existing single-boolean ok derivation. docs/dev/schema-governance.md records the additive `agy_capability_matrix/v1` extension to `agy_preflight_result/v1` (no v2 bump). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(agy): resolve OWNER fix_delta blockers in AGY capability gate (#1941) OWNER REQUEST_CHANGES on PR #1982 found the previous automated APPROVE inadequate: binary-identity binding was not actually applied to executed probes, the leading_slash_is_literal runtime probe tested the wrong argv and misclassified combined evidence, the same probe leaked the real HOME/XDG_* environment and had no cost gate, sanitization missed version_evidence.raw/agy.version and the in-memory return value, parser- rejection classification was too broad, setup_check.py never actually requested the capability matrix on the real invocation path, and memoization could bypass binary-identity drift detection. - preflight_agy.py: resolve the agy binary exactly once via os.path.realpath(shutil.which()) and bind every version/help/smoke/ capability probe to that single path; rewrite the leading-slash-literal probe to use the exact production argv with an isolated HOME/XDG_* env and a cost-confirmation gate (skips by default, exit taxonomy unaffected); route every external-facing output (return value, --json, --output-file, artifact) through the same sanitizer, including version_evidence.raw and a normalized agy.version + redacted sample; narrow classify_parser_acceptance() to require the specific --disable-slash-commands flag name and prioritize auth evidence; bind the capability memoization cache key to both pre-run and pre-runtime-probe binary identity plus an expanded config digest (.agents/hooks.json + global hooks path); populate a full-shaped capability matrix with per-predicate reasons on controlled early exits; and anchor version parsing to an explicit `agy` context line when multiple version-shaped tokens are present. - setup_check.py: check_agy_preflight() now requests compute_capabilities=True so the real invocation path actually populates the capability matrix. - Adds unit/integration tests for every P1/P2 finding, including a real subprocess round-trip against a swappable fake binary proving binary-identity drift is caught. - docs/dev/schema-governance.md: documents the agy.version / version_evidence.raw sanitization semantics change. All 9 original Issue #1941 AC verification commands, the full gemini-cli-headless-delegation test suite (1278 tests), and the repo-wide pytest suite (7633 passed) are green. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
run_worktree_agent_runtime_smoke.pyの Claude capability preflight を、claude --helpの文字列検索から実際の fixed-argv invocation 結果に基づく判定へ置き換えた(Issue 実装: run_worktree_agent_runtime_smoke.py の Claude capability 判定を --help 非掲載フラグでなく実 runtime 挙動に基づく判定へ修正する #1960)preflight_claude_flags(help 文字列検索)を撤去し、preflight_claude_available(claude実行ファイルの存在確認のみ)に置き換えたclassify_claude_structured_outcomeを追加し、structured lane の実行結果をcapability_skip(unknown/unrecognized option 診断のみ)・turn_limit_reached(--max-turns到達=flag 受理の証拠、FAIL 1)・runtime_outcome(既存の exit code / terminal event 判定)の 3 種へ narrow に分類する--max-turnsの forward を撤去し、structured-only flags に依存しないことを明示した--max-turnsに_positive_intを追加し、1 以上の整数のみを受理するようにした(0・負数は argument error).claude/skills/worktree-agent-runtime-smoke/SKILL.mdとreferences/claude-code.mdの capability 判定説明を、実 runtime 挙動ベースへ更新した(AC8)test_run_worktree_agent_runtime_smoke_help_capability.py(AC1-AC6 回帰)とtest_run_worktree_agent_runtime_smoke_runtime_evidence.py(AC9 回帰、fake claude binary で実 invocation 到達を独立証明)を追加したtest_run_worktree_agent_runtime_smoke.pyに 実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 の runtime AC 再実行可能性についての記述を追加した(AC10)preflight_herdr/preflight_claude_available/preflight_codex_flagsの SKIP 経路がschema_summary構築前に早期return EXIT_SKIPしていたため summary.md が全く書かれていなかった欠陥を修正し、これら 3 経路も含む全ての controlled exit を単一のwrite_evidencefinalizer 経由にした(AC7)preflight_claude_available/preflight_codex_flagsをshutil.which()で resolved executable を一度だけ返す設計に変更し、version capture(capture_runtime_version)と structured lane invocation(run_structured_claude/run_structured_codex)へ同一の絶対パスを共有させ、evidence にresolved_executableを追加した(Design Decision 5)。interactive lane は herdr 側で--kindから再解決されるため、同一バイナリの保証がないことをresolved_executable_binding_noteとして正直に記録したclassify_claude_structured_outcomeのテキストベース分類をstderrのみへ限定し、fixed-argv flag 名(--max-turns等)を明示的に含む「error:行頭付近のパーサーエラー行」のみを capability_skip と判定するよう narrow 化した。加えて stdout から有効な JSON stream-json event が既に観測されている場合は parser-rejection と判定しない(= runtime が既に起動した証拠を優先する)ガードを追加したChecks
uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_help_capability.py -q— 11 passed(fix-delta iteration: capability 判定の stdout/stderr 混同を防ぐ adversarial regression 2件を追加)uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py -q— 61 passed(fix-delta iteration: preflight SKIP 経路の summary.md 生成回帰 3件を追加)uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_runtime_evidence.py -q— 2 passed(fix-delta iteration:resolved_executable単一 resolve 回帰 1件を追加)rg -n "help への非掲載は capability 不足を意味しない" .claude/skills/worktree-agent-runtime-smoke/references/claude-code.md .claude/skills/worktree-agent-runtime-smoke/SKILL.md— 両ファイルで一致rg -n "1734" scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py— 一致uv run --locked ruff check scripts/agent-ops/run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_help_capability.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_runtime_evidence.py— All checks passedpnpm typecheck/pnpm lint/pnpm test/pnpm build(本 PR は Python runner / pytest / skill markdown のみを変更し、TypeScript ソースを変更しない)Schema Change Applicability
not_schema_changesummary.md(WORKTREE_AGENT_RUNTIME_SMOKE_RESULT_V1)のフィールド集合は変更する(本 PR でcapability_decision/capability_error_classificationを新規追加し、fix-delta iteration でresolved_executable/resolved_executable_binding_noteをさらに追加した)が、この artifact は他 Skill / SubAgent が読み取る versioned producer-consumer contract ではなく、worktree-local untracked な人間可読 evidence であるため、フィールド追加はnot_schema_changeと判断する(Schema Consumer Inventory 節参照。旧文言は「フィールド集合・型は変更していない」と事実誤認していたため、レビュー指摘(PR fix(agent-ops): capability 判定を claude --help ではなく実 runtime 挙動で行う #1976 owner REQUEST_CHANGES)を受けて訂正)。Schema Consumer Inventory
not_schema_change(上記 Schema Change Applicability)のため N/Asummary.mdは worktree-local untracked artifact であり、他 Skill / SubAgent が読み取る producer-consumer 境界の machine-readable contract ではないSafety Claim Matrix
claude --helpの文字列出現ではなく、実際に実行する fixed-argv invocation の結果(unknown/unrecognized option の狭い診断のみ)で SKIP を判定するclassify_claude_structured_outcome/test_help_omits_max_turns_but_runtime_accepts_flag_then_structured_smoke_runs/test_runtime_rejects_max_turns_as_unknown_option_then_skip77_with_summarytest_non_capability_runtime_failure_is_not_misclassified_as_skip--max-turnsの bound 到達(flag 受理の証拠)を capability 不足へ誤分類せず、runtime failure の exit 1 として扱うtest_max_turn_limit_reached_is_fail_not_capability_skip--output-format/--include-hook-events/--no-session-persistence/--max-turns)の help preflight に依存せず、--max-turnsを対話型起動へ転送しない--max-turns対応自体が実 runtime で別途確認されるまでは非対応のまま(Issue #1960 Outcome の明記通り)test_interactive_claude_does_not_require_or_forward_structured_only_flags--max-turnsは 1 以上の整数のみを受理し、0・負数は argument error として拒否するtest_max_turns_must_be_positivepreflight_herdr/preflight_claude_available/preflight_codex_flagsの SKIP 77 経路でも allowlist-onlysummary.mdが必ず生成される(AC7)test_given_no_claude_binary_when_preflight_runs_then_skip77/test_given_codex_help_introspection_fails_when_preflight_runs_then_skip77_with_summary/test_given_herdr_preflight_fails_when_interactive_mode_runs_then_skip77_with_summaryshutil.which()で一度だけ resolve し、version capture と structured invocation が同一の絶対パスを共有する(Design Decision 5)--kind経由再解決のため同一バイナリ保証は無く、evidence にその制約を明記するのみtest_resolved_executable_is_single_path_shared_by_version_capture_and_invocationtest_stdout_prose_saying_unknown_option_with_unrelated_stderr_failure_is_not_misclassified_as_skip/test_stdout_quoted_max_turns_text_does_not_override_genuine_stderr_parser_rejection動作検証証跡(Runtime Verification Evidence)
## Runtime Verification Applicabilityはdecision: immediate(applicable_acs: AC9)。AC9: 実 Claude Code 2.1.220 による structured smoke が help 非掲載を理由に SKIP しないことの確認
linked worktree(
.claude/worktrees/issue-1960-runtime-capability-classification)内で、実 Claude Code CLI(claude --version→2.1.220 (Claude Code))に対して実際に runner を実行した。summary.md(抜粋、redacted):claude --helpは本環境の 2.1.220 でも--max-turnsを表示しないが(Issue #1960 背景の通り)、runner は help 出力の非掲載を理由に SKIP せず、実際の fixed-argv invocation まで到達しcapability_decision: runtime_outcome・exit_code: 0の evidence を残した。fake-binary ベースの回帰テスト(test_structured_smoke_reaches_real_invocation_via_subprocess_despite_help_omission)が同じ挙動を継続的に検証する。Notes
--max-turns自体の削除、Claude Code バージョン固定、generic CLI capability framework の新設、Codex CLI lane の unrelated refactor、Herdr session isolation/cleanup 設計の変更、実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 の agent 分割実装rg -n "1734" scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.pyは文字列出現のみを確認する弱い検証であり、実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 consumer 自体の runtime AC を再実行して証明するものではない。実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 は本 fix-delta 時点で issue-creator/issue-editor へ分割再設計されており、この Issue 実装: run_worktree_agent_runtime_smoke.py の Claude capability 判定を --help 非掲載フラグでなく実 runtime 挙動に基づく判定へ修正する #1960 の Allowed Paths(本ファイル群のみ)の範囲内では 実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 側の実 Agent persona を指定した runtime smoke を新設できない(Allowed Paths 拡張が必要でこの Issue のスコープ外)。実際に本 PR で独立に確認できているのは、AC9 の fake-binary 回帰(test_structured_smoke_reaches_real_invocation_via_subprocess_despite_help_omission)と実 Claude Code 2.1.220 での動作検証証跡(下記)が「help 非掲載による false SKIP がもう起きない」ことのみで、実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 固有の consumer シナリオそのものの再実行は本 PR の検証範囲に含まれない。実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 側での実際の runtime AC 再実行確認は 実装: issue-author を issue-creator/issue-editor に分割し実行時に真である Skill 権限境界を実装する #1734 自身(またはその後継 Issue)側のフォローアップとして扱う。