Skip to content

実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: "v1"
issue_kind: implementation
parent_issue: "none"
goal_ref: "docs/dev/repository-folder-policy.md#承認済み一時作業ディレクトリ"
change_kind: schema-migration

Parent Issue

なし(単独改善)

Parent Goal Ref

N/A(親 Issue なし。関連: Refs #2004, absorbs #1418)

Current Validated Scope

N/A(親 Issue なし)。背景: Issue #2004(実装: source-bound eligibility/readiness の固定 private location を tmp/session-recording/ へ同時移行する)の issue-refinement-loop 中、OWNER 敵対的レビュー(https://github.com/squne121/loop-protocol/issues/2004#issuecomment-5204465943)で schemas/repo_temp_folder_advice_v1.schema.json の enum 1 値化を「V2 migration」として本 Issue へ分離することが明示された。

2026-09-08 の refinement iteration で、OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/2007#issuecomment-5584305323)により本 Issue のスコープが拡張された: schemas/catalog.yaml / docs/dev/schema-governance.md を Allowed Paths に含む OPEN Issue #1418(実装: repo_temp_folder_advice schema を catalog に登録する、repo_temp_folder_advice/v1 の catalog/governance 登録、未実装)を本 Issue に吸収する。V1/V2 双方の catalog 登録を単一の migration scope・単一 PR として扱う(2 PR に分割しない)。#1418 は本 Issue の PR マージ後、canonical superseded decision(issue-refinement-loop の follow-up materialization / scope-rollup 経路)で superseded として処理する。

Remaining Parent Gaps

N/A(親 Issue なし)

Outcome

schemas/repo_temp_folder_advice_v1.schema.json(REPO_TEMP_FOLDER_ADVICE_V1)を temporary root 1 値化に対応させるため、新規 schemas/repo_temp_folder_advice_v2.schema.json(REPO_TEMP_FOLDER_ADVICE_V2)を追加し、approved_write_roots: ["tmp/"] と deprecated_legacy_roots: [".claude/tmp/"] を分離した schema・producer(root_temporary_residue_policy.py)・hook(root_temporary_residue_advisory.sh)・テスト(.claude/hooks/tests/test_root_temporary_residue_advisory.py / scripts/agent-guards/tests/test_root_temporary_residue_policy.py)を追加する。V1 は breaking change を避けるため残し、producer の無指定 / --schema-version v1 明示時の挙動は既存 V1 payload と完全に同一であることを contract test で確認する。live Claude Code hook(.claude/hooks/root_temporary_residue_advisory.sh)は明示的に V2 を選択する。

schemas/catalog.yaml に repo_temp_folder_advice/v1(#1418 吸収分)と repo_temp_folder_advice/v2 の両エントリを同一 PR で登録し、schemas/tests/test_catalog.py の EXPECTED_ENTRY_COUNT を実エントリ数に合わせて更新する(false-green を残さない)。V2 live mode では .claude/tmp/** への write を deprecated_legacy_root_write として advisory 対象に追加する一方、read/scan/report/delete は従来どおり妨げない。live hook の outer envelope が Claude Code の permission flow(permissionDecision)を変更しないことを runtime test で確認した状態を完了とする。

In Scope

  • schemas/repo_temp_folder_advice_v2.schema.json を新規追加する。schema プロパティは REPO_TEMP_FOLDER_ADVICE_V2 の const。approved_write_roots は type: array + const: ["tmp/"](instance 全体を固定。enum: ["tmp/"] のような array instance と string を取り違える記述は使わない)。deprecated_legacy_roots は type: array + const: [".claude/tmp/"]。minItems/maxItems は const と重複するため追加しない(const のみで単一許容値を表現する)
  • scripts/agent-guards/root_temporary_residue_policy.py に --schema-version {v1,v2} を追加する。フラグ無指定時と --schema-version v1 明示時は既存 V1 payload と bit-for-bit 同一の出力を維持する(V1 emit 経路は削除しない)。--schema-version v2 指定時のみ V2 payload(REPO_TEMP_FOLDER_ADVICE_V2 schema 準拠)を emit する
  • .claude/hooks/root_temporary_residue_advisory.sh を更新し、live hook 実行時は明示的に --schema-version v2 を指定して producer を呼び出す(hook 自体は non-blocking / fail-open のまま維持する)。V2 live mode では .tmp/** / .temp/** / .tmp-*/** に加えて .claude/tmp/** への Write/Edit、および明確に write と判定できる Bash operation を advisory 対象に追加し、deprecated_legacy_root_write 等の reason code で通常の root-alias advisory と区別する。read / scan / report / delete 操作(.claude/tmp/** を含む)は advisory を発火させない
  • .claude/hooks/tests/test_root_temporary_residue_advisory.py に以下を追加する:
    • V2 payload(REPO_TEMP_FOLDER_ADVICE_V2 schema 準拠・approved_write_roots/deprecated_legacy_roots の値)を検証するテストケース
    • .claude/tmp/** への write 操作で advisory が発火し deprecated_legacy_root_write 相当の reason code が付与されることを検証するテストケース
    • .claude/tmp/** への read / scan / delete 操作で advisory が発火しないことを検証するテストケース
    • live hook process の returncode == 0、hookSpecificOutput.permissionDecision が出力 JSON に存在しないこと、additionalContext の prefix が V2 schema identifier であり inner JSON の schema フィールドと一致することを検証するテストケース
  • scripts/agent-guards/tests/test_root_temporary_residue_policy.py に --schema-version v2 指定時の V2 schema 準拠を検証するテストケースと、無指定 / --schema-version v1 明示時に既存 V1 出力が変化しないことを検証する回帰テストケースを追加する(既存 V1 テストは維持する)
  • schemas/catalog.yaml に repo_temp_folder_advice/v1(実装: repo_temp_folder_advice schema を catalog に登録する #1418 吸収: producer scripts/agent-guards/root_temporary_residue_policy.py、definition schemas/repo_temp_folder_advice_v1.schema.json、既存の temp_residue_classification/v1 等と同等の構造・producer/consumer 記載に揃える)と repo_temp_folder_advice/v2 の schema_id エントリを両方追加する
  • schemas/tests/test_catalog.py の EXPECTED_ENTRY_COUNT を、実装時点の schemas/catalog.yaml の実エントリ数(本 Issue 起票時点のベースラインは 25、V1+V2 の 2 エントリ追加後の期待値は実装時に schemas/catalog.yaml を実測して算出する。anchor 由来の数値を盲目的に転記しない)に更新する
  • docs/dev/schema-governance.md に repo_temp_folder_advice/v1(実装: repo_temp_folder_advice schema を catalog に登録する #1418 吸収分)と repo_temp_folder_advice/v2 の両方の追加を記録する
  • docs/dev/hook-boundaries.md の schemas/repo_temp_folder_advice_v1.schema.json に関する既存記載(Issue 実装: repo-approved local temporary workspace を tmp/ へ一本化し .claude/tmp/ を非推奨化する #1995 で「1 値化は schema v2 migration の follow-up Issue で扱う」と明記した箇所)を更新し、本 Issue で V1 catalog 登録・V2 追加・.claude/tmp/** write advisory 拡張が行われたことを反映する
  • docs/dev/repository-folder-policy.md の該当箇所(.claude/tmp/ の説明が「本 Issue のスコープでは変更しない」としている旧記載)を更新し、V2 導入後の書込先/legacy 認識先の区別と .claude/tmp/** write advisory 拡張を反映する
  • temp_residue_marker.py / temp_residue_classifier.py(scripts/agent-ops/)は .claude/tmp/ を legacy residue root として引き続き認識し、read/scan/report を維持することを明記する(本 Issue ではこの 2 スクリプトのロジック自体は変更しない。挙動が変わらないことをテストで確認する)

Out of Scope

  • V1 schema(schemas/repo_temp_folder_advice_v1.schema.json)の削除・deprecation マーキング(別 Issue)
  • V1 → V2 への consumer 全面切替、または V1 emit 経路の廃止(breaking change のため別 Issue)
  • .claude/tmp/**(および他の一時ディレクトリ)への新規書き込みを禁止する enforcement(block: true、permission deny/ask への拡張)。inner payload の block: false は維持し、outer envelope の permissionDecision は出力しない
  • temp_residue_marker.py / temp_residue_classifier.py の legacy residue 認識ロジック自体の変更
  • Issue 実装: source-bound eligibility/readiness の固定 private location を tmp/session-recording/ へ同時移行する #2004 が扱う tmp/session-recording/ への private location 移行そのもの
  • typed downstream consumer 向けの dual-reader migration infrastructure の新規構築(current repo で approved_temporary_roots を参照する program consumer は schema/producer/docs/tests 以外に確認されていないため、V1 emitter compatibility + live hook V2 選択で十分とする)

Acceptance Criteria

  • AC1: schemas/repo_temp_folder_advice_v2.schema.json が存在し、schema プロパティが REPO_TEMP_FOLDER_ADVICE_V2 の const、approved_write_roots が type: array + const: ["tmp/"]、deprecated_legacy_roots が type: array + const: [".claude/tmp/"] として定義されている
  • AC2: scripts/agent-guards/root_temporary_residue_policy.py が --schema-version {v1,v2} を受け付ける。フラグ無指定時と --schema-version v1 明示時は既存 V1 payload と同一の出力を維持し、--schema-version v2 指定時のみ V2 payload(REPO_TEMP_FOLDER_ADVICE_V2 schema 準拠)を emit する
  • AC3: .claude/hooks/root_temporary_residue_advisory.sh(live hook)が producer を --schema-version v2 で明示的に呼び出す
  • AC4: .claude/hooks/tests/test_root_temporary_residue_advisory.py に V2 payload 検証テスト、.claude/tmp/** write advisory 発火テスト(deprecated_legacy_root_write 相当 reason code 検証を含む)、.claude/tmp/** read/scan/delete 非発火テストが追加され、pytest で pass する
  • AC5: scripts/agent-guards/tests/test_root_temporary_residue_policy.py に --schema-version v2 の V2 schema 準拠検証テストと、無指定 / v1 明示時の既存 V1 出力不変を検証する回帰テストが追加され、既存 V1 テストとあわせて pytest で pass する
  • AC6: schemas/catalog.yaml に repo_temp_folder_advice/v1(実装: repo_temp_folder_advice schema を catalog に登録する #1418 吸収分)と repo_temp_folder_advice/v2 の両方の schema_id エントリが追加されている
  • AC7: schemas/tests/test_catalog.py の EXPECTED_ENTRY_COUNT が更新後の schemas/catalog.yaml の実エントリ数と一致し、pytest で pass する(catalog エントリ数変更を静かに見逃す false-green を残さない)
  • AC8: docs/dev/schema-governance.md・docs/dev/hook-boundaries.md・docs/dev/repository-folder-policy.md に V1 catalog 登録・V2 schema・approved_write_roots/deprecated_legacy_roots 分離・.claude/tmp/** write advisory 拡張の説明が追記されている
  • AC9: temp_residue_marker.py / temp_residue_classifier.py の既存挙動(.claude/tmp/ の read/scan/report を legacy residue として引き続き認識する)が本 Issue の変更後も無変更であることを既存テストで確認する
  • AC10: scripts/agent-guards/root_temporary_residue_policy.py と .claude/hooks/root_temporary_residue_advisory.sh に block: true・permission deny/ask 相当のロジックが追加されていない(grep で不在を確認する)
  • AC11 (動作検証, <!-- runtime-verification: true -->): live Claude Code PreToolUse hook(.claude/hooks/root_temporary_residue_advisory.sh)を実プロセスとして起動し、.claude/tmp/** への write 操作で advisory(additionalContext に V2 schema identifier prefix、inner JSON schema フィールドと一致)が出力されること、.claude/tmp/** への read/scan/delete 操作では advisory が出力されないこと、いずれの場合も process returncode == 0 かつ出力 JSON に hookSpecificOutput.permissionDecision フィールドが存在しない(通常の permission flow を変更しない)ことを実行環境で確認する

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n "\"const\": \"REPO_TEMP_FOLDER_ADVICE_V2\"" schemas/repo_temp_folder_advice_v2.schema.json
# baseline-expect: fail
$ rg -n "\"approved_write_roots\"" schemas/repo_temp_folder_advice_v2.schema.json
# baseline-expect: fail
$ rg -n "\"deprecated_legacy_roots\"" schemas/repo_temp_folder_advice_v2.schema.json
# AC2
$ rg -n "schema-version" scripts/agent-guards/root_temporary_residue_policy.py
$ rg -n "REPO_TEMP_FOLDER_ADVICE_V2" scripts/agent-guards/root_temporary_residue_policy.py
# AC3
$ rg -n "schema-version v2" .claude/hooks/root_temporary_residue_advisory.sh
# AC4
$ uv run --locked pytest .claude/hooks/tests/test_root_temporary_residue_advisory.py -v
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_root_temporary_residue_policy.py -v
# AC6
$ rg -n "repo_temp_folder_advice/v1" schemas/catalog.yaml
$ rg -n "repo_temp_folder_advice/v2" schemas/catalog.yaml
# AC7
$ uv run --locked pytest schemas/tests/test_catalog.py -v
# AC8
$ rg -n "REPO_TEMP_FOLDER_ADVICE_V2" docs/dev/schema-governance.md docs/dev/hook-boundaries.md docs/dev/repository-folder-policy.md
$ rg -n "repo_temp_folder_advice/v1" docs/dev/schema-governance.md
# AC9
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -v
# AC10
$ rg -c "\"block\": true" scripts/agent-guards/root_temporary_residue_policy.py .claude/hooks/root_temporary_residue_advisory.sh
$ rg -c "permissionDecision" scripts/agent-guards/root_temporary_residue_policy.py .claude/hooks/root_temporary_residue_advisory.sh
# 期待値: いずれも 0 件(matched line 数 0、grep exit 1)。1 件以上ヒットした場合は enforcement 拡張とみなし FAIL。
# AC11
# runtime-verification: true
# 動作検証。実装者は以下 2 ファイルを新規作成すること(既存の scripts/agent-ops/tests/run_runtime_verification_ac18.py と同じ「非 pytest-collected な exit-code 変換 wrapper が pytest suite を subprocess で束ねる」構成に揃える):
# (1) scripts/agent-guards/tests/test_root_temporary_residue_advisory_runtime_smoke.py — pytest suite 本体。claude CLI バイナリまたは hook 実行環境が存在しない場合は各テストが pytest.skip("SKIP: ...") する。.claude/tmp/** write / read / scan / delete の各 case で hook プロセスを実起動し、returncode / hookSpecificOutput.permissionDecision 不在 / additionalContext prefix と inner JSON schema 一致を assert で検証する。fallback 経由の成功(`_*_fallback: true` 相当)を検出した場合は assert で FAIL させる。
# (2) scripts/agent-guards/tests/run_runtime_verification_ac11.py — (1) を subprocess で実行し集計する non-pytest-collected wrapper。対象 suite が全件 skip の場合は stdout 先頭に "SKIP: ..." を出力し exit 77、genuine failure があれば exit 1、genuine pass があれば exit 0 を返す。docs/dev/runtime-verification-policy.md セクション4 の必須フィールド形式で artifacts/runtime-verification-AC11-<timestamp>.log を書き出す。
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-guards/tests/run_runtime_verification_ac11.py

Allowed Paths

  • schemas/repo_temp_folder_advice_v2.schema.json
  • schemas/catalog.yaml
  • schemas/tests/test_catalog.py
  • scripts/agent-guards/root_temporary_residue_policy.py
  • scripts/agent-guards/tests/test_root_temporary_residue_policy.py
  • scripts/agent-guards/tests/test_root_temporary_residue_advisory_runtime_smoke.py
  • scripts/agent-guards/tests/run_runtime_verification_ac11.py
  • .claude/hooks/root_temporary_residue_advisory.sh
  • .claude/hooks/tests/test_root_temporary_residue_advisory.py
  • docs/dev/schema-governance.md
  • docs/dev/hook-boundaries.md
  • docs/dev/repository-folder-policy.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • V1 emit 経路の削除や .claude/tmp/ への新規書き込み禁止(block: true 化)が必要と判断した場合
  • AC11 の動作検証実行環境(Claude Code CLI / hook 実行環境)が用意できず SKIP (exit 77) が発生した場合は、その旨を PR に明記し人間レビューを仰ぐ

Required Skills

なし

Required Design References

  • docs/dev/repository-folder-policy.md
  • docs/dev/hook-boundaries.md
  • docs/dev/schema-governance.md
  • docs/dev/runtime-verification-policy.md

Runtime Verification Applicability

decision: immediate
reason: >-
  本 Issue は `.claude/hooks/root_temporary_residue_advisory.sh`(hook_configuration /
  hook handler logic)を変更する。`docs/dev/extension-surface-runtime-policy.yaml` の
  risk-trigger rule `hook-lifecycle-matcher-or-handler-change`(`.claude/hooks/**` の
  handler logic 変更、`default_decision: immediate`)に該当するため、動作検証を本 Issue の
  実装範囲内で成立させる。
applicable_acs:
  - AC11
execution_environment:
  cli_tools:
    - python3
    - uv
    - claude
  auth_required: false
  network_required: false
skip_conditions:
  - "claude CLI バイナリまたは hook 実行環境が存在しない場合は SKIP(exit 77)として扱う"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fallback 経由の成功を PASS に変換しない。additionalContext prefix と inner JSON schema の実一致を確認する"
artifact_requirements:
  - "artifacts/runtime-verification-AC11-<timestamp>.log(docs/dev/runtime-verification-policy.md セクション4形式)"
  - "PR の ## Runtime Verification Evidence セクションへの inline 引用"

Scope Delta(任意)

N/A(Allowed Paths への schemas/tests/test_catalog.py および新規 runtime verification VC script の追加は、本 refinement iteration の OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/2007#issuecomment-5584305323)で要求された trusted scope reframe に基づく)

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    on Aug 6, 2026
  2. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    結論

    #2007 は方向性自体は妥当ですが、現状のまま実装開始するのは REQUEST_CHANGES / reframe_in_place が適切です。
    特に「schema V2 を追加したのに live hook の有用性が変わらない」「catalog を追加すると既存 catalog test が必ず壊れる」の2点が大きいです。

    #1995 で tmp/ を canonical write destination、.claude/tmp/ を deprecated legacy root とする方針はすでに決まり、#2004/PR #2008 で残っていた session-recording の production writer/consumer も tmp/session-recording/ に移行済みです。したがって V2への移行タイミングそのものは適切です。

    主要 Findings

    1. [BLOCKER] schemas/catalog.yaml を変更すると現状の Allowed Paths ではテストを green にできません。
      実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 は repo_temp_folder_advice/v2 を catalog に追加する AC5 を持ちますが、schemas/tests/test_catalog.py は現在 EXPECTED_ENTRY_COUNT = 25 として entry 数を厳密に固定しています。V2 を1件追加すれば26件になるため、そのテストも更新が必要です。しかし schemas/tests/test_catalog.py は 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 の Allowed Paths にありません。しかも AC5 の VC は rg だけなので、壊れた catalog を PASS と誤認できます。
      これは過去の 実装: source-bound eligibility/readiness の固定 private location を tmp/session-recording/ へ同時移行する #2008 でも、新規テストが実 CI lane に登録されていなかったことが OWNER review の blocker になったのと同種です。
      修正: Allowed Paths に schemas/tests/test_catalog.py を追加し、少なくとも uv run --locked pytest schemas/tests/test_catalog.py .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q を VC に含めるべきです。

    2. [BLOCKER] V2 schema の enum 記述が曖昧で、文字どおり実装すると充足不能 schema になります。
      Issue は approved_write_roots を「1要素 array、enum: ["tmp/"]」と記述しています。JSON Schema では enum はその schema が適用された instance 全体と列挙値を比較します。したがって array property に直接 enum: ["tmp/"] を置くと、array ["tmp/"] は string "tmp/" と等しくないため valid になりません。const は単一値 enum と同等なので、固定 array なら const: ["tmp/"] が最も簡潔です。(JSON Schema)
      推奨は以下です。

      "approved_write_roots": {
        "type": "array",
        "const": ["tmp/"]
      },
      "deprecated_legacy_roots": {
        "type": "array",
        "const": [".claude/tmp/"]
      }
    3. [HIGH] 「V2をemitできる」だけでは live behavior がV1のまま残れます。
      現在の producer は global ADVICE_SCHEMA = "REPO_TEMP_FOLDER_ADVICE_V1" を使い、wrapper も schema version を指定せず producer を呼んでいます。
      ところが 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 は「V2を既定にするか --schema-version で切り替えるか実装時に決めてよい」としているため、実装者が V2 の optional mode を追加しただけでも AC2 を満たせます。これでは migration Issue として弱いです。
      推奨: root_temporary_residue_policy.py は --schema-version {v1,v2} を持ち、CLI/API の無指定はV1のままにして後方互換性を維持する一方、.claude/hooks/root_temporary_residue_advisory.sh は明示的に --schema-version v2 を渡す。この形なら「旧 emitter は壊さない」「実利用はV2へ移る」の両方を簡潔に満たせます。

    4. [HIGH] 現状の設計では .claude/tmp/** に書いた当人に、V2でも何も案内されない可能性があります。
      現 producer は first segment が tmp または .claude の場合に即 None を返します。既存テストも .claude/tmp/... は non-trigger と明示的に固定しています。
      一方、folder policy は「新規書き込みは tmp/ のみ」と既に定義しています。現 hook は .tmp/.temp/.tmp-* から tmp/ または .claude/tmp/ を案内するため、そこも現行 policy と矛盾しています。
      V2を有用にするなら、V2 live mode のみ .claude/tmp/** への Write/Edit/明確な Bash write を deprecated_legacy_root_write として advisory すべきです。read/scan/delete は黙ったままにし、block はしない。この程度ならユーザーの方針どおりワークフローを邪魔しません。

    5. [HIGH] block: false をテストしても、Claude Code上で non-blocking である保証にはなっていません。
      block は inner advice payload 内の独自 field にすぎません。Claude Code の現在の公式仕様では、additionalContext は Claude の context に追加される文字列で、PreToolUse の実際の制御は hookSpecificOutput.permissionDecision が担います。(Claude)
      したがって重要なのは「inner JSON に block:false がある」ことより、outer envelope に permissionDecision: deny/ask が存在しないことです。公式仕様でも exit 0 + decisionなしは通常の permission flow を継続します。(Claude)
      V2 hook test では returncode == 0、permissionDecision 不在、additionalContext の schema prefix と inner schema が一致、を固定するのが適切です。

    6. [MEDIUM] 「V1/V2 両方を read/consume」は実態より大げさで、不要な互換ハーネスを誘発します。
      現 repo で approved_temporary_roots を参照しているのは schema・producer・docs・tests で、下流のプログラム consumer は確認できません。
      Claude Code側も additionalContext を typed protocol として consumeするのではなく、Claudeの context に文字列として注入します。(Claude)
      したがって「dual-reader migration infrastructure」を作る必要はありません。V1 emitter が明示指定で従来出力を再現できること + live hook はV2を出すことで十分です。

    #1418 の扱い

    ここは別Issueを順番待ちさせるより、#1418 のV1 catalog登録を #2007 に吸収し、#1418 は superseded として閉じるのを推奨します。

    #1418 は依然 open で、V1 の schemas/catalog.yaml / schema-governance.md 登録を扱っています。#2007 は同じ2ファイルへ V2 を追加するため、分けると小さな migration のために2 PR・2 review loop・rebase競合が発生します。

    個人趣味開発としては、1本の #2007 PR で、

    項目 | 推奨状態 -- | -- V1 schema | ファイル・emitterを完全保持 V1 catalog | #1418から吸収して登録 V2 schema | 新規登録 Python API default | V1互換 Claude live hook | V2を明示指定 .tmp/.temp/.tmp-* | V2 advisory .claude/tmp/** write | V2 advisory、非blocking .claude/tmp/** read/scan/delete | 従来通り妨げない classifier / marker | 無変更 enforcement | 導入しない

    とするのが最も整っています。

    Issue #2007 に追加すべき完了条件

    最低限、ACを「V2 schema が存在する」から一段強くして、live hook がV2を使うこと、.claude/tmp write に非blocking advisory が出ること、V1互換 emitter が同一出力を維持すること、catalog tests が実際に通ることまで固定すべきです。

    Verification は巨大な full-suite harness を増やす必要はありません。今回なら targeted に以下で十分です。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_root_temporary_residue_policy.py \
      .claude/hooks/tests/test_root_temporary_residue_advisory.py \
      schemas/tests/test_catalog.py \
      .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q
    

    uv run --locked python3 scripts/check_hook_boundaries.py

    最終判定は REQUEST_CHANGES。ただし scope split は不要で、#2007 をその場で refine すればよいです。セキュリティ強化や block enforcement を足す必要はなく、むしろ「deprecated write を軽く誘導する」「schema/catalog の false-green を防ぐ」「live path を明示する」の3点に集中するのが、このリポジトリの用途には最も実用的です。

    ## 結論

    #2007 は方向性自体は妥当ですが、現状のまま実装開始するのは REQUEST_CHANGES / reframe_in_place が適切です。
    特に「schema V2 を追加したのに live hook の有用性が変わらない」「catalog を追加すると既存 catalog test が必ず壊れる」の2点が大きいです。

    #1995 で tmp/ を canonical write destination、.claude/tmp/ を deprecated legacy root とする方針はすでに決まり、#2004/PR #2008 で残っていた session-recording の production writer/consumer も tmp/session-recording/ に移行済みです。したがって V2への移行タイミングそのものは適切です。

    主要 Findings

    1. [BLOCKER] schemas/catalog.yaml を変更すると現状の Allowed Paths ではテストを green にできません。
      実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 は repo_temp_folder_advice/v2 を catalog に追加する AC5 を持ちますが、schemas/tests/test_catalog.py は現在 EXPECTED_ENTRY_COUNT = 25 として entry 数を厳密に固定しています。V2 を1件追加すれば26件になるため、そのテストも更新が必要です。しかし schemas/tests/test_catalog.py は 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 の Allowed Paths にありません。しかも AC5 の VC は rg だけなので、壊れた catalog を PASS と誤認できます。
      これは過去の 実装: source-bound eligibility/readiness の固定 private location を tmp/session-recording/ へ同時移行する #2008 でも、新規テストが実 CI lane に登録されていなかったことが OWNER review の blocker になったのと同種です。
      修正: Allowed Paths に schemas/tests/test_catalog.py を追加し、少なくとも uv run --locked pytest schemas/tests/test_catalog.py .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q を VC に含めるべきです。

    2. [BLOCKER] V2 schema の enum 記述が曖昧で、文字どおり実装すると充足不能 schema になります。
      Issue は approved_write_roots を「1要素 array、enum: ["tmp/"]」と記述しています。JSON Schema では enum はその schema が適用された instance 全体と列挙値を比較します。したがって array property に直接 enum: ["tmp/"] を置くと、array ["tmp/"] は string "tmp/" と等しくないため valid になりません。const は単一値 enum と同等なので、固定 array なら const: ["tmp/"] が最も簡潔です。([JSON Schema]1)
      推奨は以下です。

      "approved_write_roots": {
        "type": "array",
        "const": ["tmp/"]
      },
      "deprecated_legacy_roots": {
        "type": "array",
        "const": [".claude/tmp/"]
      }
    3. [HIGH] 「V2をemitできる」だけでは live behavior がV1のまま残れます。
      現在の producer は global ADVICE_SCHEMA = "REPO_TEMP_FOLDER_ADVICE_V1" を使い、wrapper も schema version を指定せず producer を呼んでいます。
      ところが 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 は「V2を既定にするか --schema-version で切り替えるか実装時に決めてよい」としているため、実装者が V2 の optional mode を追加しただけでも AC2 を満たせます。これでは migration Issue として弱いです。
      推奨: root_temporary_residue_policy.py は --schema-version {v1,v2} を持ち、CLI/API の無指定はV1のままにして後方互換性を維持する一方、.claude/hooks/root_temporary_residue_advisory.sh は明示的に --schema-version v2 を渡す。この形なら「旧 emitter は壊さない」「実利用はV2へ移る」の両方を簡潔に満たせます。

    4. [HIGH] 現状の設計では .claude/tmp/** に書いた当人に、V2でも何も案内されない可能性があります。
      現 producer は first segment が tmp または .claude の場合に即 None を返します。既存テストも .claude/tmp/... は non-trigger と明示的に固定しています。
      一方、folder policy は「新規書き込みは tmp/ のみ」と既に定義しています。現 hook は .tmp/.temp/.tmp-* から tmp/ または .claude/tmp/ を案内するため、そこも現行 policy と矛盾しています。
      V2を有用にするなら、V2 live mode のみ .claude/tmp/** への Write/Edit/明確な Bash write を deprecated_legacy_root_write として advisory すべきです。read/scan/delete は黙ったままにし、block はしない。この程度ならユーザーの方針どおりワークフローを邪魔しません。

    5. [HIGH] block: false をテストしても、Claude Code上で non-blocking である保証にはなっていません。
      block は inner advice payload 内の独自 field にすぎません。Claude Code の現在の公式仕様では、additionalContext は Claude の context に追加される文字列で、PreToolUse の実際の制御は hookSpecificOutput.permissionDecision が担います。(Claude)
      したがって重要なのは「inner JSON に block:false がある」ことより、outer envelope に permissionDecision: deny/ask が存在しないことです。公式仕様でも exit 0 + decisionなしは通常の permission flow を継続します。([Claude]2)
      V2 hook test では returncode == 0、permissionDecision 不在、additionalContext の schema prefix と inner schema が一致、を固定するのが適切です。

    6. [MEDIUM] 「V1/V2 両方を read/consume」は実態より大げさで、不要な互換ハーネスを誘発します。
      現 repo で approved_temporary_roots を参照しているのは schema・producer・docs・tests で、下流のプログラム consumer は確認できません。
      Claude Code側も additionalContext を typed protocol として consumeするのではなく、Claudeの context に文字列として注入します。(Claude)
      したがって「dual-reader migration infrastructure」を作る必要はありません。V1 emitter が明示指定で従来出力を再現できること + live hook はV2を出すことで十分です。

    #1418 の扱い

    ここは別Issueを順番待ちさせるより、#1418 のV1 catalog登録を #2007 に吸収し、#1418 は superseded として閉じるのを推奨します。

    #1418 は依然 open で、V1 の schemas/catalog.yaml / schema-governance.md 登録を扱っています。#2007 は同じ2ファイルへ V2 を追加するため、分けると小さな migration のために2 PR・2 review loop・rebase競合が発生します。

    個人趣味開発としては、1本の #2007 PR で、

    項目 推奨状態
    V1 schema ファイル・emitterを完全保持
    V1 catalog #1418から吸収して登録
    V2 schema 新規登録
    Python API default V1互換
    Claude live hook V2を明示指定
    .tmp/.temp/.tmp-* V2 advisory
    .claude/tmp/** write V2 advisory、非blocking
    .claude/tmp/** read/scan/delete 従来通り妨げない
    classifier / marker 無変更
    enforcement 導入しない

    とするのが最も整っています。

    Issue #2007 に追加すべき完了条件

    最低限、ACを「V2 schema が存在する」から一段強くして、live hook がV2を使うこと、.claude/tmp write に非blocking advisory が出ること、V1互換 emitter が同一出力を維持すること、catalog tests が実際に通ることまで固定すべきです。

    Verification は巨大な full-suite harness を増やす必要はありません。今回なら targeted に以下で十分です。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_root_temporary_residue_policy.py \
      .claude/hooks/tests/test_root_temporary_residue_advisory.py \
      schemas/tests/test_catalog.py \
      .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q
    
    uv run --locked python3 scripts/check_hook_boundaries.py

    最終判定は REQUEST_CHANGES。ただし scope split は不要で、#2007 をその場で refine すればよいです。セキュリティ強化や block enforcement を足す必要はなく、むしろ「deprecated write を軽く誘導する」「schema/catalog の false-green を防ぐ」「live path を明示する」の3点に集中するのが、このリポジトリの用途には最も実用的です。

  3. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    確認した限り、推奨は REQUEST_CHANGES / reframe_in_place のまま #2007 を refinement loop に通し、#1418 を吸収する方向です。#1418 は現在も open で V1 catalog 登録を所有しており、#2007 と schemas/catalog.yaml / docs/dev/schema-governance.md が重複しています。 一方、現 main の producer はまだ V1 固定、Claude hook も version 指定なしなので、anchor の指摘は現状にも当たっています。

    また、schemas/tests/test_catalog.py は現時点で EXPECTED_ENTRY_COUNT = 25 です。#1418 の V1 と #2007 の V2 を両方吸収するなら、main が変わっていなければ 25→27 になります。固定値 26 を転記せず、実行時の catalog から再計算させるべきです。 JSON Schema の enum/const 指摘も仕様上正しく、固定配列なら const: ["tmp/"] の形が素直です。([JSON Schema]1) Claude Code の現行 hook 仕様でも、additionalContext は context 注入で、PreToolUse の制御は permissionDecision が担うため、「通常の permission flow を変えない」なら permissionDecision 自体を出さない検証が適切です。([Claude]2)

    そのまま既存の auto mode Claude Code に貼れる形です。

    以下を、人間の追加承認なしで最後まで実行してください。

    対象 repository:
    squne121/loop-protocol

    対象 Issue:
    #2007

    anchor comment:
    https://github.com/squne121/loop-protocol/issues/2007#issuecomment-5584305323

    使用する canonical Skill:
    .claude/skills/issue-refinement-loop

    目的

    anchor comment の REQUEST_CHANGES / reframe_in_place を入力として、Issue #2007 を current repository state と current external specifications に整合する実装可能な契約へ refinement してください。

    issue-refinement-loop の bounded loop を canonical procedure のまま実行し、可能な限り approve / proceed 相当の terminal state まで到達させてください。

    iteration 間の人間承認は不要です。
    現在の Claude Code の auto mode / permission mode は変更しないでください。
    --dangerously-skip-permissions 等への切替も不要です。

    この依頼は「planner / reviewer / worker の SSOT を迂回して手動判断する」指示ではありません。以下の推奨方向は investigation/review で検証する hypothesis として扱い、最終的な mutation/routing は issue-refinement-loop の canonical planner、review pipeline、issue-editor、scope/superseded decision に従ってください。

    anchor の扱い

    この anchor comment は、今回ユーザーが明示的に選択した human context です。

    URL 単独の unlabeled anchor として扱わず、Skill が規定する canonical human-context lane を使用してください。

    必要に応じて、

    • preflight.run.with_human_context
    • trusted contract patch plan
    • contract_update.run.with_human_context

    の正規経路を使用し、raw gh issue edit 等で canonical mutation lane を迂回しないでください。

    anchor と Issue/repository の binding を最初に検証してください。

    最初に必ず current state を再調査する

    anchor の記述をそのまま転記せず、少なくとも以下を current main / GitHub state で再確認してください。

    既存 PR / branch / worktree が #2007 または #1418 を既に実装中でないことも確認してください。

    サブエージェント

    Skill contract に従って read-only SubAgent を使用してください。

    特に repository fact の確認には codebase-investigator を使用してください。
    外部仕様の fact-check が planner 上 required になった場合は web-researcher を使用してください。

    今回の anchor には少なくとも以下の external/spec claim があるため、web research が必要と判定された場合は一次資料を優先してください。

    • JSON Schema Draft 2020-12 の enum / const semantics
    • current Claude Code PreToolUse hook の additionalContext
    • hookSpecificOutput.permissionDecision
    • decision を省略した場合の permission flow

    複数 SubAgent を起動した場合、全 SubAgent の作業完了を待って結果を join してから次の review step に進んでください。

    SubAgent に mutation をさせないでください。
    SubAgent から別 SubAgent への nested delegation は行わせないでください。

    なお canonical Step 2 では、現行 Skill の契約どおり issue-reviewer SubAgent を新たに起動しないでください。root-owned review pipeline の結果を canonical routing authority として consumeしてください。

    #2007 の推奨 reframe

    current evidence が反証しない限り、以下の方向へ #2007 を reframe してください。

    1. #1418 を #2007 に吸収する

    #1418 が依然 open で未実装なら、

    • repo_temp_folder_advice/v1 の catalog/governance 登録
    • repo_temp_folder_advice/v2 の catalog/governance 登録

    を #2007 の1本の migration scope に統合する方向を採用してください。

    #2007 本文に V1 catalog registration の ownership を明示してから、canonical scope-rollup / superseded decision が許可する場合に限り #1418 を superseded として処理してください。

    単なる title 類似だけで #1418 を閉じないこと。
    canonical superseded decision と GitHub readback を確認してください。

    別々に2 PRを作る前提にはしないでください。

    2. catalog test の false-green を除去する

    schemas/tests/test_catalog.py を #2007 の Allowed Paths に追加する必要性を検証し、必要なら trusted scope reframe として反映してください。

    現 main では EXPECTED_ENTRY_COUNT = 25 ですが、#1418 の V1 と #2007 の V2 を双方新規登録するなら単純計算では +2 です。

    ただし 26 や 27 を anchor から盲目的に hard-code せず、current schemas/catalog.yaml の実 entry 数から期待値を再計算してください。

    .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py は、変更が本当に必要なら Allowed Paths 追加を検討し、既存 validator を実行するだけでよいなら mutation scope には追加せず VC として実行してください。

    3. V2 schema の固定配列契約を曖昧にしない

    array property へ

    enum: ["tmp/"]

    のような意味的に誤った記述を要求しないでください。

    固定 array を要求するなら、例えば:

    approved_write_roots

    • type: array
    • const: ["tmp/"]

    deprecated_legacy_roots

    • type: array
    • const: [".claude/tmp/"]

    のように instance 全体を固定する契約として明文化してください。

    必要なら minItems / maxItems は redundancy を理解した上で採否を決めてください。

    4. V1 backward compatibility と live V2 adoption を分離する

    推奨契約:

    • Python/API/CLI の version 無指定 behavior は V1 compatibility を維持
    • producer に --schema-version {v1,v2} 相当の explicit selector
    • V1 explicit/default path は従来 payload を再現
    • Claude live hook は明示的に V2 を選択
    • V1 emitter を削除しない

    「V2 を emit できる」だけで AC を満たさず、実 live Claude hook が V2 を選択していることを acceptance criteria にしてください。

    不要な dual-reader migration infrastructure は作らないでください。
    現実に typed downstream consumer が存在するかを investigation で確認し、存在しないなら「V1 emitter compatibility + live hook V2」で十分としてください。

    5. .claude/tmp/** write を V2 advisory 対象にする

    current repository policy と整合するなら、V2 live mode では:

    • .tmp/**
    • .temp/**
    • .tmp-*/**

    に加えて、

    • .claude/tmp/** への Write/Edit
    • 明確に write と判定できる Bash operation

    を non-blocking advisory 対象にしてください。

    .claude/tmp/** の write は deprecated_legacy_root_write 等の明確な reason code で区別する方向を検討してください。

    一方、

    • read
    • scan
    • report
    • delete / cleanup

    は legacy residue compatibility のため妨げない契約を維持してください。

    temp_residue_marker.py
    temp_residue_classifier.py

    の legacy recognition logic は変更しないでください。

    6. enforcement を追加しない

    本 Issue の目的は guidance/migration です。

    • block: true
    • permission deny
    • permission ask
    • 強制的な write prohibition

    へ拡張しないでください。

    inner payload に block: false を残すかどうかとは独立に、Claude Code hook の outer envelope が permission flow を変更しないことを runtime test で確認してください。

    望ましい検証は少なくとも:

    • hook process returncode == 0
    • hookSpecificOutput.permissionDecision が存在しない
    • additionalContext prefix が V2 schema identifier
    • prefix と inner JSON の schema が一致
    • .claude/tmp/** write では advisory が出る
    • .claude/tmp/** read/scan/delete では advisory が出ない

    です。

    permissionDecision: allow も通常 permission flow を変えるので、この advisory hook では出さない方向を優先してください。

    Acceptance Criteria / Verification の強化

    Issue body を「V2 schema file が存在する」だけの静的 AC にしないでください。

    最低限、以下を contract として検証可能にしてください。

    1. V1 schema/emitter compatibility
    2. V1 catalog registration(実装: repo_temp_folder_advice schema を catalog に登録する #1418 absorb 時)
    3. V2 schema registration
    4. live Claude hook が V2 を明示選択
    5. .claude/tmp/** write advisory
    6. .claude/tmp/** read/scan/delete non-trigger
    7. permissionDecision 不在による non-blocking behavior
    8. catalog tests が実際に green
    9. hook boundary validation が green
    10. marker/classifier legacy behavior が無変更

    targeted verification の最低ラインは current repo state に合わせて、以下を含めてください。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_root_temporary_residue_policy.py \
      .claude/hooks/tests/test_root_temporary_residue_advisory.py \
      schemas/tests/test_catalog.py \
      .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q
    
    uv run --locked python3 scripts/check_hook_boundaries.py

    必要なら既存の relevant regression tests を追加してください。ただし巨大な新規 harness や security framework を作らないでください。

    loop 実行

    max_iterations は canonical default を使用してください。

    review が needs-fix / request_changes なら、人間確認を挟まず次 iteration へ進めてください。

    各 iteration で:

    1. current body/readback を固定
    2. 必要な investigation/web research を完了
    3. canonical root review pipeline
    4. semantic review が applicable なら canonical Step 2.5
    5. needs-fix なら issue-editor で rewrite
    6. readback/hash確認
    7. fresh final review

    を行ってください。

    planner/reviewer の machine-readable result を prose で勝手に再判定しないでください。

    停止条件

    通常の「続けますか?」という確認では停止しないでください。

    ただし canonical Skill が以下を返した場合は、捏造した approval で突破せず fail-closed にしてください。

    • human_judgment_required
    • max_iterations_exceeded
    • environment / transport / artifact integrity failure
    • trusted scope authority で解決できない新規 architecture scope
    • secret / credential が必要
    • destructive repository operation が必要

    その場合は canonical termination report を投稿して終了してください。

    完了条件

    最終的に以下を満たしてください。

    最後に簡潔に、

    を報告してください。

    このプロンプトでは、anchor の修正案を単なる「レビューコメント対応」ではなく、trusted human-context reframe → fresh review → semantic approval の流れに載せています。現行 issue-refinement-loop は iteration approval gate が既定で不要で、必要な codebase-investigator / web-researcher は Step 2 前に結果を合流させる契約なので、この運用と整合します。

  4. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  5. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(#2007)

    Final Verdict: approved(deterministic review: approve / semantic design review: approve, low-severity warning 1件)

    Iteration 概要(3回)

    1. iteration 1: anchor comment(https://github.com/squne121/loop-protocol/issues/2007#issuecomment-5584305323)の REQUEST_CHANGES を反映し、実装: repo_temp_folder_advice schema を catalog に登録する #1418 absorption・catalog false-green 対策・V2 schema const 化・V1/V2 selector 分離・.claude/tmp/** advisory 拡張・Runtime Verification Applicability(decision: immediate)を含む全面書き換えを実施。deterministic review: needs-fix(AC11 VC が preflight allowlist 違反)
    2. iteration 2: AC11 の VC を preflight allowlist 準拠形式(uv run --locked pytest ... -v、SKIP は pytest.skip())へ修正。deterministic review: approve。Step 2.5 semantic design review で blocker 検出(AC11 の SKIP 表現が docs/dev/runtime-verification-policy.md の exit code 77 SKIP 規約を満たさず、実行環境欠如時に test-runner から PASS と誤分類されうる)
    3. iteration 3: AC11 を「pytest suite 本体 + 非pytest-collected な exit-code 変換 wrapper(既存 scripts/agent-ops/tests/run_runtime_verification_ac18.py と同一パターン)」の2ファイル構成へ再設計し、# preflight-scope: runtime_only annotation で VC preflight allowlist の対象外とした。deterministic review: approve。Step 2.5 semantic design review(再実行): approve(low-severity warning 1件: AC11 対象ファイルが ## In Scope に明示列挙されていない — non-blocking、実装をブロックしない)

    Issue Body の主要 semantic delta

    • 実装: repo_temp_folder_advice schema を catalog に登録する #1418 absorption: OPEN Issue 実装: repo_temp_folder_advice schema を catalog に登録する #1418(repo_temp_folder_advice/v1 catalog/governance 登録、未着手)を 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 に吸収。単一 PR で V1+V2 両方の catalog/governance 登録を行う設計に変更。実装: repo_temp_folder_advice schema を catalog に登録する #1418 は本 Issue の PR マージ後、canonical superseded decision(scope-rollup / post-merge-cleanup 経路)で処理する方針を明記(現時点では 実装: repo_temp_folder_advice schema を catalog に登録する #1418 は close していない — 実装前の superseded 確定は時期尚早と判断)
    • catalog false-green 対策: schemas/tests/test_catalog.py を Allowed Paths に追加。EXPECTED_ENTRY_COUNT(現状 25、実測確認済み)を実装時点の実エントリ数で更新する契約に変更(anchor 由来の数値を盲目的に転記しない旨を明記)
    • V2 schema 契約明確化: approved_write_roots / deprecated_legacy_roots を enum ではなく type: array + const: [...] で instance 全体を固定する設計に修正
    • V1/V2 selector 分離: --schema-version {v1,v2} を producer に追加。無指定/明示v1は既存出力を維持、live hookのみ明示的にv2を選択
    • .claude/tmp/** advisory 拡張: V2 live mode でのみ write を deprecated_legacy_root_write として advisory 対象化。read/scan/report/delete は非対象のまま維持。enforcement(block: true / permission deny・ask)は追加しない契約を明記
    • AC11 動作検証: decision: immediate(.claude/hooks/** handler logic 変更が extension-surface risk-trigger rule hook-lifecycle-matcher-or-handler-change に該当)。live hookのSKIP/PASS/FAIL・permissionDecision不在・additionalContext一致を実プロセスで検証する契約とし、exit code 77 SKIP 規約に準拠する2ファイル構成(pytest suite + wrapper)を明記

    Verification Evidence

    • contract_readiness_check.py --mode preflight-static: 各 iteration で STATUS: go を確認してから rewrite を確定
    • run_root_review_pipeline.py produce(deterministic review): 最終 iteration で verdict: approve / canonical_step2_route: step_2_5 / blocking_issues: []
    • Step 2.5 semantic design review(issue-design-reviewer SubAgent、2回実行): 最終 assessment: findings(severity: low、requires_owner_choice: false)→ join_review_results.py で effective_verdict: approve
    • GitHub readback: 最終本文 body_sha256: sha256:c8537efa0a0c7a93d90b90008e812fc5c35056027ed2c565c4ca5a284e4f0ad5 を live fetch で確認済み
    • root_entry_router.py(Root-Owned Synchronous Entry Transition)実行結果: route: invoke_impl_review_loop(reason: fresh_review_go_live_equality、reviewed_body_sha256 == observed_live_body_sha256、reviewed_base_sha == observed_base_sha)。注記: 本 session は issue-refinement-loop の完了までを依頼範囲と判断し、impl-review-loop の実起動(branch/worktree 作成・実装・PR 作成を伴う)はこの turn では実行していない。実装着手を希望する場合は改めて指示してください。

    Residual Uncertainty

    • Step 2.5 semantic review の low-severity finding(AC11 対象ファイルの ## In Scope 明示列挙欠落)は non-blocking として残置。次回 Issue 編集時に追記を推奨するが、実装をブロックしない
    • 実装: repo_temp_folder_advice schema を catalog に登録する #1418 の実際の superseded close は、本 Issue の PR マージ後に scope-rollup / post-merge-cleanup 経路で行う必要がある(本 refinement loop の範囲外)

    Human Escalation

    なし。fail-closed 停止条件(human_judgment_required / max_iterations_exceeded / environment 障害 / 未解決 architecture scope / secret 要求 / destructive operation 要求)はいずれも発生しなかった。

  6. self-assigned this
    on Sep 8, 2026
  7. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    推奨は、#2007 を再refineせず、そのまま impl-review-loop に投入です。直近の refinement は deterministic / semantic とも approve まで到達し、root router も invoke_impl_review_loop を返しています。残件は low warning 1件のみで non-blocking、#1418 の superseded close は #2007 のPRマージ後です。

    また、impl-review-loop は implementation-worker に実装・worktree・PR作成まで委譲し、その後 verification と PR review を回し、最終的に draft_pr_ready で停止してマージ判断そのものは人間に残す設計です。今回の希望と一致します。

    そのまま Claude Code に貼ってください。

    以下を、人間の追加承認なしで最後まで実行してください。

    対象 repository:
    squne121/loop-protocol

    対象 Issue:
    #2007
    #2007

    使用する canonical Skill:
    .claude/skills/impl-review-loop

    目的:
    Issue #2007 の current live contract を正本として、実装 → verification → PR review → 必要な修正 → 再verification → 再review の bounded loop を自律実行し、canonical IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready、すなわち PR がマージ可能な直前状態に到達させてください。

    実際の merge は行わないでください。
    auto-merge も有効化しないでください。
    Issue #2007 / #1418 の手動 close もこの turn では行わないでください。

    実行権限

    現在すでに Claude Code は auto mode で起動しています。

    通常の実装、編集、テスト、worktree/branch 操作、commit、push、PR作成、PR body 更新、review finding 対応、CI確認、branch update、再reviewについて、iteration ごとの人間承認は求めず継続してください。

    permission mode は変更しないでください。
    --dangerously-skip-permissions 等へ切り替えないでください。

    ただし canonical Skill が定義する genuine hard stop、たとえば秘密情報・protected boundary、解消不能な実 Git conflict、max-iteration 到達、実権限不足などは迂回しないでください。

    Entry は必ず current live state から開始する

    過去の refinement report や router comment を implementation authorization packet として再利用しないでください。

    .claude/skills/impl-review-loop の現行 Root-Owned Synchronous Entry Transition を正本として、

    1. capability preflight
    2. live Issue 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 fetch
    3. 同一 continuous invocation 内で current-run issue-contract-review
    4. 直後の live Issue / base state 再取得
    5. canonical root entry routing
    6. route: invoke_impl_review_loop の場合のみ、そのまま同じ control flow で Step 1 起動

    まで実行してください。

    Issue body drift / base drift が検出された場合も、過去の approved comment を根拠に強行せず、canonical rerun/reconciliation route に従って fresh review してください。

    一方、古い snapshot、ledger、artifact、過去 comment の freshness 不足だけを理由に不要な human escalation を発生させないでください。

    現在までの context

    直近の issue-refinement-loop は #2007 について approved で終了しています。

    termination report:
    #2007 (comment)

    これは必要なら agent_report_comment_url 相当の structured agent report として参照してください。human-context と誤分類しないでください。

    その report 時点では、

    という状態です。

    ただし、これらは current-run live review を省略する authorization ではありません。

    実装方針

    Issue #2007 の 現在の live body にある In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Allowed Paths / Runtime Verification Applicability を literal contract として使用してください。

    特に以下を落とさないでください。

    • REPO_TEMP_FOLDER_ADVICE_V2 schema を追加する
    • approved_write_roots は固定 array ["tmp/"]
    • deprecated_legacy_roots は固定 array [".claude/tmp/"]
    • JSON Schema 上は array instance 全体を const で固定する
    • V1 schema / V1 emit path は維持する
    • producer 無指定および --schema-version v1 は既存 V1 output compatibility を維持する
    • live Claude Code hook は明示的に V2 を選択する
    • .claude/tmp/** への write は V2 non-blocking advisory 対象にする
    • .claude/tmp/** の read / scan / report / delete は妨げない
    • block: true、permissionDecision: deny/ask 等の enforcement を追加しない
    • outer hook envelope が通常の Claude Code permission flow を変更しないことを runtime verification する
    • 実装: repo_temp_folder_advice schema を catalog に登録する #1418 から吸収した repo_temp_folder_advice/v1 と、新規 repo_temp_folder_advice/v2 の両方を catalog/governance に登録する
    • schemas/tests/test_catalog.py の expected count は Issue 起票時の数値を盲目的に使わず、implementation 時点の live catalog entry 数から算出する
    • marker / classifier の legacy .claude/tmp/ read/scan recognition は壊さない
    • 不要な dual-reader infrastructure、security harness、blocking enforcement を増設しない

    個人趣味開発であるため、品質・実用性を優先しつつ、Issue の AC を超える過剰な security/harness machinery は追加しないでください。

    外部仕様

    実装判断に外部仕様が関係する箇所は、必要に応じて SubAgent / web research lane を使って current official specification を確認してください。

    特に、

    • Claude Code PreToolUse hook の additionalContext
    • hookSpecificOutput.permissionDecision
    • exit 0 + decisionなしの場合の通常 permission flow
    • JSON Schema Draft 2020-12 の const / enum

    について current official docs と矛盾しないことを確認してください。

    ただし外部調査自体を大規模な別プロジェクトにせず、#2007 の implementation decision に必要な範囲に限定してください。

    SubAgent delegation

    canonical impl-review-loop の責務分離を維持してください。

    Step 1

    implementation-worker SubAgent を起動し、
    .claude/skills/implement-issue
    を使用して implementation、worktree、branch、commit、push、PR作成まで委譲してください。

    Step 2

    test-runner SubAgent に current candidate HEAD の verification を委譲してください。

    Issue に記載された literal Verification Commands を実行し、AC単位の evidence を取得してください。
    runtime verification AC11 の PASS / FAIL / SKIP semantics、特に canonical exit 77 SKIP 規約を維持してください。

    Step 4

    current-head gate を通過した場合のみ pr-reviewer SubAgent を起動し、canonical PR review を実施してください。

    Completion synchronization

    起動した SubAgent は必ず作業完了まで待ってください。

    Agent/Task の launch 成功だけを completion とみなして次の Step に進まないでください。

    各 Step で、

    • child task の canonical completion を確認する
    • 完了結果を回収する
    • schema を parse / validate する
    • current HEAD / Issue body / verification binding が stale でないことを確認する
    • その後にだけ次の routing judgment を行う

    という順序を守ってください。

    同一 iteration で未完了 SubAgent を残したまま Step 5 や最終報告へ進まないでください。

    最終終了時には、今回起動した全 SubAgent / Task が completed または canonical terminal state になっており、未回収 task が 0 件であることを確認してください。

    Review loop

    pr-reviewer が REQUEST_CHANGES を返した場合、人間へ確認せず、その blockers を canonical fix_delta として次の implementation iteration に渡してください。

    修正後は current HEAD に対して verification と PR review を必要な範囲で再実行してください。

    以下も canonical routing に従って自動処理してください。

    • stale reviewed head → current head で re-review
    • base BEHIND → canonical update_branch worker action → verification → re-review
    • main/base drift → scope-clean reconciliation
    • body-only PR hygiene finding → canonical mechanical worker action または次 iteration
    • transient mergeability UNKNOWN → bounded retry / current-head再評価

    reviewer の自己申告だけで human escalation しないでください。
    canonical routing function と live GitHub state を正本にしてください。

    max_iterations は canonical default の 3 を使用してください。
    3 iteration 内で収束できる限り、人間承認を求めず継続してください。

    PR

    既存PRが current live state で見つかった場合は、duplicate PR を作らず canonical ownership / worktree identity を確認して再利用してください。

    存在しない場合は canonical implement-issue → open-pr lane で1本だけ作成してください。

    PR body は Issue #2007 を正しくリンクし、canonical closing-keyword policy が要求する場合は Closes #2007 を含めてください。

    #1418 は #2007 に吸収された scope ですが、実際の superseded close は post-merge cleanup 側の責務なので、このPRから先行して手動 close しないでください。必要なら Refs #1418 等、canonical policy に沿った non-closing reference にしてください。

    終了条件

    以下すべてが成立するまで継続してください。

    • Issue 実装: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2007 の current AC が実装済み
    • Allowed Paths gate が pass
    • literal Verification Commands が canonical adjudication 上 blocking false
    • runtime verification applicable AC が規約どおり PASS、または規約上正当な SKIP として扱われている
    • required CI / current-head checks が必要な状態まで確認済み
    • pr-reviewer が current HEAD に対して APPROVE
    • reviewer blockers が空
    • live mergeability が canonical approvable state
    • stale review / stale head / stale Issue body がない
    • unresolved actionable review finding がない
    • 起動した全 SubAgent の完了結果を回収済み
    • IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready

    ここまで到達したら 停止してください。

    git merge / GitHub merge API / auto-merge は実行しないでください。

    最終報告

    最後に簡潔に以下を報告してください。

    • final IMPL_REVIEW_LOOP_RESULT_V1
    • PR URL / PR number
    • branch / final head SHA
    • implementation iterations
    • verification summary
    • runtime verification AC11 の結果
    • CI / live mergeability
    • pr-reviewer final verdict
    • unresolved blockers / warnings
    • 実装: repo_temp_folder_advice schema を catalog に登録する #1418 post-merge follow-up が残っていること
    • unfinished SubAgent task count(0 であること)
    • human escalation の有無

    通常の loop で解決可能な finding がある限り、途中経過を人間への質問で止めず、自律的に処理してください。

    特に重要なのは、過去の invoke_impl_review_loop コメントを認可証として使わず、現在の Skill が要求する fresh synchronous entry transition を実行させる点です。現行 Skill は SubAgent への実装委譲と完了回収を前提にしているので、明示的な「全SubAgent完了待ち」も上乗せしています。

  8. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  9. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-08T12:33:59Z)

    • PR: feat: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2581
    • Worktree: .claude/worktrees/issue-2007-repo-temp-folder-advice-v2
    • Branch: worktree-issue-2007-repo-temp-folder-advice-v2
    • Verification: pnpm typecheck/lint/test/build 4/4 PASS、対象 pytest suite(161 tests, hook/producer/catalog/classifier regression)PASS、AC11 runtime verification genuine PASS (6/6)
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  10. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-08T13:10:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2581"
      head_sha: "9fd708484836481d829959651a16ea42a6e86e6c"
      issue_number: 2007
      termination_reason: approved
      merge_ready: false
      iteration: 2
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "issue-1418-superseded-close-post-merge"
          source_url: "https://github.com/squne121/loop-protocol/issues/2007"
          source_note_id: "issue-2007-notes-for-reviewer"
          summary: "#1418 は #2007 に scope absorption 済み。#2007 の PR #2581 マージ後、post-merge-cleanup の canonical superseded decision 経路で #1418 を superseded close する(今回の turn では close しない、ユーザー指示どおり)。"
  11. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-08T14:05:00Z)

    指定レビューコメントの Finding 対応

    • Finding 1 [BLOCKER]: 解消。.claude/tmp/** Bash-write classifier を destination-aware narrow helper(_detect_bash_legacy_root_write 系)に置き換え、V1 _match_command() は無変更。false-negative(cat >, sed -i, compound &&)と false-positive(cp source-only, echo/printf/git status)を両方修正。10 fixture(positive 5 / negative 5)で境界を固定。
    • Finding 2 [MEDIUM]: 解消。runtime smoke test の claude CLI 存在チェックを削除し、実態(hook process 起動のみ、Claude CLI 自体は起動しない)に即した wording へ修正。AC11 は genuine PASS(6 passed, 0 skipped)。
    • Finding 3 [MEDIUM]: 解消。V1 CLI subprocess stdout の byte-level golden regression test を追加(dict equality ではなく実 serialized bytes 比較)。
    • Finding 4: 見送り。fresh pr-reviewer が現行 diff で merge blocker に格上げしなかったため未実装のまま。
    • Finding 5(ci-verdict-summary harness false-red): feat: REPO_TEMP_FOLDER_ADVICE_V2 schema と write-root/legacy-root 分離を導入する #2581 のスコープに混ぜず。別途 follow-up が必要。
    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2581"
      head_sha: "4e25fbeba1caefad5ae4d35e1536772bc5e72d56"
      issue_number: 2007
      termination_reason: approved
      merge_ready: true
      iteration: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions