Skip to content

実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887

Closed
2 of 2 issues completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1860"
goal_ref: "minimal harness の runtime verification を、linked worktree 内の native CLI structured output と herdr pane observation で再利用可能にする"
change_kind: mixed

Parent Issue

#1860

Related Issues

Parent Goal Ref

  • Goal: AIエージェント運用を minimal harness へ縮退し、過剰な state machine、schema、digest、receipt、publisher を導入せず、実際の runtime output と postcondition を検証する。
  • Desired Destination: Claude Code と Codex CLI の双方について、linked worktree 内で fresh session を起動し、structured event、herdr pane output、必要時のみ native session-log metadata を取得できる共有 Skill が存在する。

Current Validated Scope

  • PR fix: Codex permission profile root default を :workspace に復元する (#1859) #1864 の runtime evidence では、herdr 0.7.5 上の linked worktree から Codex TUI を起動し、/status、Skill一覧、filesystem read、pane transcript を確認している。
  • 上記は個別 PR の手動手順と tracked evidence であり、Claude Code と Codex CLIに共通利用できる Skill/runner にはなっていない。
  • Claude Code は非対話実行で stream JSON、hook lifecycle event、turn上限、session persistence無効化を利用できる。
  • Codex CLI は非対話の codex exec で worktree cwd、JSONL event、ephemeral session、sandbox modeを指定できる。
  • herdr は通常プロセスに対する pane API と、認識済みAIエージェントに対する agent API を分離している。
  • current repository の scripts/agent-ops/tests/ は既存 Python CI targetに含まれているため、runner testを同ディレクトリへ配置すれば新しいCI targetの追加は不要である。
  • .agents/skills/<name>/SKILL.md から .claude/skills/<name>/SKILL.md を読む derived thin wrapper の既存パターンが存在する。

Remaining Parent Gaps

Problem

runtime verification のたびに、実装者またはレビュアーが以下を手作業で行っている。

  1. 対象 worktree を確認する
  2. Claude Code または Codex CLI を起動する
  3. 検証用 prompt を投入する
  4. subagent、hook、Skill、cwd、context の状態を端末表示から読む
  5. native session logやpane outputを探索する
  6. raw transcriptやcredentialを漏らさないよう証跡を手作業で要約する
  7. pane/sessionを終了する

この手順は再利用可能な入口がなく、runtimeごと・PRごとに実行方法と証跡品質が変わる。

一方、これを新しい generic orchestration framework、独自result schema、session replay authority、永続state storeへ拡張すると、#1860で撤去した過剰なcontrol-planeを再導入する。

Outcome

次の二つの実行laneを持つ repo-local共有Skill worktree-agent-runtime-smoke が提供される。

Lane A: structured smoke

通常はこちらを使用する。

  • Claude Code:
    • print mode
    • stream JSON
    • hook event出力
    • session非永続
    • bounded turns
  • Codex CLI:
    • codex exec
    • JSONL event
    • ephemeral session
    • explicit worktree cwd
      -既存sandbox/permission設定を維持

structured output、exit code、worktree postconditionを証跡とする。

Lane B: interactive herdr smoke

TUI固有挙動、Skill picker、approval画面、subagent UI、context表示、interactive statusの観測が必要な場合だけ使用する。

  • linked worktreeをcwdとするherdr sibling paneを作成する
  • Claude CodeまたはCodex CLIを対話Agentとして起動する
    -検証用promptをatomicに送信する
  • lifecycle stateをbounded timeoutで待つ
  • pane output、agent detection、native session referenceを取得する
    -必要時だけnative session logのmetadataを抽出する
    -証跡取得後にpaneを閉じる。明示指定時のみpaneを残す

本Skillはruntime起動・観測・証跡収集だけを所有する。対象Issue固有の semantic verdict、permission分類、APPROVE/REQUEST_CHANGES判定はcallerが所有する。

Design Decisions

1. structured laneを既定とする

hook event、tool event、exit code、postconditionを非対話で取得できる場合、TUI screen scrapingを使わない。

interactive laneは次の場合に限定する。

  • TUI /status やSkill pickerを確認する
  • approval/blocked UIを確認する
  • structured modeでは露出しないsubagent/context状態を確認する
    -人間が端末状態を直接監督する必要がある

2. herdrをrepository全体のhard dependencyにしない

  • mode=structured はherdr外でも直接実行可能とする
  • transport=auto はherdr内ならpaneを利用し、herdr外ではdirect subprocessを利用できる
  • mode=interactive はherdrを必須とする
  • HERDR_ENV=1、必要CLI capability、running serverがない場合、interactive laneは SKIP: と exit 77を返す
  • herdr unavailableをstructured laneの失敗へ波及させない

3. paneとagentの責務を分離する

  • claude -p、codex exec 等の終了型コマンドは pane run/direct subprocessで実行する
  • Claude Code/Codex CLIの対話TUIは agent start で起動する
  • prompt投入は agent prompt
  • lifecycle待機は agent wait
    -出力取得は agent read または pane read
  • agent stateだけをprocess成功の代替にしない

4. raw transcriptをauthorityにしない

保存可能な証跡:

  • runtime名とversion
  • tested HEAD
  • repo-relative worktree
  • branch
    -実行lane/transport
  • process exit code
  • herdr pane ID/agent name
  • observed lifecycle state
  • native event typeの件数
  • caller指定のexpected markerの有無
  • bounded redacted output
  • filesystem/Git postcondition
  • session-log metadataの取得可否

既定で保存しないもの:

  • raw prompt全文
  • raw transcript全文
  • reasoning
  • tool output全文
  • credential
  • environment dump
    -認証情報
  • HOMEを含む絶対パス
  • native session logのworktreeへの複製

5. native session logは補助証跡とする

  • structured eventまたはherdr outputで判定可能なcaseではsession logを必須にしない
  • callerが明示的に要求した場合のみmetadataを読み取る
  • session IDまたはruntimeが公開するsession referenceに束縛する
  • event type、agent/subagent label、timestamp、cwd marker等のallowlist metadataだけを抽出する
  • undocumentedなlog pathまたはrecord shapeをstable schemaとして扱わない
  • logが見つからないことをruntime成功・失敗へ自動変換しない
  • --require-session-log-metadata が指定されたcaseだけ、取得不能をexit 77とする

6. semantic判定を再実装しない

runnerは次だけを判定する。

  • runtimeを起動できたか
    -指定worktreeで動いたか
  • timeoutせず終了またはsettled stateへ到達したか
    -必要なevidenceを取得できたか
  • caller指定のliteral markerが観測されたか
    -禁止されたfilesystem/Git postcondition changeが起きていないか

次はcaller側の責務とする。

  • hook reasonの意味分類
  • mutation denyの妥当性
  • Skill preload成功のドメイン判定
  • context budget評価
  • review verdict
  • merge readiness

In Scope

Shared Skill

  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md をcanonical bodyとして追加する
  • .agents/skills/worktree-agent-runtime-smoke/SKILL.md をderived/non-canonical thin wrapperとして追加する
  • Skill本文はtrigger、inputs、lane選択、主要手順、安全境界、reference mapに限定する
  • runtime固有の詳細をreferencesへ分離する

Runtime references

  • Claude Code structured/interactive invocation
  • Codex CLI structured/interactive invocation
  • herdr pane/agent APIの使い分け
  • evidence hygieneとsession-log metadata boundary
  • timeout/cleanup/SKIP規約

Runner

scripts/agent-ops/run_worktree_agent_runtime_smoke.py を追加する。

最低限のCLI:

--runtime claude | codex
--mode structured | interactive
--transport auto | direct | herdr
--worktree <path>
--prompt-file <path>
--output-dir <path>
--timeout-seconds <integer>
--expect-marker <literal>        # repeatable
--require-clean-postcondition
--inspect-session-log-metadata
--require-session-log-metadata
--keep-pane

runnerは以下を実施する。

  • shell=False を基本とする
  • canonical repositoryとlinked worktree identityを確認する
  • root checkout、別repository、cwd mismatchを拒否する
  • runtimeとherdrのcapabilityを実コマンドでpreflightする
  • fixed argvでnative CLIを起動する
  • promptをargument interpolationせず、fileまたはstdinで渡す
  • output sizeをboundedにする
  • timeout時にchild processまたはpaneをcleanupする
  • raw outputをmain contextへ展開しない
  • worktree-local untracked directoryにevidenceを保存する
  • exit code 0/1/77を返す

Claude Code structured invocation

次のcapabilityを利用する。

claude -p \
  --output-format stream-json \
  --include-hook-events \
  --no-session-persistence \
  --max-turns <bounded> \
  <prompt>

runtime versionによりflagが利用できない場合は、silent fallbackせずexit 77とする。

Codex CLI structured invocation

次のcapabilityを利用する。

codex exec \
  -C <worktree> \
  --json \
  --ephemeral \
  <prompt>
  • current repository configurationのsandbox/permission profileを利用する
  • --dangerously-bypass-approvals-and-sandbox、--yolo、danger-full-accessへの自動変更を行わない
  • callerが指定していないmodel/profileをrunnerが上書きしない

herdr interactive invocation

概念的な手順:

herdr pane split --current --direction <right|down> \
  --cwd <worktree> --no-focus

herdr agent start <unique-name> \
  --kind claude|codex \
  --pane <pane-id>

herdr agent prompt <unique-name> \
  "<prompt>" \
  --wait \
  --timeout <milliseconds>

herdr agent get <unique-name>
herdr agent explain <unique-name> --json
herdr agent read <unique-name> \
  --source recent-unwrapped \
  --lines <bounded>

-既存paneのfocusを奪わない

  • unique agent nameはrun-localとする
  • unknown stateを成功扱いしない
  • blocked は自動承認せず証跡を取得して停止する
  • timeoutを必須とする
  • cleanupで検証paneだけを閉じる
  • caller pane、別agent、別workspaceを変更しない

Evidence output

<worktree>/artifacts/runtime-smoke/<run-id>/ に次を保存する。

summary.md
native-events.jsonl       # structured lane。native outputをbounded/redacted
pane-output.txt           # interactive lane。bounded/redacted
agent-detection.json      # herdr agent explainのnative response
session-log-metadata.txt  # requested and availableの場合のみ

これらはworktree-local untracked evidenceであり、schema、receipt、digest、publisher、approval authorityではない。

PR本文には summary.md のredacted excerptだけを引用する。

Tests

unit/integration testではfake executableとfake herdr CLIを使用し、以下を検証する。

  • argvとcwd
  • prompt file handling
  • timeout
  • exit 0/1/77
  • root checkout拒否
    -別repository拒否
  • pane ID parsing
  • agent start/prompt/read/cleanup順
  • blocked/unknownをPASSにしない
  • output truncation
  • credential/HOME path redaction
  • raw transcript非保存
  • session-log metadata optional/required分岐
  • postcondition change検出
  • thin Codex wrapper

CIでは実Claude/Codex認証を要求しない。実runtime evidenceはPR review時のmanual/runtime laneで取得する。

Out of Scope

  • 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 の .claude/settings.json、hook、permission rule変更
  • GitHub server-side mutation impossibilityの証明
  • GitHub credential scopeの変更
  • generic multi-agent task orchestrator
  • worktreeの新規作成/削除
    -自動Issue/PR mutation
  • Agentの実装作業、commit、push
    -自動approval
  • semantic review verdict classifier
  • context budgetの数値評価
  • model品質比較
  • replay、resume、session migration
  • native session log formatの独自stable schema化
  • raw transcriptのtracked artifact化
    -新しいJSON/YAML result schema
  • digest、receipt、publisher、state store
  • cross-repository/plugin distribution

Acceptance Criteria

  • AC1: Claude canonical SkillとCodex thin wrapperが追加され、Codex wrapperはcanonical bodyへのpointerとruntime固有注意だけを持つ
  • AC2: runnerはcanonical repository内のlinked worktreeだけを受理し、root checkout、別repository、cwd mismatchを実行前に拒否する
  • AC3: Claude structured laneがfresh processでstream JSONとhook eventsを取得し、sessionを永続化せず、bounded timeout後に終了する
  • AC4: Codex structured laneがcodex exec -C <worktree> --json --ephemeralで実行され、JSONL outputとexit codeを取得する
  • AC5: herdr interactive laneがClaude CodeとCodex CLIのそれぞれについてpane作成、agent起動、prompt投入、state待機、bounded output取得、cleanupを実行できる
  • AC6: caller指定のexpected marker、runtime version、tested HEAD、worktree、pane/agent identity、event type count、postconditionがredacted evidenceへ記録され、modelの自然言語自己申告だけを成功証拠にしない
  • AC7: session-log inspectionは明示指定時のみ実行され、allowlist metadataだけを抽出し、raw prompt、reasoning、tool output、credential、HOME絶対パスを保存しない
  • AC8: runtime/auth/required capability/herdrが利用不能なcaseはSKIP:とexit 77、runtime failure/timeout/identity mismatch/unexpected postconditionはexit 1、成功はexit 0を返す
  • AC9: runnerは新しいschema、digest、receipt、publisher、state store、semantic verdict classifierを追加せず、worktree外への書き込みを行わない
  • AC10: fake runtime/fake herdrを用いたunit testがCIでPASSし、認証済み開発環境のlinked worktreeでClaude structured、Codex structured、Claude interactive、Codex interactiveの4 smoke evidenceがcurrent PR headに対して取得される
  • AC11: docs/dev/runtime-verification-policy.md と docs/dev/agent-runtime-ops.md に、structured laneを既定、interactive herdr laneを必要時のみ利用する境界が記載される
  • AC12: docs/dev/agent-skill-boundaries.md に新Skillのowner、trigger、non-trigger、output boundaryが記録される

Runtime Verification Applicability

decision: immediate
reason: >
  本IssueはClaude Code、Codex CLI、herdrの実process/TUIを起動し、
  worktree binding、structured event、agent lifecycle、pane output、
  cleanupを観測する機能を追加するため、static testだけでは完了を証明できない。
applicable_acs:
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
  - AC10
execution_environment:
  os: "WSL2 Ubuntu 24.04"
  repository_state: "clean linked worktree"
  required_commands:
    - claude
    - codex
    - herdr
  authentication: "既存の認証済みローカル環境"
  herdr_policy: "interactive laneのみ必須。structured direct laneには必須にしない"
skip_conditions:
  - "対象runtimeが未インストールまたは未認証"
  - "要求したnative structured-output capabilityが利用不能"
  - "interactive caseでHERDR_ENV=1またはrunning herdr serverが利用不能"
  - "native session-log metadataをrequireしたcaseでsession referenceを取得不能"
fallback_policy:
  - "structured capability不在をplain text self-reportでPASSにしない"
  - "herdr interactive caseをdirect subprocessの成功でPASSにしない"
  - "session-log-required caseをpane outputだけでPASSにしない"
  - "SKIPをPASSへ昇格しない"
artifact_requirements:
  - "worktree-local artifacts/runtime-smoke/<run-id>/summary.md"
  - "Claude structured native-events.jsonl"
  - "Codex structured native-events.jsonl"
  - "Claude interactive pane-output.txt / agent-detection.json"
  - "Codex interactive pane-output.txt / agent-detection.json"
  - "requested caseのみsession-log-metadata.txt"

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py tests/test_codex_agent_bridge_contract.py -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py -q -k 'worktree or exit_code or timeout or postcondition'
# AC3
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --transport auto --worktree "$PWD" --prompt-file tmp/runtime-smoke/claude-structured.md --output-dir artifacts/runtime-smoke/claude-structured --timeout-seconds 180 --require-clean-postcondition
# AC4
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime codex --mode structured --transport auto --worktree "$PWD" --prompt-file tmp/runtime-smoke/codex-structured.md --output-dir artifacts/runtime-smoke/codex-structured --timeout-seconds 180 --require-clean-postcondition
# AC5
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode interactive --transport herdr --worktree "$PWD" --prompt-file tmp/runtime-smoke/claude-interactive.md --output-dir artifacts/runtime-smoke/claude-interactive --timeout-seconds 300 --inspect-session-log-metadata --require-clean-postcondition
# AC6
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime codex --mode interactive --transport herdr --worktree "$PWD" --prompt-file tmp/runtime-smoke/codex-interactive.md --output-dir artifacts/runtime-smoke/codex-interactive --timeout-seconds 300 --inspect-session-log-metadata --require-clean-postcondition
# AC7
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode interactive --transport herdr --worktree "$PWD" --prompt-file tmp/runtime-smoke/claude-interactive.md --output-dir artifacts/runtime-smoke/claude-interactive --timeout-seconds 300 --inspect-session-log-metadata --require-clean-postcondition
# AC8
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py -q -k 'exit_code or timeout'
# AC9
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py tests/test_codex_agent_bridge_contract.py -q
# AC10
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py -q
# AC11
# baseline-expect: fail
$ rg -n -e "worktree-agent-runtime-smoke" -e "structured lane" -e "interactive.*herdr" docs/dev/runtime-verification-policy.md docs/dev/agent-runtime-ops.md docs/dev/agent-skill-boundaries.md
# AC12
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py tests/test_codex_agent_bridge_contract.py -q

Allowed Paths

  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
  • .claude/skills/worktree-agent-runtime-smoke/references/claude-code.md
  • .claude/skills/worktree-agent-runtime-smoke/references/codex-cli.md
  • .claude/skills/worktree-agent-runtime-smoke/references/herdr.md
  • .claude/skills/worktree-agent-runtime-smoke/references/evidence-hygiene.md
  • .agents/skills/worktree-agent-runtime-smoke/SKILL.md
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py
  • tests/test_codex_agent_bridge_contract.py
  • docs/dev/runtime-verification-policy.md
  • docs/dev/agent-runtime-ops.md
  • docs/dev/agent-skill-boundaries.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • .claude/settings.json、.codex/config.toml、hook、permission profileの変更が必要
  • GitHub credential scope変更が必要
  • native session logの全record shapeを独自schemaとして固定する必要
  • actual Claude/Codex/herdr runtimeを実行できず、SKIPをPASSへ昇格する必要
  • nested subagentのsemantic結果をrunner自身が再判定する必要

Required Skills

  • Python
  • pytest
  • Claude Code CLI
  • Codex CLI
  • herdr CLI/agent automation
  • Git worktree
  • terminal output redaction

Required Design References

  • docs/dev/runtime-verification-policy.md
  • docs/dev/agent-runtime-ops.md
  • docs/dev/agent-skill-boundaries.md
  • Claude Code CLI reference: https://code.claude.com/docs/en/cli-usage
  • Claude Code hooks reference: https://code.claude.com/docs/en/hooks
  • Codex developer commands: https://developers.openai.com/codex/cli/reference
  • herdr Agent automation: https://herdr.dev/docs/agent-automation/
  • herdr Socket API: https://herdr.dev/docs/socket-api/
  • herdr CLI reference: https://herdr.dev/docs/cli-reference/

Scope Delta

-追加: worktree-local cross-runtime smoke Skill
-追加: Claude Code structured/interactive adapter
-追加: Codex CLI structured/interactive adapter
-追加: herdr pane/agent observation
-追加: optional metadata-only native session-log inspection
-維持:既存runtime permission、sandbox、hook、GitHub credential
-非追加: schema、digest、receipt、publisher、state store、semantic classifier

Delivery Rule

  • 1 Issue = 1 Draft PR
  • dedicated linked worktree
  • current headに対して4 runtime smokeを再実行する
  • raw transcriptをcommitしない
  • PR本文にはredacted summaryだけを記載する
    -人間による最終マージを維持する

Notes for Reviewer

本Issueは runtime verification のtransport/observationを共通化するだけであり、個別Issueの安全判定を一元化するcontrol-planeではない。

#1881は、本IssueのrunnerでClaude Code/Codex CLIを起動しても、mutation denyの意味判定、hook reason、postconditionの期待値を引き続き#1881側で所有する。

Codex CLIの先行herdr smokeで行った /status、Skill picker、pane transcript確認を一般化するが、そのtracked artifact形式やSHA256 manifestは再利用しない。

Scope Collision (C1) preflight は既存 Issue の Allowed Paths と重複する以下のパスを検出したが、本 Issue は runtime smoke の新規 Skill/runner を追加する独立スコープであり、既存 Issue の実装対象を変更しない。docs/dev/agent-skill-boundaries.md、docs/dev/agent-runtime-ops.md、docs/dev/runtime-verification-policy.md は SSOT 追記のため共有され、tests/test_codex_agent_bridge_contract.py は契約テストの既存配置を利用する。依存順序は親 #1860 の minimal harness 方針に従い、#1881 は本 Issue の merge 後に consumer として再束縛する。

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 31, 2026
  2. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    人間が作業しているherdr sessionと同じ場所に検証用のペンを追加されると、画面が阻害されて邪魔なので、人間が作業しているセッションとは別のセッションを起動し、作業するようにしてほしいです。また、必ず作業終了後に検証用のセッションを終了し、現状復旧することをしてほしいです。複数セッションで並列作業を行うことを念頭において、作業手順を設計してほしいです。

  3. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    判定

    review_verdict: REQUEST_CHANGES
    implementation_ready: false
    classification: contract_reconstruction_required
    primary_route: issue-refinement-loop
    blocker_count: 5

    structured output を既定にし、TUI 固有確認だけを Herdr に限定する方向性は妥当です。しかし現行本文は、指定コメントが否定した 「人間の作業 session 内へ sibling pane を追加する」設計を中心契約として残したままです。加えて、session 所有権、並列実行、強制 cleanup、証跡の機密性、postcondition の保証範囲が不十分です。現状のまま implementation-worker に渡すべきではありません。


    P0 ブロッカー

    P0-1. OWNER コメントが Issue の中心設計に反映されていない

    現在の本文は次を契約化しています。

    • linked worktree を cwd とした sibling pane
    • herdr pane split --current
    • transport=auto は Herdr 内なら pane を使用
    • interactive lane の前提として HERDR_ENV=1
    • --keep-pane
    • cleanup は「検証 pane だけを閉じる」

    一方、指定コメントは明確に次を要求しています。

    1. 人間が使用中の Herdr session とは別 sessionを起動する
    2. 作業後は検証 session を必ず終了する
    3. 複数 session の並列実行を前提にする
    4. 人間の画面レイアウトを変更しない

    これは一部のコマンドを差し替えるだけでは直りません。Outcome、Design Decisions、CLI、AC5、AC8、AC10、VC、cleanup、SKIP 条件をまとめて再設計する必要があります。

    Herdr 公式仕様でも、named session は pane、tab、workspace、socket、runtime state を独立させるための境界です。workspace 作成時には root pane も同時に作られるため、検証 session 内でさらに pane split する必要はありません。([Herdr]1)

    必須修正

    • Lane B を interactive isolated-session smoke に変更する
    • herdr pane split --current を全面削除する
    • --keep-pane を削除する
    • HERDR_ENV=1 を前提条件から外す
    • mode=structured は direct subprocess 固定
    • mode=interactive は新規 named Herdr session 固定
    • transport=auto|direct|herdr は削除する。mode と責務が重複している
    • caller の default/current session、pane、workspace、focus を一切参照しない
    • workspace create が返す root_pane.pane_id をそのまま agent start に渡す

    P0-2. session 所有権と cleanup 契約がなく、並列実行時に他 session を破壊し得る

    現行設計は「run-local な agent 名」と「検証 pane を閉じる」までしか規定していません。これでは以下を防げません。

    • 同じ session 名や output-dir を使う並列 run
    • 既存 session への誤接続
    • caller から継承した HERDR_SOCKET_PATH による別 socket 接続
    • timeout 後に agent/server が残留
    • nominal PASS 後に cleanup が失敗
    • SIGINT/SIGTERM 中断時の session 残留
    • session stop は成功したが persisted session が残るケース

    Herdr は HERDR_SESSION で CLI の named session を選択でき、session stop と session delete を別々に提供しています。wait 系コマンドは timeout を省略すると無期限待機になり、timeout/server error は status 1、CLI 構文エラーは status 2 です。([Herdr]2)

    runner の lifecycle は少なくとも次に固定すべきです。

    1. session 名、agent 名、output directory を高エントロピーで生成し、排他的に確保する
    2. herdr session list --json で同名 session が存在しないことを確認する
    3. 継承環境から HERDR_SESSION、HERDR_SOCKET_PATH、HERDR_PANE_ID、HERDR_TAB_ID、HERDR_WORKSPACE_ID、HERDR_ENV を除去する
    4. runner 所有の HERDR_SESSION=<generated-name> だけを設定する
    5. named server を起動し、workspace と root pane を作成する
    6. agent start/prompt/wait/read の全段階に timeout を設定する
    7. finally で session stop、続いて session delete
    8. session list --json を再取得し、session が消えていることを確認する
    9. cleanup 失敗は、それ以前の probe が成功していても最終 exit 1
    10. runner が作成したと証明できない session は絶対に stop/delete しない

    「必ず終了」は、SIGKILL、OS 強制終了、電源断まで含む絶対保証にはできません。契約上は 正常終了、例外、timeout、SIGINT、SIGTERM の全 controlled path を保証範囲として明記すべきです。

    さらに、named session が分離するのは Herdr runtime namespace です。Herdr の global config は共有され、integration install は ~/.claude/settings.json や ~/.codex/hooks.json/config.toml を変更します。runner 内で integration install/uninstall/update/plugin enable を実行してはなりません。必要な integration がない場合は optional metadata を省略するか、required case だけ exit 77 にすべきです。([Herdr]1)


    P0-3. 「現状復旧」「worktree 外へ書き込まない」という保証が成立していない

    現行 Issue は既存 sandbox/permission を維持しながら、clean postcondition と「worktree 外への書き込みを行わない」を要求しています。

    しかし current repository の Codex root profile は :workspace を継承し、workspace/temporary directory への write と広い development network access を許可しています。また filesystem read は workspace 内だけに制限されていません。

    さらに公式仕様上、

    • Codex の --ephemeral が保証するのは session rollout file を保存しないこと
    • Claude の --no-session-persistence が保証するのは session を保存・resume 可能にしないこと
    • Codex に --sandbox を追加すると、現在の permission profile ではなく旧 sandbox 設定へ切り替わる

    という境界です。したがって runner が --sandbox read-only を勝手に追加して安全化することも、--ephemeral だけで host side effect がないと主張することもできません。([OpenAI Developers]3)

    契約は次のように狭めるべきです。

    • Herdr state restoration
      runner 所有 named session を停止・削除し、人間の session/layout を変更しない。
    • repository postcondition assertion
      HEAD、branch、index、tracked diff、untracked inventory が実行前後で一致することを検査する。
    • 非保証
      host 全体、HOME、external service、network side effect の完全復旧は主張しない。
    • mutation 検証
      実装: minimal harness の permission/runtime safety boundary を復旧する #1881 のような caller が専用 clean worktree で実施し、deny の意味判定は caller が所有する。
    • 自動 rollback 禁止
      git reset --hard や git clean を generic runner が実行しない。検出したら FAIL にする。

    また、evidence を worktree 内へ書いた後で clean postcondition を検査すると、runner 自身の出力で dirty になります。逆に output-dir 全体を除外すると、そのディレクトリ内への予期しない mutation を見逃します。

    実装では、

    1. evidence directory 作成前に baseline を取得
    2. runner が作成した exact path 集合だけを所有物として記録
    3. postcondition 比較では、その exact file 集合だけを許容
    4. 想定外の file、subdirectory、symlink、既存 file の変更は FAIL

    とする必要があります。


    P0-4. evidence hygiene が「redaction-first」であり、既に発生した漏えいを再発させる

    Issue は「raw transcript を保存しない」としながら、実際には次の raw に近い成果物を保存します。

    • native-events.jsonl
    • pane-output.txt
    • agent-detection.json
    • session-log-metadata.txt

    これは契約内で矛盾しています。

    先行 PR #1864 の tracked pane transcript には、実際に次が残りました。

    • アカウントメール
    • 利用枠情報
    • native session ID
    • HOME 配下の絶対パス
    • worktree 絶対パス

    同じ失敗を実証済みです。

    Claude の hook event 自体にも session_id、transcript_path、cwd、permission mode、tool input、assistant message 等が含まれ得ます。credential 用 regex と HOME path 置換だけでは、任意の tool input/model output/file content を安全化できません。([Claude]4)

    redaction-first ではなく allowlist-first に変更すべきです。

    永続化する成果物は原則 summary.md 一つで十分です。

    Runtime
    Runtime version
    Tested HEAD
    Repo-relative worktree
    Branch
    Mode
    Process exit code
    Expected marker: present / absent
    Observed event types and counts
    Postcondition: pass / fail
    Herdr session cleanup: pass / fail
    Failure reason
    

    保存しないもの:

    • native JSONL record
    • pane text
    • prompt
    • assistant response
    • reasoning
    • tool input/tool output
    • account identifier
    • native session ID/path
    • absolute filesystem path
    • environment dump

    生出力がデバッグに必要な場合だけ、明示 opt-in で repository 外の mode 0600 temporary directory に保存し、PR evidence には使わず、run 終了時に削除する設計が妥当です。


    P0-5. CLI capability と version contract が不十分

    Claude/Codex/Herdr は更新頻度が高く、現在のコマンド文字列だけでは deterministic な実装契約になりません。

    Claude Code については、

    • --include-hook-events は stream-json を要求する
    • --max-turns 到達は正常終了ではなく error exit
    • claude --help は全 flag を列挙しないため、help 出力にないことを capability 不在の証拠にできない
    • --no-session-persistence は print mode の session 保存を無効化する

    という仕様です。([Claude]5)

    Codex については、

    • codex exec が scripted/CI 向け
    • --json は newline-delimited JSON
    • --ephemeral は rollout file 非保存
    • prompt は - を指定して stdin から渡せる
    • dangerous bypass flags は isolated runner 限定

    です。([OpenAI Developers]3)

    Herdr は installed binary から herdr api schema --json を取得でき、wait 系は timeout 必須です。PR #1864 が実証したのは Herdr 0.7.5 上の単一 pane smoke であり、現在要求されている named-session stop/delete/parallel isolation の証拠ではありません。 ([Herdr]2)

    Issue に次を追加すべきです。

    • 実行時の Claude/Codex/Herdr version を必ず記録
    • supported minimum version、または exact feature probe を定義
    • Herdr は installed binary の API schema/command probe を利用
    • Claude capability を --help の文字列検索だけで判定しない
    • Claude max-turns reached を明示的な failure reason とする
    • Codex prompt は PROMPT=- で stdin 経由
    • CLI usage error と runtime unavailable を区別する
    • malformed JSON/JSONL、unexpected event shape、cleanup failureは SKIP ではなく exit 1

    P1 指摘

    P1-1. Herdr lifecycle state は runtime 成功の authority ではない

    Claude Code と Codex の working/blocked/idle/done は screen manifest による判定で、integration は主に native session identity を提供します。また idle と done は対象 tab が見られたかにも影響され、unknown は単に分類不能です。([Herdr]6)

    したがって interactive lane の成功条件は、

    • agent が起動した
    • prompt を送れた
    • caller marker を取得した
    • timeout しなかった
    • postcondition が不変
    • cleanup が成功した

    に限定すべきです。done/idle 自体を PASS 証拠にしてはいけません。blocked は「承認画面を観測できた」という observation にはなりますが、probe 完了ではありません。


    P1-2. minimal harness としては依然過剰

    現行案は、2 mode × 3 transport、11 個の CLI option、5 種類の evidence file、optional session-log inspection、3 文書更新、4 runtime smoke を抱えています。これは #1860 が拒否した state machine/artifact surface の再増殖に近づいています。#1860 は新しい schema、digest、receipt、publisher、reason-code enum を追加せず、runtime output と実 postcondition に寄せる方針です。

    v1 では以下まで縮小するのが妥当です。

    mode=structured  -> direct native CLI
    mode=interactive -> isolated named Herdr session
    evidence         -> summary.md only
    

    session-log inspection は #1881 の実装で本当に不足が判明してから追加すべきです。先に generic option として公開すると、利用実績のない metadata surface が固定化されます。


    P1-3. 親・consumer Issue の契約が drift している

    #1881 は #1887 を hard dependency とし、#1887 の runner、pane lifecycle、session-log metadata を consumer として利用すると規定しています。#1887 の session model を named session へ変更した後、#1881 も「isolated named-session lifecycle」「summary-only evidence」へ再束縛する必要があります。

    また #1887 は parent_issue: "#1860" と宣言していますが、#1860 の Child Issues/Closure Matrix に #1887 は登録されていません。#1860 の closure rule は列挙 child の完了を close 条件にしているため、親子 tracking が不整合です。

    次のどちらかが必要です。


    P1-4. thin wrapper 方針自体は維持してよい

    .claude/skills/... を canonical body、.agents/skills/... を derived/non-canonical thin wrapper とする方向は既存資産と整合しています。

    ただし既存テストは、単なる pointer の存在だけでなく、

    • derived/non-canonical marker
    • canonical body を読む exact imperative
    • procedure body の非重複
    • wrapper bloat の禁止
    • duplicate target の禁止

    まで検証しています。AC1 は「thin wrapper である」だけでなく、既存 validator を変更せず通過することまで固定すべきです。


    推奨する最小再設計

    タイトル

    実装: worktree 内の Claude Code/Codex CLI runtime smoke を
    structured direct/isolated Herdr session で観測する共有 Skill を追加する
    

    CLI

    --runtime claude | codex
    --mode structured | interactive
    --worktree <path>
    --prompt-file <path>
    --output-dir <path>
    --timeout-seconds <integer>
    --expect-marker <literal>        # repeatable
    --require-clean-postcondition
    

    削除対象:

    --transport
    --keep-pane
    --inspect-session-log-metadata
    --require-session-log-metadata
    

    session 名は caller に指定させず、runner が生成します。任意 session 名を受け付けると、既存 session の takeover/誤削除リスクが増えます。

    interactive lifecycle

    validate linked worktree and baseline
    generate exclusive session / agent / output identifiers
    verify session does not already exist
    start isolated named Herdr server
    create workspace in target worktree
    use returned root pane
    start agent
    prompt with bounded timeout
    collect allowlisted observations
    finally:
        stop owned session
        delete owned session
        verify session absence
    write sanitized summary
    compare exact postcondition
    

    Herdr の実際の headless named-server 起動方法は、実装時に installed binary の herdr api schema --json と command smoke で確定してください。online documentation だけを version proof にしてはいけません。


    修正版 Acceptance Criteria 案

    - [ ] AC1: Claude canonical Skill と Codex thin wrapper が追加され、既存 bridge validator の marker、exact imperative、non-duplication、body-bloat 条件を満たす。
    
    - [ ] AC2: runner は canonical repository の clean linked worktree のみを受理し、root checkout、別 repository、HEAD/branch mismatch を実行前に拒否する。
    
    - [ ] AC3: Claude structured lane は direct subprocess で fresh print-mode process を起動し、stream JSON/hook events/exit codeを取得する。max-turns 到達、malformed event、marker 不在を PASS にしない。 <!-- runtime-verification: true -->
    
    - [ ] AC4: Codex structured lane は `codex exec -C <worktree> --json --ephemeral -` を使用し、prompt を stdin から渡し、JSONL/exit codeを取得する。dangerous bypass、sandbox/profile の暗黙上書きを行わない。 <!-- runtime-verification: true -->
    
    - [ ] AC5: interactive lane は実行ごとに独立 named Herdr session を生成し、default/current/caller session、pane、workspace、focusを参照・変更しない。workspace create が返す root pane で agent を起動する。 <!-- runtime-verification: true -->
    
    - [ ] AC6: 正常終了、runtime failure、timeout、例外、SIGINT、SIGTERM の全 controlled path で、runner 所有 session を stop/deleteし、session listからの消失を確認する。cleanup failure は最終 exit 1 とする。`--keep-pane` 相当の例外を設けない。 <!-- runtime-verification: true -->
    
    - [ ] AC7: 二つ以上の interactive smoke を並列実行しても session、agent、workspace、pane、output directory が衝突せず、一方の cleanup が他方または既存人間 session を停止しない。 <!-- runtime-verification: true -->
    
    - [ ] AC8: 永続 evidence は allowlisted `summary.md` のみとし、raw JSONL、pane output、prompt、assistant text、tool input/output、credential、account identifier、native session ID、HOME絶対パスを保存しない。 <!-- runtime-verification: true -->
    
    - [ ] AC9: postcondition は HEAD、branch、index、tracked diff、untracked inventory の実行前後一致を検証し、runner が作成した exact evidence fileだけを許容する。host全体やexternal side effectの復旧は主張しない。 <!-- runtime-verification: true -->
    
    - [ ] AC10: unavailable runtime/auth/required capability は `SKIP:` + exit 77、probe failure/timeout/malformed output/identity mismatch/unexpected mutation/cleanup failureは exit 1、全条件成立時のみ exit 0 とする。
    
    - [ ] AC11: fake runtime/fake Herdr test に加え、current PR headで Claude structured、Codex structured、Claude interactive、Codex interactive を実行し、runtime version、tested HEAD、marker、postcondition、session cleanupをsanitized summaryで提示する。 <!-- runtime-verification: true -->
    
    - [ ] AC12: #1881 の consumer contract と #1860 の parent tracking を isolated named-session modelへ更新する。

    最低限追加すべきテスト

    test_never_targets_current_or_default_session
    test_inherited_herdr_socket_and_pane_environment_is_scrubbed
    test_preexisting_session_collision_is_rejected_and_untouched
    test_two_parallel_runs_use_distinct_sessions_and_outputs
    test_cleanup_runs_after_start_workspace_prompt_wait_read_failures
    test_sigint_and_sigterm_trigger_cleanup
    test_cleanup_failure_overrides_success
    test_stop_then_delete_and_verify_absence
    test_integration_install_update_uninstall_are_never_invoked
    test_summary_allowlist_rejects_email_session_id_home_path_and_tool_input
    test_output_directory_does_not_hide_unexpected_mutation
    test_claude_max_turns_is_not_success
    test_cli_usage_error_is_failure_not_skip
    

    結論

    #1887 の目的は維持できますが、現行本文を incremental fix するより、interactive lane を独立 named session 前提で全面的に書き直す方が安全です。

    修正順序は次です。

    1. 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 を isolated named-session/summary-only/mandatory teardown 契約へ改訂
    2. 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 の consumer 前提を更新
    3. 導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 の Child Issues/Closure Matrixへ登録するか、parent bindingを解除
    4. issue-refinement-loop で再レビュー
    5. implementation_ready: true 後に実装開始

    本レビューでは live GitHub Issue/コメント/repository assets と現行の Claude Code、Codex、Herdr 公式資料を照合しました。Claude/Codex/Herdr の実機 runtime command は今回実行していないため、version-specific capability は PR の current-head smoke で確定させる必要があります。

  4. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    LOOP_TERMINATION_RESULT_V1:
      termination_reason: human_escalation
      max_iterations: 3
      blockers_history:
        - iteration: 0
          blockers:
            - artifact_absolute_path_rejected
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  5. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    判定

    推奨は、#1887 の本文更新を無理に再開せず、先に issue-refinement-loop の producer/validator 不整合を独立した改善 Issue として修正することです。

    今回の直接原因はかなり明確です。

    • compact_review_result.py は、artifact_dir から生成した artifact_path をそのまま str(artifact_path) として EVIDENCE/ARTIFACT に出力します。したがって、呼び出し側が絶対 --artifact-dir を渡すと wire output も絶対パスになります。
    • 一方、validate_review_compact_output.py は先頭 / を artifact_absolute_path_rejected として拒否し、.claude/artifacts/issue-refinement-loop/... の repo-relative path だけを受理します。
    • issue-reviewer.md の標準実行例は相対 --artifact-dir .claude/artifacts/issue-refinement-loop を指定していますが、producer 自身はこの契約を強制していません。

    つまり、validator が厳しすぎるのではなく、producer が validator-invalid な出力を正常生成できる split-brain です。validator を緩和して絶対パスを受け入れるのは不適切です。

    さらにテストにも明確な欠陥があります。test_compact_review_result_rejects_absolute_artifact_dir は、その名前に反して compact_review_result() を呼ばず、未接続の _validate_artifact_path() を直接検査するだけです。他の正常系テストは絶対 tmp_path を artifact_dir に渡し、absolute wire output を許容しています。 一方、producer/validator parity test は monkeypatch.chdir() 後に相対 artifact dir を使うため、実障害の配線を再現していません。

    推奨アクション

    1. 専用の改善 Issue を起票する
      推奨タイトルは次です。

      fix(issue-refinement-loop): compact review artifact の wire reference を repo-relative に正規化する

    2. producer 側を修正する
      実ファイルの書込み先は絶対パスでもよい一方、compact stdout の EVIDENCE/ARTIFACT は、検証済み repo_root を基準とした POSIX repo-relative path に変換します。成功 envelope と producer-failure envelope の両方を対象にします。

    3. 一回限りの deterministic regeneration を復旧する
      PR 実装: review/refinementのreplay・envelope・custom publisherをbounded loopへ置換する #1875 は、最小形式を parse できない場合に一度だけ再出力を要求し、その後は人間可読 blocker へ fallback する bounded loop を実装したとしています。現在の iteration 0 即時停止は、その方針との回帰または配線漏れです。

    4. 修正 PR が main に入ってから 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 を再開する
      その後、anchor review の isolated named Herdr session、mandatory teardown、summary-only evidence へ本文を全面改訂します。現行の sibling pane、--keep-pane、transport=auto を部分修正するだけでは不十分です。

    CodexCLI 向け作業プロンプト

    あなたは squne121/loop-protocol の CodexCLI 実装担当です。

    対象インシデント:

    最終目的

    次の順序で作業する。

    1. artifact_absolute_path_rejected の producer/validator split-brain を再現し、専用の改善 Issue が存在するか確認する。
    2. 存在しなければ改善 Issue を起票する。
    3. 改善 Issue 用の dedicated linked worktree と Draft PR を作成し、producer が validator-invalid な absolute wire reference を生成できないよう修正する。
    4. 修正が current main にマージ済みの場合だけ、Issue 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 の issue-refinement-loop を再実行する。
    5. 修正が未マージなら、実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 を変更せず、改善 PR を dependency としてコメントし、そこで停止する。

    無効な compact review を根拠に #1887 本文を更新してはならない。

    サブエージェント利用

    利用可能な subagent 機構を確認し、次の独立調査を優先的に gpt-5.3-codex-spark へ委譲する。

    Subagent A: producer/validator root-cause audit

    調査対象:

    • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
    • .claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.py
    • .claude/skills/issue-refinement-loop/scripts/command_registry.py
    • .claude/agents/issue-reviewer.md
    • .codex/agents/issue-reviewer.toml
    • 実際の issue-reviewer invocation path
    • failure comment #5145487558

    出力:

    • absolute artifact path が生成された exact invocation chain
    • producer、caller、validator の各責務
    • 最小修正案
      -変更対象候補
      -回帰テスト案

    Subagent B: contract drift audit

    調査対象:

    出力:

    Subagent C: adversarial test reviewer

    A・B の結果と main agent の patch を独立レビューする。

    最低限確認すること:

    • absolute canonical artifact directory
    • relative canonical artifact directory
    • repo 外への escape
    • symlink escape
    • success envelope
    • producer-failure envelope
    • EVIDENCE/ARTIFACT parity
    • validator subprocess parity
    • one-shot regeneration
    • second failure時の bounded fallback
      -秘密・HOME絶対パスの非出力

    サブエージェントは GitHub mutation、commit、push、Issue/PR の最終判断を行わない。これらは main agent が所有する。nested delegation は行わない。

    subagent 機構が利用不能なら、利用不能理由を最終報告へ一行記録し、main agent が同じ分割で調査を継続する。

    Phase 0: fresh preflight

    最初に以下を確認する。

    git status --short
    git branch --show-current
    git rev-parse HEAD
    git remote -v
    gh --version
    gh auth status
    gh issue view 1887 --repo squne121/loop-protocol --comments
    gh issue view 1507 --repo squne121/loop-protocol --comments
    gh issue view 1873 --repo squne121/loop-protocol --comments
    gh pr view 1875 --repo squne121/loop-protocol --json state,mergedAt,headRefOid,body,url

    gh の current usage は実機の gh help/各 subcommand の --help で再確認する。記憶上の syntax を信用しない。

    current main とローカル HEAD の差異を確認する。古い issue body、古い comment、古い branch を authority にしない。

    Phase 1: 改善 Issue の有無を確認

    次の語を OPEN/CLOSED Issue と PR から検索する。

    • artifact_absolute_path_rejected
    • compact_review_result absolute path
    • repo-relative artifact
    • review compact producer validator
    • invalid compact regeneration
    • producer output invalid

    専用 Issue が存在し、今回の producer/validator mismatch、テスト欠陥、retry regression の全てを扱うなら重複起票しない。

    該当 Issue が存在しない場合、次の趣旨で新規改善 Issue を作成する。

    推奨タイトル

    fix(issue-refinement-loop): compact review artifact の wire reference を repo-relative に正規化する

    Issue が必ず含む内容

    Issue 作成後に URL と issue number を readbackする。

    Phase 2: 再現テストを先に追加

    専用 linked worktree を改善 Issue 番号に束縛して作成する。root checkout で実装しない。

    最初に、現在の main で次の failure を再現するテストを追加する。

    1. temporary repository rootを作る。
    2. absolute path の
      <repo_root>/.claude/artifacts/issue-refinement-loop
      を --artifact-dir に渡す。
    3. --repo-root <repo_root> も渡す。
    4. compact_review_result.py の stdout を取得する。
    5. stdout を validate_review_compact_output.py --issue-number <N> に渡す。
    6. current main では artifact_absolute_path_rejected で失敗することを確認する。

    単なる helper の直接テストではなく、実 subprocess producer → validator chain を通すこと。

    失敗が再現しなければ、実際の #1887 invocation、cwd、artifact-dir、repo-root を再調査し、推測で patch しない。

    Phase 3: producer 修正

    原則として validator を緩和しない。

    推奨設計:

    filesystem artifact path:
        absolute/resolved/containment checked path
    
    wire artifact reference:
        repo_root からの repo-relative POSIX path
        例:
        .claude/artifacts/issue-refinement-loop/1887/
        compact_review_result_YYYYMMDDTHHMMSSZ.json
    

    実装要件:

    • artifact_path.resolve() が canonical artifact subtree 内にあることを先に確認する。
    • wire reference は artifact_path.resolve().relative_to(repo_root.resolve()).as_posix() で導出する。
    • EVIDENCE と ARTIFACT は wire reference だけを使用する。
      -実ファイル書込みには filesystem path を使用する。
    • success envelope と producer-failure envelope の両方を同じ helper で正規化する。
    • repo_root がない状態で absolute artifact path を受け取った場合は、invalid wire outputを出さず fail-closed にする。
    • repo 外、..、symlink escape、issue number mismatchを拒否する。
    • EVIDENCE は ARTIFACT から prefix を除いた値と完全一致させる。
    • Windows separatorが混入しても wire representation は POSIX / にする。
    • absolute path、HOME、worktree root を stdout に出さない。
    • failure detail に絶対パスをそのまま含めない。

    既存の _validate_artifact_path() が production path から呼ばれていないなら、次のいずれかを行う。

    • production pathへ正しく統合する。
      -新しい canonical helperへ統合して dead helperを削除する。

    名前だけ安全そうな未接続 helperを残さない。

    Phase 4: retry/fallback 配線の確認

    PR #1875 の bounded-loop contract と current implementation を照合する。

    期待動作:

    1. subagent compact output が parse/validation failure

    2. Issue mutationはまだ行わない
      3.同じ reviewed bodyに対し、canonical rendererを使った再出力を一度だけ要求
      4.再出力が validなら通常 routingへ復帰
      5.再出力も失敗した場合:
      -無限 retryしない

      • invalid artifactをconsumeしない
        -人間可読の tooling blockerを返す
        -可能なら通常の improvement Issue/comment routeへ記録
        -新しい公開 schemaや複雑なfailure taxonomyは追加しない

    current production pathに既に実装されているなら、regression testだけ追加する。

    存在しない、または実際には validator-first immediate termination になっているなら、改善 Issue の Allowed Paths と scopeを正式更新してから最小修正する。Issue scopeを変更せずに Allowed Paths 外を編集しない。

    Phase 5: 必須テスト

    最低限、次を追加する。

    • absolute canonical artifact-dir + repo-root:

      • producer stdout は repo-relative
      • validator valid
    • relative canonical artifact-dir:
      -従来どおり valid

    • absolute artifact-dir outside repo:

      • fail-closed
    • symlink escape:

      • fail-closed
    • producer-failure envelope:

      • artifact path自体は canonical repo-relative
      • producer failureであることによる semantic invalid と、absolute path violationを混同しない
    • EVIDENCE/ARTIFACT parity

    • POSIX wire separator

    • stdoutにabsolute repo path/HOME pathなし
      -実 subprocess producer → validator parity

    • 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 incident regression fixture

    • first malformed output:
      -一回だけ regeneration

    • second malformed output:

      • bounded fallback
      • Issue mutationなし
        -無限 loopなし

    既存の misleading test:

    test_compact_review_result_rejects_absolute_artifact_dir
    

    は、producer本体または CLI subprocessを実際に検査するテストへ置換する。helperだけを呼ぶテストのまま残さない。

    Phase 6: 検証

    対象テストを先に実行する。

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py \
      .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py \
      -q

    retry/fallbackを変更した場合は、該当する issue-refinement-loop routing testsも追加して実行する。

    次に広域回帰を実行する。

    uv run --locked pytest .claude/skills/issue-refinement-loop/ -q
    git diff --check

    リポジトリ標準ゲートが Issue 契約で要求される場合は、その exact commands も実行する。無関係な既存 failureを修正範囲へ取り込まず、baselineとcandidateを区別して報告する。

    Phase 7: 独立レビュー

    gpt-5.3-codex-spark の adversarial subagentに current diffとテスト結果を渡し、次を重点確認させる。

    blockerがあれば修正し、同一current headで再検証する。

    Phase 8: commit/push/Draft PR

    改善 Issueの専用branchにだけcommitする。

    PR本文には最低限次を記載する。

    Draft PRを作成し、作成後にrepository、base、head、head SHA、changed filesをreadbackする。

    Phase 9: #1887 の扱い

    改善 PR が未マージの場合

    #1887本文を変更しない。

    #1887へ通常のIssue commentとして次を記録する。

    そこで停止する。

    改善がcurrent mainへマージ済みの場合

    fresh mainを取得し、clean dedicated contextで #1887 の issue-refinement-loopを再実行する。

    valid compact outputを得た後、anchor reviewに従って #1887 を全面改訂する。

    必須の改訂方向:

    • interactive laneは人間のcurrent Herdr session内のsibling paneではなく、run-owned isolated named session
    • herdr pane split --current を削除
    • --keep-pane を削除
    • transport=auto|direct|herdr を削除
    • structured modeはdirect subprocess固定
    • interactive modeはnew named Herdr session固定
    • callerのdefault/current session、pane、workspace、focusを参照しない
    • workspace createで得たroot paneを使用
    • session名、agent名、output directoryをhigh-entropy run IDに束縛
    • inherited HERDR_* identityを利用しない
      -全操作にtimeout
    • finallyでstop→delete→absence verification
    • cleanup failureはexit 1
      -未所有sessionを削除しない
      -永続evidenceはallowlist summaryを基本とし、raw transcript、native JSONL、pane text、prompt、assistant response、tool input/output、session ID、absolute pathを保存しない
    • repository postconditionはHEAD、branch、index、tracked diff、untracked inventoryに限定
    • host全体の復旧を主張しない
    • actual Claude/Codex/Herdr versionとcapability probeを記録
    • 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 consumerと親 導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 child matrixを整合
    • fresh reviewで implementation_ready: true を得るまで実装開始しない

    禁止事項

    • validatorをabsolute path受理へ緩和しない
    • invalid compact reviewを手動でapprove相当に読み替えない
    • #1887のdomain reviewとtooling bugを同じPRで実装しない
      -新規schema、digest、receipt、publisher、永続state storeを追加しない
    • raw transcriptやabsolute local pathをGitHubへ投稿しない
    • root checkoutを直接変更しない
    • current human Herdr session/paneを変更しない
      -別Issue/別PRの未関連変更を取り込まない
    • mergeを自動実行しない
    • Draft解除を自動実行しない

    最終報告形式

    status: completed | draft_pr_opened | blocked
    incident:
      issue: 1887
      comment: 5145487558
    root_cause:
      producer:
      caller:
      validator:
    test_gap:
    improvement_issue:
      number:
      url:
      created: true | false
    draft_pr:
      number:
      url:
      head_sha:
    subagents:
      - role:
        model:
        result:
    verification:
      targeted:
      regression:
      diff_check:
    issue_1887:
      body_updated: true | false
      refinement_rerun: true | false
      reason:
    remaining_blockers: []
    next_action:

    推測で completed にしない。改善PRが未マージなら draft_pr_opened とし、#1887の再開を次の明示アクションとして残す。

    再発防止策が未起票であることへの批評

    GitHub の Issue/PR をエラーコードと関連語で検索した範囲では、今回の producer/validator mismatch を専用に扱う改善 Issue は見つかりませんでした。終了結果の follow_up_issues: [] は不十分です。

    特に問題なのは次の3点です。

    • 分類が不正確です。
      artifact_absolute_path_rejected は domain judgment ではなく、決定論的な tooling contract failure です。これを一律 human_judgment_required に畳むと、何を人間が判断すべきなのか分からなくなります。

    • 既知の機械的故障なのに materialization がゼロです。
      本文を安全に更新できない判断自体は正しいものの、改善 Issue、note-only observation、再実行手順のどれも残さないのは、fail-closed ではなく単なる dead-end です。

    • merged bounded-loop 方針との回帰です。
      PR 実装: review/refinementのreplay・envelope・custom publisherをbounded loopへ置換する #1875 は parser failure時の一回再出力と fallbackを前提にしています。今回の iteration 0 即時終了は、その配線が機能していないことを示します。

    再発防止は、複雑な新 taxonomy や state machine ではなく、producer 境界での canonicalization、実 subprocess parity test、一回限りの regeneration、通常の改善 Issue 記録の4点で十分です。

    この会話環境には Codex subagent を直接起動する実行機能がないため、調査自体は GitHub connector で行い、上記プロンプト内で gpt-5.3-codex-spark subagent の優先利用を必須化しています。

  6. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-01 10:16:40

    • status: blocked
    incident:
    issue: 1887
    comment: 5145487558
    root_cause:
    producer: "absolute --artifact-dir を EVIDENCE/ARTIFACT の wire 値としてそのまま出力していた"
    caller: "issue-reviewer の実際の起動 runner は repo 外 control-plane。repo 内には Step 2 契約のみ存在"
    validator: "repo-relative POSIX path のみを受理し、absolute path を artifact_absolute_path_rejected とす
    る"
    test_gap: "既存テストは helper と absolute failure path を固定しており、producer→validator subprocess
    parity が不足"
    improvement_issue:
    number: 1882
    url: "#1882"
    created: false
    draft_pr:
    number: null
    url: null
    head_sha: null
    subagents:
    - role: "producer/validator root-cause audit"
    model: "gpt-5.3-codex-spark"
    result: "split-brain と repo 外 caller を確認"
    - role: "contract drift audit"
    model: "gpt-5.3-codex-spark"
    result: "iteration 0 停止は通常の bounded iteration ではなく validator failure"
    - role: "adversarial review"
    model: "gpt-5.3-codex-spark"
    result: "canonical artifact base 自体の symlink escape を指摘。修正と回帰テストを追加済み"
    verification:
    targeted: "修正前 reproduction: absolute path が stdout に漏れ validator で失敗。修正後 targeted 102
    passed"
    regression: "issue-refinement-loop 全体を candidate で実行し完走。その後 adversarial 指摘の追加修正は未再
    実行"
    diff_check: "実施済み(追加修正前)"
    issue_1887:
    body_updated: false
    refinement_rerun: false
    reason: "改善 PR は未作成・未マージ。invalid compact output は consume していない"
    remaining_blockers:
    - "one-shot regeneration / bounded fallback は repo 内に実行 runner がなく、SKILL 契約の更新のみ。外部
    control-plane の実装・実行証明なしに Draft PR として完了扱いにできない"
    - "adversarial review後の追加 symlink-base 修正について、対象・広域テスト、commit、push、Draft PR 作成が
    未完了"
    next_action: "外部 issue-reviewer runner の変更権限・所在を確定後、追加修正を再検証し、#1882 の dedicated
    branch へ commit/pushして Draft PR を作成する"

    #1887 本文・コメントは変更していません。#1882 の本文は incident と必要な Allowed Paths を controlled
    transaction で更新済みです。

    コーデックスCLIに作業プロンプトを出してください。
    gpt-5.3-codex-spark モデルサブエージェント 優先的に使って。
    サブエージェントを使って。
    レビューループにおける中間・最終報告は、GitHubにコメントを残してください。推奨アクションを確認して教えてください。


    chatgpt response

    #1887 の停止原因、#1882 の現行契約、関連 runner/Skill/テストの所在を確認し、実行順・停止条件・GitHub報告要件まで含む Codex CLI 用プロンプトに落とします。外部 control-plane が未特定なら、そこを無理に完了扱いしない構成にします。

    現行 #1882 は go 判定済みで、AC10 に symlink escape と repo-relative wire reference がすでに組み込まれています。一方、外部 runner の所在・権限確認は実装完了条件ではなく、repo 内変更と実行証明を分離して扱う必要があります。

    推奨アクション

    next_action の前半、つまり 外部 issue-reviewer runner の所在と変更権限を先に確定する方針は妥当です。ただし、runner が repo 外かつ変更不能だった場合に #1882 全体を停止し続けるべきではありません。

    推奨する処理順は次のとおりです。

    1. 実装: compact artifact wire reference をrepo-relativeへ正規化する #1882 の契約を実装可能性で分離する

    2. adversarial review 後の symlink-base 修正を再検証する

      • targeted testだけでなく、producer CLI → validator subprocess、issue-refinement-loop 全体、Allowed Paths、絶対パス漏えいを再検証します。
      • 現行 producer は failure envelope でも artifact_path をそのまま文字列化する経路を持つため、success/failure の双方を共通 helper に通す必要があります。
    3. 専用 branch へ commit/pushし、Draft PRを作成する

    以下のプロンプトでは、リポジトリに定義済みの spark-deep、spark-skim、spark-worker を役割どおり使用します。いずれも gpt-5.3-codex-spark ですが、manual invocation onlyであり、deep/skimはread-only、workerはAllowed Paths内のbounded edit専用です。

    Codex CLI用プロンプト

    **Document Title: **

    squne121/loop-protocol の Issue #1882 を対象に、停止している実装作業を再開してください。

    最終目標は、Issue #1887 comment 5145487558 で発生した artifact_absolute_path_rejected を再発不能にし、Issue #1882 の実装を dedicated linked worktree/dedicated branch 上で完了させ、検証済みの Draft PR を作成することです。

    gpt-5.3-codex-spark を使用する設定済みSubAgentを優先的に使用してください。SubAgentを使わずに単独で調査・実装を進めないでください。

    対象

    既知の状況

    以下は仮説ではなく、作業開始時に一次情報から再検証する入力です。

    • producer が absolute --artifact-dir から得た filesystem path を EVIDENCE/ARTIFACT の wire値へそのまま出力していた。
    • validator は repo-relative POSIX path のみを受理する。
    • 実際の issue-reviewer 起動runnerは repo外 control-plane である可能性が高い。
    • adversarial reviewにより、canonical artifact base自体のsymlink escapeが指摘され、候補修正がローカルに存在する可能性がある。
    • adversarial修正後のtargeted/全体回帰、commit、push、Draft PR作成は未完了。
    • invalid compact outputをconsumeしてはならない。
    • 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 の本文更新とlive refinement rerunは、修正がmainへマージされる前に実行してはならない。

    自律実行方針

    途中で通常の確認を求めず、一次情報を読んで安全な推奨ルートを選択してください。

    ただし、次の事項を推測で完了扱いにしてはいけません。

    • repo外runnerを変更していないのに、one-shot regeneration/bounded fallbackを実装済みと主張すること
    • SKILL.mdの記述変更だけでruntime control-planeの動作を証明すること
    • adversarial修正前のテスト結果をcurrent diffの証跡として再利用すること
    • invalid compact outputをIssue本文更新やreview verdictに利用すること
    • SKIP、未実行、外部権限不足をPASSへ昇格すること

    Step 0: fresh preflight

    最初に以下をfresh readbackしてください。

    1. git status --short --branch
    2. canonical repository root、current branch、worktree一覧
    3. remote URLとdefault branch
    4. origin/mainのfresh SHA
    5. Issue #1882本文、全コメント、最新body SHA、contract reviewのbody SHA一致
    6. Issue #1887本文と指定3コメント
    7. #1882に紐づく既存branch/PR/worktreeの有無
    8. OPEN PRとのchanged-path overlap
    9. 現在存在する未commit candidate diffの有無とprovenance
    10. gh --version、gh auth status
    11. 書込み前に次を確認すること:
      • gh issue comment --help
      • gh pr create --help
      • gh pr comment --help
      • gh pr view --help

    既存candidate diffが見つかった場合は、作成元、base SHA、変更ファイル、未追跡ファイル、テスト時点を確認してください。provenance不明な変更をそのまま採用しないでください。

    Step 1: Spark SubAgentによる並列監査

    以下をtop-level SubAgentとして並列実行してください。各SubAgentからのnested delegationは禁止します。

    A. spark-skim: scope/asset inventory

    必須入力:

    出力で最低限確認すること:

    • live Allowed Paths
    • candidate changed paths
    • Allowed Paths違反
    • 既存PR/branchとの重複
    • missing test file
    • contract body drift
    • current-main baseline
    • 作業を引き継げるcandidateか、破棄してfresh worktreeに移すべきか

    B. spark-deep: producer/caller/validator provenance

    必須入力:

    • task_scope: artifact_absolute_path_rejected に至るexact invocation chainと変更権限の監査
    • target_paths:
      • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
      • .claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.py
      • .claude/skills/issue-refinement-loop/scripts/command_registry.py
      • .claude/skills/issue-refinement-loop/SKILL.md
      • .claude/agents/issue-reviewer.md
      • .codex/agents/issue-reviewer.toml
      • 関連テスト

    確認事項:

    • absolute --artifact-dir が渡されたexact caller
    • producerのsuccess envelopeとfailure envelope
    • validatorのrepo-relative grammar
    • repo内に実行runnerが存在するか
    • repo外runnerの候補所在地
    • そのrunnerが別repository、ユーザー設定、Codex/Claude control-plane、生成runtimeのどれか
    • 現セッションに変更権限があるか
    • repo内契約更新で証明できる範囲と、外部runtime変更が必要な範囲

    raw transcript、credential、環境変数全量、HOME配下の無関係な内容は取得しないでください。

    C. spark-deep: adversarial security review

    必須入力:

    • task_scope: filesystem path/wire reference分離とsymlink containmentの敵対的レビュー
    • target_paths:
      • producer implementation
      • validator implementation
      • artifact security tests
      • wire reference tests
      • producer fail-closed tests

    最低限レビューする攻撃・失敗ケース:

    • absolute artifact directory inside repository
    • repo外absolute artifact directory
    • ..
    • canonical subtree外
    • artifact directory自身のsymlink escape
    • canonical base .claude/artifacts/issue-refinement-loop 自体のsymlink escape
    • 中間directoryのsymlink escape
    • broken symlink
    • repo root不在
    • repo rootがsymlinkを含む場合
    • issue number mismatch
    • Windows separator混入
    • success/failure envelope間のpath表現drift
    • stdout、stderr、fallback artifactへのabsolute repo path/HOME path/secret漏えい
    • TOCTOUを完全防止したという過剰な主張
    • resolved filesystem pathをwire値へ戻してしまう実装

    Step 2: implementation contractの実現可能性を確定

    SubAgent結果をmain threadで統合し、次のdecision treeを適用してください。

    Route A: actual runnerがrepo内かつAllowed Paths内で変更可能

    #1882の現行contractを維持し、producer/validator/callerを一つのPRで修正してください。

    one-shot regenerationとdeterministic fallbackについて、実際のproduction invocation pathをsubprocess testで証明してください。

    Route B: actual runnerがrepo外または変更不能

    これが推奨routeです。

    #1882の現在のOutcome/In Scope/AC8が、repo-local PRだけでは達成不能なら、そのまま実装開始してはいけません。

    先に issue-refinement-loop を使用し、controlled transactionで#1882を次の境界へ修正してください。

    #1882が所有するもの:

    • filesystem write pathとwire referenceの分離
    • success/failure envelope共通helper
    • repo-relative POSIX wire reference
    • canonical subtree containment
    • canonical base自体のsymlink escape拒否
    • stdout/stderrへのabsolute path、HOME path、secret非漏えい
    • producer CLI → validator subprocess parity
    • Claude/Codex issue-reviewer handoff contract parity
    • malformed serializationをIssue内容のhuman judgmentと区別するrepo-local contract

    #1882から分離するもの:

    • repo外control-plane runnerの実装
    • production runnerによる最大1回regeneration
    • production runnerによるdeterministic fallback実行
    • 外部runner上のruntime integration evidence

    外部runner変更用の既存Issueを検索してください。存在しない場合のみ、dedupe keyを定めてfollow-up Issueを起票してください。

    推奨タイトル:

    改善: external issue-reviewer control-plane に compact producer の one-shot regeneration と deterministic fallback を実装する

    follow-upには最低限以下を記載してください。

    #1882本文を修正した場合は、issue-contract-reviewをfresh bodyに対して再実行し、status: go とbody SHA一致を確認してから実装を開始してください。

    Step 3: GitHub中間報告

    実装開始前に、#1882へ中間報告コメントを残してください。

    コメントには以下を含めます。

    GitHub mutationにはrepository-sanctioned pathを使用してください。hookやcontrolled publisherが要求される場合、raw ghで迂回しないでください。投稿後は必ずreadbackしてください。

    Step 4: dedicated worktree/branch

    既存の正規worktreeがなければ、fresh origin/mainからdedicated linked worktreeを作成してください。

    推奨branch:

    worktree-issue-1882-compact-wire-reference

    以下を禁止します。

    • root checkout上の実装
    • 他Issueのworktree流用
    • unrelated dirty diffの混載
    • force push
    • current mainの直接変更
    • Allowed Paths外の編集
    • auto merge
    • Draft解除

    Step 5: bounded implementation

    main agentが設計判断と統合を所有してください。

    必要に応じて spark-worker を使い、Allowed Paths内のbounded editを委譲してください。各spark-worker呼出しには必ず次を渡してください。

    • task_scope
    • live allowed_paths
    • 修正対象ファイル
      -期待するテスト
      -変更してはならない契約
    • publish/commit/review judgment禁止

    spark-workerをimplementation-worker、issue-author、pr-reviewerの代替として使用してはいけません。

    実装上の必須条件:

    1. artifact書込み用filesystem pathとwire用referenceを別の値として扱う。
    2. wire値はrepository-relative POSIX pathだけにする。
    3. success envelopeとproducer-failure envelopeを同じcanonical helperへ通す。
    4. absolute --artifact-dir がrepo内canonical subtreeを指す場合は、書込みにはabsolute pathを利用できても、wireにはrepo-relative referenceだけを出す。
    5. repo外、canonical subtree外、..、issue mismatch、symlink escapeはfail-closedにする。
    6. canonical base自体がrepo外へresolveする場合も拒否する。
    7. resolved repo rootとresolved canonical baseのcontainmentを明示的に検証する。
    8. exception detail、stdout、stderr、failure envelopeへresolved absolute pathを含めない。
    9. fallbackの<write_failed>等のsentinelはvalidator contractと一致させる。
      10.既存schema、digest、receipt、publisher、state store、reason-code familyを追加しない。
    10. unrelated refactorを行わない。
      12.自動rollback、git reset --hard、git cleanで検出結果を隠さない。

    Step 6: regression tests

    最低限、Issue #1882の全Verification Commandsをcurrent diffに対して実行してください。

    加えて、以下を実行してください。

    Targeted security/wire tests

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_compact_review_wire_reference.py \
      .claude/skills/issue-refinement-loop/tests/test_artifact_security.py \
      .claude/skills/issue-refinement-loop/scripts/tests/test_producer_fail_closed.py \
      -q

    Producer/validator parity

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_issue_reviewer_handoff.py \
      .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py \
      .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py \
      -q

    Full related regression

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests \
      .claude/skills/issue-refinement-loop/scripts/tests \
      -q

    Static checks

    git diff --check
    python3 -m compileall -q \
      .claude/skills/issue-refinement-loop/scripts

    repositoryにcanonical lint/ruff commandがある場合は、それも実行してください。

    Required subprocess cases

    テスト名に依存せず、次を実際のproducer CLI subprocessからvalidator subprocessへ渡して検証してください。

    • valid approve
    • valid needs-fix
    • absolute canonical artifact-dir
    • relative canonical artifact-dir
    • success envelope
    • producer-failure envelope
    • trailing whitespace除去後
    • legacy field混入
    • reviewed body SHA欠落
    • repo外absolute artifact-dir
    • canonical base symlink escape
    • artifact subdirectory symlink escape
    • POSIX separator
    • stdout/stderr path leak検査

    Local loop regression

    adversarial修正後のcandidateでissue-refinement-loopのlocal/fixture-driven E2Eを再実行してください。

    live #1887の本文、コメント、contract snapshotを変更してはいけません。live #1887 refinementを再実行せず、fixtureまたはread-only inputで再現してください。

    すべてのテスト結果は、修正後current HEADに結び付けてください。修正前の102 passedや追加修正前の全体完走をcurrent evidenceとして流用しないでください。

    Step 7: diff/scope review

    commit前に以下を確認してください。

    • git status --short
    • git diff --stat
    • git diff --name-status
    • git diff --check
    • live Allowed Pathsとの照合
    • symlinkを含む新規fixtureの意図
    • snapshot/goldenの安易な再生成がないこと
    • absolute repository path、HOME path、credentialがtracked fileへ入っていないこと
    • unrelated generated artifactがないこと
    • branchがfresh mainをbaseとしていること

    差分がAllowed Paths外へ出た場合は、勝手にscopeを拡張せず、#1882へblockerコメントを投稿して停止してください。

    Step 8: commit/push/Draft PR

    全必須検証がcurrent diffでPASSした場合のみcommitしてください。

    推奨commit/PR title:

    fix(issue-refinement-loop): compact review artifact の wire reference を repo-relative に正規化する

    push後、Draft PRを作成してください。

    PR本文に最低限以下を含めます。

    Draftを解除せず、mergeしないでください。

    Step 9: implementation review loop

    Draft PRのcurrent headに対して impl-review-loop を実行してください。

    各iterationで以下を行います。

    1. current PR head SHAをfresh取得
    2. test evidenceが同じSHAに結び付いていることを確認
      3.独立したreviewerを実行
    3. spark-deep による追加adversarial security reviewを実行
    4. blockerをmain agentが統合
      6.修正が必要ならAllowed Paths内だけ修正
      7.対象テストと全関連回帰を再実行
    5. commit/push
      9.新しいcurrent headで再review

    reviewerとSparkは互いの結論をコピーせず、独立一次確認を行ってください。

    GitHub報告要件

    各iterationの中間報告をDraft PRのconversation commentとして投稿してください。

    各コメントには以下を含めます。

    • iteration
    • reviewed head SHA
    • reviewer role/model
    • verdict
    • blocking findings
    • non-blocking findings
    • changed paths
    • targeted test結果
    • regression結果
    • Allowed Paths結果
      -次アクション

    最終iterationでも必ずPRへ最終コメントを残してください。ローカル出力だけで終了してはいけません。

    コメント投稿後はGitHubからreadbackし、対象PRとhead SHAを確認してください。

    Step 10: Issue最終報告

    Draft PR作成とreview loop完了後、#1882へ最終報告コメントを投稿してください。

    最終報告形式:

    status: completed | draft_pr_opened | blocked
    incident:
      issue: 1887
      comment: 5145487558
    improvement_issue:
      issue: 1882
      body_sha256:
      contract_route: repo_local_complete | split_external_runner_followup
      external_follow_up_issue:
    root_cause:
      producer:
      caller:
      validator:
    test_gap:
    security_fix:
      filesystem_wire_split:
      canonical_base_symlink_escape:
      stdout_path_leak:
    verification:
      targeted:
      producer_validator_subprocess:
      full_regression:
      local_loop_regression:
      diff_check:
      allowed_paths:
    draft_pr:
      number:
      url:
      head_sha:
      branch:
    review_loop:
      iterations:
      final_verdict:
    github_comments:
      issue_intermediate:
      pr_iterations:
      issue_final:
    issue_1887:
      body_updated: false
      refinement_rerun: false
      reason: "#1882の修正がmainへ未マージのため"
    remaining_blockers:
      - ""
    next_action:
      - ""
    subagents:
      - role:
        agent:
        model: gpt-5.3-codex-spark
        result:

    #1887の扱い

    この作業中は次を厳守してください。

    #1882の修正がmainへマージされた後の別工程で、fresh mainから#1887のrefinementを再実行してください。

    完了条件

    次をすべて満たした場合だけ status: draft_pr_opened または completed としてください。

    • external runner境界が一次証拠で確定
    • 実装: compact artifact wire reference をrepo-relativeへ正規化する #1882 contractが実装可能なscopeになっている
    • symlink-base追加修正後の全検証がPASS
    • producer→validator subprocess parityがPASS
    • current diffがAllowed Paths内
    • commit済み
    • push済み
    • Draft PR作成済み
    • current headに対するreview loop完了
      -各中間/最終報告がGitHubに投稿・readback済み
    • #1887が未変更

    外部runner境界、テスト失敗、Allowed Paths違反、GitHub write失敗のいずれかが残る場合は、無理にDraft PR完了扱いせず、#1882へ具体的blockerコメントを残して status: blocked で終了してください。

    このプロンプトは、外部 runner の未実装をrepo-local修正で隠さず、同時にsymlink修正済みコードを放置せずDraft PRまで進める構成です。


    you asked

    message time: 2026-08-01 10:52:00

    また、過剰実装に方向性が触れていないか、敵対的にレビューしてください。個人趣味開発の範囲で、安全確実に動くよりも、有効活用を最大限にすることを目標として開発を進めていきたいです。修正完全版プロンプトを出し直して。


    chatgpt response

    前回プロンプトを、#1860 の minimal harness 方針と「個人趣味開発で有効活用を最大化する」という優先順位に照らして削ります。特に、外部runner分割・多段レビューループ・全面回帰・GitHub報告粒度が成果に対して過剰かを見直します。

    敵対的レビュー結果

    前回版は、過剰実装へ再び寄る危険が高いです。特に問題なのは次の点です。

    1. 外部runnerの特定・改修をDraft PRの前提にした

      今回の直接原因は「filesystem上の絶対パスをwire値として出した」という狭いproducer bugです。外部control-planeのretry/fallbackまで同時に解決しようとすると、単純な修正が別プロジェクト化します。

    2. 新規follow-up Issueを既定ルートにした

      実装場所が存在するかも不明な外部runnerについてIssueを増やすのは、利用価値より管理コストを増やします。現時点では「非保証」として記録するだけで十分です。

    3. 監査、セキュリティレビュー、回帰テストを重複させた

      3つの事前SubAgent、実装SubAgent、実装後レビュー、全体回帰、local loop回帰を要求していました。狭いpath変換修正に対して重すぎます。

    4. symlink問題を汎用filesystem security frameworkへ広げかねない

      canonical baseのsymlink escapeは修正対象に含めてよい一方、broken symlink、Windows全般、TOCTOU、hardlink、host全体の復旧まで扱う必要はありません。

    5. GitHub報告が成果物より多い

      全iteration・全段階でコメントを要求すると、コードより報告契約が主役になります。開始時、実際のレビュー時、終了時だけで十分です。

    6. #1882自体も広すぎる

      現行Issueは、#1877の空値・旧field・SHA欠落、#1887のabsolute path、Claude/Codex parity、symlink、最大1回retry、deterministic fallbackを一つに束ねています。その一方でruntime verificationを不要としています。外部runnerがrepo外なら、retry/fallbackのproduction動作をrepo内pytestだけで証明することはできません。

    #1860の方針は、live Issue/PR、実diff、実test、current-head CI、独立reviewをauthorityとし、独自control-plane、ledger、digest、checker、enforcing hookを増やさないことです。今回もこの基準に戻すべきです。

    推奨する最小着地点は次です。

    • producerの書込みパスとwire referenceを分離する
    • success/failure envelopeの両方を同じ変換helperに通す
    • canonical baseのsymlink escapeだけは拒否する
    • producer subprocess → validator subprocessの回帰テストを追加する
    • 外部runnerの自動retry/fallbackは実装しない
    • 外部runner未対応はDraft PRのblockerにしない
    • レビューループは最大2回
    • 広域回帰は最終差分に対して1回だけ
    • 新規Issueは原則作らない

    以下が修正完全版です。

    **Document Title: **

    squne121/loop-protocol の Issue #1882 を、個人趣味開発向けの minimal harness 方針で実装してください。

    この作業では、「起こり得る全障害を防ぐこと」よりも、実際のAIエージェント運用を早く正常化し、有効活用できる状態に戻すことを優先します。

    安全性については最低限の境界を維持しますが、汎用control-plane、完全な自動復旧、外部runnerの包括的管理、過剰なsecurity frameworkは実装しないでください。

    対象

    OWNER優先順位

    以下を設計判断の最上位に置いてください。

    1. AIエージェントを実用上止めないこと
    2. 修正を小さく保ち、Draft PRまで早く到達すること
    3. live Issue/PR、実diff、実test、current-head CI、独立reviewをauthorityにすること
    4. 明示的な失敗は許容するが、無効な出力をvalidとしてconsumeしないこと
    5. 自動復旧機構より、再実行可能な単純な失敗を選ぶこと
    6. 個人趣味開発に不要な運用・保守コストを追加しないこと

    次は最低限守る安全境界です。

    • secretを出力しない
    • HOMEまたはrepositoryの絶対パスをwire出力へ載せない
    • repo外へartifactを書かない
    • invalid compact outputをreview verdictとしてconsumeしない
    • destructive git command、force push、auto mergeを行わない
    • #1887を修正のmerge前に書き換えない

    それ以外は、理論上の完全性より実用性を優先してください。

    明示的な非目標

    次を新規実装しないでください。

    • 新しいschema family
    • digest/receipt/attestation
    • persistent state store
      -専用publisher
    • generic retry orchestrator
    • generic fallback framework
    • external runner registry
    • agent execution ledger
    • filesystem security framework
    • cross-platform path abstractionの全面再設計
    • crash recovery/resume機構
      -新規GitHub Issueの自動起票
      -全Issue/全PRを対象にしたsemantic overlap分析
      -外部control-planeの存在証明をDraft PRの完了条件にすること

    現在のrepo内資産で小さく修正できない機能は、実装せず limitation として記録してください。

    成功条件

    最小の成功状態は次です。

    1. absoluteなcanonical --artifact-dirを使ってartifactを書ける
    2. EVIDENCEとARTIFACTのwire値はrepo-relative POSIX pathになる
    3. success envelopeとproducer-failure envelopeで同じpath変換を使う
    4. canonical artifact baseがrepo外へsymlink escapeする場合は拒否する
    5. producer CLIのstdoutをvalidator CLIへそのまま渡すsubprocess testがPASSする
    6. 実装: 修正: iteration 0 の trusted anchor を body-delta 非依存で contract update へ routing する #1877/#1887の既知transport failureに回帰しない
    7. current差分をcommit、pushし、Draft PRを作成する
    8. current-headに対する独立reviewを完了する
      9.必要な中間・最終報告をGitHubへ残す

    Step 1: fresh readback

    最初に次を確認してください。

    • git status --short --branch
    • canonical repository root
    • current branch
    • git worktree list
    • remoteとdefault branch
    • fresh origin/main SHA
    • Issue #1882の本文、コメント、contract review
    • Issue #1887本文と指定コメント
    • Issue #1860のminimal harness方針
    • #1882に関連する既存branch、worktree、PR
      -現在存在する未commit candidate diff
    • candidate diffのbase SHA、変更ファイル、作成経緯
    • gh --version
    • gh auth status

    既存candidate diffがある場合、最初から再実装せず、内容を監査して利用可能なら引き継いでください。

    candidateを破棄するのは、次のいずれかの場合だけです。

    • provenanceを確認できない
    • unrelated変更が混入している
    • live #1882のAllowed Paths外へ出ている
      -修正前のmainに対して作られ、現mainへ安全に移せない
      -実装が明らかに過剰である

    Step 2: SubAgentによる事前レビュー

    gpt-5.3-codex-sparkを使用する既存SubAgentを優先してください。

    事前調査は spark-deep 1つだけで行ってください。複数の重複監査を並列起動しないでください。

    spark-deep task

    task_scope: >
      Issue #1882とcandidate diffを、#1860 minimal harnessおよび
      個人趣味開発のtime-to-value優先方針から敵対的にレビューする。
    target_paths:
      - .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
      - .claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.py
      - .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py
      - .claude/skills/issue-refinement-loop/tests/test_validate_review_compact_output.py
      - .claude/skills/issue-refinement-loop/tests/test_artifact_security.py
      - .claude/skills/issue-refinement-loop/tests/test_compact_review_wire_reference.py
      - .claude/skills/issue-refinement-loop/scripts/tests/test_producer_fail_closed.py

    次の質問に回答させてください。

    1. incidentを直す最小のproduction diffは何か
    2. #1882のどの要求がrepo外runnerなしでは証明不能か
    3. どの要求が個人趣味開発に対して過剰か
    4. candidate diffに不要なabstraction、schema、helper、test matrixがないか
      5.必要な最低限の回帰テストは何か
      6.この修正はおおむね数十行程度の変更で収束可能か
      7.より大きい設計を正当化する実証済みの必要性があるか

    「将来役立つかもしれない」だけを理由に実装範囲を増やしてはいけません。

    SubAgentのnested delegationは禁止します。

    Step 3: #1882 contractの縮小判断

    live #1882を読み、次の基準で判断してください。

    そのまま実装してよい場合

    次のすべてを満たす場合です。

    • actual production callerがrepo内に存在する
    • caller変更が既存Allowed Paths内に収まる
      -最大1回retryまたはfallbackが既存関数への小さな分岐追加で済む
      -新しいrunner、state、schema、registryを追加しない
    • focused subprocess testでproduction pathを証明できる

    contractを縮小すべき場合

    次のいずれかに該当する場合です。

    • actual callerがrepo外
    • caller所在地を確認できない
    • callerへのwrite authorityがない
    • retry/fallbackを実装するには新しいcontrol-planeが必要
    • SKILL文書更新だけになり、production実行を証明できない
    • external runner対応がDraft PR作成を止める
    • incident修正より運用基盤の設計量が大きくなる

    この場合、#1882をcontrolled transactionで次の最小scopeへ修正してください。

    最小Outcome

    • compact producerがfilesystem pathとwire referenceを分離する
    • canonical artifact pathをrepo-relative POSIX referenceとして出力する
    • success/failure envelopeのpath表現を一致させる
    • repo外およびcanonical base symlink escapeを拒否する
    • producer CLI → validator CLI subprocess parity testを追加する
    • malformed compact outputをIssue内容のhuman judgmentとしてconsumeしない

    削除する要求

    • production runnerによる自動regeneration
    • deterministic fallback execution
    • external control-plane runtime evidence
    • external runnerの変更権限確立
      -外部runnerのための新規Issue起票
      -完全自動復旧

    自動retry/fallbackが無くても、producer failureを明確に返し、人間または親runnerが再実行できれば十分です。

    #1882本文を変更した場合のみ、fresh bodyに対してissue-contract-reviewを再実行してください。本文を変更しない場合は、不要なcontract review再実行を行わないでください。

    Step 4: GitHub開始報告

    実装開始前に#1882へ1件だけ中間コメントを投稿してください。

    内容:

    • fresh main SHA
    • selected scope
    • candidate diffの採用/破棄
    • actual callerがrepo内かrepo外か
      -今回実装するもの
      -意図的に実装しないもの
      -使用したSubAgent
    • dedicated branch/worktree
    • #1887を変更しないこと

    調査段階ごとに追加コメントを投稿しないでください。

    投稿後はreadbackしてください。

    Step 5: dedicated worktree

    正規の既存worktreeがない場合、fresh origin/mainから作成してください。

    推奨branch:

    worktree-issue-1882-compact-wire-reference
    

    禁止事項:

    • root checkoutでの実装
      -他Issue worktreeの流用
    • unrelated変更の混載
    • force push
    • auto merge
    • Draft解除
    • git reset --hard
    • git clean

    Step 6: bounded implementation

    設計と統合はmain agentが所有してください。

    編集をSubAgentへ委譲する場合は spark-worker を1回使用できます。

    必須入力:

    task_scope: >
      Issue #1882の縮小済みcontractに従い、
      artifact filesystem pathとwire referenceの分離を最小diffで実装する。
    allowed_paths:
      - live Issue #1882に記載されたAllowed Paths

    spark-workerにはpublish、commit、push、PR judgmentを行わせないでください。

    実装原則

    1. 書込み用pathとwire用referenceを別変数にする
    2. wire referenceはrepo-relative POSIX pathにする
    3. successとfailureで同じ変換helperを使う
    4. helperは既存script内の小さいprivate関数を優先する
      5.新しいmoduleまたはgeneric path libraryを作らない
    5. repo root配下かつcanonical artifact subtree配下であることだけ確認する
    6. canonical base自体のsymlink escapeを拒否する
    7. exception detailへabsolute pathを埋め込まない
      9.既存のreason codeを再利用する
    8. schemaやfield集合を変更しない
      11.既存validatorを緩めてabsolute pathを許可しない
    9. unrelated refactorを行わない

    目安として、production変更が大きな新規クラス、複数module、新規schemaを必要とする場合は設計が過剰です。

    「この問題は10〜50行程度のproduction修正と数件のtestで解けないか」を常に先に検討してください。

    対象外のsecurity concern

    次は今回の実装理由にしないでください。

    • hardlink攻撃
    • OS強制終了
      -電源断
      -同一UIDの悪意あるprocess
      -完全なTOCTOU排除
    • Windows全path semantics
    • network side effect
    • HOME全体の変更監視
    • cryptographic provenance
      -署名または鍵管理

    既存コードを大きくせず無料で検証できる場合を除き、対象外です。

    Step 7: テスト

    テストは次の順序で行ってください。

    A. focused tests

    最低限、次を検証します。

    • absolute canonical artifact-dirからrepo-relative wire referenceが出る
    • success envelopeのEVIDENCE/ARTIFACTが一致する
    • producer-failure envelopeもrepo-relativeになる
    • producer stdoutをvalidator subprocessへ渡すとvalidになる
    • repo外artifact-dirは拒否される
    • canonical base symlink escapeは拒否される
    • stdout/stderrへabsolute repo pathまたはHOME pathが出ない

    既に同じ性質を検証するtestがある場合、重複testを増やさず既存testを拡張してください。

    B. Issue記載のVerification Commands

    current #1882本文のコマンドを実行してください。

    同じtest fileをACごとに何度も実行する必要はありません。重複するコマンドはまとめて1回実行し、対応する複数ACへ同じ結果を参照してください。

    C. related regression

    最終変更後に1回だけ実行してください。

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests \
      .claude/skills/issue-refinement-loop/scripts/tests \
      -q

    この全体回帰を、SubAgent修正ごと、commitごと、reviewerごとに繰り返さないでください。

    D. static checks

    git diff --check
    python3 -m compileall -q .claude/skills/issue-refinement-loop/scripts

    repositoryでPython向けのcanonical Ruff commandが確認できる場合は、変更したPython fileだけを対象に実行してください。

    JS/TSを変更していない場合、pnpm typecheck、pnpm lint、pnpm test、pnpm buildをローカルで必須にしないでください。広域検証はGitHub CIに任せてください。

    Step 8: diff review

    commit前に確認してください。

    • changed pathsがAllowed Paths内
    • production変更がincident修正に直接必要
      -新規schema、state、publisher、runnerがない
      -不要なhelperやabstractionがない
    • test fixtureが過大でない
    • raw incident全文を大量fixture化していない
    • tracked fileへabsolute path、HOME path、secretが入っていない
    • unrelated generated artifactがない
    • git diff --checkがPASS

    Allowed Paths外の変更が必要な場合、勝手にscopeを拡張しないでください。ただし、外部runnerを直すためだけに作業全体をblockedにもしないでください。

    repo-local修正をDraft PRとして出し、外部runnerはlimitationとして記録してください。

    Step 9: commit、push、Draft PR

    focused testと最終related regressionがPASSした場合、commitしてください。

    推奨title:

    fix(issue-refinement-loop): compact artifact wire pathをrepo-relativeにする
    

    Draft PR本文には次を簡潔に含めてください。

    長いSchema Consumer Inventoryや大規模Safety Claim Matrixは、schemaまたはconsumer契約を実際に変更した場合だけ追加してください。

    変更していない契約について形式的な表を作らないでください。

    Step 10: bounded review loop

    レビューループは最大2回です。

    Round 1

    current PR headに対して次を実行してください。

    • repository標準のpr-reviewerまたはimpl-review-loop
    • spark-deepによる独立adversarial review

    spark-deepの確認範囲:

    • incidentを本当に直しているか
    • absolute pathがsuccess/failureのどちらかに残っていないか
    • symlink修正が過剰なframeworkになっていないか
    • testがimplementation detailへ過度に固定されていないか
    • unrelated refactorがないか
    • external runner問題を不当にPR blockerへしていないか

    Round 2

    Round 1にcurrent-headの実blockerがある場合だけ実施します。

    • blockerを修正
    • focused testsを再実行
      -影響範囲が広がった場合だけrelated regressionを再実行
    • commit/push
      -新current headを再review

    Round 2後も、external runner未対応のみが残る場合はrepo-local PRをblockedにしないでください。

    新しいschema、control-plane、state machineが必要というreview指摘は、incident修正に不可欠な具体的証拠がない限り採用しないでください。

    Step 11: GitHubレビュー報告

    GitHubへの報告は次だけに限定してください。

    1. #1882の開始コメント
    2. Draft PRのRound 1レビューコメント
      3.修正を行った場合のみRound 2レビューコメント
    3. #1882の最終コメント

    各PRレビューコメントには以下を含めます。

    iteration:
    reviewed_head_sha:
    reviewer:
    model:
    verdict:
    blocking_findings:
    overimplementation_findings:
    tests:
    next_action:

    同じ内容をIssueとPRの両方へ重複投稿しないでください。

    Step 12: #1887の扱い

    この作業では次を維持してください。

    issue_1887:
      body_updated: false
      refinement_rerun: false

    理由:

    • #1882の修正がまだmainへ入っていない
    • invalid compact outputをconsumeしない
    • Draft PRのbranchだけでは外部control-planeのproduction callerが更新されない可能性がある

    #1887のfresh refinement rerunは、#1882 PRのmerge後の別作業としてください。

    Step 13: 最終報告

    #1882へ最終コメントを投稿し、readbackしてください。

    形式:

    status: draft_pr_opened | blocked
    incident:
      issue: 1887
      comment: 5145487558
    scope_decision:
      original_contract_overbuilt: true | false
      contract_reduced: true | false
      external_runner_in_scope: false
    implementation:
      filesystem_wire_path_split:
      success_failure_shared_helper:
      canonical_base_symlink_check:
      new_control_plane_added: false
    verification:
      focused:
      producer_validator_subprocess:
      related_regression:
      diff_check:
    draft_pr:
      number:
      url:
      head_sha:
      branch:
    review:
      iterations:
      final_verdict:
      remaining_findings:
    subagents:
      - agent: spark-deep
        model: gpt-5.3-codex-spark
        purpose: scope_and_adversarial_review
      - agent: spark-worker
        model: gpt-5.3-codex-spark
        purpose: bounded_edit
        used: true | false
    issue_1887:
      body_updated: false
      refinement_rerun: false
    limitations:
      - external issue-reviewer runnerの自動retry/fallbackは実装・証明していない
    next_action:
      - Draft PRをreviewし、merge後に#1887 refinementをfresh rerunする

    blocked判定

    次の場合だけblockedとしてください。

    次はblockerではありません。

    • external runnerの所在地が完全には判明しない
    • external runnerを変更できない
      -自動retry/fallbackを実装していない
      -理論上のfilesystem attackを完全に排除していない
      -全repo testをローカル実行していない
      -追加のfollow-up Issueを起票していない

    最終的な判断基準は、「この差分によって実際のcompact producer/validator経路が再び使えるようになるか」です。

    前回版から、外部control-plane改修、新規Issue、重複監査、無制限レビューループ、過剰なsecurity matrixを完了条件から除外しています。


    Powered by AI Exporter

  7. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-01T07:55:28Z)

  8. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 1 対応報告(PR #1921 レビュー指摘)

    再現・原因

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py の main() が
    repo_root = args.repo_root or str(Path(__file__).resolve().parent.parent.parent)
    という __file__ 相対のデフォルト解決を行っていた。本 script は運用上
    .claude/worktrees/<slug>/ 内にも実体としてチェックアウトされるため、
    worktree 内から --repo-root を指定せず(Issue 記載の AC3〜AC7 の
    Verification Commands どおり)実行すると repo_root が worktree 自身に
    誤解決され、verify_worktree_identity() が常に
    "root checkout rejected: --worktree must be a linked worktree, not the canonical repository root" を返し exit 1 で失敗することを、実際に worktree
    issue-1887-runtime-smoke-skill から AC3 コマンドを実行して再現確認した。

    修正

    _default_repo_root() を追加し、git rev-parse --git-common-dir が
    canonical checkout でも linked worktree でも同一の共有 .git ディレクトリを
    指す性質を利用して canonical repository root を導出するよう変更した
    (--repo-root は test 用途として引き続き override 可能)。

    検証

    • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py に、
      runner script 自身が linked worktree 内にチェックアウトされた状態を模した
      fixture(repo_with_worktree_and_script)と、--repo-root 未指定・
      worktree 内の script コピーから起動して "root checkout rejected" が
      発生しないことを検証するテストを追加した。
    • 修正後、worktree .claude/worktrees/issue-1887-runtime-smoke-skill から
      --repo-root を指定せず Issue 記載どおりの AC3 コマンド
      (--runtime claude --mode structured --transport auto --worktree "$PWD" ...)
      を実際の Claude Code structured lane で再実行し、exit 0 で成功、
      artifacts/runtime-smoke/claude-structured/summary.md に
      native_event_count: 16 / worktree: .claude/worktrees/issue-1887-runtime-smoke-skill
      が記録されることを確認した(postcondition_unexpected_changes: [])。
    • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py 全26テスト PASS。
    • ruff check PASS(修正・追加ファイル)。

    修正コミット: bed0fa8(PR #1921 head)

  9. added a commit that references this issue on Aug 1, 2026
    b3cbe01
  10. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 2 対応報告

    根本原因

    herdr agent prompt <text> --wait --timeout <ms> に複数行 prompt(改行を含む文字列)を渡すと、Claude Code の対話 TUI 入力欄が [Pasted text #N +M lines] という折りたたみ表示のまま 未送信 になることがある。Claude Code の端末は bracketed-paste の終端シーケンスが送信用の Enter を吸収してしまい、agent lifecycle state が idle のまま変化しないため、herdr 自身の固定 5000ms 観測窓により agent_prompt_stalled("no state change within 5000ms" 相当のエラー)が返っていた。

    Codex CLI は複数行ペーストを自動送信するため、この事象は再現しない(AC6 が常に成功していた理由)。単一行 prompt でも通常は再現しない(改行が無いため paste-collapse を経由しない)。

    worktree 内で実際の herdr agent API を直接操作し、pane 出力に [Pasted text #1 +N lines] が残っていることを確認して原因を特定した。

    修正内容

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py の interactive herdr lane に、agent_prompt_stalled を検知した場合に限定した 1 回限りの回復処理を追加した。

    1. herdr agent get で state_change_seq の baseline を取得する
    2. herdr agent send-keys <name> enter で保留中の送信を完了させる
    3. state_change_seq が baseline から実際に変化したことをポーリングで確認する(herdr agent wait は既に idle 状態と即時マッチしうるため、これを確認せずに信頼すると false pass になる — 実装初版で実際にこの race を再現・検出し、poll ベースの検証へ修正した)
    4. 変化が確認できた場合のみ herdr agent wait で settle を待つ
    5. いずれかの段階で失敗した場合は SKIP へ降格せず exit 1 を返す(結果の errors リストに記録)

    evidence には prompt_stall_recovered: true/false/None(回復不要だった場合は None)を記録し、成功を偽装しない。

    実機検証

    worktree .claude/worktrees/issue-1887-runtime-smoke-skill 内で AC5/AC7 相当の Claude interactive herdr コマンドを、修正後に複数回(4 回連続)実行し、全て exit 0・--expect-marker 一致・pane-output.txt に実際の応答内容(例: RUNTIME_SMOKE_FINAL_OK)が含まれることを確認した。4 回中 3 回で agent_prompt_stalled が実際に発生し、回復処理が正しく機能したことを prompt_stall_recovered: true と pane 出力の実応答内容で確認した(偶発ではなく安定して再現・修正できることを確認済み)。

    pane-output.txt / agent-detection.json / session-log-metadata.txt / summary.md の生成も確認済み。

    テスト

    scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py に以下を追加(fake herdr CLI 使用、CI で認証不要):

    • agent_prompt_stalled から send-keys + poll による回復が成功するケース
    • 回復の send-keys 自体が失敗するケース(exit 1、SKIP に降格しない)
    • 回復の wait が失敗するケース(exit 1、SKIP に降格しない)
    • agent_prompt_stalled 以外の理由での失敗では回復処理を試行しないケース
    • agent wait が state_change_seq 未変化のまま即時マッチしうる race を再現し、poll による検証がないと false pass になることを検証するケース

    31 テスト全て PASS。ruff check clean。

    PR #1921 へ追加コミット・push 済み。

  11. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 3 対応完了(CI green)

    PR #1921 の python-test-core 4件の FAIL を修正し、push しました。

    原因

    scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py の interactive lane テスト4件(test_given_agent_state_blocked_when_interactive_lane_runs_then_not_treated_as_pass / test_given_agent_state_unknown_when_interactive_lane_runs_then_not_treated_as_pass / test_given_pane_split_succeeds_when_lane_finishes_then_pane_close_invoked_for_cleanup / test_given_keep_pane_flag_when_lane_finishes_then_pane_close_not_invoked)は、fake_bin に fake herdr のみを注入し、fake claude を注入していませんでした。run_worktree_agent_runtime_smoke.py の main() は interactive/structured を問わず preflight_claude_flags()(shutil.which("claude") → claude --help flags 検査)を必ず通すため、CI runner に実 claude CLI が存在しないと SKIP(77) になります。ローカル開発環境では実 claude が PATH にあるため見えていませんでした。

    同ファイル内の他の interactive テスト(例: test_given_fake_herdr_lane_when_interactive_runs_then_pane_lifecycle_completes や iteration 2 の stall-recovery テスト)は既に _write_fake_exe(fake_bin / "claude", _HELP_BRANCH + "exit 0\n") を注入するパターンを踏襲していました。

    修正

    • 4テストそれぞれに、fake herdr 注入の直後に fake claude 注入(_write_fake_exe(fake_bin / "claude", _HELP_BRANCH + "exit 0\n"))を追加。
    • ローカルで通常 PATH(実 claude あり)で31テスト全て pass を確認。
    • 追加で PATH から claude を除去した状態(CI runner を模擬)でも31テスト全て pass することを確認(.local/bin の他ツールを symlink した専用 no-claude PATH を組み、CI 相当の preflight 失敗を再現不可能なことを確認)。

    副次的に発見した非ブロッキング事項

    同一 push で PR Body Japanese Check workflow が .agents/skills/worktree-agent-runtime-smoke/SKILL.md(Codex 向け薄い wrapper)の per-block 日本語比率不足で fail していたため、日本語の要約文を1行追加しこのファイル分は解消しました。ただし .claude/skills/worktree-agent-runtime-smoke/SKILL.md 本体や references/ 配下、docs/dev/ 配下の複数ファイルにも同種の per-block 日本語比率不足が既に存在します(本 fix_delta iteration 3 のスコープ外、かつ PR #1921 の以前のコミットから存在)。PR Body Japanese Check は branch protection の required checks(typecheck / lint / test / build / python-test / validate-generated-artifact)には含まれておらず、ci-verdict-summary は green です。広範な prose 書き換えが必要なため、別途人間判断(follow-up Issue 化 or 許容)を推奨します。

    CI 状態(push 後、head e25a25d2)

  12. added 2 commits that reference this issue on Aug 1, 2026
    9dd6056
    ead77c9
  13. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 4 対応報告

    対応内容

    .claude/skills/worktree-agent-runtime-smoke/SKILL.md で日本語比率が threshold(0.1) 未満だった 4 個の prose block("### Lane A" 見出し、Lane A 起動コマンド箇条書き、"## Reference Map" 見出し、Reference Map の参照先箇条書き)に、内容を要約する日本語の説明文を追加した。コマンド文字列・パス・技術識別子は変更していない。

    この修正で "PR Body Japanese Check" workflow の fail-fast ループが先へ進んだ結果、本 PR が変更した他の Markdown ファイル(references/claude-code.md、references/codex-cli.md、references/evidence-hygiene.md、references/herdr.md、docs/dev/agent-runtime-ops.md、docs/dev/agent-skill-boundaries.md、docs/dev/runtime-verification-policy.md)でも同様の日本語比率不足が発覚した(従来は先頭ファイルの FAIL で早期終了していたため未検出だった)。docs/dev/agent-skill-boundaries.md の 3 block は本 Issue の変更前から main に存在していた既存の不足で、1 行追加した diff のみで whole-file check の対象になったため顕在化した。他ファイルの不足は本 Issue で追加した新規 prose block。全て同様に日本語の説明文を追加して解消した。

    検証

    uv run python3 .claude/skills/create-issue/scripts/validate_japanese_content.py --file <各ファイル> --threshold 0.1
    

    本 PR が変更した 9 個の Markdown ファイル全てで exit 0(PASS)を確認した。

    PR #1921 CI 結果

    • "PR Body Japanese Check": pass
    • 全 required checks: pass(python-test-core/lint/typecheck/test/build/e2e/deploy-pr 等)
    • mergeStateStatus: CLEAN(修正前は UNSTABLE)
    • mergeable: MERGEABLE
    • head: ead77c91ce528ff0f6f227b408f5330f45518d54

    コミット:

    • 9dd6056 fix(worktree-agent-runtime-smoke): SKILL.md の日本語比率不足 prose block を解消する
    • ead77c9 fix(worktree-agent-runtime-smoke): 残る prose block の日本語比率不足を解消する

    PR #1921 へ追加コミット・push 済み。

  14. added a commit that references this issue on Aug 1, 2026
    4162c60
  15. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    PR #1921 に対する OWNER の REQUEST_CHANGES(interactive lane が人間の Herdr session に相乗りしていた等の P0 指摘)に対応しました。

    • interactive lane を毎回新規生成する isolated named Herdr session へ完全分離し、真の isolation を確立できない場合はフォールバックせず SKIP とするようにしました
    • cleanup は session の消失確認まで行い、確認できない場合は事前の成功を上書きして exit 1 にするようにしました(SIGTERM でも保証)
    • postcondition 検査を content-hash ベースの fingerprint 比較へ強化しました
    • evidence を allowlist-only の summary.md 1 ファイルへ縮小し、Codex prompt の stdin 化・Claude Code の bounded turns も追加しました

    実 herdr バイナリに対して isolated session 生成 → SKIP(フォールバックなし)→ 残留なしの経路を確認済みです。詳細は PR #1921 の本文とコメントを参照してください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions