Skip to content

実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2744

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: "v1"
issue_kind: implementation
parent_issue: "none"
goal_ref: "#2570 AC8"
change_kind: fix

Parent Issue

なし(単独改善。関連: #2570 で発見、#2568 は runtime-smoke isolation の実装元、PR #2708 が既に
task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() を canonical entrypoint として
実装済み)

Parent Goal Ref

該当なし(Parent Issue なし)

Current Validated Scope

該当なし(Parent Issue なし)

Remaining Parent Gaps

該当なし(Parent Issue なし)

Outcome

scripts/task-context/task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() を、
Task Context 自身の runtime 検証における唯一の canonical orchestration entrypoint として明文化・
回帰保護する設計変更 PR を作成する。

現状調査(2026-09-24 時点の repository state)で確認済みの事実として、orchestrate_runtime_smoke() は
既に子 generic runner(scripts/agent-ops/run_worktree_agent_runtime_smoke.py)へ、常に
--task-context-scope runtime_smoke と run-scoped isolated --task-context-state-root <isolated-root>
の両方を argv でハードコード的に渡している(#2568 / PR #2708 REQUEST_CHANGES fix_delta item 2 で導入済み)。
また generic runner 自身は --task-context-scope / --task-context-state-root を一切解釈せず、
両方 未指定(None/None)のときは子プロセス env を変更しない(_task_context_env_pairs(None, None) == [])。
この責務分離(generic runner = transport、Task Context semantics = verifier)は #2568/PR #2708 で
意図的に導入されたものであり、本 Issue ではこの境界を変更しない。

本 Issue が実際に発見した事故(#2570 AC8 検証時に production canonical Task Context DB へ余分な行が
書き込まれた件、Issue #2569 に紐づく)は、generic runner のデフォルト挙動が危険だったからではなく、
Task Context の acceptance/runtime-verification 手順が canonical entrypoint
(orchestrate_runtime_smoke()) を経由せず、generic runner を直接 unscoped で起動したこと
が原因である
(Issue #2570 acceptance comment
#2570 (comment) および本 Issue の
trusted anchor comment
#2744 (comment) で確認済み)。

したがって本 Issue の対応は、caller 側の canonical-route enforcement(呼び出し経路の強制)と
misuse-prevention documentation、および対応する deterministic/live 回帰検証の追加に限定する。
generic runner 側の default behavior 変更(fail-closed 化等)は採用しない。

完了条件は、該当 PR がマージされ、以下が満たされることとする。

  1. orchestrate_runtime_smoke() が常に scope/root pair を子 generic runner へ渡すことを、deterministic
    な回帰テストで検証できる。
  2. disposable な shadow canonical root 上での live runtime 実行によって、synthetic/runtime-hook writes
    が isolated runtime-smoke 側にのみ入り、shadow canonical 側へ想定外の mutation が入らないことを
    確認できる。
  3. .claude/skills/worktree-agent-runtime-smoke/SKILL.md に、Task Context 自身を検証する場合は
    generic runner を direct unscoped で呼ばず canonical entrypoint を使うという normative MUST が
    明記されている。

Runtime Verification Applicability

  • decision: immediate
  • reason: 本 Issue の中心的な検証対象は、canonical entrypoint 経由の runtime-smoke 実行が実際に
    production canonical Task Context DB を汚染しないことであり、静的な文字列/構造検証だけでは
    証明できない。disposable な shadow canonical state root を用いた実行時 smoke 実行によって
    isolation が有効であることを確認する必要がある(docs/dev/runtime-verification-policy.md の
    SKIP 規約・証跡保存・Stop Condition 連動に従う)。
applicable_acs:
  - AC2
execution_environment: >
  ローカル worktree 上、実 claude CLI が利用可能な環境。一時ディレクトリへ XDG_STATE_HOME を
  設定した disposable shadow canonical state root と、runtime-smoke 用の run-scoped isolated
  state root の 2 つを用意し、本物の ~/.local/state/loop-protocol/... には一切触れない。
skip_conditions: >
  claude CLI が実行環境に存在しない、または起動権限がない場合は SKIP(exit code 77、stdout に
  SKIP: プレフィックス)とし、docs/dev/runtime-verification-policy.md の SKIP 規約に従う。
  --safe-mode / --restricted 等で project hooks 自体を無効化して SKIP・PASS を偽装しない
  (Task Context hooks は production 同様に動作させ、state のみを隔離する)。
fallback_policy: >
  fallback 経由(例: _*_fallback: true を含む結果)の「成功」は FAIL として扱う。SKIP を PASS と
  誤認しない。
artifact_requirements: >
  実行前後の shadow canonical DB における該当 4 テーブル(execution_runs / events /
  runtime_locations / projection_outbox)の row identity/content delta、および isolated state
  root 側に書き込まれた該当行を、docs/dev/runtime-verification-policy.md の証跡フォーマットに
  従って PR に添付する。

In Scope

  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md の該当記述を、Task Context 自身の runtime
    検証では generic runner を direct unscoped で呼ばず、必ず canonical entrypoint
    (task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke()) を経由することを
    normative MUST として明記する形に更新する。
  • 新規ファイル tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py に、
    orchestrate_runtime_smoke() が子 generic runner 呼び出し argv へ常に
    --task-context-scope runtime_smoke と run-scoped isolated --task-context-state-root を渡すことを
    検証する deterministic な回帰テストを追加する(invoke_generic_runner 相当の呼び出しを monkeypatch
    し、実 subprocess を起動せず argv を捕捉する形でよい。tests/task-context/conftest.py の既存 fixture
    を再利用してよい)。既存 tests/task-context/test_runtime_smoke_verifier.py 自体は変更不要。
  • 新規ファイル tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py に、
    disposable な shadow canonical root(一時 XDG_STATE_HOME)+ runtime-smoke 用 isolated state root
    を用いた live runtime 検証テストを追加する。synthetic/runtime-hook writes が isolated 側にのみ入り、
    shadow canonical 側の該当 4 テーブルへ想定外の mutation が入らないことを、table row count だけでなく
    該当行の identity/content delta 比較で検証する。
  • 上記テスト容易性のために必要な最小限の範囲で
    scripts/task-context/task_context_runtime_smoke_verifier.py のコメント・docstring・(必要なら)
    内部シームを調整する。orchestrate_runtime_smoke() の既存の argv 構築ロジック・責務境界
    (実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568/PR feat: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2708)自体は変更しないことを原則とするが、caller が渡す runner_argv_extra に
    予約済みの --task-context-scope / --task-context-state-root と同名のオプションが含まれた場合に
    実効値(子プロセスが実際に解釈する値)が上書きされてしまう構造上の欠陥については、
    Task Context 側(orchestrate_runtime_smoke() 自身)が所有する argv 構築の順序またはガードのみを
    狭く修正してよい。scripts/agent-ops/run_worktree_agent_runtime_smoke.py(generic runner)側の
    オプション解釈・デフォルト挙動は本修正でも変更しない(Out of Scope のまま維持する)。
  • 現行 AC1(production canonical DB の row count 比較)と、それを検証できていなかった VC
    (--help 実行、rg -n "既定" のみ)を、上記の deterministic / live 検証へ置き換える。

Out of Scope

Acceptance Criteria

  • AC1: 新規ファイル tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    に、orchestrate_runtime_smoke() が子 generic runner 呼び出し argv へ常に
    --task-context-scope runtime_smoke と run-scoped isolated
    --task-context-state-root <isolated-root> の両方を渡すことを検証する deterministic な回帰
    テストが存在し、pass する。tests/task-context/ ディレクトリ全体の既存テストも pass する。
    caller が runner_argv_extra に予約済みオプション名と同じ --task-context-scope /
    --task-context-state-root を重複指定しても、子プロセスが実際に解釈する実効値が
    canonical な予約値のまま保たれることを、argv 内の最初の出現位置だけでなく実効値ベースで
    検証する adversarial regression テストが存在し、pass する。
  • AC2: disposable な shadow canonical root(一時 XDG_STATE_HOME)上で orchestrate_runtime_smoke()
    を実際の real subprocess として実行したとき、synthetic/runtime-hook writes が runtime-smoke
    isolated state root 側にのみ着地し、shadow canonical 側の該当 4 テーブル
    (execution_runs / events / runtime_locations / projection_outbox)へ想定外の mutation が
    入らないことを、row count だけでなく該当行の identity/content delta 比較で確認できる。
    project hooks を --safe-mode / --restricted 等で無効化する設計は不可(hooks は production
    同様に動作させ、state のみを隔離する)。
  • AC3: .claude/skills/worktree-agent-runtime-smoke/SKILL.md に、Task Context 自身の runtime
    検証では generic runner を direct unscoped で呼ばず、必ず canonical entrypoint
    (task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke()) を経由することが
    normative MUST として明記されている。単に「既定」という文字列が存在するだけでは本 AC を
    満たさない(該当記述を deterministic に一意な文言で検証する)。

Verification Commands

# targeted: canonical carrier argv/env regression (new file, must not yet exist)
# AC1
# baseline-expect: fail
$ uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v
# full existing + new Task Context runtime-smoke regression suite
# AC1
# baseline-expect: pass
$ uv run pytest tests/task-context/ -v
# live runtime verification: disposable shadow canonical root + isolated runtime-smoke root
# AC2
# baseline-expect: fail
$ uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v
# documentation / misuse prevention: normative MUST presence
# AC3
# baseline-expect: fail
$ rg -nF "generic runner を直接 unscoped で呼ばず、必ず canonical entrypoint" .claude/skills/worktree-agent-runtime-smoke/SKILL.md

Allowed Paths

  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
  • scripts/task-context/task_context_runtime_smoke_verifier.py
  • tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
  • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py の --task-context-scope /
    --task-context-state-root の解釈・デフォルト挙動(optional・verbatim additive passthrough・
    None/None で env 不変)を変更する必要が生じた場合。その場合は generic runner 全 consumer への
    影響確認を伴う別 Issue とし、本 Issue では実装しない
  • live runtime 検証を行う場合は、必ず disposable な shadow canonical root(一時 XDG_STATE_HOME)を
    用意し、既存の稼働中 canonical DB(~/.local/state/loop-protocol/...)を直接汚染しない
  • 検証中に production canonical DB へ誤って書き込んでしまった場合は、直ちに作業を中断し、
    影響範囲(テーブル・行)を記録した上で人間に報告する
  • 本 Issue の Out of Scope に記載した「Issue 実装: Herdr cold restartでTask BindingとNative/Claude-GPT runtime flavorを自動復元する #2569 に紐づく余分な行のクリーンアップ」を無条件の
    自動 DELETE として実装しない
  • project hooks を --safe-mode / --restricted 等で無効化することで AC2 の live 検証を PASS させる
    実装にしない

Required Skills

なし

Required Design References

Delivery Rule

1 Issue = 1 PR を原則とする。worktree を切って作業し、Draft PR を既定とする。

Notes for Reviewer

Activity

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

    @squne121
    OwnerAuthor

    判定

    #2744 は REQUEST_CHANGES 相当です。 問題の観測自体は正しいですが、現在の Issue は「どの層で直すか」が未確定なままなのに、AC は一方の設計しか満たせない形になっています。さらに Verification Commands と Allowed Paths が実装方針と噛み合っていません。

    確認対象の main は cfa1cc9a166496d05402372ff0f7baa8bd764e05 で、#2744 には現時点でコメント・対応PRはありません。Issue #2744

    最も重要なのは、これは generic runtime-smoke runner の「危険な設計」が新たに発覚したというより、#2568 で既に用意した Task Context 専用の正規入口を #2570 が通らず、generic runner を直接 unscoped で起動したことで発生した事故だという点です。#2570 acceptance result

    敵対的レビュー結果

    優先度 | Finding | 問題 -- | -- | -- P0 | caller必須化とAC1が論理矛盾 | a) caller側規約だけ直しても「flags無しの generic runner 既定 invocation」は今までどおりcanonical DBへ行くので、現AC1を絶対に満たせない P0 | 修正責務を generic runner に寄せる根拠が弱い | #2568/PR #2708 は「generic runner = transport」「Task Context semantics = verifier」と意図的に分離済み P0 | AC1のVCが何も検証していない | --help はClaudeを起動せず、hookもDB writeも発生しないので、AC1が常に偽陽性PASSできる P0 | Allowed Pathsがどちらの実装案にも不足 | runner挙動変更なら既存carrier test変更が必要。caller修正ならcanonical verifierが必要。どちらも現在scope外 P1 | production DBの「行数比較」が検証oracleとして弱い | UPDATEやdelete+insertを見逃し、逆に並列operatorの正当な書き込みを誤検知する P1 | CLI flag省略とeffective unscopedを混同 | runnerはflags省略時に親process環境を継承するので、--task-context-*無し=必ずunscopedではない P1 | AC2も rg "既定" だけ | 文字「既定」が1個存在すればPASSでき、normative contractの内容を検証していない P1 | Runtime Verification契約が自己矛盾 | decision: immediate なのに実runtime VCがなく、動的ACにruntime-verification markerもない P2 | 設計判断を人間エスカレーションするStop Condition | a/bの選択こそIssue refinement段階で決めるべきで、実装中に作業を止める必要がない

    1. P0 — #2744 は原因レイヤーを取り違えている

    #2568 ではこの境界がかなり明確に設計されています。

    generic run_worktree_agent_runtime_smoke.py は --task-context-scope / --task-context-state-root を解釈せず、そのまま渡すだけです。両方省略なら従来どおり環境を変更しません。一方、Task Context側には task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() という 「ONE canonical Task Context orchestration entrypoint」 が既にあり、ここでは毎回、

    --task-context-scope runtime_smoke
    --task-context-state-root <run-scoped isolated root>

    を generic runner に渡します。

    #2568
    PR #2708
    current Task Context verifier

    実装では orchestrate_runtime_smoke() の runner argv に scope と state-root がハードコードされています。

    したがって今回の再発防止で最初に問うべきなのは、

    「なぜ #2570 の Task Context acceptance が、このcanonical entrypointではなくgeneric runnerを直接呼べたのか」

    です。

    ここを直さず generic runner の全 invocation を fail-closed にすると、原因ではなく共有基盤を変更することになります。


    2. Claude Code側は「想定どおり」に動いている

    ここは外部仕様でも確認できます。

    Claude Code は working directory の .claude/settings.json を project settings として読みます。また --settings は設定ファイル全体を置換するものではなく、指定したキーだけを上書きし、指定していないキーはproject settings側の値が残ります。Claude

    さらに hooks はsettings source間で置換ではなくマージされます。.claude/settings.json のproject hooksも実行対象です。Claude

    特に重要なのは claude -p です。公式仕様では print/SDK session はworkspace trust dialogを出さず、そのfolderをtrustedとして扱うため、repoにcommitされた .claude/settings.json のhookが動作します。Claude

    つまり現在の、

    generic runner
      ↓
    claude -p
      ↓
    project .claude/settings.json
      ↓
    SessionStart hook
      ↓
    Task Context
      ↓
    scope未指定なのでcanonical state root

    は upstream 的には自然な結果です。

    generic runnerのバグというより、Task Context verificationがisolated carrierを付けずgeneric laneへ入ったcaller contract violationです。


    3. P0 — 「aかbのどちらでもよい」は成立していない

    現在のOutcomeは、

    • a) caller側でscope必須
    • b) runner側fail-closed
    • または両方

    から実装者が選べる、としています。

    一方AC1は、

    --task-context-scope / --task-context-state-root を明示指定しない既定 invocation でもcanonical DBが変化しない

    です。

    aだけではこのACを満たせません。

    caller規約をいくら強化しても、人が直接、

    run_worktree_agent_runtime_smoke.py ...

    と実行した場合の挙動は変わらないからです。

    したがって Issue refinement で先に二択にしなければなりません。

    私なら今回の前提では aを選び、ACを変更します。

    理由はセキュリティではなく、generic runner の再利用性と検証忠実度です。


    4. generic runnerのdefault isolation化は、ワークフロー上の副作用が大きい

    このrunnerはTask Context専用ではなく、Agent persona、reviewer permission、provider route、Claude-GPT、skill invocationなど多数のruntime smokeから共有されています。

    現在のcarrier regression testも、

    _task_context_env_pairs(None, None) == []

    および「flags省略ならchild envを変えない」を明示的に保証しています。

    current carrier regression test

    ここを「未指定なら自動disposable root」にすると、無関係なruntime smokeまでTask Context的にはproduction runtimeと異なる環境になります。

    たとえば、

    statusLine
    current Task
    current Activity
    Binding
    projection
    SessionStart behavior

    が、通常operatorとは異なる状態になる可能性があります。

    これは安全になる代わりにruntime smokeの再現性を落とす変更です。

    また --allow-unscoped-canonical-write を全generic callerへ要求する案も、Task Contextを意識する必要のないconsumerに追加ceremonyを押し付けます。個人開発用途では費用対効果が悪いです。


    5. P0 — 現Verification CommandsではAC1を一切検証できない

    現在のAC1 VCは、

    uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --claude-adapter native \
      --help

    です。

    これはClaude runtimeを起動しません。

    したがって、

    SessionStart hook
    Task Context DB path resolution
    SQLite write
    canonical DB delta

    のどれも発生しません。

    実装が完全に壊れていても100% PASSできます。

    AC2の、

    rg -n "既定" .claude/skills/worktree-agent-runtime-smoke/SKILL.md

    も同様で、「既定」という日本語が1個書かれていればPASSです。

    さらにrepository自身のruntime verification policyは decision: immediate に対しruntime AC、実VC、evidence、SKIP/fallback handlingを要求しています。現在のIssueは自分が参照しているpolicyと整合していません。runtime verification policy


    6. P0 — Allowed Pathsも実装不能に近い

    runner defaultを変更するなら、少なくとも既存の

    test_run_worktree_agent_runtime_smoke_task_context_carrier.py

    を書き換えなければ、現在の「flags省略時はenv unchanged」というテスト契約と衝突します。

    しかし #2744 の Allowed Paths にはこのtestがありません。

    逆に私が推すcaller-owned fixなら、

    task_context_runtime_smoke_verifier.py

    と

    tests/task-context/test_runtime_smoke_verifier.py

    を改善・回帰検証したいところですが、こちらもscope外です。

    つまり現在のAllowed Pathsでは、

    aを選んでもbを選んでも、まともな回帰テストを追加しようとするとStop Conditionに入ります。

    これは実装前に直した方がよいです。


    7. P1 — 「production DBの行数」をoracleにしない方がいい

    AC1は4テーブルのrow countをbefore/after比較しています。

    これは二方向に弱いです。

    まず、

    UPDATE
    DELETE + INSERT
    同数行の置換

    ではrow countが変わらないのでmutationを見逃します。

    逆に実際のproduction DBでは、別の通常Claude operatorが同時に/clearやTask遷移を行っただけでrow countが変わり、#2744のrunが完全に無実でもFAILします。

    これは #2570 のレビューでも既に問題になった構図です。

    検証用production DBを用意すべき

    本物の ~/.local/state/... は触らず、たとえば一時的な XDG_STATE_HOME を使い、

    /tmp/issue-2744/xdg-state/
      loop-protocol/task-context/v1/<repo-key>/task-context.sqlite3

    を「canonical fallback先のshadow」として作る方がよいです。

    ここなら、

    • 本物のoperatorと競合しない
    • exact row/content deltaを取れる
    • current canonical fallback pathそのものを検証できる
    • cleanupも簡単

    です。

    新しいharness frameworkは要りません。


    8. --safe-mode / --restricted で逃げるのも不適切

    Claude Codeには現在、eval harness向けの --restricted があり、project/user settingsを読み込まない実行ができます。また --safe-mode はhooksなどのcustomizationを無効化します。Claude

    しかし今回これを使うべきではありません。

    #2568の目的は、

    candidate project Task Context hooksをfresh Claude runtimeで実際に動かしながら、stateだけ隔離する

    ことだからです。

    hooks自体を消してcanonical writeがなくなっても、検証対象を消しているだけです。

    ここは現行設計の

    project hooks: production同様
    state root: run-scoped isolation

    を維持するのが正しいです。


    推奨する #2744 の設計変更

    今回の「個人趣味開発・ワークフローを止めない」という前提なら、私は generic runnerのdefault behaviorを変更しません。

    次の契約へreframeするのが最も小さく、既存設計にも合います。

    1. Task Context runtime verificationは task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() を唯一のcanonical entrypointとする。
    2. worktree-agent-runtime-smoke/SKILL.md には、Task Context自身を検証する場合にgeneric runnerを直接unscopedで呼ばず、canonical verifierを使用することをMUSTで明記する。
    3. generic runnerのNone/None → env unchanged契約は維持する。Task Context semanticをgeneric runnerへ逆流させない。
    4. tests/task-context/test_runtime_smoke_verifier.py で、canonical entrypointが必ずscope/root pairをchildへ渡すことを回帰検証する。
    5. live VCはdisposableなshadow canonical root + isolated runtime-smoke rootを使用し、synthetic stateがisolated側へ入ることと、canonical側が 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568 で許されたdelta以外変化しないことを確認する。
    6. #2570で起きたようなTask Context acceptanceからgeneric runnerへのdirect unscoped invocationを、document/procedure regressionとして禁止する。

    その場合、#2744のAC1も、

    「flags無しのgeneric runnerは絶対canonicalへ書かない」

    ではなく、

    「canonical Task Context runtime-smoke entrypointから起動されるchildは、常にexplicit runtime_smoke scope + run-scoped state rootを持ち、synthetic/runtime hook writesをproduction canonical DBへ送らない」

    に変えるべきです。

    これなら #2568/PR #2708 の責務境界を壊さず、今回実際に起きた誤用経路を閉じられます。

    逆に、どうしても 「generic runnerを直接叩いても絶対canonicalへ書かせたくない」 をOutcomeにするなら、a) caller必須化は選択肢から削除し、b) runner-level default isolationを明示決定すべきです。その場合は既存carrier testsとgeneric runner全consumerへの影響確認をscopeに含める必要があります。

    結論

    #2744で直す価値がある問題そのものは実在します。ただ、現在のIssueは 「Task Context verificationのcaller bug」を「generic harnessのdefault bug」として扱いかけているのが最大の問題です。

    このまま実装へ進むより、まず #2744 を caller-owned canonical route固定へrefinementするのが、品質と日常の開発速度の両方に最も合います。

    ## 判定

    #2744 は REQUEST_CHANGES 相当です。 問題の観測自体は正しいですが、現在の Issue は「どの層で直すか」が未確定なままなのに、AC は一方の設計しか満たせない形になっています。さらに Verification Commands と Allowed Paths が実装方針と噛み合っていません。

    確認対象の main は cfa1cc9a166496d05402372ff0f7baa8bd764e05 で、#2744 には現時点でコメント・対応PRはありません。[Issue #2744](https://github.com/squne121/loop-protocol/issues/2744?utm_source=chatgpt.com)

    最も重要なのは、これは generic runtime-smoke runner の「危険な設計」が新たに発覚したというより、#2568 で既に用意した Task Context 専用の正規入口を #2570 が通らず、generic runner を直接 unscoped で起動したことで発生した事故だという点です。[#2570 acceptance result](#2570)

    敵対的レビュー結果

    優先度 Finding 問題
    P0 caller必須化とAC1が論理矛盾 a) caller側規約だけ直しても「flags無しの generic runner 既定 invocation」は今までどおりcanonical DBへ行くので、現AC1を絶対に満たせない
    P0 修正責務を generic runner に寄せる根拠が弱い #2568/PR #2708 は「generic runner = transport」「Task Context semantics = verifier」と意図的に分離済み
    P0 AC1のVCが何も検証していない --help はClaudeを起動せず、hookもDB writeも発生しないので、AC1が常に偽陽性PASSできる
    P0 Allowed Pathsがどちらの実装案にも不足 runner挙動変更なら既存carrier test変更が必要。caller修正ならcanonical verifierが必要。どちらも現在scope外
    P1 production DBの「行数比較」が検証oracleとして弱い UPDATEやdelete+insertを見逃し、逆に並列operatorの正当な書き込みを誤検知する
    P1 CLI flag省略とeffective unscopedを混同 runnerはflags省略時に親process環境を継承するので、--task-context-*無し=必ずunscopedではない
    P1 AC2も rg "既定" だけ 文字「既定」が1個存在すればPASSでき、normative contractの内容を検証していない
    P1 Runtime Verification契約が自己矛盾 decision: immediate なのに実runtime VCがなく、動的ACにruntime-verification markerもない
    P2 設計判断を人間エスカレーションするStop Condition a/bの選択こそIssue refinement段階で決めるべきで、実装中に作業を止める必要がない

    1. P0 — #2744 は原因レイヤーを取り違えている

    #2568 ではこの境界がかなり明確に設計されています。

    generic run_worktree_agent_runtime_smoke.py は --task-context-scope / --task-context-state-root を解釈せず、そのまま渡すだけです。両方省略なら従来どおり環境を変更しません。一方、Task Context側には task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() という 「ONE canonical Task Context orchestration entrypoint」 が既にあり、ここでは毎回、

    --task-context-scope runtime_smoke
    --task-context-state-root <run-scoped isolated root>
    

    を generic runner に渡します。

    [#2568](https://github.com/squne121/loop-protocol/issues/2568?utm_source=chatgpt.com)
    [PR #2708](https://github.com/squne121/loop-protocol/pull/2708?utm_source=chatgpt.com)
    [current Task Context verifier](https://github.com/squne121/loop-protocol/blob/cfa1cc9a166496d05402372ff0f7baa8bd764e05/scripts/task-context/task_context_runtime_smoke_verifier.py?utm_source=chatgpt.com)

    実装では orchestrate_runtime_smoke() の runner argv に scope と state-root がハードコードされています。

    したがって今回の再発防止で最初に問うべきなのは、

    「なぜ #2570 の Task Context acceptance が、このcanonical entrypointではなくgeneric runnerを直接呼べたのか」

    です。

    ここを直さず generic runner の全 invocation を fail-closed にすると、原因ではなく共有基盤を変更することになります。


    2. Claude Code側は「想定どおり」に動いている

    ここは外部仕様でも確認できます。

    Claude Code は working directory の .claude/settings.json を project settings として読みます。また --settings は設定ファイル全体を置換するものではなく、指定したキーだけを上書きし、指定していないキーはproject settings側の値が残ります。:chatgpt-content-reference{index="5"}

    さらに hooks はsettings source間で置換ではなくマージされます。.claude/settings.json のproject hooksも実行対象です。:chatgpt-content-reference{index="6"}

    特に重要なのは claude -p です。公式仕様では print/SDK session はworkspace trust dialogを出さず、そのfolderをtrustedとして扱うため、repoにcommitされた .claude/settings.json のhookが動作します。:chatgpt-content-reference{index="7"}

    つまり現在の、

    generic runner
      ↓
    claude -p
      ↓
    project .claude/settings.json
      ↓
    SessionStart hook
      ↓
    Task Context
      ↓
    scope未指定なのでcanonical state root
    

    は upstream 的には自然な結果です。

    generic runnerのバグというより、Task Context verificationがisolated carrierを付けずgeneric laneへ入ったcaller contract violationです。


    3. P0 — 「aかbのどちらでもよい」は成立していない

    現在のOutcomeは、

    • a) caller側でscope必須
    • b) runner側fail-closed
    • または両方

    から実装者が選べる、としています。

    一方AC1は、

    --task-context-scope / --task-context-state-root を明示指定しない既定 invocation でもcanonical DBが変化しない

    です。

    aだけではこのACを満たせません。

    caller規約をいくら強化しても、人が直接、

    run_worktree_agent_runtime_smoke.py ...

    と実行した場合の挙動は変わらないからです。

    したがって Issue refinement で先に二択にしなければなりません。

    私なら今回の前提では aを選び、ACを変更します。

    理由はセキュリティではなく、generic runner の再利用性と検証忠実度です。


    4. generic runnerのdefault isolation化は、ワークフロー上の副作用が大きい

    このrunnerはTask Context専用ではなく、Agent persona、reviewer permission、provider route、Claude-GPT、skill invocationなど多数のruntime smokeから共有されています。

    現在のcarrier regression testも、

    _task_context_env_pairs(None, None) == []

    および「flags省略ならchild envを変えない」を明示的に保証しています。

    current carrier regression test

    ここを「未指定なら自動disposable root」にすると、無関係なruntime smokeまでTask Context的にはproduction runtimeと異なる環境になります。

    たとえば、

    statusLine
    current Task
    current Activity
    Binding
    projection
    SessionStart behavior
    

    が、通常operatorとは異なる状態になる可能性があります。

    これは安全になる代わりにruntime smokeの再現性を落とす変更です。

    また --allow-unscoped-canonical-write を全generic callerへ要求する案も、Task Contextを意識する必要のないconsumerに追加ceremonyを押し付けます。個人開発用途では費用対効果が悪いです。


    5. P0 — 現Verification CommandsではAC1を一切検証できない

    現在のAC1 VCは、

    uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --claude-adapter native \
      --help

    です。

    これはClaude runtimeを起動しません。

    したがって、

    SessionStart hook
    Task Context DB path resolution
    SQLite write
    canonical DB delta
    

    のどれも発生しません。

    実装が完全に壊れていても100% PASSできます。

    AC2の、

    rg -n "既定" .claude/skills/worktree-agent-runtime-smoke/SKILL.md

    も同様で、「既定」という日本語が1個書かれていればPASSです。

    さらにrepository自身のruntime verification policyは decision: immediate に対しruntime AC、実VC、evidence、SKIP/fallback handlingを要求しています。現在のIssueは自分が参照しているpolicyと整合していません。runtime verification policy


    6. P0 — Allowed Pathsも実装不能に近い

    runner defaultを変更するなら、少なくとも既存の

    test_run_worktree_agent_runtime_smoke_task_context_carrier.py

    を書き換えなければ、現在の「flags省略時はenv unchanged」というテスト契約と衝突します。

    しかし #2744 の Allowed Paths にはこのtestがありません。

    逆に私が推すcaller-owned fixなら、

    task_context_runtime_smoke_verifier.py

    と

    tests/task-context/test_runtime_smoke_verifier.py

    を改善・回帰検証したいところですが、こちらもscope外です。

    つまり現在のAllowed Pathsでは、

    aを選んでもbを選んでも、まともな回帰テストを追加しようとするとStop Conditionに入ります。

    これは実装前に直した方がよいです。


    7. P1 — 「production DBの行数」をoracleにしない方がいい

    AC1は4テーブルのrow countをbefore/after比較しています。

    これは二方向に弱いです。

    まず、

    UPDATE
    DELETE + INSERT
    同数行の置換
    

    ではrow countが変わらないのでmutationを見逃します。

    逆に実際のproduction DBでは、別の通常Claude operatorが同時に/clearやTask遷移を行っただけでrow countが変わり、#2744のrunが完全に無実でもFAILします。

    これは #2570 のレビューでも既に問題になった構図です。

    検証用production DBを用意すべき

    本物の ~/.local/state/... は触らず、たとえば一時的な XDG_STATE_HOME を使い、

    /tmp/issue-2744/xdg-state/
      loop-protocol/task-context/v1/<repo-key>/task-context.sqlite3
    

    を「canonical fallback先のshadow」として作る方がよいです。

    ここなら、

    • 本物のoperatorと競合しない
    • exact row/content deltaを取れる
    • current canonical fallback pathそのものを検証できる
    • cleanupも簡単

    です。

    新しいharness frameworkは要りません。


    8. --safe-mode / --restricted で逃げるのも不適切

    Claude Codeには現在、eval harness向けの --restricted があり、project/user settingsを読み込まない実行ができます。また --safe-mode はhooksなどのcustomizationを無効化します。:chatgpt-content-reference{index="10"}

    しかし今回これを使うべきではありません。

    #2568の目的は、

    candidate project Task Context hooksをfresh Claude runtimeで実際に動かしながら、stateだけ隔離する

    ことだからです。

    hooks自体を消してcanonical writeがなくなっても、検証対象を消しているだけです。

    ここは現行設計の

    project hooks: production同様
    state root: run-scoped isolation
    

    を維持するのが正しいです。


    推奨する #2744 の設計変更

    今回の「個人趣味開発・ワークフローを止めない」という前提なら、私は generic runnerのdefault behaviorを変更しません。

    次の契約へreframeするのが最も小さく、既存設計にも合います。

    1. Task Context runtime verificationは task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() を唯一のcanonical entrypointとする。
    2. worktree-agent-runtime-smoke/SKILL.md には、Task Context自身を検証する場合にgeneric runnerを直接unscopedで呼ばず、canonical verifierを使用することをMUSTで明記する。
    3. generic runnerのNone/None → env unchanged契約は維持する。Task Context semanticをgeneric runnerへ逆流させない。
    4. tests/task-context/test_runtime_smoke_verifier.py で、canonical entrypointが必ずscope/root pairをchildへ渡すことを回帰検証する。
    5. live VCはdisposableなshadow canonical root + isolated runtime-smoke rootを使用し、synthetic stateがisolated側へ入ることと、canonical側が 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568 で許されたdelta以外変化しないことを確認する。
    6. #2570で起きたようなTask Context acceptanceからgeneric runnerへのdirect unscoped invocationを、document/procedure regressionとして禁止する。

    その場合、#2744のAC1も、

    「flags無しのgeneric runnerは絶対canonicalへ書かない」

    ではなく、

    「canonical Task Context runtime-smoke entrypointから起動されるchildは、常にexplicit runtime_smoke scope + run-scoped state rootを持ち、synthetic/runtime hook writesをproduction canonical DBへ送らない」

    に変えるべきです。

    これなら #2568/PR #2708 の責務境界を壊さず、今回実際に起きた誤用経路を閉じられます。

    逆に、どうしても 「generic runnerを直接叩いても絶対canonicalへ書かせたくない」 をOutcomeにするなら、a) caller必須化は選択肢から削除し、b) runner-level default isolationを明示決定すべきです。その場合は既存carrier testsとgeneric runner全consumerへの影響確認をscopeに含める必要があります。

    結論

    #2744で直す価値がある問題そのものは実在します。ただ、現在のIssueは 「Task Context verificationのcaller bug」を「generic harnessのdefault bug」として扱いかけているのが最大の問題です。

    このまま実装へ進むより、まず #2744 を caller-owned canonical route固定へrefinementするのが、品質と日常の開発速度の両方に最も合います。

  3. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    確認した範囲では、対象コメント #issuecomment-5813327260 の指摘を trusted human-context anchor として issue-refinement-loop に投入し、Issue #2744 自体を caller-owned canonical route に再定義するのが適切です。

    現行 worktree-agent-runtime-smoke は --task-context-* を「解釈しない transport」と明記しており、task_context_runtime_smoke_verifier.py が Task Context semantics を所有しています。また issue-refinement-loop 自体は loop_iteration_approval_gate.default_required: false なので、通常の needs-fix → rewrite → re-review は人間承認なしで継続できます。

    推奨する refinement の着地点は次です。

    • generic runner の None/None → child env unchanged は維持する。
    • Task Context runtime verification の正規入口を task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() に固定する。
    • Issue 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2744 の「a) caller / b) runner のどちらでもよい」を廃止し、caller-owned 修正を確定設計にする。
    • AC1 を「flags なし generic runner が安全」から「canonical Task Context entrypoint が必ず runtime_smoke scope + run-scoped state root を付与し、production canonical DB に synthetic write を送らない」へ変更する。
    • --help と rg "既定" は VC として不十分なので廃止。canonical verifier の targeted regression test と disposable/shadow canonical root を使った live VC に置換する。
    • Allowed Paths に最低限 scripts/task-context/task_context_runtime_smoke_verifier.py と tests/task-context/test_runtime_smoke_verifier.py を追加する。generic runner 本体は調査で必要性が立証されない限り変更対象にしない。
    • 「a/b を実装者が判断できなければ人間レビュー」という Stop Condition は削除する。今回の anchor comment がその設計判断を既に解決しているためです。
    • refinement 中は codebase-investigator、必要なら web-researcher、rewrite の issue-editor を使い、起動した全 SubAgent の terminal completion を待ってから次工程へ進む。
    • 新規 Issue・PR作成やコード実装には進まず、今回は Issue contract が fresh review で approve になるところまで。

    そのまま対話中の Claude Code に渡すなら、以下を推奨します。

    Issue #2744 を、以下の human review anchor を起点として issue-refinement-loop で refinement してください。

    Target Issue:
    #2744

    Trusted human-context anchor:
    #2744 (comment)

    使用する skill:
    .claude/skills/issue-refinement-loop/SKILL.md

    目的:
    対象コメントの REQUEST_CHANGES findings を Issue #2744 の live contract に反映し、Issue 本文を implementation-ready な状態まで改善してください。

    実行方針

    • 既に auto mode で動作しているため、通常の refinement iteration ごとの人間承認は要求しないでください。
    • issue-refinement-loop の loop_iteration_approval_gate.default_required: false に従い、needs-fix → rewrite → fresh review を自律的に継続してください。
    • anchor comment は direct human context として扱い、canonical with_human_context route を使用してください。
    • max_iterations は 6 を上限として開始してください。
    • clarification や設計選択のために人間へ戻さず、anchor comment・current repository state・関連 Issue/PR の evidence から解決してください。
    • ただし skill が定義する genuine hard-stop、environment/integrity failure、権限不足、破壊的操作、secret/credential 要求については勝手に迂回しないでください。

    必須 SubAgent 方針

    issue-refinement-loop が要求する SubAgent を実際に使用してください。

    特に:

    1. Step 1 の codebase-investigator を使用して current repository state を独立調査する。
    2. external specification が disposition に必要な場合だけ web-researcher を使用する。
    3. Issue 本文 rewrite が必要な場合は canonical Step 4 の issue-editor を使用する。
    4. その他 planner が要求する SubAgent があれば、その契約どおり使用する。

    重要:

    • SubAgent を fire-and-forget しない。
    • 起動したすべての SubAgentについて terminal completion / canonical result を待つ。
    • completion を確認する前に次 Step へ進まない。
    • SubAgent の自己申告だけを root thread で再解釈して verdict を捏造しない。
    • nested delegation が各 agent contract で禁止されている場合はその制約を守る。
    • background task が残った状態で最終報告しない。

    今回の設計 disposition

    対象 anchor のレビュー結果を踏まえ、Issue #2744 は次の方向へ reframe してください。

    1. ownership

    generic:

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py

    は Task Context 専用 runner ではなく generic transport として維持してください。

    現行の:

    • --task-context-scope
    • --task-context-state-root

    について、

    • optional
    • verbatim additive passthrough
    • runner 自身は Task Context semantics を解釈しない
    • None/None なら child env を変更しない

    という #2568 / PR #2708 の責務境界を、今回の理由だけで変更しないでください。

    Task Context runtime verification の semantic ownership は:

    scripts/task-context/task_context_runtime_smoke_verifier.py

    側に維持してください。

    2. canonical entrypoint

    Task Context 自身を runtime verification する場合は、

    task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke()

    を唯一の canonical orchestration entrypoint とする contract にしてください。

    この canonical entrypoint は child generic runner に必ず:

    --task-context-scope runtime_smoke

    および run-scoped isolated:

    --task-context-state-root <isolated-root>

    を渡すものとしてください。

    Task Context acceptance / runtime verification procedure から generic runner を direct unscoped invocation する経路を禁止してください。

    3. 現 Issue の二択を解消

    現在の Issue にある:

    • a) caller 側必須化
    • b) runner fail-closed 化
    • または両方

    という未確定設計は削除してください。

    今回の refinement では caller-owned canonical-route enforcement を採用済み設計として固定してください。

    「a/b のどちらを採るか実装者が判断できなければ人間レビュー」という Stop Condition も削除してください。

    その設計判断は、この trusted human anchor によって既に解決済みです。

    Acceptance Criteria の修正

    現在の AC1:

    「task-context flags を指定しない generic runner の既定 invocation でも production canonical DB が変化しない」

    は caller-only design と論理的に両立しないため、その形のまま残さないでください。

    少なくとも以下の意味を acceptance contract にしてください。

    AC: canonical carrier

    canonical Task Context runtime-smoke entrypoint から起動された child runtime は常に:

    • effective scope = runtime_smoke
    • run-scoped isolated state root

    を持つこと。

    AC: production isolation

    canonical Task Context runtime verification が発生させる synthetic/runtime-hook writes が production canonical Task Context DB に流入しないこと。

    AC: deterministic regression

    tests/task-context/test_runtime_smoke_verifier.py 等で、canonical orchestration entrypoint が generic runner argv/env に scope/root pair を必ず渡すことを deterministic regression test で検証できること。

    AC: documentation / misuse prevention

    .claude/skills/worktree-agent-runtime-smoke/SKILL.md に、

    Task Context 自身を検証するときは generic runner を direct unscoped で呼ばず、canonical Task Context verifier を使う

    という normative MUST を明記すること。

    単に「既定」という文字列が存在することを AC にしないでください。

    Verification Commands の修正

    現状の:

    run_worktree_agent_runtime_smoke.py ... --help

    は runtime を起動せず DB write path も通らないため AC oracle として使用しないでください。

    また:

    rg -n "既定" ...

    だけで normative contract を PASS にしないでください。

    VC は current repository state を調査して具体化し、最低限:

    1. canonical verifier の targeted pytest
    2. relevant Task Context regression tests
    3. live runtime verification

    を組み込んでください。

    live VC では本物の:

    ~/.local/state/loop-protocol/...

    を検証対象として直接汚染しないでください。

    一時的な XDG_STATE_HOME 等を用いて shadow canonical root を作り、

    • canonical fallback 側
    • runtime-smoke isolated 側

    を完全に disposable な環境内で分離してください。

    単純な table row count だけを oracle にせず、必要に応じて relevant row identity/content delta を比較し、

    • synthetic/runtime-smoke writes が isolated 側へ入る
    • shadow canonical 側へ想定外 mutation が入らない

    ことを検証できる contract にしてください。

    --safe-mode / --restricted 等で project hooks 自体を無効化して PASS にする設計にはしないでください。
    検証対象の Task Context hooks は production 同様に動かし、state だけを isolation してください。

    Allowed Paths の再評価

    現在の Allowed Paths は採用する caller-owned design と一致していません。

    current repository を調査したうえで、少なくとも必要性を評価してください:

    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
    • scripts/task-context/task_context_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier.py
    • docs/dev/runtime-verification-policy.md(実際に contract/evidence 更新が必要な場合のみ)

    generic runner:

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py

    および carrier regression tests は、今回の caller-owned design で変更が不要なら Allowed Paths から外してください。

    「念のため」で scope を広げないでください。
    一方、実際の regression test を書くために必要な path は漏らさないでください。

    Related evidence

    少なくとも以下を current state で参照してください。

    過去コメントの prose より current repository state と current live Issue contract を優先してください。

    Scope discipline

    今回は Issue refinement のみです。

    follow-up candidate が見つかった場合も、今回の Issue contract に不可欠でなければ observation として記録するだけにしてください。

    Loop completion

    rewrite 後は必ず:

    1. live Issue body readback
    2. fresh preflight
    3. fresh Step 2 review
    4. applicable なら semantic design review
    5. needs-fix なら次 iteration
    6. terminal routing

    まで実行してください。

    一度 Issue 本文を書き換えただけで終了しないでください。

    fresh review が current live body に対して approve / implementation-ready 相当になるまで、自動 iteration を継続してください。

    max iteration 到達、canonical skill hard-stop、environment/integrity failure の場合だけ停止し、原因と残 blocker を正確に報告してください。単なる設計選択や reviewer feedback の適用について人間承認を要求しないでください。

    最終報告

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

    途中経過だけで終了せず、SubAgent completion と canonical loop termination まで完遂してください。

    このプロンプトでは、レビューコメントが問題視した最大点である「実装者に a/b を選ばせたまま、AC は b しか満たせない」という矛盾を最初から除去しています。これにより refinement-loop が同じ設計判断で human_judgment_required に戻る可能性も下げられます。

  4. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

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

    trusted anchor comment(OWNER、issuecomment-5813327260)の REQUEST_CHANGES 判定を反映し、Issue 本文を全面的に reframe しました。

    反映した主な設計変更

    • generic runner(scripts/agent-ops/run_worktree_agent_runtime_smoke.py)の --task-context-scope/--task-context-state-root は optional・verbatim additive passthrough のまま維持(実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568/PR feat: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2708 の責務境界を変更しない)。
    • scripts/task-context/task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() を Task Context 自己検証の唯一の canonical entrypoint として明文化・回帰保護する方針に固定(既に実装済みであることを codebase-investigator で確認)。
    • a) caller 必須化 / b) runner fail-closed 化 の二択と、それに伴う human review Stop Condition を撤去し、caller-owned canonical-route enforcement を採用済み設計として固定。
    • AC1(旧: row count 比較のみ)を、canonical carrier の deterministic regression / production isolation の live 検証 / SKILL.md への normative MUST 明記の3本立て(AC1〜AC3)へ置き換え。
    • 旧 VC(--help 実行、rg -n "既定")を、targeted pytest(新規専用テストファイル参照、baseline exit 4 パターン)+ 既存 regression suite + live 検証 + 一意な文言での doc 検証へ置き換え。
    • Runtime Verification Applicability に <!-- runtime-verification: true --> タグと applicable_acs/execution_environment/skip_conditions/fallback_policy/artifact_requirements を追加。
    • Allowed Paths を caller-owned 設計に合わせて更新(generic runner とその carrier test を除外し、task_context_runtime_smoke_verifier.py と新規2テストファイルを追加)。

    iteration 経過

    • iteration 1: 本文全面書き換え → deterministic checker needs-fix(VC preflight allowlist 違反: 既存ファイルへの -k 未存在名指定が exit 5 hard-block)
    • iteration 2: VC を新規専用テストファイル直接参照(exit 4 パターン)へ修正 → deterministic checker approve → Step 2.5 semantic design review で AC1 のファイル参照不整合(severity: high)を検出
    • iteration 3: AC1 のファイル参照を修正 → deterministic checker approve → Step 2.5 semantic design review assessment: clear(findings なし)

    使用 SubAgent

    • codebase-investigator(Step 1、current repository state 独立調査)
    • issue-editor ×3(Step 4 rewrite、iteration 1/2/3)
    • issue-design-reviewer ×2(Step 2.5 semantic design review、iteration 2/3 の live body に対して)

    全 SubAgent は terminal completion まで join 済みです。web-researcher は disposition に外部仕様の追加調査が不要だったため起動していません(anchor comment 自身が Claude Code hooks/settings の外部仕様引用を含んでいましたが、これは設計判断の根拠説明であり本 Issue の AC/VC/Allowed Paths の disposition 自体を左右しないため)。

    Scope discipline

    本サイクルは Issue refinement のみです。tracked file の実装変更・PR 作成・merge・auto-merge 設定・#2569 production DB への DELETE・新規 follow-up Issue の自動起票は一切行っていません。

    terminal status: approved

  5. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    現状では、そのまま impl-review-loop に移行するのが妥当です。Issue #2744 は refinement が 3 iteration で approved まで完了しており、caller-owned canonical-route enforcement、AC1〜AC3、Allowed Paths、live runtime verification の契約が確定しています。現時点の GitHub 検索では #2744 に対応する PR は見つかりませんでしたが、実行時には impl-review-loop 自身の Evidence-Based Landing Disposition を正本として再確認させるべきです。

    特に今回のポイントは、ユーザーのこの指示を branch publish / PR 作成・更新までの事前承認として扱わせることです。open-pr は publish: yes を要求するため、ここを明示しないと途中で不要な承認待ちになります。一方、merge / auto-merge は許可しないよう境界を固定します。

    また AC2 は通常の unit test とは違い、実 Claude runtime と project hooks を使う live verification です。production の canonical DB は触らず disposable XDG_STATE_HOME を使い、SKIP や fallback success を PASS にしないことを強調しています。

    以下を、そのまま現在 auto mode で起動中の Claude Code に渡す形を推奨します。

    Issue #2744 を対象に、.claude/skills/impl-review-loop/SKILL.md の canonical procedure に従って、実装 → 独立検証 → PR review → fix loop を自律実行し、merge 直前の draft_pr_ready / merge-ready 状態まで進めてください。

    Target Issue:
    #2744

    使用する skill:
    .claude/skills/impl-review-loop/SKILL.md

    Repository:
    squne121/loop-protocol

    目的

    Issue #2744 の live contract を実装し、Verification Commands と current-head PR review を通過させ、impl-review-loop の canonical terminal route が approved となるところまで進めてください。

    PR の merge 自体は実行しないでください。
    auto-merge も設定しないでください。

    それ以外の通常の実装・修正・push・PR 作成/更新・レビュー反映について、iteration ごとの人間承認は要求しないでください。

    Human authorization / publish authorization

    この root prompt 自体を、今回の Issue #2744 に限定した以下の明示的な human authorization として扱ってください。

    • canonical issue worktree / branch の作成
    • Allowed Paths 内の実装
    • commit
    • canonical branch への push / publish
    • open-pr skill への publish: yes
    • Draft PR の作成
    • 既存 PR がある場合の canonical resume / update
    • PR body の更新
    • impl-review-loop が必要とする review / result comment の投稿
    • REQUEST_CHANGES に対する修正 iteration
    • BEHIND 時の canonical update_branch action
    • skill の canonical procedure 上、merge-ready 判定に必要な Ready-for-review transition が存在する場合の実行

    これらについて追加の human approval を要求しないでください。

    ただし以下は authorization に含めません。

    Loop policy

    max_iterations: 6

    通常の

    Implementation → Verification → PR Review → Judgment

    を自律的に反復してください。

    以下だけを理由に人間へ戻らないでください。

    • reviewer の通常の REQUEST_CHANGES
    • test failure で Allowed Paths 内の修正が可能
    • contract snapshot / artifact の advisory warning
    • SubAgent の単なる human_review_required: true 自己申告
    • mergeability の一時的 UNKNOWN
    • PR が BEHIND
    • stale review/head で fresh verification/re-review が可能
    • CI の再評価で解決可能な状態

    impl-review-loop の canonical routing を優先し、

    • continue_loop → fix_delta を渡して次 iteration
    • route_to_update_branch → worker に update_branch を委譲し、その後 Verification + PR Review を再実行
    • route_stale_head_rereview → current head で再 review
    • route_scope_clean_reconciliation → canonical reconciliation を実行して resume

    としてください。

    Root-owned entry transition

    過去の refinement コメントや過去の approved report を Step 1 authorization として再利用しないでください。

    root/main thread が current run 内で canonical Root-Owned Synchronous Entry Transition を実行してください。

    すなわち current live state に対して、

    1. capability preflight
    2. live Issue fetch
    3. current-run issue-contract-review
    4. 直後の live Issue readback
    5. root entry routing
    6. invoke_impl_review_loop の場合のみ同じ control flow 内で Step 1

    まで進めてください。

    過去コメントは evidence / telemetry として参照して構いませんが、authorization packet として扱わないでください。

    Pre-Step-1 duplicate-dispatch gate

    worker dispatch、worktree 作成、新規 PR 作成より前に、必ず canonical Evidence-Based Landing Disposition を実行してください。

    build_intake_capsule.py --include-implementation-landed-evidence

    および current canonical producer/consumer を使用し、返された pre_step1_data_plane / disposition を自己解釈せず従ってください。

    • existing_pr_resume → 既存 PR を resume。重複 PR を作成しない
    • implementation_already_landed → worker / worktree / new PR を開始しない
    • already_satisfied → canonical recommendation を報告し、不要な PR を作らない
    • ordinary_dispatch_or_explicit_recovery → Step 1 へ
    • reconciliation_required → canonical reconciliation を優先

    外部からの単純な PR 検索結果だけを landing authority にしないでください。

    Issue #2744 の確定設計

    live Issue 本文を SSOT としてください。

    今回の設計 ownership は既に refinement 済みです。

    generic runner:

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py

    の以下の契約は変更しないでください。

    • --task-context-scope は optional
    • --task-context-state-root は optional
    • verbatim additive passthrough
    • generic runner 自身は Task Context semantics を解釈しない
    • None/None なら child environment を変更しない

    Task Context runtime verification の semantic ownership は:

    scripts/task-context/task_context_runtime_smoke_verifier.py

    に維持してください。

    Task Context 自己検証の唯一の canonical orchestration entrypoint は:

    task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke()

    です。

    この entrypoint が child generic runner に常に:

    --task-context-scope runtime_smoke

    と run-scoped isolated:

    --task-context-state-root <isolated-root>

    を渡す契約を回帰保護してください。

    generic runner の default behavior を fail-closed 化する方向へ scope を広げないでください。

    Allowed Paths

    live Issue 本文を最終正本としたうえで、現在の contract では変更を以下に限定してください。

    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
    • scripts/task-context/task_context_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    Allowed Paths 外の変更が必要になった場合は勝手に scope を拡大しないでください。

    特に以下は本 Issue では変更しないでください。

    Step 1 — implementation-worker

    canonical implementation-worker SubAgent を使用し、.claude/skills/implement-issue/SKILL.md を実行させてください。

    root thread 自身が implementation edit を代行しないでください。

    initial iteration と各 fix iteration で、実際の値を materialize した message を渡してください。

    少なくとも以下を bind してください。

    placeholder のまま child に渡さないでください。

    SubAgent completion — 必須

    SubAgent は fire-and-forget にしないでください。

    implementation-worker、test-runner、pr-reviewer、および loop 中に canonical procedure が起動するその他すべての SubAgentについて、Common Completion Protocol を厳守してください。

    各 SubAgent ごとに:

    1. canonical task name を保存する
    2. 必要なら wait_agent で activity を待つ
    3. child の final result を取得する
    4. list_agents で同じ canonical task の terminal state が completed であることを確認する
    5. final result と terminal completed の両方を確認してから次 Step へ進む

    以下を completion とみなさないでください。

    • spawn 成功だけ
    • mailbox update
    • timeout
    • intermediate progress
    • final result だけ
    • completed state だけ

    errored / interrupted / shutdown / not_found は成功扱いしないでください。

    background task / 未join SubAgent が残っている状態で最終報告しないでください。

    nested delegation が各 agent contract または Issue Stop Conditions に抵触する場合は行わないでください。

    Step 2 — independent Verification

    Step 1 の自己検証結果だけで PASS としないでください。

    必ず canonical test-runner SubAgent を新規 task として使用し、current PR head に対する独立 verification を実行してください。

    test-runner には live Issue の:

    • AC 全文
    • literal Verification Commands 全文
    • actual Issue number
    • actual PR number
    • current contract body SHA
    • current PR head SHA

    を materialize して渡してください。

    Verification Commands は live Issue 本文にある literal commands を改変・省略・代替しないでください。

    現在の主要 VC は以下です。実行時には必ず live Issue readback と照合してください。

    uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v

    uv run pytest tests/task-context/ -v

    uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v

    rg -nF "generic runner を直接 unscoped で呼ばず、必ず canonical entrypoint" .claude/skills/worktree-agent-runtime-smoke/SKILL.md

    test-runner completion 後、root は current PR head SHA と report head SHA、および literal command hashes を独立照合し、canonical VC_ADJUDICATION_RESULT_V1 を生成してください。

    blocking == false が current head に対して成立するまで Step 4 の pr-reviewer を起動しないでください。

    AC2 live runtime verification

    AC2 は特に厳密に扱ってください。

    本物の production canonical state:

    ~/.local/state/loop-protocol/...

    を検証 target として直接使用・mutation しないでください。

    一時ディレクトリの XDG_STATE_HOME 等を利用して disposable shadow canonical state root を作成し、その disposable environment 内で:

    • shadow canonical root
    • runtime-smoke 用 run-scoped isolated state root

    を分離してください。

    実 Claude CLI / real subprocess を使い、project hooks は production 同様に有効な状態で実行してください。

    以下で AC2 を見かけ上 PASS させないでください。

    • --safe-mode
    • --restricted
    • project hooks の無効化
    • synthetic-only mock への置換

    検証では該当 4 テーブル:

    • execution_runs
    • events
    • runtime_locations
    • projection_outbox

    について、row count だけでなく relevant row identity / content delta を比較してください。

    成功条件は少なくとも:

    • synthetic/runtime-hook writes が isolated runtime-smoke state 側に着地する
    • shadow canonical state 側へ想定外 mutation が入らない

    ことです。

    SKIP は PASS ではありません。

    claude CLI unavailable 等、Issue contract に定義された正当な SKIP condition の場合は exit 77 / SKIP: evidence を保持し、canonical adjudication で blocking として扱ってください。

    fallback path (_*_fallback: true 等) による「成功」も PASS にしないでください。

    production canonical DB への accidental write を検知した場合は即時停止し、対象 table / row evidence を保存して報告してください。自動 DELETE しないでください。

    Step 4 — current-head PR review

    Step 2 の current-head VC adjudication が nonblocking になった後でのみ、canonical pr-reviewer SubAgent を起動してください。

    spawn 直前に canonical current-head gate を再評価してください。

    以下のいずれかが stale / malformed なら pr-reviewer を起動せず Step 2 に戻してください。

    • current PR head SHA
    • live Issue body SHA
    • literal Verification Command hashes
    • persisted VC adjudication

    required CI は canonical wait_ci_checks.sh --required route で current head に対して評価してください。

    pr-reviewer の結果についても、final result + terminal completed の両方を確認してください。

    root/control-plane は reviewer が返す:

    • verdict
    • reviewed_head_sha
    • blockers
    • warnings

    のみを canonical reviewer convention として扱い、mergeability は root が live GitHub state から独立取得してください。

    REQUEST_CHANGES loop

    REQUEST_CHANGES は通常の loop continuation です。

    人間承認を求めず:

    1. blockers を exact fix_delta に変換
    2. iteration increment
    3. implementation-worker に再委譲
    4. SubAgent terminal completion を待つ
    5. current-head independent Verification
    6. current-head PR Review
    7. Step 5 routing

    を繰り返してください。

    レビュー blocker を root thread が直接編集して直さないでください。

    Mergeability

    APPROVE 単独では終了しないでください。

    current live:

    • mergeable == MERGEABLE
    • merge_state_status in {CLEAN, HAS_HOOKS}
    • blockers == []
    • current-head VC nonblocking

    を canonical routing で確認して approved に到達してください。

    BEHIND は conflict ではありません。
    canonical update_branch action を implementation-worker に委譲し、その後 Verification と PR Review を current head で再実行してください。

    stale reviewed head は human escalation にせず re-review してください。

    一時的な UNKNOWN は skill の bounded retry に従ってください。

    actual:

    • mergeable == CONFLICTING
    • merge_state_status == DIRTY

    のみ、canonical conflict hard-stop に従ってください。

    Human-stop boundary

    通常の loop iteration では人間承認を要求しないでください。

    ただし canonical skill / live Issue が要求する genuine hard stop は迂回しないでください。

    例:

    • actual Git conflict
    • secret-policy Decision Gate
    • protected path violation
    • Allowed Paths 外の変更が本当に必要
    • destructive operation が必要
    • formal pr-reviewer verdict HUMAN_REVIEW_REQUIRED
    • max_iterations exhaustion
    • production canonical DB accidental mutation
    • environment / integrity failure で canonical recovery 不能
    • permission failure で canonical operation が不可能

    単なる reviewer feedback や実装選択を hard stop に昇格させないでください。

    External research

    今回の Issue は current repository contract と既存 runtime behavior が中心なので、外部仕様調査は default では不要です。

    外部仕様が実装または review disposition に実際に必要になった場合だけ、impl-review-loop が定義する canonical external-research route を使用してください。

    不要なら LOOP_STATE.external_research_skip_basis に理由を記録してください。

    Scope discipline

    以下を禁止します。

    follow-up candidate を発見した場合は、current Issue contract に不可欠でない限り observation として残してください。

    Terminal target

    目標 terminal route:

    approved

    目標 output:

    IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready

    ただしこれは GitHub の Draft flag そのものとは別概念であることに注意してください。

    canonical skill が current PR を merge-ready にするための Ready-for-review transition を定義している場合は、その canonical route に従ってください。

    merge はしないでください。

    termination_reason: approved を立てる前に canonical AUTONOMY_POLICY_V1 validator を実際の終了 report に対して実行し、pass を確認してください。

    最終報告

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

    • Issue #2744 URL
    • PR URL / PR number
    • final branch
    • final head SHA
    • implementation iteration 数
    • Evidence-Based Landing Disposition
    • 起動した SubAgent 一覧
    • 各 SubAgent の canonical task name
    • 全 SubAgent が final result + terminal completed 済みであること
    • AC1 / AC2 / AC3 の final result
    • literal Verification Commands の結果
    • AC2 shadow canonical / isolated root evidence の要約
    • production canonical DB を mutation していないこと
    • Allowed Paths compliance
    • required CI result
    • final pr-reviewer verdict
    • final live mergeability
    • final route_loop_verdict_v2() route
    • IMPL_REVIEW_LOOP_RESULT_V1
    • unresolved blocker がある場合は exact reason
    • merge / auto-merge を実行していないこと

    途中の実装完了や PR 作成だけで終了せず、canonical Verification、PR Review、SubAgent join、Step 5 terminal routing まで完遂してください。

    参照した current state は Issue #2744、[refinement 完了報告](https://github.com/squne121/loop-protocol/issues/2744#issuecomment-5813790412)、および現行 [impl-review-loop](https://github.com/squne121/loop-protocol/blob/main/.claude/skills/impl-review-loop/SKILL.md) です。特に open-pr の publish: yes 承認ゲートを最初から解決している点が、今回の「承認不要でマージ直前まで」という意図に対して重要です。

  6. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-24T13:25:36Z)

  7. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-24T13:50:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2745"
      head_sha: "0294734d43717d818cd59d2ea9e12777e0d88b77"
      issue_number: 2744
      termination_reason: approved
      merge_ready: true
      iteration: 0
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "pr-2745-stale-scope-coverage-head-sha"
          source_url: "https://github.com/squne121/loop-protocol/pull/2745"
          source_note_id: "pr-reviewer-a44c81fad3d3ec546-warning-1"
          summary: "PR本文のIMPLEMENTATION_SCOPE_COVERAGE_V1.pr_head_shaが838e9d0e...(最終コンテンツコミット)を指しており、現head 0294734d...(main merge commit)と異なる。diff内容には影響しないadvisory self-report metadataのstaleさのみ。follow-up Issue化不要、note記録のみ。"
    
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-09-24T13:50:00Z"
      rollup_plan_ref:
        body_sha256: null
        generated_at: null
      decision: skipped
      executed_actions: []
      skipped_reason: "#1860 Owner Decision により automatic dispatch 対象外の任意 advisory diagnostic。本 loop 実行では手動起動しなかった。"
      candidates_reviewed: []
  8. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  9. squne121 commented on Sep 24, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

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