Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2456"
goal_ref: "#2456 の調査結果に基づき、secret-free の固定 enum runtime diagnostic を literal-path helper として提供し、worktree verifier の complex shell limitation を回避する。"
change_kind: mixed
dedupe_key: "claude-runtime-diag:literal-helper:v1"Parent Issue
Parent Goal Ref
- Goal: 調査: worktree isolation / secret boundary guard が secret-free診断まで過剰拒否する #2456 で確定した、secret 値・実 HOME 絶対パスを露出せず runtime 状態を切り分ける診断経路を提供する。
- Desired Destination: repository-owned の固定 helper を、Claude Code worktree runtime から simple literal invocation で実行できる状態にする。
Current Validated Scope
scripts/agent-ops/claude_runtime_diag.pyに fixed probe ID 専用の診断 helper を追加する。scripts/agent-ops/tests/test_claude_runtime_diag.pyに test-owned subprocess env と synthetic PreToolUse guard input だけを使う focused test を追加する。docs/dev/agent-runtime-ops.mdに canonical invocation と secret-free 安全境界を記録する。
Remaining Parent Gaps
- helper が actual isolated Claude Code runtime で block される場合の
secret_boundary_guard.sh/ settings contract update は別 Issue とし、本 Issue では変更しない。 - 実装: Claude-GPT self-launch で isolated HOME を runtime root に再基準化しない #2455 / fix: Claude-GPT lib.sh が canonical runtime root を export し self-launch での再基準化を防ぐ #2460 の runtime-root propagation と PR fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 の変更は本 Issue の対象外。
Outcome
scripts/agent-ops/claude_runtime_diag.py が、固定 probe ID の literal invocation に対して raw env 値・raw path・secret を出力せず固定 enum classification を返し、focused test、baseline quality gates、および isolated Claude Code structured runtime smoke が PASS する状態。
Runtime Verification Applicability
decision: immediate
reason: >-
worktree verifier と PreToolUse guard を通る literal helper invocation は実 runtime でのみ確認できる。
applicable_acs: [AC8, AC9]
execution_environment: >-
isolated Claude Code linked worktree; the existing worktree runtime skill supplies the runner and is not changed by this Issue.
skip_conditions: >-
auth/capability insufficiency (including exit 77), runner unavailability, or any condition that prevents the hygiene procedure.
fallback_policy: >-
Do not upgrade a skip or failure to PASS; stop, retain no GitHub evidence, and report only generic blocked status.
artifact_requirements: >-
A newly-created private temp prompt and new untracked worktree-local runner output directory; review only sanitized summary.md and never commit or post it.
evidence_policy: >-
controller は newly-created private temp prompt に static Japanese instruction と三つの literal helper invocation だけを書き、
新規の untracked worktree-local artifact output directory を runner に渡す。review 対象は runner の summary.md だけとし、
summary.md は fixed enum/boolean output だけを含まなければならない。prompt、raw stdout/stderr、transcript、raw env value、
raw path は commit または GitHub 投稿しない。raw egress 又は sanitized summary.md 不在は FAIL とし、verification を停止し、
GitHub evidence を残さず generic blocked status だけを報告する。
skip_policy: >-
auth/capability 不足などで structured runtime smoke が exit 77 の場合は PASS に昇格させず、
runtime verification policy の SKIP 証跡と Stop Conditions に従う。In Scope
- 次の three fixed probe IDs だけを受理する Python helper を実装する。helper は environment から exactly
CLAUDE_GPT_HOMEとHOMEだけを読み、一つの positional probe ID だけを受理する。OS/filesystem access、os.path.realpath、Path.resolve、symlink resolution、file read は禁止する。
| Probe ID | 固定 output | 決定論的 lexical rule |
|---|---|---|
claude-gpt-root-state |
`runtime_root=present | absent` |
claude-gpt-home-class |
`home_class=isolated | nested |
claude-gpt-root-relation |
`root_relation=same | nested |
raw string は nonempty かつ / で始まる場合だけ valid_absolute であり、missing、empty、relative は valid_absolute ではない。expansion、normalization、resolution は行わず、raw input は success/error のいずれの path でも echo しない。
| Fixture | CLAUDE_GPT_HOME |
HOME |
root-state | home-class | root-relation |
|---|---|---|---|---|---|
| isolated | /synthetic/root |
/synthetic/root/claude-home |
present | isolated | other |
| nested | /synthetic/home/.claude-gpt |
/synthetic/home |
present | nested | nested |
| same | /synthetic/same |
/synthetic/same |
present | unexpected | same |
| absent | missing | /synthetic/home |
absent | unexpected | other |
| empty | `` | /synthetic/home |
absent | unexpected | other |
| relative/malformed | relative-root |
/synthetic/home |
present | unexpected | other |
| unrelated absolute | /synthetic/root-a |
/synthetic/root-b |
present | unexpected | other |
CLAUDE_GPT_HOMEとHOMEは classification 内部でのみ読み、stdout/stderr には fixed enum output だけを出す。all other args(unknown probe ID と extra args を含む)は exactlyerror=invalid_argumentsと nonzero で reject する。- fixture table の isolated、nested、same、absent、empty、relative/malformed、unrelated absolute の全 row を test-owned subprocess
envmapping(only synthetic values)で実行し、expected enum を検証する。actual host HOME は読まず、利用しない。 - arbitrary variable / path / expression を引数で指定する generic interface を提供しない。
- synthetic PreToolUse guard input で exact helper invocation は allow され、inline Python、env dump、sensitive path は block のままであることを確認する。
- linked worktree の isolated Claude Code structured smoke を一度行い、三つの literal invocation が safe fixed output を返し、worktree verifier の refusal がないことを確認する。既存の worktree runtime skill が runner を提供し、runner/skill の変更は本 Issue の対象外である。
- canonical invocation と「分類以外の env/path egress をしない」安全境界を docs に記録する。
Out of Scope
secret_boundary_guard.sh、.claude/settings.json、その他 guard/settings の変更。actual runtime で helper が block された場合も、まず停止して別 contract update Issue を作成する。- generic env/path/arbitrary CLI、inline Python/shell source、credential/config file/network access、raw env dump、raw absolute path egress。
- 実装: Claude-GPT self-launch で isolated HOME を runtime root に再基準化しない #2455 / fix: Claude-GPT lib.sh が canonical runtime root を export し self-launch での再基準化を防ぐ #2460 の root propagation、PR fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 の変更。
- Allowed Paths 外の runtime smoke runner / skill の変更。
Acceptance Criteria
-
AC1: helper は environment から exactly
CLAUDE_GPT_HOMEとHOMEだけを読み、one positional fixed probe ID だけを受理する。各 successful call は expected fixed enum の exactly one-line stdout と empty stderr を返す。 -
AC2: fixture table の isolated、nested、same、absent、empty、relative/malformed、unrelated absolute の全 row について、test-owned subprocess
envmapping(only synthetic values)で三 probe を実行し、表の root-state、home-class、root-relation enum と一致する。actual hostHOMEは使用しない。 -
AC3: unknown probe ID、extra args、または positional probe ID 以外の invocation は exactly
error=invalid_argumentsを出力し nonzero で終了する。 -
AC4: lexical classification は raw string の nonempty
/prefix と fixture table の exact string comparison だけに従い、missing、empty、relative/malformed をvalid_absoluteと扱わない。OS/filesystem access、os.path.realpath、Path.resolve、symlink resolution、file read、expansion、normalization、resolution を行わない。 -
AC5: 全 fixture row と invalid-argument path で stdout/stderr に raw test sentinel、raw env value、raw path が現れない。successful call は stderr empty である。
-
AC6: arbitrary variable/path/expression を指定する interface は存在せず、unknown ID と extra args を含む任意の追加 argv は AC3 の fixed error と nonzero で reject する。
-
AC7: synthetic guard input は exact helper invocation を allow し、inline Python、env dump、sensitive path を引き続き block する。
-
AC8: controller は newly-created private temp prompt を作り、static Japanese instruction と次の three literal helper invocations だけを入れる。three literal helper invocations 以外の変数名、値、path を prompt に追加しない。既存の worktree runtime skill が提供する runner を用い、新規の untracked worktree-local artifact output directory で structured runtime smoke を実行する。runner/skill の変更は本 Issue の対象外である。
以下の三つのコマンドをそのまま実行し、各結果の固定 enum/boolean 一行だけを summary.md に記録してください。 python3 scripts/agent-ops/claude_runtime_diag.py claude-gpt-root-state python3 scripts/agent-ops/claude_runtime_diag.py claude-gpt-home-class python3 scripts/agent-ops/claude_runtime_diag.py claude-gpt-root-relation -
AC9: controller が review するのは runner
summary.mdだけであり、同 file は fixed enum/boolean output だけを含む。raw prompt、raw stdout/stderr、transcript、raw env value、raw path は commit または GitHub 投稿しない。raw egress 又は sanitizedsummary.md不在はFAILとし、verification を停止し、GitHub evidence を一切残さず generic blocked status だけを報告する。 -
AC10: focused pytest と
pnpm typecheck、pnpm lint、pnpm test、pnpm build、Gemini routing test が PASS する。 -
AC12: PR 本文は日本語中心とし、この Issue を
Closes #<this-issue-number>、調査: worktree isolation / secret boundary guard が secret-free診断まで過剰拒否する #2456 をRelated #2456と記載する。調査: worktree isolation / secret boundary guard が secret-free診断まで過剰拒否する #2456 を close しない。
Verification Commands
# AC1
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k fixed_probe_ids
# AC2
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k subprocess
# AC3
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k invalid_arguments
# AC4
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k lexical
# AC5
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k no_raw_egress
# AC6
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k arbitrary
# AC7
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k guard
# AC8
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree "$PWD" --prompt-file /tmp/claude-runtime-diag-smoke.md --output-dir artifacts/runtime-smoke/claude-runtime-diag --timeout-seconds 180 --require-clean-postcondition
# AC9
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py -k evidence_hygiene
# AC10
$ uv run pytest scripts/agent-ops/tests/test_claude_runtime_diag.py
# AC12
$ gh pr view "$PR_NUMBER" --repo squne121/loop-protocol --json bodyAllowed Paths
scripts/agent-ops/claude_runtime_diag.pyscripts/agent-ops/tests/test_claude_runtime_diag.pydocs/dev/agent-runtime-ops.md
Scope Collision Note
Overlap preflight is advisory and found only declared-path overlap, not a duplicate outcome. #2456 is the completed research source; #2437 and #1499 have unrelated docs/dev/agent-runtime-ops.md edit intents; broad historical scripts / docs/dev declarations are false-positive containers. This Issue owns only the new helper, its dedicated test, and the helper-specific documentation paragraph. If any of #2437 or #1499 remains unmerged when implementation starts, rebase and resolve the documentation hunk serially; do not expand scope or modify their Issue bodies/comments.
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合。
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合。
- nested SubAgent delegation が必要になった場合。
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Runtime Block Disposition
actual literal helper が block された場合、controller は producer を sanitized static reason だけで classify し、guard/settings を編集しない。変更の前に amended Allowed Paths を含む separate Issue を作成し、本 Issue は open/blocked のままにする。この disposition は pytest が prove するものではない。raw block evidence は publish せず、AC8-AC9 の hygiene procedure に従い generic blocked status だけを報告する。
- runtime smoke が exit 77 または nonzero の場合、PASS に代替せず runtime verification policy に従って停止・証跡化する。
Required Skills
なし
Required Design References
docs/dev/secret-policy.mddocs/dev/runtime-verification-policy.mddocs/dev/agent-runtime-ops.md.claude/skills/worktree-agent-runtime-smoke/SKILL.md- 調査: worktree isolation / secret boundary guard が secret-free診断まで過剰拒否する #2456
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR。linked worktree で実装し、Draft PR を既定とする。- PR は日本語中心で記述し、
Closes #<this-issue-number>とRelated #2456を含める。Closes #2456は禁止する。
Activity
fix: localize Claude-GPT diagnostic heading (#2471)
docs: govern Claude runtime diagnostic examples (#2471)
squne121 commentedon Sep 1, 2026
Runtime Verification Evidence(current head)
tested_head:a3ae5d331524016f01420f43f0d5412284e0490aliteral_command_set_sha256:sha256:8ee3b8108fefd0a4af83c54f473dd608fec1e664488efcf8aa951d7bbc534657このコメントは #2471 の immediate runtime verification の sanitized completion record です。
feat: secret-free Claude runtime diagnostic を追加 (#2474)