Repository navigation
fix: uv_not_found 診断可能性とローカル dev 復旧手順を追加する - #2314
Conversation
`_resolve_trusted_executable("uv", ...)` の探索失敗時に、実際に shutil.which へ
渡した candidates_searched・expected_version・recommended_install_dir・
remediation_hint を含む構造化 JSON 診断ペイロードを uv_not_found: prefix 付き
RuntimeError として送出するようにした。git 等の非 uv executable の探索対象・
エラー文字列は変更しない。docs/dev/workflow.md に CI hosted-toolcache lane /
system-directory lane / no-sudo user-local lane を区別した復旧手順を追記した。
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2314 closed). |
判定REQUEST_CHANGES 対象は Draft PR #2314、head FindingsP1-1: 「consumerなし/schema非該当」は誤り。既存の構造化preflightへ二重JSONとして流出するPR本文は、 既存の したがって、missing時の実際の出力は概念的に次の形になります。 {
"checks": {
"uv": {
"status": "trusted_uv_missing",
"reason": "uv_not_found: {\"error\":\"uv_not_found\", ...}"
}
}
}つまり、構造化JSONの中へ、prefix付きJSON文字列をもう一度埋め込む二重エンコードです。既存wrapperのdocstringは しかも、 現行テストがgreenでも検出できません。
推奨修正は、診断を実際のpreflightでも使える構造にすることです。 {
"status": "trusted_uv_missing",
"reason": "uv_not_found",
"resolved_path": null,
"diagnostic": {
"candidates_searched": [],
"expected_version": "0.11.29",
"recommended_install_dir": "/home/user/.local/bin",
"remediation_hint": "..."
}
}
スコープを最小化するなら、wrapper側では新しい例外を P1-2: 復旧手順が、対象であるisolated
|
人間 REQUEST_CHANGES(PR #2314 review comment)を反映するfix_delta iteration。 trusted_runtime_capabilities.check_trusted_uv() の実consumer経路(workflow_capability_preflight.py) 向けにreasonを安定したcode文字列へ戻しdiagnosticを別フィールドへ分離、 workflow.mdのローカル復旧手順を実account home導出・厳密なversion pin抽出・探索順序の訂正で書き直し、 claude-gpt-runtime-prerequisites.mdへSSOTポインタを追加した。
impl-review-loop 判定(fix_delta iteration、Issue #2275)Mergeability: Evidence Check:
Blockers: なし Non-blockers / Warnings: なし verdict: APPROVE
reviewed_head_sha: "b7d386b32d49b4c665ba003c3aea0f13476fe85c"
blockers: []
warnings: [] |
Summary
scripts/agent-guards/skill_runtime_exec.pyの_resolve_trusted_executable("uv", ...)が探索失敗時に送出する例外を、uv_not_foundの裸文字列からuv_not_found: <JSON payload>へ変更した。payload はerror/candidates_searched(実際にshutil.which()へ渡したpath=引数そのもの。CI hosted-toolcache lane と no-sudo user-local lane(account-home.local/bin)はディレクトリが実在する場合のみ含まれるが、system-directory lane(/usr/local/bin・/usr/bin等)は既存の固定リストであり実在確認なしに無条件で含まれる) /expected_version(pyproject.tomlの pin) /recommended_install_dir(real account home の.local/bin。未作成でも算出) /remediation_hintの 5 キーのみを含む。git等uv以外の trusted executable の探索対象・{name}_not_foundエラー文字列は一切変更していない。docs/dev/workflow.mdに### Trusted uv のローカル開発復旧セクションを新設し、CI hosted-toolcache lane / no-sudo user-local lane / system-directory lane を区別した復旧手順を明記した。scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py(既存ファイル)へ、AC1〜AC4 に対応する 4 つの behavior-level pytest 関数を追加した。fix_delta iteration(人間 REQUEST_CHANGES 反映、review comment)
scripts/agent-guards/trusted_runtime_capabilities.pyのcheck_trusted_uv()が_resolve_trusted_executable()を直接呼び出し、RuntimeErrorを捕捉してstr(exc)をreasonへ格納していたため、scripts/claude-gpt/workflow_capability_preflight.pyがCLAUDE_GPT_WORKFLOW_CAPABILITIES_V1.checks.uv.reasonへ二重 JSON エンコードされた文字列を伝播させてしまう実 consumer 経路が判明した。check_trusted_uv()側でuv_not_found:prefix を剥がして JSON を一度だけ parse し、reasonは安定した reason code 文字列(例:uv_not_found)のまま、parse 済み payload を新設のdiagnosticフィールドへ分離して伝播するよう修正した。非uv_not_found形式(uv_version_mismatchや、将来の legacy/plain-string メッセージ)はreason = 元のメッセージ,diagnostic = nullへ defensive fallback する。docs/dev/workflow.mdの復旧手順を、ambient$HOME(sandbox/isolated 環境では実 OS アカウントと乖離しうる)ではなくpython3 -c 'import os, pwd; print(pwd.getpwuid(os.getuid()).pw_dir)'で求めた real OS account home を使うよう修正した。またpyproject.tomlの[tool.uv].required-version(==X.Y.Zの PEP 440 specifier)からtomllibで bare なX.Y.Zを抽出してから versioned installer URL に使うよう修正し(==付きのまま URL へ渡さない)、version 確認は絶対パスの${account_home}/.local/bin/uv --versionで行うようにした。docs/dev/workflow.mdの説明順序が実装(hostedtoolcache -> account-home(user-local) -> systemの順で_dedupe_path_entries()に渡す)と逆(hosted -> system -> user-local)になっていたバグを修正し、実務上の含意(pin と一致しない~/.local/bin/uvが system lane より先に検査されるため、system lane に正しい version があっても silently fallback せず version-mismatch で fail する)を追記した。あわせてscripts/claude-gpt/tests/test_workflow_capability_preflight.pyのtest_workflow_capability_rejects_unpinned_local_bin_uvに残っていた「hostedtoolcache/system が account-home より優先される」という誤ったコメントを実際の順序に合わせて修正した。docs/dev/claude-gpt-runtime-prerequisites.mdに、詳細な探索lane・version pinの正規化・復旧コマンドはdocs/dev/workflow.mdの「Trusted uv のローカル開発復旧」を正本とする旨の短いポインタ行を追加した。test_uv_not_found_diagnostic_payload_keysにキー集合だけでなく実際の値(error == "uv_not_found"、expected_versionが pin と一致、recommended_install_dirが real account home 由来のパスと一致、remediation_hintが非空)の assertion を追加した。またcheck_trusted_uv()->workflow_capability_preflight.assess()-> 外側 JSON までの consumer 経路を、resolver を monkeypatch した deterministic テスト(実 uv アンインストールや live canary なし)で検証するテストをscripts/agent-guards/tests/test_trusted_runtime_capability_preflight.pyとscripts/claude-gpt/tests/test_workflow_capability_preflight.pyへ追加した。Checks
uv run --locked pytest scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py scripts/agent-guards/tests/test_trusted_runtime_capability_preflight.py scripts/claude-gpt/tests/test_workflow_capability_preflight.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q— 94 passeduv run --locked ruff check(変更した全 Python ファイル) — All checks passeduv run --locked pytest scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q(Issue 原本 AC6 コマンド) — 66 passed(回帰なし)scripts/agent-guards/**/scripts/claude-gpt/**とdocs/dev/**のみを変更する Python-only の変更であり、pnpm typecheck/pnpm lint/pnpm test/pnpm build(JS/TS 側)は対象コードに影響しないため実行は省略した。影響ファイルは Allowed Paths 内の 7 ファイルのみ(git diff --statで確認済み)。Schema Change Applicability
not_schema_changeuv_not_foundの例外メッセージ形式(文字列 → JSON payload 付き文字列)を変更するが、これはこのモジュール内部のRuntimeErrorの message 文字列であり、外部 schema ファイル・JSON Schema 定義として公開された machine-readable contract ではない。ただし fix_delta iteration で判明した通り、scripts/agent-guards/trusted_runtime_capabilities.check_trusted_uv()が実際にこのRuntimeErrorを捕捉してCLAUDE_GPT_WORKFLOW_CAPABILITIES_V1.checks.uv.reasonへ投影する実 consumer 経路が存在するため、その consumer 側でreason(安定 code 文字列)とdiagnostic(parse 済み payload)を分離する修正を同一 PR に含めた。CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1のchecks.uvに新規diagnosticフィールドが追加されるが、これは既存キー(status/reason)の型・意味を変更しない後方互換な追加である。Schema Consumer Inventory
scripts/agent-guards/trusted_runtime_capabilities.check_trusted_uv():skill_runtime_exec._resolve_trusted_executable("uv", ...)のRuntimeErrorを捕捉し、reason(安定 code)/diagnostic(parse 済み payload、非uv_not_found形式ではnull)へ分離する。scripts/claude-gpt/workflow_capability_preflight.assess():check_trusted_uv()の結果をchecks.uv.status/checks.uv.reason/checks.uv.diagnosticとしてCLAUDE_GPT_WORKFLOW_CAPABILITIES_V1へそのまま転送する。Visual Impact Declaration(視覚影響申告)
UI(DOM/CSS)変更を含まないため省略。
Safety Claim Matrix
uvの trust boundary(探索候補ディレクトリ集合・探索順・pyproject.tomlに対する version pin 照合)は本 PR で変更していない。uv_not_found発生時の診断メッセージ内容のみを変更したcandidates_searchedはshutil.which(name, path=safe_path)へ実際に渡したsafe_entriesをそのまま使い再計算しない実装(scripts/agent-guards/skill_runtime_exec.py内_resolve_trusted_executable)。test_uv_not_found_candidates_searched_matches_safe_entriesがshutil.whichを patch して一致を検証(94 passed)git等uv以外の trusted executable には account-home lane も診断 payload も追加しないtest_non_uv_not_found_unchangedがgitの{name}_not_found文字列が変更されないことを検証(94 passed)recommended_install_dirは存在しないディレクトリでも算出するが、candidates_searchedはshutil.whichへ実際に渡した PATH エントリそのものである(未作成の no-sudo user-local lane のみ existence-check により確実に除外される。system-directory lane は固定リストのため existence-check を経ずに含まれる場合がある)candidates_searchedは「探索したディレクトリ一般が存在しないことを保証しない」ことに注意(system lane は無条件で含む)test_uv_not_found_recommended_install_dir_without_existing_dirが no-sudo user-local lane の分離を検証(94 passed)。system lane の無条件 include は_resolve_trusted_executableの_SYSTEM_STANDARD_PATH_DIRS参照で確認trusted_runtime_capabilities.check_trusted_uv()のreasonはworkflow_capability_preflight.assess()を経由して外側 JSON まで、JSON-in-a-string の二重エンコードなしで到達するtest_check_trusted_uv_splits_reason_and_diagnostic_on_uv_not_foundとtest_workflow_capability_uv_not_found_reason_and_diagnostic_reach_outer_jsonが resolver を monkeypatch した deterministic テストで検証(94 passed)Notes
not_applicable(Issue 本文の decision に従う。candidate 集合・探索順・version 判定を変更しないため、deterministic unit test で完全に検証できる)。