Skip to content

実装: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2663

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "hook-chain-runtime-smoke policy が要求する all_matching_hooks_observed と sibling_side_effect_inventory_complete を、raw transcript を保存せず current HEAD に束縛した bounded allowlist-only evidence で、handler identity 単位・post-condition 単位に独立に判定可能にする"
change_kind: workflow
dedupe_key: "worktree-agent-runtime-smoke:generic-hook-chain-evidence:v1"

Parent Issue

なし(単独改善。新規 Issue は #1573 の hard predecessor として dependency を登録する。)

Parent Goal Ref

  • Goal: hook-chain-runtime-smoke が要求する2 assertionを、genericなruntime evidence capabilityでfail-closedに判定できるようにする。
  • Desired Destination: consumerがcurrent HEADの実行からboundedなallowlist-only summaryを取得し、特定のconsumer Issueに依存しないhook-chain assertionを検証できる状態。

Current Validated Scope

  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py の structured Claude lane は --include-hook-events と invocation-local additive --settings overlay を使用し、current project settingsを変更せず追加hookを併走させる。
  • 同runnerは summary.md だけをoutput directoryに永続化し、tested_head、runtime metadata、redacted schema summaryを記録する。raw prompt、raw stream transcript、credential、HOME absolute pathは保存しない。
  • current .claude/settings.json の PreToolUse(Bash matcher)には secret boundary guard・Japanese prose guard・CI performance advisory・temporary residue advisory の4つの異なる command hook handlerが一致し、runner自身も SubagentStart/SubagentStop に観測用hookを追加する。Claude Codeのhookはproject settingsだけで完結せず、user/local/managed/plugin/skill等からも合成されうるため、settings配列の要素数だけでは runtime全体の実行期待数を証明できない。
  • 既存 .claude/hooks/tests/hookchain_harness.py は、実 .claude/settings.json を読み込み matcher に一致する command hook を subprocess として実行し、hook単位の decision(deny/defer/ask/allow/no_decision/hook_error)を収集する、read-onlyな settings-driven observation の既存手法である。本Issueの bounded verification cohort(下記 In Scope 参照)は、この既存手法が扱う「current project settingsの、選択したhook eventに一致するcommand hook」を基準とする。
  • .claude/hooks/session_manifest_coordinator.sh は、内部guard stepが失敗した場合(内部 exit code != 0 の場合)にも、また producer stepが失敗コードを返した場合にも、最終的には exit 0 で終了する既存hookである。hookの正常終了(exit 0)と、そのhookが意図した副作用(session manifest生成等)を完了させたことは、現状のrunner設計では独立に確認できない。
  • Claude Code公式ドキュメント(hooks reference)は、同一event/matcherにマッチする複数hookの並列実行や、hookのstart/completionを別lifecycle phaseとして区別できる公開フィールドの有無を明記していない。実装はこれらを保証された仕様として前提にせず、実際のruntime evidenceから判定する必要がある。

Remaining Parent Gaps

Outcome

更新された worktree-agent-runtime-smoke runner、skill contract、既存runner testsが、current HEADを示すallowlist-only summary.md 内で all_matching_hooks_observed と sibling_side_effect_inventory_complete の各判定結果を、実際のhook-chain evidenceから独立に、かつ handler identity 単位 / post-condition 単位で記録する状態。各assertionは pass | fail | unverified の3値ステータスで記録され、boolean field は status == pass の場合にのみ true となる(cohortの完全性を識別できない場合や副作用の観測可能性が不足する場合に、件数一致や観測用hookの成功だけを根拠に true へ昇格しない)。hook-chain evidence PASSは、両assertionが共に status: pass の場合にのみ成立する。

Runtime Verification Applicability

runtime_verification_applicability:
  decision: immediate
  reason: "成果物がClaude structured runtimeのhook-chain execution evidence capabilityであり、fixture-only testはlive hook delivery/concurrencyを代替しない。"
  applicable_acs: [AC5]
  verification_profile: hook-chain-runtime-smoke
  execution_environment: "linked worktree、existing worktree-agent-runtime-smoke、native Claude structured lane。"
  skip_conditions: "Claude CLI又はrequired isolated runtimeが利用不能ならstdoutをSKIP:で開始しexit 77とする。SKIPはruntime PASSではない。"
  fallback_policy: "prompt self-report、marker text、raw transcript、既存sequential hookchain_harness、又はassertion/inventoryの片方だけをPASSの代替にしない。"
  artifact_requirements: "runner-owned bounded summary.mdのtested_head、2 assertionのstatus(pass/fail/unverified)、eventとcount-only inventoryをreviewする。raw prompt/transcript、credential、HOME absolute path、hook command/output bodyを保存又は引用しない。"

In Scope

  • structured native Claude laneにopt-inのgeneric hook-chain evidence capabilityを追加し、対象eventとinventory targetをbounded closed allowlistからのみ受理する。caller-supplied shell command、hook command、任意path、任意marker、又はarbitrary configをevidence sourceとして受理しない。
  • all_matching_hooks_observed のexpected cohortを、「current project settings(.claude/settings.json)内の、選択したhook eventに一致するcommand hook」に限定して定義する。runnerが追加する観測用hookはこのcohortから明示的に除外し、別扱いとする。expected cohortの各要素と実際の実行証拠を、handler identity(event + matcher + command文字列の組、又はruntimeが実際に提供する同等の識別子)単位で照合する。件数が一致しても、いずれかのhandlerの実行証拠が欠落・重複・未知entryである場合は fail とする。user/local/managed/plugin/skill等、project settingsから独立に合成されるhook sourceは初期cohortの対象外とし、その存在をもって「runtime全体の全hookを証明した」とは主張しない(識別不能な場合は unverified とする)。観測用hook自身の実行成功を、既存sibling command hookすべての実行証拠へ昇格させない。
  • sibling_side_effect_inventory_complete をhookの実行完了(exit code等)とは独立したassertionとして扱う。初期allowlistで検証対象とする各副作用について、少なくとも(1) 対象handler、(2) 期待する変化、(3) 実際に読むpost-condition(例: .claude/hooks/session_manifest_coordinator.sh が書くsession manifestファイルの実状態)、(4) 正常な無変更の条件、(5) observation timing(対象sibling hook群の実行完了後に post-condition を読む join point)、(6) bounded location/resource、を実装が明示する。denyを返すhookがあってもsiblingのallowlisted side effectを実行事実からinventoryし、expected/observed mismatch、missing、unknown、duplicate、overflow、又は未観測の全caseを fail とする。既存hookのexit code semantics自体は変更しない(session_manifest_coordinator.sh の内部guard/producer失敗時exit 0挙動を含む既存hookの動作は変更しない)。
  • 2 assertionとaggregate verdictを、summary.md / optional existing --evidence-json schema summaryにcount/status(pass|fail|unverified)/boolean(status==passのときのみtrue)で記録する。existing tested_head を保持し、headがevidence reviewの対象と比較できない場合、consumerはPASSを主張できない。開発中のtrial実行はAllowed Paths内の未commit candidateに対して許可し、失敗時は診断として修正・再実行できるものとする。ただし最終acceptance evidenceは対象変更をcommitしたHEADに対してのみ成立させ、(a) tested_head(commit SHA)、(b) 検証対象tracked inputsがそのHEADと一致していること、(c) 実行前後で対象worktreeに意図しないdriftがないこと、の3点を記録する。before/after fingerprint一致だけを「開始時点でHEADと一致していた」の意味として扱わない。
  • existing hook/configurationを変更・disable・replaceせず、invocation-local additive observationのみを使う。existing .claude/hooks/tests/hookchain_harness.py のsequential subprocess実行手法を、runtime evidence producerとしてそのまま再利用しない(本capabilityは native structured Claude lane上の実行証拠を対象とする)。
  • canonical live invocationに、無害な入力による再現可能な positive scenario(選択したallowlisted hook eventを1回以上実際に発生させ、対応するsibling command hook群の実行証拠とallowlisted side-effect post-conditionをidentity単位で確認する)と deny scenario(PreToolUse guard系hookが実際にdenyを返す状況を発生させ、deny後もsiblingの実行証拠・post-conditionを照合する)を定義する。空のexpected setと空のobserved setが一致しただけのPASSは禁止する。hook lifecycleの複数レコード(開始・進捗・完了等が別々に届く場合を含む)や、別のtool callに対する正当な同一handler再実行を、根拠なく「重複」と誤認しない。--max-turns は品質条件ではなく実行上限として扱い、上限到達をcapability不足に分類しない。
  • existing runner unit/integration testsを拡張し、both assertionのindependent PASS/FAIL、各failure mode(handler欠落・count一致だが実行証拠不一致・副作用欠落・空集合false green・lifecycle複数レコードの誤判定防止)、deny-with-sibling-side-effect、concurrent/out-of-order delivery、raw-evidence hygiene、pre-existing caller backward compatibilityをdeterministicに検証する。Skillにcanonical live invocationとexit semanticsを記載する。

Out of Scope

  • #1573固有のmarker、prompt、settings mutation、validator/test mutation、又はIssue-specific evidence format。#1573のAC7 command自体の更新は#1573側で行う。
  • .claude/settings.json、.claude/hooks/**、scripts/claude-gpt/**、Task Context、Herdr configurationの変更。既存hookのexit code semantics(例: 常にexit 0を返す既存advisory hookの挙動)を変更すること。
  • raw stream-json、raw hook stdin/stdout、prompt、transcript、hook command/output body、credential、token、HOME absolute pathの永続化。
  • model self-report、prompt text、fake marker、又はsequential test harness(.claude/hooks/tests/hookchain_harness.py 等)の成功をassertion PASSの代替とすること。
  • generic runnerにhook policyのsemantic authorization verdictを実装すること。
  • user/local/managed/plugin/skill等、project settings外から合成されるhook sourceまで含めた完全なruntime全体のhook母集団を解決する汎用engineを実装すること(初期capabilityはproject settings由来のcommand hookとrunner観測hookの区別に限定する)。
  • Claude Codeの並列実行semanticsやhook lifecycle実装そのものを変更・新設すること(新しい監視基盤、SDK全面移行、又は新しいhook identityフィールドをClaude Code本体側に追加すること)。

Acceptance Criteria

  • AC1: opt-in capabilityはbounded closed allowlistのevent/inventory inputsだけを受理し、caller-supplied command/path/marker/configによるevidence injectionをusage errorとして拒否する。
  • AC2: all_matching_hooks_observed のexpected cohortを「current project settingsの、選択したhook eventに一致するcommand hook」に限定し、runner自身が追加する観測用hookをこのcohortから明示的に除外して個別に扱う。expected cohortの各要素と実際の実行証拠をhandler identity(event + matcher + command文字列の組、又はruntimeが実際に提供する同等の識別子)単位で照合し、件数一致だけでは pass としない。照合結果は pass | fail | unverified の3値ステータスで記録し、boolean fieldは status == pass の場合にのみtrueとする。project settings外から合成されるhook sourceの存在によって「runtime全体の完全性を証明した」と主張せず、識別不能な場合は unverified とする。観測用hook自身の実行成功を、他のsibling command hook全体の実行証拠として昇格させない。
  • AC3: sibling_side_effect_inventory_complete をhookの実行完了(exit code等)とは独立したassertionとして判定する。初期allowlistで検証対象とする各副作用について、対象handler・期待する変化・実際に読むpost-condition・正常な無変更の条件・observation timing(対象sibling hook群の実行完了後に post-condition を読む join point)・bounded location/resourceを実装及びSkill契約で明示する。denyが起きてもsiblingのallowlisted side effect inventoryを実行事実(post-condition読み取り)から照合し、欠落・重複・未知・overflow・未観測の全caseを fail とする。session_manifest_coordinator.sh のように内部guard/producer失敗時にもexit 0を返す既存hookがある前提で、hookのexit code正常終了だけを根拠に pass としない。既存hookのexit code semanticsは変更しない。
  • AC4: aggregate hook-chain PASSは、AC2とAC3が共に status: pass(boolean true)の場合にのみ成立し、いずれかが fail 又は unverified の場合は成立しない。summary/evidence JSONはexisting tested_head と、AC2/AC3それぞれのcount/status(pass|fail|unverified)/boolean assertion resultを残す。raw evidence、prompt self-report、又はhook lifecycleの複数レコードからPASSに昇格しない。
  • AC5: 開発中のtrial実行はAllowed Paths内の未commit candidateに対して許可し、失敗時は診断として修正・再実行できる。最終acceptance evidenceは対象変更をcommitしたHEADに対してのみ成立させ、evidenceに (a) tested_head(commit SHA)、(b) 検証対象tracked inputsがそのHEADと一致していること、(c) runtime実行前後で対象worktreeに意図しないdriftがないこと、の3点を記録する。before == after のfingerprint一致だけを「HEADと一致している」の意味として扱わない。current HEADのlinked-worktree native structured runをSkillのcanonical invocationで実行し、次の再現可能なbounded scenarioを使う: (1) positive scenario — 無害な入力で選択したallowlisted hook eventを1回以上実際に発生させ、対応するsibling command hook群の実行証拠とallowlisted side-effect post-conditionをidentity単位で確認する。(2) deny scenario — 無害な入力でPreToolUse guard系hookが実際にdenyを返す状況を発生させ、deny後もsiblingの実行証拠・post-conditionを照合する。空のexpected setと空のobserved setが一致しただけのPASSは禁止する。hook lifecycleの複数レコード(開始・進捗・完了等)や、別の正当なtool callに対する同一handlerの再実行を、根拠のない「重複」と誤認しない(公式ドキュメントはhookの並列実行やstart/completionの分離記録を保証として明記していないため、実装はこれらを既知の保証として前提にせず、実際のruntime evidenceから判定する)。--max-turns は品質条件ではなく実行上限として扱い、上限到達をcapability failureに分類しない。runtime availableなら両assertion PASSのbounded summaryを、runtime unavailableなら SKIP: + exit 77を返す。SKIP、fallback、missing assertion、unverified inventoryはPASSではない。
  • AC6: existing testsは少なくとも次を含めてAC1–AC5のindependent PASS/FAIL、deny-with-sibling、concurrent/順序前後のsibling delivery、raw-evidence hygiene、legacy caller compatibilityをcoverする: (a) 件数は同じだがexpected handlerが1つ欠けているケースで AC2 が pass にならないこと、(b) hookの開始・進捗・完了の複数レコードや兄弟hookの完了順逆転を重複実行と誤判定しないこと、(c) hookは全て呼ばれたがproducerの副作用が欠けるケースでAC2とAC3が独立に判定されること、(d) 正常仕様として副作用が発生しないケースを「無変更だから失敗」と決めつけないこと、(e) deny後にsibling side effectが完了するケースで、siblingの完了を待ってから実状態を確認すること、(f) 対象イベントがゼロ回、又はdeny系なのにdenyがゼロ回の空集合ケースでPASSにならないこと、(g) 未commit変更又は前回実行のartifactが存在する状態でcurrent HEADの証拠に取り違えないこと、(h) 新フラグなし・runtime利用不能・証拠破損の各ケースで既存callerが維持され、未検証・実行失敗・検証失敗が区別されること。current existing hooks/configurationは変更されない。

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

# AC2
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

# AC3
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

# AC4
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

# AC5
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree /absolute/linked-worktree --prompt-file /absolute/nontracked-hook-chain-prompt.md --output-dir artifacts/runtime-smoke/hook-chain-current-head --timeout-seconds 180 --max-turns 4 --require-clean-postcondition --require-hook-chain-evidence

# AC6
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

AC5 is the post-implementation canonical live command (preflight-scope: runtime_only; a mechanical baseline preflight must not execute this command before implementation exists). The implementation must document its fixed allowlist selection and the concrete positive/deny scenarios it uses; it must not add a marker, raw-evidence, arbitrary command, path, or config option.

Allowed Paths

  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py
  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • existing hooks/configurationのedit、disable、replace、又はcaller-supplied arbitrary shell/config inputが必要になった場合
  • raw transcript/prompt/hook bodyを保存するか、prompt self-report/fake marker/sequential harnessをPASS根拠にする必要が生じた場合
  • 意図しない破壊的操作、secret/credentialの利用又は提示、permission/security boundaryのbypassが必要になった場合
  • current HEADとevidenceの tested_head を照合できない場合(tracked inputsの改ざん・想定外drift等、SKIP/unverified以外の異常)

Allowed Paths内の実装不足によるassertion失敗(例: AC2/AC3のいずれかが最初の実行で fail を返す)は、原因を修正して再実行する通常の実装・レビューループとして扱い、上記停止条件には該当しない。意図したnegative test(deny scenario等)のassertion失敗も同様にテストの期待結果であり停止理由にしない。runtime又は必要な観測capabilityが利用不能な場合は SKIP: / unverified として記録し、静的検証やDraft PR作成は継続してよい。ただしその場合、最終AC5 acceptanceはPASSを主張できない。

Required Skills

なし

Required Design References

Scope Delta(任意)

Source

Delivery Rule

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Sep 18, 2026
  2. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    結論:REQUEST_CHANGES

    2つのassertionを追加する方向性には賛成ですが、現在のIssueは「何を、どの証拠で確認するか」が未確定な一方、確認できない場合の停止条件だけが厳密です。 このまま実装に渡すと、実際には証明できていないのにPASSするか、正常な利用環境でも止まり続けるか、どちらかに寄る危険があります。特に、hookの実行確認と、副作用の確認を別物として実装できる契約に直す必要があります。

    確認した基準は、取得時の main af702b06e29e797a6ae180af4f86c730568a8e74 です。Issue #2663、consumerの #1573 と停止報告、関連する #2568・#2651、既存の証拠判定を扱ったPR #2220・#2500、runner・Skill・テスト・settings・runtime policy・実際のhook処理を参照しました。以下はコードと契約のレビューであり、この環境でClaude実機のsmokeやpytestを実行した結果ではありません。

    1. P1:「全hook」の母集団と、設定エントリへの対応付けが未定義

    対象:AC2、all_matching_hooks_observed、In Scopeのcomplete expected set。

    現在の .claude/settings.json では、Bashの PreToolUse に対して、secret boundary、Japanese prose guard、CI performance advisory、temporary residue advisoryという4つの異なるhandlerが一致します。さらに、runner自身も SubagentStart/SubagentStop に観測用の cat hookを追加しています。

    一方、Claude Codeのhookはproject settingsだけで完結しません。user・local・managed・pluginなどから合成され、同じhandlerの重複排除もあるため、settingsの配列要素数を数えれば実行期待数になる、とは限りません。(Claude)

    ここで必要なのは、件数の一致ではなく、期待するhandlerそれぞれと実行証拠との対応です。

    例えば、次は私が作った単純な反例です。

    期待したhandler: A, B, C, D
    実際の実行:     A, A, C, D
    

    expected_count = 4
    observed_count = 4

    件数は一致しても、Bは一度も動いていない。

    hook_event == PreToolUse というイベント種別だけでは、この違いを識別できません。実行ごとの hook_id を使う場合も、そのIDが設定内のどのhandlerに対応するかをどう取得するかが必要です。

    推奨修正

    Issueに「観測対象の範囲」と「対応付けの方法」を追加してください。最初からあらゆる設定元を解釈する汎用エンジンを作る必要はありません。

    初期実装は、例えば「current project settingsの、今回選んだイベントに一致する対応済みcommand hook」と「runnerが追加した観測hook」を区別して扱う範囲で十分です。ただし、その場合は「runtime全体の全hookを証明した」とは表示しません。

    対象外と確実に識別できる追加hookは対象外として扱い、識別できないため完全性を保証できない場合は、そのassertionを未判定にします。観測用hookが動いた事実を、既存の兄弟hookすべてが動いた証拠へ昇格させないことが重要です。

    実装着手前に、対象Claudeバージョンの実イベントでこの対応付けが可能かを、小さな実行で確認するのがよいです。これは新しい承認ゲートではなく、採用する方式が成立するかの確認です。

    2. P1:hookの正常終了では、副作用の完了を証明できない

    対象:AC3、sibling_side_effect_inventory_complete。

    これは抽象的な懸念ではなく、現在のリポジトリに具体的な反例があります。

    .claude/hooks/session_manifest_coordinator.sh は、内部のguardが失敗した場合にも exit 0 で終了します。また、producerの失敗コードを取得しても、最終的には exit 0 を返します。つまり、このhookが呼ばれて正常終了したことと、manifest生成などの内部処理が成功したことは一致しません。

    公式Python SDKの公開実装でも、hookの開始と完了は別のlifecycle phaseで扱われ、完了イベントにはoutput・exit code・outcomeなどが載ります。しかし、それ自体がファイル書き込みなどの完了を検証する仕組みではありません。

    したがって、次の実装ではAC3を満たせません。

    hookの完了イベントがある
    かつ exit_code == 0
    ↓
    sibling_side_effect_inventory_complete = true

    既存policyが要求するのは、denyがあっても兄弟hookのファイル書き込み・外部呼び出しなどが、意図した結果になったかというinventoryです。単にhookが終了したかというAC2とは、証明対象が異なります。

    推奨修正

    AC3のallowlistを「後で実装者が決めるもの」にせず、対象の副作用と確認方法まで列挙してください。最低限、各対象について、期待する変化、確認する実状態、正常な無変更の条件、確認するタイミングが必要です。

    例えば、対象となるhook群の完了を待ってから、限定された出力先の実状態を確認する方式です。観測用hook自身も兄弟として並行実行されるため、そのhook内で確認しただけでは、他のhookの処理後を観測したことになりません。(Claude)

    ここで既存hookを全部「失敗時は非ゼロ終了」に変える必要はありません。 advisoryとして通常作業を妨げない設計を維持し、検証側で「hookは実行された」「期待した副作用は確認できなかった」を分ける方が、今回の用途に合っています。

    Task ContextのDBなどをinventory対象にする場合は、#2568が所有するrun-scoped state rootの隔離との関係も明記すべきです。単に同じファイルを変更するという競合と、副作用を安全・正確に検証するための実際の前提条件は、区別してください。

    3. P1:tested_head と「実際にそのHEADのコードを検証したこと」が混同されやすい

    対象:AC4・AC5、current HEADへの証拠の紐付け。

    現在のrunnerの repo_fingerprint() と diff_fingerprints() は、変更済みファイルの状態・内容も含めて前後比較します。これは「smoke実行中にworktreeを変えなかったか」を確認する仕組みとして有用ですが、前後で同じだったことと、開始時点でHEADと一致していたことは別です。

    例えば、次の状態では、前後比較だけなら変更なしになります。

    HEAD: commit A
    開始前: hookやrunnerに未commitの変更Bが存在
    smoke: 変更Bを含むworktreeで実行
    終了後: 開始前と同じ状態

    before == after
    tested_head == A

    この結果を「commit Aを検証した証拠」として扱うのは誤りです。#1573の停止報告でも、未commit candidateでの実行がcurrent-head evidenceにならないことが問題になっています。

    推奨修正

    用途を二段階に分けてください。

    開発中の試行は未commit状態でも実行可能にし、候補変更の確認として扱います。そこで不具合が分かったら、Allowed Paths内で修正を続けられるようにします。

    最終的な受入証拠は、対象変更をcommitした後に取得し、検証対象のtracked inputsがそのHEADと一致していること、および実行前後で変化していないことを確認します。

    新しい署名・証明台帳・多段のdigest制度は不要です。既存のHEAD・fingerprintを正しく使い、「候補変更の試行」と「受入証拠」を混ぜない契約にするだけで十分です。

    4. P1:opt-in capabilityを追加しても、#1573の現在のコマンドは有効化しない

    対象:Remaining Parent Gaps、Delivery Rule、consumerへの引き渡し。

    #2663は --require-hook-chain-evidence によるopt-inを追加する契約です。しかし、今回取得した #1573 のAC7コマンドには、このフラグがありません。さらに、停止報告で存在しないとされた固定worktree pathが、そのまま記載されています。

    したがって、#2663をmergeするだけでは、#1573の現在の検証手順は修復されません。

    これは#2663のPRに#1573固有の実装を混ぜるべき、という意味ではありません。既存のPR #2500も、generic runnerの能力追加と、そのconsumerである #2194 のVerification Command更新を別の責務として扱っています。今回も、この分離自体は妥当です。

    ただし、引き渡し条件を具体化してください。

    #2663 merge後、#1573の既存Issue内でAC7を新しいopt-in invocationへ更新し、実在するcanonical worktree・今回の出力先・commit済みの対象HEADに対して再実行する。runnerのmergeのみをもって#1573のAC7達成とはしない。

    また、#1573のimmediate判断は、hookの実変更があるからではなく、Allowed Pathsベースの保守的な検出を受けたOWNER choiceとして明記されています。個人開発の効率を優先するなら、permissionsのanchor変更にgeneric hook-chain機能の完成を必須依存させ続けるべきかは、改めて見直す価値があります。 その見直しは既存契約を無視するのではなく、#1573のOWNER判断とAC7を明示的に更新して行うべきです。

    5. P2:canonical live invocationに、再現可能な検証シナリオがない

    対象:AC5、fixed allowlist selection、Verification Commands。

    現在のAC5は、次のようなplaceholderを含むコマンドです。

    --worktree /absolute/linked-worktree
    --prompt-file /absolute/nontracked-hook-chain-prompt.md
    --max-turns 4
    --require-hook-chain-evidence

    しかし、本文では「何をさせて、どのイベントを何回発生させ、どのdenyと副作用を観測するか」が定義されていません。固定allowlistも、実装側で文書化するという指定に留まっています。

    この状態では、CLIが利用可能でも、モデルが必要なtool callを行わない、denyが一度も起きない、選択したイベントが発生しない、といった理由で受入条件を満たせません。例えば公式仕様上、StopFailure はAPIエラーでturnが終了した場合のイベントであり、通常成功するシナリオで当然に発生するものではありません。(Claude)

    さらに、「duplicateはすべてFAIL」も、その単位が必要です。公式SDKの実装では同じhookの開始と完了は異なるphaseです。開始・進捗・完了の複数レコードや、別tool callに対する正当な再実行を、重複実行と取り違えてはいけません。

    推奨修正

    初期版では、小さな、明示された正常系とdeny系に絞るのがよいです。実credentialや破壊的操作を使わず、検証対象のhookが扱う無害な入力で、必要なイベントを発生させます。

    成功条件には、少なくとも「対象イベントが実際に1回以上発生した」「deny系ではdenyが実際に観測された」「その発生回に対応する兄弟hookと副作用を確認した」を含めます。空のexpected setと空のobserved setが一致しただけのPASSは認めません。

    --max-turns 4 は品質条件ではなく実行上限です。上限到達をcapability不足に分類したり、必要なシナリオを満たせることを未確認のまま4に固定したりしない方がよいです。CLIの公式説明でも、max-turns到達はエラー終了です。(Claude)

    また、AC5は実装後専用という説明と、機械的なpreflightの扱いを揃えるべきです。#1573にある preflight-scope: runtime_only の既存方式を確認し、まだ存在しない新フラグをbaselineで実行して停止する構成を避けてください。

    6. P2:「証拠をPASSにしない」と「開発作業を止める」が一体化している

    対象:Stop Conditions、runtime unavailable、missing assertion、inventory incomplete。

    #2663は、live runがSKIP・missing assertion・incomplete inventoryなどを返した場合に停止する契約です。このままでは、新機能を初めて実機で動かして、自分の実装の不足を見つけた時点で、その修正にも人間判断が必要という運用になりかねません。#1573では、実際に証拠不足を理由としてcommit・push・PR作成前に停止した報告があります。

    ここは分離した方がよいです。

    状況 推奨する扱い
    Allowed Paths内の実装不足でassertion失敗 原因を修正して再実行。通常の実装・レビューループを継続
    意図したnegative testでassertion失敗 テストの期待結果。作業停止理由にしない
    runtime/必要な観測capabilityが利用不能 SKIP・未検証として記録。静的検証やDraft PR作成は続行可能
    最終受入時に必要なassertionが未検証 そのACを完了扱いにしない
    対象外の破壊的変更や秘密情報の利用が必要 停止して判断を求める

    PR #2220はmarkerだけの証拠から実際の因果関係の確認へ進めた先例です。一方、PR #2500のOWNERレビューでは、入力echoや最終応答の再掲を証拠として数える誤判定が指摘されています。今回も、証拠フィールドを追加することより、その値がどの実行事実から導かれるかを先に固定することが重要です。

    推奨アクションは、実装開始前に #2663 の契約を精緻化し、「対象hook集合」「副作用の実観測方法」「再現可能なシナリオ」「最終HEADへの紐付け」「#1573のコマンド更新」「失敗時も修正を続けられる条件」を確定することです。厳しい停止条件を追加するのではなく、証明できる範囲を明確にして、通常の作業を止めずに正しい証拠を出せる設計に直すのがよいです。

    ## 結論:REQUEST_CHANGES

    2つのassertionを追加する方向性には賛成ですが、現在のIssueは「何を、どの証拠で確認するか」が未確定な一方、確認できない場合の停止条件だけが厳密です。 このまま実装に渡すと、実際には証明できていないのにPASSするか、正常な利用環境でも止まり続けるか、どちらかに寄る危険があります。特に、hookの実行確認と、副作用の確認を別物として実装できる契約に直す必要があります。

    確認した基準は、取得時の main af702b06e29e797a6ae180af4f86c730568a8e74 です。Issue #2663、consumerの #1573 と停止報告、関連する #2568・#2651、既存の証拠判定を扱ったPR #2220・#2500、runner・Skill・テスト・settings・runtime policy・実際のhook処理を参照しました。以下はコードと契約のレビューであり、この環境でClaude実機のsmokeやpytestを実行した結果ではありません。

    1. P1:「全hook」の母集団と、設定エントリへの対応付けが未定義

    対象:AC2、all_matching_hooks_observed、In Scopeのcomplete expected set。

    現在の .claude/settings.json では、Bashの PreToolUse に対して、secret boundary、Japanese prose guard、CI performance advisory、temporary residue advisoryという4つの異なるhandlerが一致します。さらに、runner自身も SubagentStart/SubagentStop に観測用の cat hookを追加しています。

    一方、Claude Codeのhookはproject settingsだけで完結しません。user・local・managed・pluginなどから合成され、同じhandlerの重複排除もあるため、settingsの配列要素数を数えれば実行期待数になる、とは限りません。([Claude]1)

    ここで必要なのは、件数の一致ではなく、期待するhandlerそれぞれと実行証拠との対応です。

    例えば、次は私が作った単純な反例です。

    期待したhandler: A, B, C, D
    実際の実行:     A, A, C, D
    
    expected_count = 4
    observed_count = 4
    
    件数は一致しても、Bは一度も動いていない。
    

    hook_event == PreToolUse というイベント種別だけでは、この違いを識別できません。実行ごとの hook_id を使う場合も、そのIDが設定内のどのhandlerに対応するかをどう取得するかが必要です。

    推奨修正

    Issueに「観測対象の範囲」と「対応付けの方法」を追加してください。最初からあらゆる設定元を解釈する汎用エンジンを作る必要はありません。

    初期実装は、例えば「current project settingsの、今回選んだイベントに一致する対応済みcommand hook」と「runnerが追加した観測hook」を区別して扱う範囲で十分です。ただし、その場合は「runtime全体の全hookを証明した」とは表示しません。

    対象外と確実に識別できる追加hookは対象外として扱い、識別できないため完全性を保証できない場合は、そのassertionを未判定にします。観測用hookが動いた事実を、既存の兄弟hookすべてが動いた証拠へ昇格させないことが重要です。

    実装着手前に、対象Claudeバージョンの実イベントでこの対応付けが可能かを、小さな実行で確認するのがよいです。これは新しい承認ゲートではなく、採用する方式が成立するかの確認です。

    2. P1:hookの正常終了では、副作用の完了を証明できない

    対象:AC3、sibling_side_effect_inventory_complete。

    これは抽象的な懸念ではなく、現在のリポジトリに具体的な反例があります。

    .claude/hooks/session_manifest_coordinator.sh は、内部のguardが失敗した場合にも exit 0 で終了します。また、producerの失敗コードを取得しても、最終的には exit 0 を返します。つまり、このhookが呼ばれて正常終了したことと、manifest生成などの内部処理が成功したことは一致しません。

    公式Python SDKの公開実装でも、hookの開始と完了は別のlifecycle phaseで扱われ、完了イベントにはoutput・exit code・outcomeなどが載ります。しかし、それ自体がファイル書き込みなどの完了を検証する仕組みではありません。

    したがって、次の実装ではAC3を満たせません。

    hookの完了イベントがある
    かつ exit_code == 0
        ↓
    sibling_side_effect_inventory_complete = true
    

    既存policyが要求するのは、denyがあっても兄弟hookのファイル書き込み・外部呼び出しなどが、意図した結果になったかというinventoryです。単にhookが終了したかというAC2とは、証明対象が異なります。

    推奨修正

    AC3のallowlistを「後で実装者が決めるもの」にせず、対象の副作用と確認方法まで列挙してください。最低限、各対象について、期待する変化、確認する実状態、正常な無変更の条件、確認するタイミングが必要です。

    例えば、対象となるhook群の完了を待ってから、限定された出力先の実状態を確認する方式です。観測用hook自身も兄弟として並行実行されるため、そのhook内で確認しただけでは、他のhookの処理後を観測したことになりません。([Claude]1)

    ここで既存hookを全部「失敗時は非ゼロ終了」に変える必要はありません。 advisoryとして通常作業を妨げない設計を維持し、検証側で「hookは実行された」「期待した副作用は確認できなかった」を分ける方が、今回の用途に合っています。

    Task ContextのDBなどをinventory対象にする場合は、#2568が所有するrun-scoped state rootの隔離との関係も明記すべきです。単に同じファイルを変更するという競合と、副作用を安全・正確に検証するための実際の前提条件は、区別してください。

    3. P1:tested_head と「実際にそのHEADのコードを検証したこと」が混同されやすい

    対象:AC4・AC5、current HEADへの証拠の紐付け。

    現在のrunnerの repo_fingerprint() と diff_fingerprints() は、変更済みファイルの状態・内容も含めて前後比較します。これは「smoke実行中にworktreeを変えなかったか」を確認する仕組みとして有用ですが、前後で同じだったことと、開始時点でHEADと一致していたことは別です。

    例えば、次の状態では、前後比較だけなら変更なしになります。

    HEAD: commit A
    開始前: hookやrunnerに未commitの変更Bが存在
    smoke: 変更Bを含むworktreeで実行
    終了後: 開始前と同じ状態
    
    before == after
    tested_head == A
    

    この結果を「commit Aを検証した証拠」として扱うのは誤りです。#1573の停止報告でも、未commit candidateでの実行がcurrent-head evidenceにならないことが問題になっています。

    推奨修正

    用途を二段階に分けてください。

    開発中の試行は未commit状態でも実行可能にし、候補変更の確認として扱います。そこで不具合が分かったら、Allowed Paths内で修正を続けられるようにします。

    最終的な受入証拠は、対象変更をcommitした後に取得し、検証対象のtracked inputsがそのHEADと一致していること、および実行前後で変化していないことを確認します。

    新しい署名・証明台帳・多段のdigest制度は不要です。既存のHEAD・fingerprintを正しく使い、「候補変更の試行」と「受入証拠」を混ぜない契約にするだけで十分です。

    4. P1:opt-in capabilityを追加しても、#1573の現在のコマンドは有効化しない

    対象:Remaining Parent Gaps、Delivery Rule、consumerへの引き渡し。

    #2663は --require-hook-chain-evidence によるopt-inを追加する契約です。しかし、今回取得した #1573 のAC7コマンドには、このフラグがありません。さらに、停止報告で存在しないとされた固定worktree pathが、そのまま記載されています。

    したがって、#2663をmergeするだけでは、#1573の現在の検証手順は修復されません。

    これは#2663のPRに#1573固有の実装を混ぜるべき、という意味ではありません。既存のPR #2500も、generic runnerの能力追加と、そのconsumerである #2194 のVerification Command更新を別の責務として扱っています。今回も、この分離自体は妥当です。

    ただし、引き渡し条件を具体化してください。

    #2663 merge後、#1573の既存Issue内でAC7を新しいopt-in invocationへ更新し、実在するcanonical worktree・今回の出力先・commit済みの対象HEADに対して再実行する。runnerのmergeのみをもって#1573のAC7達成とはしない。

    また、#1573のimmediate判断は、hookの実変更があるからではなく、Allowed Pathsベースの保守的な検出を受けたOWNER choiceとして明記されています。個人開発の効率を優先するなら、permissionsのanchor変更にgeneric hook-chain機能の完成を必須依存させ続けるべきかは、改めて見直す価値があります。 その見直しは既存契約を無視するのではなく、#1573のOWNER判断とAC7を明示的に更新して行うべきです。

    5. P2:canonical live invocationに、再現可能な検証シナリオがない

    対象:AC5、fixed allowlist selection、Verification Commands。

    現在のAC5は、次のようなplaceholderを含むコマンドです。

    --worktree /absolute/linked-worktree
    --prompt-file /absolute/nontracked-hook-chain-prompt.md
    --max-turns 4
    --require-hook-chain-evidence
    

    しかし、本文では「何をさせて、どのイベントを何回発生させ、どのdenyと副作用を観測するか」が定義されていません。固定allowlistも、実装側で文書化するという指定に留まっています。

    この状態では、CLIが利用可能でも、モデルが必要なtool callを行わない、denyが一度も起きない、選択したイベントが発生しない、といった理由で受入条件を満たせません。例えば公式仕様上、StopFailure はAPIエラーでturnが終了した場合のイベントであり、通常成功するシナリオで当然に発生するものではありません。([Claude]1)

    さらに、「duplicateはすべてFAIL」も、その単位が必要です。公式SDKの実装では同じhookの開始と完了は異なるphaseです。開始・進捗・完了の複数レコードや、別tool callに対する正当な再実行を、重複実行と取り違えてはいけません。

    推奨修正

    初期版では、小さな、明示された正常系とdeny系に絞るのがよいです。実credentialや破壊的操作を使わず、検証対象のhookが扱う無害な入力で、必要なイベントを発生させます。

    成功条件には、少なくとも「対象イベントが実際に1回以上発生した」「deny系ではdenyが実際に観測された」「その発生回に対応する兄弟hookと副作用を確認した」を含めます。空のexpected setと空のobserved setが一致しただけのPASSは認めません。

    --max-turns 4 は品質条件ではなく実行上限です。上限到達をcapability不足に分類したり、必要なシナリオを満たせることを未確認のまま4に固定したりしない方がよいです。CLIの公式説明でも、max-turns到達はエラー終了です。([Claude]2)

    また、AC5は実装後専用という説明と、機械的なpreflightの扱いを揃えるべきです。#1573にある preflight-scope: runtime_only の既存方式を確認し、まだ存在しない新フラグをbaselineで実行して停止する構成を避けてください。

    6. P2:「証拠をPASSにしない」と「開発作業を止める」が一体化している

    対象:Stop Conditions、runtime unavailable、missing assertion、inventory incomplete。

    #2663は、live runがSKIP・missing assertion・incomplete inventoryなどを返した場合に停止する契約です。このままでは、新機能を初めて実機で動かして、自分の実装の不足を見つけた時点で、その修正にも人間判断が必要という運用になりかねません。#1573では、実際に証拠不足を理由としてcommit・push・PR作成前に停止した報告があります。

    ここは分離した方がよいです。

    状況 推奨する扱い
    Allowed Paths内の実装不足でassertion失敗 原因を修正して再実行。通常の実装・レビューループを継続
    意図したnegative testでassertion失敗 テストの期待結果。作業停止理由にしない
    runtime/必要な観測capabilityが利用不能 SKIP・未検証として記録。静的検証やDraft PR作成は続行可能
    最終受入時に必要なassertionが未検証 そのACを完了扱いにしない
    対象外の破壊的変更や秘密情報の利用が必要 停止して判断を求める

    fail-closedにすべきなのは、証拠に基づくPASS判定です。すべての失敗を人間への停止要請にする必要はありません。

    同じ考え方は出力制限にも当てはまります。「rawを保存しない」は、まずこの新機能が生成・公開する証拠の境界として定義すべきです。既存の session_manifest_coordinator.sh は、一時ディレクトリにhook stdinや各処理のstdout/stderrを書き、終了時に削除します。既存hookを変更しない契約のまま、プロセス全体で一切rawがディスクに載らないという保証まで拡張すると、別の矛盾になります。

    summaryにはraw本文を残さなくても、固定のreason code、イベント名、安全なhandler識別子、expected/observedの件数があれば、原因をかなり絞れます。booleanだけを増やして、失敗のたびに再調査が必要になる形は避けたいです。

    推奨する実装の着地点

    **「任意のhook環境について全副作用を証明する機能」ではなく、「明示した対象について、実行の完全性と副作用の完全性を別々に検証する、小さなopt-in機能」**が適切です。

    新しい監視基盤や承認レイヤーは不要です。既存runnerのnative structured経路、イベント解析、fingerprint、summary出力を拡張し、対象を増やす必要が生じた時点でallowlistを広げればよいです。既存のnative経路はすでに --include-hook-events とinvocation-local overlayを使用しており、新たにSDKへ全面移行する理由はありません。

    また、#2651のrunner変更はSpark関連helperの撤去という別の目的です。共有ファイルを触ることによるmerge調整は必要でも、同じファイルを触る全Issueの完成待ちを、無条件の機能依存にしない方がよいです。Task Contextの実状態を観測する場合の #2568 のように、実際の前提となるものだけを依存として扱ってください。

    最低限、追加したい回帰テスト

    既存テストには、fake executableと一時的なlinked worktreeを作る基盤があります。これを拡張することで、別のharnessを新設せずに主要な反例を検証できます。

    ケース 確認したい結果
    件数は同じだが、期待したhandlerが1つ欠けている AC2はPASSしない
    同じhookの開始・進捗・完了が届く/兄弟hookの完了順が逆転する 正常なlifecycleを重複実行と誤判定しない
    hookはすべて呼ばれたが、producerの副作用が欠ける AC2とAC3を独立に判定する
    正常仕様として副作用が発生しないケース 「無変更だから失敗」と決めつけない
    denyした後に兄弟hookの副作用が完了する 兄弟の完了を待ち、その実状態を確認する
    対象イベントがゼロ回/deny系なのにdenyがゼロ回 空集合の一致でPASSしない
    未commit変更または前回実行のartifactが存在する 今回の対象HEADの証拠に取り違えない
    新フラグなし/runtime利用不能/証拠破損 既存callerは維持し、未検証・実行失敗・検証失敗を区別する

    PR #2220はmarkerだけの証拠から実際の因果関係の確認へ進めた先例です。一方、PR #2500のOWNERレビューでは、入力echoや最終応答の再掲を証拠として数える誤判定が指摘されています。今回も、証拠フィールドを追加することより、その値がどの実行事実から導かれるかを先に固定することが重要です。

    推奨アクションは、実装開始前に #2663 の契約を精緻化し、「対象hook集合」「副作用の実観測方法」「再現可能なシナリオ」「最終HEADへの紐付け」「#1573のコマンド更新」「失敗時も修正を続けられる条件」を確定することです。厳しい停止条件を追加するのではなく、証明できる範囲を明確にして、通常の作業を止めずに正しい証拠を出せる設計に直すのがよいです。

  3. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    確認した限り、推奨アクションは #2663 の実装へ進むことではなく、指定の OWNER REQUEST_CHANGES を direct human context として issue-refinement-loop に投入し、Issue 契約を再精緻化することです。

    確認時点の main は af702b06e29e797a6ae180af4f86c730568a8e74 で、レビューコメントが基準にした SHA と一致しています。また #2568 / #2569 / #2651 は現在も open なので、#2663 の collision/merge-order 記述は消さず、再確認させるのが適切です。

    レビューの技術的な前提も妥当です。現行 Claude Code 公式仕様では、hook は user/project/local/managed/plugin 等から合成され、同一 handler の重複は一度だけ実行される一方、plugin/skill 側の同一 handler は別扱いです。また、matching hook はすべて並列実行されます。したがって単純な「settings entry 数 = 実行数」では完全性を証明できません。([Claude]1) --max-turns も「品質条件」ではなく、到達するとエラー終了する実行上限です。([Claude]2)

    今回の refinement では、次の6点を Issue に固定させるのが中心です。

    issue-refinement-loop 自身は loop_iteration_approval_gate.default_required: false で、通常の needs-fix は反復上限まで自動継続する契約です。今回の OWNER コメントは preflight.run.with_human_context → contract_update.run.with_human_context の正規 lane に乗せるのが重要です。

    以下を、すでに auto mode で起動済みの対話的 ClaudeCode にそのまま渡す想定です。

    Issue #2663 を、指定の OWNER review comment を anchor として issue-refinement-loop で再精緻化してください。

    対象 Issue:
    #2663

    今回の authoritative review / anchor comment:
    #2663 (comment)

    使用する skill:
    https://github.com/squne121/loop-protocol/tree/main/.claude/skills/issue-refinement-loop

    目的

    上記 OWNER REQUEST_CHANGES を direct human context として扱い、Issue #2663 の契約を実装着手可能な状態まで精緻化する。

    今回のタスクは issue-refinement-loop による Issue 契約の修正・レビュー完了までを対象とする。コード実装そのものは行わない。

    既に ClaudeCode は auto mode で起動済みである。repository の refinement loop iteration ごとの人間承認は要求せず、skill の canonical loop policy に従って自動継続すること。

    ただし Claude Code 自体の permission model を変更する指示ではない。--dangerously-skip-permissions、hook disable、guard bypass、force push 等を追加してはならない。

    anchor の扱い

    この anchor comment は今回 operator が明示的に指定した direct human context であり、OWNER の REQUEST_CHANGES として処理する。

    canonical main root / default branch の root control-plane から、必ず human-context lane を使用すること。

    すなわち、URL だけを渡す unlabeled preflight.run.with_anchor や with_agent_report として扱わず、skill の現行契約に従って:

    • preflight.run.with_human_context
    • 必要なら contract_update.run.with_human_context
    • NEXT_ACTION: issue_editor_required なら既存 issue-editor controlled rewrite lane

    を使用すること。

    同じ anchor URL を reviewer feedback provenance として保持し、raw snapshot 本文を ad-hoc に別 lane へコピーしないこと。

    最初に確認するもの

    作業開始時点で current main、Issue 本文、anchor comment、関連 Issue / PR / repository assets を fresh に読み直すこと。

    最低限、以下を調査対象に含めること。

    現在の branch / Issue / comments が anchor review 時点から drift している場合は、古い前提をそのまま適用せず fresh evidence を優先すること。

    SubAgent 必須方針

    この作業では canonical skill が許可する SubAgent lane を実際に使用すること。

    planner の investigation_policy が required の場合、codebase-investigator を起動し、少なくとも以下を調べさせること。

    planner の web_research_policy が required の場合、web-researcher を sibling SubAgent として起動し、Claude Code の現行公式一次資料を調べさせること。特に Hooks reference / CLI reference について:

    • hook locations と settings merge
    • same handler duplicate semantics
    • all matching hooks の parallel execution
    • matcher / handler semantics
    • PreToolUse deny
    • StopFailure 等の event 発火条件
    • lifecycle records を execution identity と混同してよいか
    • --max-turns の意味

    を確認すること。

    Step 1 / Step 1b の両方が required なら sibling SubAgent として並列起動してよい。

    重要: SubAgent を起動しただけで次へ進まないこと。全 SubAgent の完了を必ず待ち、結果を join してから Step 2 へ進むこと。

    Step 2.5 semantic design review が applicable の場合も issue-design-reviewer を canonical contract に従って起動し、必ず completion join barrier を満たしてから結果を consume すること。

    SubAgent に Issue mutation をさせないこと。mutation authority は root/main control-plane に保持する。

    nested SubAgent delegation を SubAgent 自身に行わせないこと。

    今回の refinement で必ず解消する OWNER findings

    anchor comment の6項目を単なる prose コメントではなく、Issue の Goal / In Scope / AC / Verification / Stop Conditions / Delivery Rule 等へ反映すること。

    1. all_matching_hooks_observed の母集団と identity

    「runtime 全体の全 hook」を証明する契約にしない。

    初期 capability が実際に証明できる bounded verification cohort を明示すること。

    repository と Claude Code runtime の fresh investigation に基づき、例えば current project settings 内の対応可能な command hooks、runner-owned observation hooks 等、実際に expected member と runtime evidence を identity 単位で対応付け可能な範囲を定義する。

    単なる:

    expected_count == observed_count

    を PASS 根拠にしてはならない。

    A,B,C,D expected に対して A,A,C,D observed のようなケースを必ず FAIL / unverified とできる契約にする。

    Claude Code が複数 settings source の同一 handler を deduplicate する場合や、plugin/skill 等が別 handler として追加される場合も考慮する。

    対象外 hook を確実に識別できるなら cohort 外としてよいが、complete set を識別できないなら runtime 全体の完全性を主張しないこと。

    観測用 hook が実行された事実を「既存 sibling hook が全部動いた」という証明へ昇格させないこと。

    既存 boolean field を維持する場合でも、pass / fail / unverified 等の status semantics を別途明確化し、unverified を boolean true に変換しないこと。

    2. hook execution と side-effect completion の分離

    all_matching_hooks_observed と sibling_side_effect_inventory_complete は別の証明対象として設計すること。

    hook finished && exit_code == 0 を side-effect completion の証拠として扱わない。

    repository の実 hook を調べ、初期 allowlist で検証対象とする side effect ごとに最低限:

    • 対象 handler
    • expected side effect
    • 実際に読む post-condition / state
    • 正常な no-change の条件
    • observation timing
    • bounded location / resource
    • missing / duplicate / unknown / overflow 等の failure semantics

    を Issue 契約で特定すること。

    実 hook の完了を待った後に post-condition を読む必要がある場合、その join point を契約化すること。

    並列 sibling の一つである observation hook 自身が早く終了しただけの時点で他 sibling の side effect 完了を主張しないこと。

    既存 advisory hooks を non-zero exit 化する等、今回不要な production behavior change を要求しないこと。検証側で「execution observed」と「side effect verified」を分離する。

    3. dirty trial と current-HEAD acceptance evidence の分離

    開発中は Allowed Paths 内の未commit candidate に対する trial runtime を許可してよい。

    その trial が失敗した場合は実装不足の diagnostic として修正→再実行できる契約にする。

    ただし最終 AC acceptance evidence は対象変更を commit した HEAD に対してのみ成立させる。

    最終 evidence では少なくとも:

    • evidence の tested_head
    • 検証対象 tracked inputs がその HEAD と一致
    • runtime 前後で対象 worktree が意図せず drift していない

    ことを確認する。

    before == after だけを「HEAD と一致している」の意味にしてはならない。

    新しい大掛かりな署名台帳等は導入せず、既存 HEAD / fingerprint primitives を利用する方向を優先する。

    4. #1573 consumer handoff

    #2663 の merge 自体を #1573 AC7 の達成として扱わないこと。

    #2663 の generic capability と #1573 consumer contract は分離したままにする。

    ただし Delivery Rule / Remaining Parent Gaps 等で、#2663 merge 後に #1573 側で何を更新するかを明確にする。

    最低限:

    ことを handoff contract として記載する。

    #1573 固有コードを #2663 の Allowed Paths に混ぜないこと。

    5. reproducible live scenarios

    AC5 の live verification を単なる placeholder prompt にしない。

    初期版で実行可能な bounded scenario を明示する。

    少なくとも harmless な:

    • positive scenario
    • deny scenario

    を定義し、必要な対象 event が実際に発火する入力を使う。

    PASS 条件に:

    • target event が 1 回以上実際に発生
    • deny scenario では deny が実際に発生
    • その invocation / occurrence に対応する expected sibling executions を identity 単位で確認
    • allowlisted side-effect post-condition を確認

    を含める。

    expected=0 / observed=0 の空集合一致を PASS にしない。

    hook lifecycle の start/progress/completion 等を duplicate handler execution と誤認しないよう invocation identity / phase semantics を定義する。

    複数 tool call に対する正当な同一 handler 再実行も duplicate failure と混同しない。

    --max-turns は quality assertion ではなく execution bound として扱い、上限到達を capability failure と誤分類しない。

    baseline でまだ存在しない post-implementation CLI flag を機械的 preflight が実行して停止する設計にしない。

    6. evidence failure と workflow stop の分離

    現在の Stop Conditions を修正し、以下を区別する。

    Allowed Paths 内の candidate implementation 不足による assertion fail:
    → 原因を直して trial を再実行。通常の implementation/review loop 継続可能。

    意図した negative test の assertion fail:
    → expected test result。human stop にしない。

    runtime / observation capability unavailable:
    → SKIP / unverified として記録。static test・コード修正・必要なら Draft/通常の作業は継続可能。ただし final runtime AC は未達のまま。

    最終 acceptance で assertion が未検証:
    → AC PASS を主張しない。

    scope 外の破壊的変更、secret/credential の利用、permission-boundary bypass、既存 hook/config の不当な disable/replace、解決不能な semantic ambiguity:
    → canonical human/operator stop。

    「正しい evidence が得られなかった」と「開発作業全体を停止する」を同一条件にしない。

    collision / dependency

    #2568 / #2569 / #2651 その他 overlapping work が現在も open か fresh に確認すること。

    実際に同一ファイルを変更する implementation が競合する場合は #2663 の Delivery Rule に merge/rebase serialization を残す。

    ただし単なるファイル重複と、#2663 の assertion semantics が本当に依存する prerequisite は区別する。

    不要な hard dependency を追加しない。

    新しい Issue が本当に必要と canonical planner が判断した場合のみ、skill の materialization policy に従う。安易な scope split は行わない。

    refinement loop の実行

    .claude/skills/issue-refinement-loop/SKILL.md と normative references を SSOT とし、独自の簡易フローに置き換えないこと。

    通常の needs-fix / request_changes は human approval を要求せず bounded loop を継続する。

    Step 2 の root_review_pipeline.produce は現行契約どおり background launch し、完了 task notification / JSON を必ず join してから canonical_step2_route を consumeすること。

    canonical routing authority を prose で再判定しない。

    Step 2.5 semantic review が applicable なら実行し、SubAgent 完了を待つ。

    Step 4 rewrite が必要なら issue-editor を使用し、fresh readback → fresh Step 2 review を行う。

    OWNER findings が残っているのに iteration を終了しないこと。

    loop 内の通常修正について「続けてよいですか」「Issueを書き換えてよいですか」等の確認をユーザーへ求めないこと。

    人間停止について

    今回の「人間承認不要」は canonical safety / integrity hard stop を無視する意味ではない。

    以下は勝手に bypass しない。

    • destructive / non-idempotent operation が必要
    • secret / credential の提示や変更が必要
    • permission / security boundary の bypass が必要
    • unrelated repository scope の mutation が必要
    • Issue split / heavy mutation に真の owner decision ambiguity が残る
    • source provenance / binding / artifact integrity が壊れていて canonical recovery 不可能
    • skill が genuine human_judgment_required として扱う、技術 evidence だけでは一意に決定不能な選択

    それ以外の routine needs-fix、contract rewrite、deterministic repair、read-only investigation、fresh review、retry は人間承認なしで最後まで進める。

    hard stop に到達した場合も、まず skill が許す deterministic recovery / bounded retry / read-only investigation を使い切ること。

    単に「assertion が FAIL した」「runtime が SKIP した」「max-turns に達した」「reviewer が needs-fix を返した」というだけで user escalation しない。

    完了条件

    Issue #2663 の本文が anchor comment の全 finding を反映し、fresh review で実装契約として approve / impl-ready 相当まで到達すること。

    特に最終 Issue 本文について:

    • execution completeness と side-effect completeness が別 assertion
    • bounded cohort と identity mapping が明示
    • side-effect inventory の actual post-condition が明示
    • dirty trial と commit済み HEAD acceptance が分離
    • deterministic positive/deny live scenario が明示
    • empty-set false green が禁止
    • 実装: .claude/settings.json の Edit(path) ルールの path anchoring を project root / home directory 相対に正規化する #1573 follow-up が明示
    • assertion failure / SKIP と workflow stop が分離
    • Allowed Paths / Out of Scope が実装可能な粒度
    • Verification Commands が post-implementation / baseline の phase を混同していない
    • current collision/dependency が fresh evidence に基づく

    ことを確認する。

    最終 fresh review が approve するまで、許可された bounded iteration 内で自動修正を続けること。

    本依頼の境界は Issue refinement まで。impl-review-loop によるコード実装は開始せず、implementation handoff が可能になった時点で refinement の最終結果を報告して終了する。

    最終報告

    完了時は簡潔に以下を報告すること。

    この形なら、「人間承認不要」を permission bypass ではなく、needs-fix → rewrite → fresh review を自動で完走させる意味に限定できます。今回のコメントは単なる agent report ではなく指定された OWNER human context なので、特に with_human_context を明示するのが重要です。

  4. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    OWNER の REQUEST_CHANGES anchor review(https://github.com/squne121/loop-protocol/issues/2663#issuecomment-5736277277、確認時点 main: af702b06e29e797a6ae180af4f86c730568a8e74)を direct human context として preflight.run.with_human_context lane に投入し、issue-refinement-loop で本 Issue を再精緻化した。

    anchor の6 findingsの契約反映

    1. all_matching_hooks_observed の母集団/identity: expected cohort を「current project settingsの、選択したhook eventに一致するcommand hook」に限定し、runner観測hookを除外。handler identity(event+matcher+command文字列の組)単位の照合と、pass|fail|unverifiedの3値ステータスを導入し、件数一致だけではPASSにならない契約にした(AC2)。
    2. hook正常終了と副作用完了の分離: sibling_side_effect_inventory_complete をhook実行完了とは独立なassertionとし、対象handler・期待変化・実post-condition・無変更条件・observation timing(join point)・bounded locationの明示を要求。session_manifest_coordinator.sh の具体的counter-example(内部guard/producer失敗時もexit 0)を明記した(AC3)。
    3. tested_headとdirty trialの分離: 開発中trialは未commit candidateで許可しつつ、最終acceptance evidenceはcommit済みHEADにのみ成立させ、tracked inputs一致とdrift不在を要求。before/after fingerprint一致だけをHEAD一致の意味にしない契約にした(AC5、In Scope)。
    4. 実装: .claude/settings.json の Edit(path) ルールの path anchoring を project root / home directory 相対に正規化する #1573 consumer handoff: 実装: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2663 mergeのみでは実装: .claude/settings.json の Edit(path) ルールの path anchoring を project root / home directory 相対に正規化する #1573 AC7達成にならないことを明記し、--require-hook-chain-evidence実使用・実在canonical worktree・commit済みHEAD再実行の4点を実行可能なchecklistとしてRemaining Parent Gapsに記載した。
    5. reproducible live scenarios: AC5にpositive/deny scenarioの具体的定義を追加し、空集合PASS禁止、lifecycle多重レコードと重複実行の誤認防止、--max-turnsを実行上限として扱う旨を明記した。
    6. evidence failure と workflow stop の分離: Stop Conditionsを、実装不足によるfail(通常ループ継続)、意図したnegative test fail(停止理由にしない)、runtime unavailableによるSKIP/unverified(静的検証・Draft PR継続可)、真に破壊的/secret/permission-boundary/解決不能な曖昧性(human stop)に分離した。

    また、deterministic checkerが検出した2件のblocking issue(C11_decision_tag_consistency: fail = AC5への <!-- runtime-verification: true --> タグ欠落、AC5 VCの command_not_allowed = uv run python3 がpreflight allowlist外)を、それぞれタグ追加と # preflight-scope: runtime_only マーカー追加で解消した。

    Iteration 概要

    • iteration 1: preflight.run.with_human_context(Step 0f)→ codebase-investigator + web-researcher 並列実行 → Step 2 review(needs-fix, canonical_step2_route: step_4)→ issue-editor による本文更新(anchor 6 findings + 2 deterministic blocker 解消)
    • iteration 2: fresh Step 2 review(approve)→ Step 2.5 semantic design review(issue-design-reviewer)→ medium severity 1件(Stop Conditions内の自己矛盾)検出 → join_review_results は effective_verdict: approve(medium はブロックしない)だが、品質改善としてissue-editorで追加修正
    • iteration 3: fresh Step 2 review(approve)→ Step 2.5 再検証(assessment: clear)→ join_review_results: effective_verdict: approve(warnings なし)
    • Final Gate: run_contract_review_once.py --mode static → CONTRACT_REVIEW_RESULT_V1.status: go(fresh, 現在のIssue body sha256と一致)

    使用した SubAgent(全て完了 join 済み)

    native dependency

    #2663 は既存の GitHub native blocking: [#1573] を維持(本サイクルで新規変更なし。dependency materialization gate は該当なし)。

    #1573 への handoff 条件

    本 Issue merge後、#1573 側で以下を満たすまで #1573 AC7 は未達扱いとする(Issue本文の Remaining Parent Gaps に明記済み):

    1. 新設 --require-hook-chain-evidence を実際に使用するinvocationへAC7コマンドを更新する
    2. 実在するcanonical linked worktreeを指定する(placeholder/存在しないabsolute pathを除去する)
    3. commit済みのcurrent HEADに対する最終runtime verificationとして再実行する
    4. runner側(実装: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2663)のmergeのみをもって#1573のAC7 PASSとしない

    未解決 blocker

    なし。

    implementation について

    本依頼のスコープは Issue refinement までであり、impl-review-loop によるコード実装は開始していない。以下は Final Gate 確認結果の記録であり、canonical routing action(run_impl_review_loop)はこの turn では実行しない。

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: null
        generated_at: "2026-09-18T22:15:32Z"
        body_sha256: "sha256:6a04d23d1eb5998fdd0e391f56ffb3ddd1ff29de512f1ce5fe8e8fe0042545bb"
      metadata:
        title_prefix_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-09-18T22:15:32Z"
      checked_body_sha256: "sha256:6a04d23d1eb5998fdd0e391f56ffb3ddd1ff29de512f1ce5fe8e8fe0042545bb"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    注記: 本依頼(issue-refinement-loop 単体実行)の境界により、routing_action: run_impl_review_loop は telemetry として記録するのみで、この turn 内では実行しない。impl-review-loop の起動は別途の明示的な依頼を待つ。

  5. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    確認した現状では、#2663 は open / 実装未着手 / 関連PRなしで、最新の issue-refinement-loop 終了報告は approved、LOOP_HANDOFF_RESULT_V1.status: impl_ready / routing_action: run_impl_review_loop / blockerなしです。競合候補では #2651 は closed、#2568/#2569 は open ですが、GitHub 上では関連する open PR や issue番号付き branch は確認できませんでした。

    したがって推奨は、#2663 を dedicated linked worktree で今から impl-review-loop に投入です。ただし開始直前にローカル worktree/branch まで確認し、#2568/#2569 が同じ3ファイルで実作業中なら並行編集せず直列化します。通常の実装失敗・テスト失敗・レビュー REQUEST_CHANGES は人間確認なしで修正ループを続け、最終的に PRが current HEAD でレビュー承認され、マージ可能な「マージ直前」状態になったところで停止させるのが現行 skill と一致します。

    そのまま ClaudeCode に貼れる形です。

    Issue #2663 を対象に、repository canonical skill .claude/skills/impl-review-loop を使って、実装・検証・PRレビュー・修正ループを実行してください。

    対象 Issue:
    #2663

    使用する skill:
    https://github.com/squne121/loop-protocol/tree/main/.claude/skills/impl-review-loop

    既にこの ClaudeCode セッションは auto mode で対話的に起動済みです。
    permission mode の変更や ClaudeCode の再起動は不要です。

    最終目標

    Issue #2663 の current live contract を満たす実装を完成させ、1 Issue = 1 PR としてPRを作成し、impl-review-loop の canonical implementation → verification → PR review → fix loop を、人間の逐次承認なしで実行してください。

    最終到達点は「マージ直前」です。

    具体的には、current PR headについて:

    • Issue Acceptance Criteria / Verification Commands が満たされている
    • required verification が current head に束縛されている
    • pr-reviewer が APPROVE
    • blockers が空
    • live mergeability が skill の approved route を満たす
    • unresolved review finding がない
    • branch/head drift がない
    • CI / required checksについて canonical evaluator が必要な判定を完了している

    状態まで進めてください。

    PRそのものはマージしないでください。
    merge, auto-merge enable 等は行わず、マージ直前で終了してください。

    authoritative state

    開始時に必ず fresh な GitHub / repository state を読み直してください。

    少なくとも確認するもの:

    古い snapshot やこのプロンプト中の状態よりも、実行時点の live Issue / main / PR / CI を優先してください。

    現時点での開始方針

    Issue #2663 の refinement は既に approved / impl_ready です。
    再度 issue-refinement-loop を最初から実行する必要はありません。

    ただし preparation で live contract drift を確認し、canonical impl-review-loop が要求する contract snapshot / intake処理は通常どおり実施してください。

    Issue #2663 の Delivery Rule に従い、dedicated linked worktree を使用してください。

    #2568 / #2569 / #2651 との直列化

    Issue #2663 は対象3ファイルについて concurrent implementation を禁止しています。

    開始前に GitHub 上の PR/branch だけでなく、ローカルの linked worktree / branch / unmerged commit も確認してください。

    特に:

    について、#2663 の Allowed Paths と重なる実作業が現在進行中か確認してください。

    現時点の外部確認では:

    ですが、この情報を固定前提にせず fresh state を使ってください。

    同一ファイルを編集する active implementation が本当に存在する場合は同時編集しないこと。
    merge order を決定し、current main を基準に直列化してください。

    単に Issue が open であるだけでは「active concurrent implementation」と決めつけないでください。
    実 branch / worktree / PR / unmerged delta を根拠に判定してください。

    SubAgent 実行方針 — 必須

    このタスクは root orchestrator が control-plane を担当し、canonical SubAgent を実際に使用してください。

    最低限:

    1. Step 1:
      implementation-worker
    2. Step 2:
      test-runner
    3. Step 4:
      pr-reviewer

    を canonical skill の指示に従って起動してください。

    completion join barrier

    SubAgent を起動しただけで次の Step に進んではいけません。

    各 SubAgent について:

    • spawn
    • 実行中状態を必要に応じて確認
    • final completion を待つ
    • canonical structured result を取得
    • resultを検証
    • LOOP_STATEへ反映
    • その後にだけ次Stepへ進む

    という join barrier を必須にしてください。

    複数SubAgentを並列起動することが canonical skill 上許可される局面でも、必要な全SubAgentが完了するまで次の routing decision を行わないこと。

    SubAgent がまだ running / pending の状態で、その結果を推測して先へ進まないでください。

    nested delegation

    SubAgent自身に新たなSubAgentを勝手にspawnさせないでください。
    root orchestrator が必要な canonical SubAgent を直接管理してください。

    Issue #2663 の Stop Conditions にある nested SubAgent delegation 境界を維持してください。

    Step 1 — implementation

    implementation-worker に Issue #2663 の live contract を渡し、Allowed Paths 内だけで実装してください。

    Allowed Paths:

    • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py
    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md

    これ以外のファイルを変更しないでください。

    実装の中心は Issue 本文を正本とし、少なくとも以下を満たしてください。

    bounded hook-chain evidence

    structured native Claude lane に opt-in capability を追加する。

    新 capability は bounded closed allowlist のみを扱い、caller supplied の:

    • arbitrary shell command
    • arbitrary hook command
    • arbitrary path
    • arbitrary marker
    • arbitrary config

    を evidence source として受け付けないこと。

    Issue contract の canonical option --require-hook-chain-evidence を実装すること。

    all_matching_hooks_observed

    expected cohort を、Issue contract が定義する:

    「current project .claude/settings.json に存在し、選択eventに一致する command hook」

    に限定する。

    runner-owned observation hook は cohort から分離する。

    単なる count equality を evidence にしない。

    handler identity 単位で expected / observed を対応させ:

    • missing
    • unknown
    • identity mismatch
    • invalid duplicate
    • 判別不能

    を正しく扱うこと。

    status:

    • pass
    • fail
    • unverified

    を保持し、boolean true は status == pass の場合だけにする。

    runtime全hookの完全性を証明したかのような過剰主張をしない。

    sibling_side_effect_inventory_complete

    hook execution completion / exit code と side-effect post-condition を別assertionとして扱う。

    少なくとも fixed allowlist の各side effectについて:

    • target handler
    • expected change
    • actual post-condition
    • valid no-change condition
    • observation timing / join point
    • bounded resource/location

    を明示する。

    session_manifest_coordinator.sh のように exit 0 でも内部 producer 成功を意味しないケースを正しく扱う。

    sibling hook の完了を待った後に post-condition を確認すること。

    missing / duplicate / unknown / overflow / unobserved はIssue契約どおり扱う。

    aggregate

    hook-chain aggregate PASS は:

    • all_matching_hooks_observed.status == pass
    • sibling_side_effect_inventory_complete.status == pass

    の両方を満たす場合のみ成立させる。

    fail または unverified を true に昇格させない。

    evidence hygiene

    保存してよいのは Issue が認める bounded summary/evidence のみ。

    保存・引用してはいけないもの:

    • raw prompt
    • raw stream transcript
    • raw hook stdin/stdout body
    • credential
    • token
    • HOME absolute path
    • prompt self-report を証拠化したもの
    • fake markerによるPASS証明

    既存 sequential hookchain_harness.py の成功を live runtime evidence の代替にしない。

    HEAD binding

    開発途中の未commit candidateに対する trial runtime は許可する。

    ただし最終acceptance evidenceは commit済み current HEAD のみを対象とする。

    最終 evidence では最低限:

    • tested_head
    • 対象 tracked inputs がそのHEADと一致
    • runtime前後に意図しない worktree drift がない

    ことを確認する。

    before fingerprint == after fingerprint だけで「開始時点からHEADと一致」とみなさない。

    tests

    Issue AC6 に書かれたケースを deterministic tests として実装する。

    特に:

    • count同数だがhandler identityが違う
    • lifecycle multiple records
    • sibling completion order inversion
    • all hooks observedだがside effect missing
    • valid no-change
    • deny後のsibling completion
    • empty expected/observed false green
    • deny scenarioなのにdeny zero
    • stale artifact / uncommitted candidateをcurrent HEAD evidenceと誤認
    • flag無しlegacy caller
    • runtime unavailable
    • corrupted evidence

    をカバーする。

    既存callerのbackward compatibilityを壊さない。

    実装途中の trial runtime

    Allowed Paths内の candidate implementation に対して、必要なら runtime trial を行ってください。

    ここで assertion が fail した場合は、人間確認を求めず:

    1. 原因分析
    2. Allowed Paths内で修正
    3. deterministic tests
    4. runtime trial再実行

    を行ってください。

    Issue本文にも明記されている通り、Allowed Paths内の通常の実装不足や expected negative scenario のfailは human stop ではありません。

    commit / PR

    実装と必要な検証を行い、通常の commit / push をしてください。

    force pushは禁止です。

    1 Issue = 1 PR とし、PR本文には Issueを閉じる closing keyword:

    Closes #2663

    を canonical repository rule に従って含めてください。

    PR作成後はそのPRを impl-review-loop の対象として継続してください。

    Step 2 — verification

    test-runner SubAgent を起動し、完了を待ってから結果を取得してください。

    Issue #2663 の Verification Commands を live contract から読み、canonical adjudicationで実行してください。

    最低限 static/unit側では:

    uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py

    を含む Issue 指定 command を検証してください。

    AC5 の canonical live runtime verification は Issue本文の current commandを使用してください。

    placeholder /absolute/linked-worktree や /absolute/nontracked-hook-chain-prompt.md を文字どおり使わず、実在する dedicated linked worktree と、このrun用の適切な nontracked bounded prompt file に解決してください。

    実行時は Issue が指定する:

    • --runtime claude
    • --mode structured
    • --require-clean-postcondition
    • --require-hook-chain-evidence
    • current HEAD
    • bounded positive scenario
    • bounded deny scenario

    を満たしてください。

    runtime unavailable

    required runtime が本当に利用不能なら Issue契約どおり:

    • SKIP:
    • exit 77
    • unverified

    として扱って構いません。

    ただし:

    • SKIPをPASSへ変換しない
    • static/unit検証は続行してよい
    • Draft PR作成・レビュー準備は続行してよい
    • AC5を満たしたと主張しない
    • runtime evidenceなしに最終 draft_pr_ready / merge-ready を捏造しない

    こと。

    Step 4 — PR review

    Step 2 の canonical current-head gateを満たした後だけ、pr-reviewer SubAgent を起動してください。

    pr-reviewer の完了を必ず待ってから Step 5 routing を行ってください。

    review対象は必ず current PR head SHA とすること。

    レビューでは少なくとも:

    を確認してください。

    Step 5 — automatic feedback loop

    impl-review-loop の canonical route_loop_verdict_v2() 等を正本として routing してください。

    REQUEST_CHANGES

    REQUEST_CHANGES なら、人間承認を求めず Step 1 に戻してください。

    blockersを fix_delta として implementation-worker に渡し:

    • 修正
    • commit/push
    • Step 2 再検証
    • Step 4 current-head rereview

    まで自動継続してください。

    stale reviewed head

    reviewed head と current PR head がずれていた場合、人間確認を求めず current head を再reviewしてください。

    BEHIND

    canonical route が update_branch を要求する場合、skillどおり workerへ委譲し、更新後に verification と review をやり直してください。

    force pushは禁止です。

    BLOCKED / UNSTABLE / UNKNOWN

    skill が current-head CI / branch-protection evaluator に委譲する種類の状態は、それだけを理由に人間確認へ逃げないでください。

    canonical bounded retry / evaluator / rereviewを実行してください。

    loop iteration

    各 iteration ごとの人間承認は要求しないでください。

    canonical max_iterations まで自動で継続してください。

    human stop を限定する

    「慎重を期すため」「判断が難しいため」だけで停止しないでください。

    以下のような canonical hard boundary の場合だけ停止してください。

    • Issue 実装: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2663 Allowed Paths 外の変更が本当に必要
    • Issue の固定 In Scope contract自体を変更しないと実装不能
    • 新規Issueへのscope splitが不可避
    • 別phase / 別scopeへの実変更が不可避
    • nested SubAgent delegationが不可避
    • external service / privilege escalationが必要
    • existing hooks/configuration の edit / disable / replace が必要
    • arbitrary shell/config evidence injectionが必要
    • raw transcript / prompt / hook body 保存が必要
    • secret / credential の利用・提示が必要
    • permission/security boundary bypassが必要
    • destructive operationが必要
    • current HEAD と tested_head を信頼可能に照合できない異常
    • actual Git conflictについて canonical conflict runbookでも自動解消すべきでない状態
    • live Issue/PR上でOWNER等から明示的な停止指示が出ている
    • canonical max_iterations超過

    Step 1〜4 SubAgentが単に human_review_required: true と自己申告しただけでは即停止しないでください。
    現行 impl-review-loop の routing policy を適用してください。

    禁止事項

    以下は行わないこと:

    #1573 handoff

    #2663 の実装/PRが完成しても、このrunでは #1573 のAC7を達成済みとして扱わないでください。

    #2663 merge後に #1573 側で別途:

    というhandoffが必要です。

    今回は #1573 の本文・コードを変更しないでください。

    終了条件

    次のいずれかで終了してください。

    成功

    canonical impl-review-loop が approved route に到達し、current PR headについて merge直前状態になった場合。

    その時点で停止し、マージは実行しない。

    canonical hard stop

    上記 human stop 条件、actual conflict escalation、max_iterations 等の canonical termination に到達した場合。

    最終報告

    終了時は簡潔に、機械可読情報を維持したまま以下を報告してください。

    途中経過の説明だけで作業を終了せず、canonical termination condition に到達するまで実際に impl-review-loop を遂行してください。

    このプロンプトでは、#2663 特有の重要点である 「runtime failure は通常の修正ループ」「SKIP はPASSにしない」「最終 evidence は commit 済み HEAD」「#1573 は別handoff」 を明示してあります。

  6. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-19)

    • PR: feat: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2668
    • Worktree: .claude/worktrees/issue-2663-hook-chain-evidence
    • Branch: worktree-issue-2663-hook-chain-evidence
    • Verification: uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py 109 passed(既存82件維持+新規27件)、uv run ruff check scripts/agent-ops/ エラーなし
    • AC5 live trial(positive + deny 両scenario、--require-hook-chain-evidence --require-clean-postcondition): 終了コード0、hook_chain_evidence.status: pass。ただし対象HEADは実装コミット前のbase commitであり、commit済みHEADに対する最終acceptance evidenceはtest-runnerが別途取得する。
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  7. squne121 commented on Sep 19, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-19T01:05:00Z)

    anchor review (#2668 (comment)) 4件の対応状況

    # 内容 対応
    P1-2 同一assistantメッセージ内の複数Bash呼び出しが常にunverifiedになる 解消済み。_partition_shared_stream_index_span() で自己echoのtool_use_id値により各Bash呼び出しへ正しく対応付け。反例の回帰テスト追加済み
    P1-3(a) 副作用ファイルがsession/run紐付けなしでPASSしうる 解消済み。新規ファイルのactor.session_idを現在runと照合
    P1-3(b) observerのみのstop_hook_activeで対象coordinator未確認のままPASS 解消済み。coordinator自身のstderrマーカー(SESSION_MANIFEST_COORDINATOR_RESULT_V1)との両方確認を要求
    P2-1 2000件snapshotの切り捨てで新規Stop manifestを見落とす 解消済み。トークンフィルタをsort/cap前に適用し、切り捨て発生時はunverified化
    P1-1 hook_idによる開始・完了対応付けをhandler identityと取り違え 公式ドキュメント確認済みの runtime capability boundary として確定・停止扱い。Claude Code公式ドキュメント(hooks-guide / agent-sdk hooks)は同一event+matcherのsibling hookが並列・非決定順で実行されると明記しており、hook_id(実行単位の相関ID)・hook_name(event+matcher共有ラベル)以外にどのsibling command hookが実行されたかを示す公式フィールドは存在しない。件数一致をidentity evidenceと再定義せず、順序ヒューリスティックも導入せず、.claude/settings.json/hooksの変更もIssue契約(AC2)の変更も行わずに、正確な境界説明への文書修正(--setting-sources projectの誤記修正含む)のみに留めた。AC2の残り部分(hook_idペアリング・orphan検出・unattributable-extra-hookのunverified化・P1-2の window対応)は引き続き機能しており「件数のみ」への後退はない

    検証結果

    • pytest (AC1/AC2/AC3/AC4/AC6, 独立実行): 119 passed
    • AC5 live canonical invocation (tested_head = 現HEAD一致): hook_chain_evidence.status: pass(positive window 1件 + deny window 1件、両方PASS)、sibling_side_effect_inventory_complete.status: pass
    • Allowed Paths gate: PASS(scripts/agent-ops/run_worktree_agent_runtime_smoke.py / scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py / .claude/skills/worktree-agent-runtime-smoke/SKILL.md のみ変更)
    • current-head CI: 20/20 passed
    • final pr-reviewer verdict: APPROVE(blockers: [])
    • live mergeability: mergeable=MERGEABLE, merge_state_status=CLEAN
    • unresolved blockers: []
    • worktree: クリーン、意図しないdirty stateなし

    マージは未実施です。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2668"
      head_sha: "a67e520e572310c15680f4c977ae1a4c4b1ef236"
      issue_number: 2663
      termination_reason: approved
      merge_ready: true
      iteration: 2
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "issue-2663-ac2-contract-narrowing-p1-1-boundary"
          source_url: "https://github.com/squne121/loop-protocol/pull/2668#issuecomment-5738411543"
          source_note_id: "pr-reviewer-warning-2"
          summary: "AC2文言を、確認済みのP1-1 runtime制約(hook_id/hook_nameはinvocation/group identityのみを証明)に合わせて明示的に狭めるfollow-up Issueの起票を推奨。documentation/contract-hygiene follow-upでありコードブロッカーではないため、本ループでは起票せず記録のみとする。
    
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-09-19T01:05:00Z"
      rollup_plan_ref:
        body_sha256: null
        generated_at: null
      decision: skipped
      executed_actions: []
      skipped_reason: "advisory diagnostic; not run this iteration (production dispatch is manual-only per #1860 Owner Decision)"
      candidates_reviewed: []
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