Skip to content

調査: scope_rollup.run exact executor を registry SSOT 経路(skill_runtime_exec 相当)へ統合すべきか検討する #1580

Open
0 of 1 issue completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "Issue #1547 review P1-5 follow-up: scope_rollup.run の canonical entrypoint と契約所有境界を決定する"
change_kind: research-only

Parent Issue

なし(単独調査)

Outcome

最新 main の再レビューに基づく integrate_sibling_profile の go 判断、implementation Issue #1601、固定 review base SHA、cutover 安全責務を記録し、依存 Issue がすべて解消されるまで実装開始を抑止する。

In Scope

Out of Scope

  • scope_rollup.run 統合コード、テスト、設定、documentation の実装。
  • GitHub inventory、pagination、planner、verifier、private invocation directory、domain result construction を outer executor へ吸収する generic engine refactor。
  • skill_runtime_exec.py 内の if command_id == "scope_rollup.run" のみの暫定分岐。
  • 実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601 の dependency Issue が未解消の間に同一 path の重複実装を開始すること。

Decision Record

SCOPE_ROLLUP_EXECUTOR_DECISION_V1:
  verdict: go
  decision: integrate_sibling_profile
  rationale: "canonical admission/supervision を skill_runtime_exec.py に一本化しつつ、GitHub inventory、pagination、planner/verifier、private artifact、domain result は specialized worker に隔離する。これにより独立 lane の contract drift を解消し、generic engine 化と単純分岐の双方を避ける。"
  observed_dependencies:
    registry_contract_issue:
      number: 1579
      current_state: CLOSED
      closing_pr: 1594
    overlapping_runtime_pr:
      number: 1572
      current_state: MERGED
      resolution_pr: 1572
    implementation_blockers:
      - number: 1593
        current_state: OPEN
      - number: 1595
        current_state: OPEN
      - number: 1565
        current_state: OPEN
      - number: 1573
        current_state: OPEN
  base_sha: "c0048fab6e5544c5b599cd0feb8f85571a9bd4b8"
  canonical_entrypoint: "uv run --locked --offline --no-sync python3 scripts/agent-guards/skill_runtime_exec.py --command-id scope_rollup.run --issue-number <N> --repo squne121/loop-protocol --invocation-id <ID> --requested-at <RFC3339>"
  legacy_direct_entrypoint: blocked_after_cutover
  worker: "scripts/agent-guards/run_scope_rollup_preflight.py"
  implementation_issue: 1601
  result_schema_compatibility: "SCOPE_ROLLUP_RUN_RESULT_V1 and ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 semantics preserved"
  re_review_trigger: "base SHA または dependency state が変わった場合"

Current Call Graph and Contract Ownership

契約次元 現行所有者 cutover 後の責務
canonical user-facing argv / child argv registry と direct worker caller registry は specialized worker の child argv を render、policy は outer argv を exact validate
placeholders / type validation registry と caller registry/policy の profile metadata が invocation_id と requested_at を required string として一致検証
execution class / cwd / branch / repo policy、local/worktree guard、Codex rules sibling profile metadata が required cwd、default branch、repo identity を検証
write roots / environment sanitation direct scope policy と worker outer が empty write roots と sanitized environment を監督
launcher / timeout / deadline / output worker と preflight executor outer が locked/no-sync launcher、bounded streaming、global deadline、process-tree cancellation を所有
private artifact / cleanup / result schema worker と parser worker が private data と domain result を構築・cleanup、outer は result を再解釈せず forward
callers / consumers / authorization runner、preparation、docs、Claude/Codex guards caller を canonical outer command へ移行し、双方で canonical allow・legacy deny を一致させる

Options Compared

案 canonical path 数 duplicated policy/supervision safety property の証明可能性 change surface / current conflict rollback specialized domain logic 判定
retain_independent 2 高い split-brain と registry drift が残る 小 / 低い 容易 隔離維持 不採用
integrate_sibling_profile 1 control plane に限定 outer safety と worker domain safety を個別に証明可能 中 / dependencies 解消後 1 squash revert worker に隔離維持 採用
generic_engine_refactor 1 一見低い pagination/artifact/schema の境界を失う 大 / 高い 困難 outer に流出 不採用

Safety Responsibility and Cutover Conditions

  • scope profile の repository write roots は空配列であり、既存 artifact/exclusion root を継承しない。任意 repository mutation は fail-closed とする。
  • outer と worker の双方が stdout/stderr cap を持つ。outer は unbounded capture_output=True を用いない。
  • outer の global deadline は stage ごとの remaining budget を上限にし、graceful cancellation、bounded grace、hard termination を実装する。別 session の child/grandchild も実プロセス試験で残存なしを確認する。
  • worker の private artifact cleanup は success、worker error、inner/outer timeout、cap exceed、malformed output、cancellation、cleanup failure の全経路で hard failure とする。
  • launcher は --locked --offline --no-sync で uv lock/sync mutation を防止し、uv.lock と .venv unchanged を検証する。
  • worker は GitHub inventory、pagination、server totalCount cross-check、planner/verifier、domain schema を所有し続ける。
  • Claude/Codex は canonical outer command のみを allow し、direct worker の absolute/relative/wrapper/uv-option variant を deny する。
  • runner、preparation、docs は legacy direct command を許可例として残さない。

Acceptance Criteria

Verification Commands

# AC1
$ gh issue view 1580 --repo squne121/loop-protocol --json body
# AC2
$ gh issue view 1580 --repo squne121/loop-protocol --json body
# AC3
$ gh issue view 1580 --repo squne121/loop-protocol --json body
# AC4
$ gh issue view 1601 --repo squne121/loop-protocol --json body
# AC5
$ gh issue view 1601 --repo squne121/loop-protocol --json body
# AC6
$ gh issue view 1601 --repo squne121/loop-protocol --json state,body
# AC7
$ gh issue view 1579 --repo squne121/loop-protocol --json state

Allowed Paths

Stop Conditions

Handoff Contract

Source

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    phase/research
    state/queued
    agent/research
    on Jul 18, 2026
  2. squne121 commented on Jul 18, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — reframe_in_place。

    Issue #1580の問題意識、すなわち「scope_rollup.runだけが別のexact-executorレーンを持つことで、契約ドリフトや二重実装が発生している」という指摘は妥当です。ただし、Issue本文が前提としている「既存のregistry SSOT経路」は、現行実装上は汎用的な registry → render → validate → dispatch エンジンではありません。

    設計判断は次のように分けるべきです。

    • Issue #1580の現行本文: No-Go。前提、比較軸、依存関係、ACを修正する必要がある。

    • アーキテクチャ判断: 条件付きGo。

    • 推奨方式: skill_runtime_exec.pyを外側のcanonical admission/supervision entrypointに統合する。ただし、run_scope_rollup_preflight.pyのドメイン固有transaction実装はworkerとして維持する。

    • 非推奨方式: scope-rollupのGitHub取得・pagination・一時ファイル・planner/verifier処理をskill_runtime_exec.pyへ吸収する。

    • 禁止すべき方式: 現行skill_runtime_exec.pyへ単純なif command_id == "scope_rollup.run"分岐だけを追加する。

    2026年7月18日時点で#1580はopenかつコメント0件で、本文以外の合意形成証跡はありません。別途、registry argv修正用の#1579がopen、skill_runtime_exec.pyを変更するPR #1572がopen draftです。直前には同ファイルへ1,707行追加したPR #1552がマージされています。したがって「500行超の別PRとの衝突リスク」は抽象的な懸念ではなく、現在進行中の具体的な依存関係です。


    マージブロッカー

    P0-1. 「SSOT」が何を意味するか未定義で、Issueの比較対象が成立していない

    command_registry.pyは、自身をoperator/orchestrator向けコマンドのSSOTと定義し、呼び出し側がshell文字列を手組みせずargvを構築する契約を掲げています。

    一方、現行のscope_rollup.runエントリはコメント上も実装上も、次の状態です。

    • registry登録は「documentation/SSOT registration」

    • 実際のdispatchはskill_runtime_exec.pyを通らない

    • local_main_branch_guard.pyとskill_runtime_command_policy.pyの専用parserが直接許可する

    • registry argvは--issue-numberと--repoまでの旧形状で、現行executorが必須とする--invocation-idと--requested-atを含まない

    これはregistryが実効SSOTではなく、非実行カタログになっていることを明記した実装です。

    さらに、汎用側のvalidate_registry_entry()は対象command-idごとのargvとplaceholderをPythonリテラルで再定義し、write rootを.claude/artifacts/issue-refinement-loop/{active_issue}/へ固定しています。scope_rollup.runはこのexpected-mapに存在せず、allowed_write_roots: []も受理できません。

    skill_runtime_exec.py自身も汎用dispatcherではありません。CLI形状はpreflight.run系の3profileを前提に分岐し、最終的に実行するscript pathをrun_refinement_preflight.pyへハードコードしています。

    したがって、現在の契約所有者は少なくとも4つあります。

    契約 | 現在の所有箇所 -- | -- argv生成 | command_registry.py exact admission | skill_runtime_command_policy.py 実行監督・write監査 | skill_runtime_exec.py scope-rollup transaction | run_scope_rollup_preflight.py

    実装前提

    実装Issueの起票条件を次のように固定すべきです。

    1. #1579のregistry argv/placeholder契約が確定していること。

    2. PR #1572の扱いが確定し、skill_runtime_exec.pyの最新base SHAへrebase済みであること。

    3. #1552以降のwrite-path policyを前提に再レビューすること。

    4. implementation issueにbase_sha、依存Issue/PR、変更予定pathを記録すること。

    5. 変更中にbase SHAまたは#1572のstateが変わった場合、design reviewを再実行すること。


    最小影響ファイル

    実装IssueのAllowed Paths候補は少なくとも以下です。

    Control plane

    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    scripts/agent-guards/local_main_branch_guard.py
    .claude/hooks/worktree_scope_guard.py
    scripts/agent-guards/pretool_fastpath_classifier.py
    .claude/settings.json
    

    Caller / documentation

    .claude/agents/scope-rollup-runner.md
    .claude/skills/impl-review-loop/steps/preparation.md
    docs/dev/hook-boundaries.md
    docs/dev/agent-skill-boundaries.md
    

    Tests

    .claude/skills/issue-refinement-loop/tests/test_command_registry.py
    scripts/agent-guards/tests/test_skill_runtime_command_policy*.py
    scripts/agent-guards/tests/test_skill_runtime_exec*.py
    .claude/hooks/tests/test_worktree_scope_guard.py
    .claude/hooks/tests/test_local_main_branch_guard.py
    tests/codex/test_local_main_branch_guard.py
    tests/codex/test_scope_rollup_run_exact_executor.py
    tests/codex/test_run_scope_rollup_preflight.py
    

    PR #1500の先例からも、registry・policy・executor・両guard・settings・parity testsを横断しない変更は、split-brainを残す可能性が高いと判断できます。


    改訂Acceptance Criteria案

    SCOPE_ROLLUP_EXECUTOR_DECISION_V1:
      verdict: go | no_go | deferred
      decision:
        one_of:
          - retain_independent
          - integrate_sibling_profile
          - generic_engine_refactor
      base_sha: "<40-hex>"
      prerequisites:
        registry_contract_issue:
          number: 1579
          state: closed
        overlapping_runtime_pr:
          number: 1572
          state: merged | closed | superseded
      canonical_entrypoint: "<exact argv template>"
      legacy_direct_entrypoint: blocked | retained
      worker: scripts/agent-guards/run_scope_rollup_preflight.py
      write_policy: no_repo_writes
      launcher_policy: locked_offline_no_sync
      output_policy: bounded_streaming
      cancellation_policy: staged_process_tree
      implementation_issue: <positive-int|null>
    

    Acceptance Criteriaは次の内容に置き換えるべきです。

    AC1: 現行call graphと契約所有者を、argv、placeholder、execution class、write root、environment、timeout、result schemaごとに列挙する。

    AC2: 「独立維持」「sibling profile統合」「generic engine refactor」の3案を、canonical path数、安全特性、変更面積、衝突リスク、rollback可能性で比較する。

    AC3: 判断を上記machine-readable blockで固定し、base SHAと依存Issue/PRのstateを記録する。

    AC4: 統合案では次の安全特性をすべて維持する。

    • repository write root 0件

    • outer/inner双方のstdout/stderr cap

    • global deadline

    • process-tree cancellation

    • private artifact cleanup

    • uv lock/sync mutationなし

    • trusted executable/environment

    • PR filesを含むpagination完走

    • producer → executor → worker → consumerのE2E

    AC5: cutover後にcanonical invocationが1本だけ存在し、旧direct invocationがClaude/Codex双方でdenyされる。

    AC6: implementation issueにexact Allowed Paths、test matrix、dependencies、base SHA、rollback planを記載する。

    AC7: ISSUE_NUMBER_PLACEHOLDERを残さず、verification commandがdecision blockとimplementation issue番号を実際にassertする。


    必須テスト行列

    実装Issueには最低限、次を要求すべきです。

    1. registry renderとpolicy parseのpositive parity

    2. flag欠落、重複、順序変更、--flag=value、extra flag

    3. invalid repo、invalid invocation ID、calendar上無効なtimestamp

    4. Claude/Codex両guardのallow/deny parity

    5. cutover後の旧direct形状deny

    6. registry/policy mismatch時のfail-close

    7. .claude/artifacts/issue-refinement-loop/<issue>/を含む全repo path書込み拒否

    8. uv.lockと.venvが生成・変更されないこと

    9. outer stdout/stderr cap

    10. outer timeout後にchild process、process group、一時directoryが残らないこと

    11. PR変更ファイル101件以上の完走

    12. server totalと取得件数不一致のfail-close

    13. runner → outer executor → worker → parserの実subprocess E2E

    14. result payload hash、invocation ID、requested-atのend-to-end一致


    GitHubコメント用要約

    REQUEST_CHANGES — reframe_in_place
    

    調査テーマ自体は妥当ですが、現行本文は統合先を「generic registry SSOT
    path」と誤認しています。

    現状は以下の4層が別々に契約を所有しています。

    • command_registry.py: argv生成
    • skill_runtime_command_policy.py: exact admission
    • skill_runtime_exec.py: preflight.run専用の実行監督
    • run_scope_rollup_preflight.py: scope-rollup固有transaction

    特に、現行skill_runtime_exec.pyへscope_rollup.runを単純追加すると、
    allowed_write_roots=[]にもかかわらず
    .claude/artifacts/issue-refinement-loop/<issue>/ がsnapshot除外されるため、
    no-repo-write契約が成立しません。

    また、専用workerはbounded streaming、process-group kill、private directory
    cleanupを実装していますが、outer executorはcapture_output=Trueの
    subprocess.runであり、outer timeout時にworkerのfinallyや別sessionの
    child cleanupを保証できません。

    推奨判断は「条件付き統合」です。

    • skill_runtime_exec.pyをcanonical outer admission/supervision entrypointにする
    • run_scope_rollup_preflight.pyはspecialized workerとして維持する
    • profile-derived write roots、global deadline、outer output cap、
      process-tree cancellationを追加する
    • bare uv runを廃止し、lock/sync mutationを防止する
    • cutover後は旧direct invocationを明示denyする

    前提として#1579のregistry契約確定、PR #1572の解決、最新base SHAでの
    再レビューが必要です。実装Issueを起票する前に、Issue本文とACを上記条件へ
    reframeしてください。

    # 判定

    REQUEST_CHANGES — reframe_in_place。

    Issue #1580の問題意識、すなわち「scope_rollup.runだけが別のexact-executorレーンを持つことで、契約ドリフトや二重実装が発生している」という指摘は妥当です。ただし、Issue本文が前提としている「既存のregistry SSOT経路」は、現行実装上は汎用的な registry → render → validate → dispatch エンジンではありません。

    設計判断は次のように分けるべきです。

    • Issue #1580の現行本文: No-Go。前提、比較軸、依存関係、ACを修正する必要がある。
    • アーキテクチャ判断: 条件付きGo。
    • 推奨方式: skill_runtime_exec.pyを外側のcanonical admission/supervision entrypointに統合する。ただし、run_scope_rollup_preflight.pyのドメイン固有transaction実装はworkerとして維持する。
    • 非推奨方式: scope-rollupのGitHub取得・pagination・一時ファイル・planner/verifier処理をskill_runtime_exec.pyへ吸収する。
    • 禁止すべき方式: 現行skill_runtime_exec.pyへ単純なif command_id == "scope_rollup.run"分岐だけを追加する。

    2026年7月18日時点で#1580はopenかつコメント0件で、本文以外の合意形成証跡はありません。別途、registry argv修正用の#1579がopen、skill_runtime_exec.pyを変更するPR #1572がopen draftです。直前には同ファイルへ1,707行追加したPR #1552がマージされています。したがって「500行超の別PRとの衝突リスク」は抽象的な懸念ではなく、現在進行中の具体的な依存関係です。


    マージブロッカー

    P0-1. 「SSOT」が何を意味するか未定義で、Issueの比較対象が成立していない

    command_registry.pyは、自身をoperator/orchestrator向けコマンドのSSOTと定義し、呼び出し側がshell文字列を手組みせずargvを構築する契約を掲げています。

    一方、現行のscope_rollup.runエントリはコメント上も実装上も、次の状態です。

    • registry登録は「documentation/SSOT registration」
    • 実際のdispatchはskill_runtime_exec.pyを通らない
    • local_main_branch_guard.pyとskill_runtime_command_policy.pyの専用parserが直接許可する
    • registry argvは--issue-numberと--repoまでの旧形状で、現行executorが必須とする--invocation-idと--requested-atを含まない

    これはregistryが実効SSOTではなく、非実行カタログになっていることを明記した実装です。

    さらに、汎用側のvalidate_registry_entry()は対象command-idごとのargvとplaceholderをPythonリテラルで再定義し、write rootを.claude/artifacts/issue-refinement-loop/{active_issue}/へ固定しています。scope_rollup.runはこのexpected-mapに存在せず、allowed_write_roots: []も受理できません。

    skill_runtime_exec.py自身も汎用dispatcherではありません。CLI形状はpreflight.run系の3profileを前提に分岐し、最終的に実行するscript pathをrun_refinement_preflight.pyへハードコードしています。

    したがって、現在の契約所有者は少なくとも4つあります。

    契約 現在の所有箇所
    argv生成 command_registry.py
    exact admission skill_runtime_command_policy.py
    実行監督・write監査 skill_runtime_exec.py
    scope-rollup transaction run_scope_rollup_preflight.py

    ここで独立policyを単純に「重複だから削除」と扱うのも不適切です。argvを生成するregistryと、argvを独立に認可するpolicyが別実装であることは、防御層としては合理性があります。解消すべきなのは独立検証そのものではなく、どの層が何の正本で、どの不一致をfail-closeするかが定義されていないことです。

    IssueのOutcomeは「単一SSOT」ではなく、次に変更すべきです。

    単一canonical entrypointを確立し、declarative registryと独立authorization policyの決定論的parityを保証する。


    P0-2. 現行skill_runtime_exec.pyへ単純統合すると、no repo writes契約が弱くなる

    scope_rollup.runのpolicyはallowed_write_roots: []です。つまりrepository内には一切書き込まないprofileです。

    しかし、現行skill_runtime_exec.pyのsnapshot処理はregistry entryを読む前に、issue番号から次のpathを無条件に「許可artifact root」として除外します。

    .claude/artifacts/issue-refinement-loop/<issue-number>/
    

    そのrootと配下はsnapshotへ記録されないため、後段のunauthorized-write検査対象にも入りません。

    したがって、現行executorへscope_rollup.runの分岐だけを追加すると、

    allowed_write_roots: []

    と宣言しながら、実際にはissue artifact rootへの書込みを検出しないsplit-brainが発生します。

    統合実装では、snapshot除外をissue_numberから自動生成してはなりません。registry/policy profileから導出し、次の意味を厳密に固定する必要があります。

    allowed_write_roots: []
    # repository内の除外pathは0件

    この修正がない統合案は、独立レーン維持より安全性が低下するためNo-Goです。


    P0-3. 外側のexecutorを追加すると、既存workerのbounded executionとcleanup保証を破壊し得る

    run_scope_rollup_preflight.pyはPR #1560のレビュー後、以下を専用実装しています。

    • stdout/stderr双方のstreaming byte cap

    • cap超過またはtimeout時のprocess group kill

    • start_new_session=True

    • private invocation directory

    • O_EXCL、O_NOFOLLOW、0600

    • hardlink-based exclusive finalize

    • 成功・失敗・timeoutを問わないcleanup

    • cleanup失敗のhard failure化

    • GitHub inventory、planner、verifierの個別timeout

    これに対し、現行skill_runtime_exec.pyのchild実行は次の単純なsubprocess.run()です。

    subprocess.run(
        child_argv,
        capture_output=True,
        text=True,
        timeout=timeout_seconds,
    )

    outer layerにはstdout/stderr byte capも、process-tree単位のstaged cancellationもありません。

    Pythonのcapture_output=Trueはstdout/stderrをPIPEで取得し、communicate()系の読取データはmemoryへbufferされます。Python公式文書も、大きい、または上限のない出力には使用しないよう明記しています。 ([Python documentation]1)

    より重大なのはtimeout時です。subprocess.run()は直接のchildをkillしますが、scope workerは内部childを別sessionで起動しています。外側からworkerだけを強制終了した場合、

    • workerのfinallyが完走しない
    • private directory cleanupが実行されない
    • 別sessionのghまたはplanner process groupが残る
    • cleanup failureをschema化する機会自体が失われる

    という経路が成立します。

    統合には単一のmonotonic deadlineと、少なくとも次の終了protocolが必要です。

    1. outerがworkerへgraceful signal
    2. workerが保有するprocess groupを停止
    3. private directory cleanup
    4. bounded grace period
    5. 残存process treeを強制終了
    6. 安定したreason codeを返す

    registryのtimeout_seconds: 180をそのまま外側timeoutにするだけでは不十分です。worker内部には複数の60秒・30秒timeoutがあり、独立したtimeoutの総和がouter deadlineを超える可能性があります。global deadlineから各処理へ残時間を配分する必要があります。


    P0-4. bare uv runはexecutor起動前にrepositoryを変更し得るため、write監査の外側にある

    現在のcanonical呼出しはbareな次の形です。

    uv run python3 scripts/agent-guards/run_scope_rollup_preflight.py ...

    uv公式文書によれば、uv runは対象コマンドを起動する前にprojectのlockとsyncを自動実行します。--lockedはlockfile更新を拒否し、--no-syncはenvironment syncを停止します。project environmentがなければ.venvも作成され、uv.lockもuv invocationによって自動作成・更新され得ます。 ([Astral Docs]2) ([Astral Docs]3)

    つまり、

    uvによるlock/sync/write
        ↓
    Python executor開始
        ↓
    before snapshot取得
    

    という順序になります。executorは自分が起動する前のmutationを検出できません。

    同じregistry内には既に、mutation: Falseとnetwork_effect: local_onlyを実動作と一致させるため、次のlauncher形状を使う先例があります。

    uv run --locked --offline --no-sync python3 ...

    scope-rollup統合時も、少なくとも次のどちらかを採用すべきです。

    • pre-provision済みinterpreterをabsolute pathで直接実行する
    • uv run --locked --offline --no-syncをouter launcherで使用する

    さらにnested uv runを避ける必要があります。outer executorがuv経由で起動され、registry-rendered childも再びuv経由で起動される構造は、lock/sync判断、binary trust、timeout、エラー責任範囲を二重化します。

    必須の回帰テストは次です。

    before:
      uv.lock absent / unchanged
      .venv absent / unchanged
    
    execute canonical command
    
    after:
      uv.lock absent / byte-identical
      .venv absent / unchanged
    

    P0-5. cutover条件がなく、統合後も旧direct laneが残る可能性がある

    現在のcaller文書はrun_scope_rollup_preflight.pyを直接実行するよう指示しており、policyにもそのdirect 12-token shape専用parserがあります。

    統合実装で新しいskill_runtime_exec.py --command-id scope_rollup.run ...を追加するだけでは、canonical pathが2本になります。

    旧: uv run ... run_scope_rollup_preflight.py ...
    新: uv run ... skill_runtime_exec.py --command-id scope_rollup.run ...
    

    必要なのは追加ではなくcutoverです。

    • runnerとpreparationを新形状へ変更
    • Claude/Codex双方のguardを新形状だけallow
    • 旧direct形状を明示的にdeny
    • settings/permissionsを新形状へ変更
    • fast-path telemetryを新command-idへ統合
    • 文書とテストから旧形状を削除
    • near-missとして旧形状のdeny testを固定

    PR #1500は、既存exact profileへsibling profileを追加した最も近い先例です。この変更ではregistry、policy、executor、複数guard、settings、文書、Claude/Codex parity testまで更新され、実際に「追加command-idが旧10-token parserからsuffixなしで許可される」というlatent wideningが検出されています。

    したがって、#1580の「Allowed Paths拡張範囲」はskill_runtime_exec.py単体では成立しません。


    Major findings

    P1-1. registryはdataではなく、検証前に実行されるPython codeである

    load_registry_entry()はrepository内のcommand_registry.pyをexec_module()で実行してからentryを取得します。skill_runtime_exec.pyも再度同ファイルをimportし、render_commandを呼び出します。

    したがって、registryを「privileged executorが検証するuntrusted declaration」と位置づけることはできません。検証より先に任意のmodule top-level codeが実行されます。

    脅威モデルを次のどちらかに固定すべきです。

    1. Trusted-project model
      repository checkout全体を信頼し、registryは実行可能なtrusted configurationと明記する。

    2. Untrusted-declaration model
      registryをJSON/TOML/YAML等のdata-only manifestへ分離し、schema検証後に利用する。あるいはmodule hashをpinする。

    現行Codex rule文書自身も、hooks/rulesはsecurity boundaryではなく、untrusted project stateやparent runtime overrideで弱められると明記しています。

    「SSOT統合によってsecurityが向上する」と主張する場合、このtrust modelを曖昧にしてはなりません。


    P1-2. requested_atはISO 8601の意味検証ではなくregex shape検証に留まる

    policyとworkerの双方は、requested_atを次のようなregexだけで検証しています。

    \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}...

    これは例えば月99、時刻99:99:99のようなcalendar上無効な値もshape上は受理します。

    registryへplaceholderを追加する#1579では、汎用string型に落とすべきではありません。現行placeholder validatorはstringについてPythonのstrであることしか確認しません。

    次のsemantic typeが必要です。

    invocation_id:
      type: invocation_id_v1
      max_bytes: 128
    
    requested_at:
      type: rfc3339_timestamp
      timezone_required: true
      canonical_utc: true

    parserはdatetime.fromisoformat()等で実在日時を検証し、必要ならZ形式へcanonicalizeすべきです。


    P1-3. GitHub CLI環境のdeterminismをもう一段固定できる

    専用workerはtrusted search dirsからghを解決し、GH_HOST、prompt、PATH-shadowing等を制御しています。これは維持すべき実装です。

    ただしGitHub CLIは環境変数によってhost、repository、TTY formatting、configuration directory、update notification、telemetry等の挙動が変わります。公式文書上、ghは24時間に一度version確認を行い得ます。 (GitHub CLI)

    automation用environment profileでは、明示的に次を固定する方が堅牢です。

    GH_HOST=github.com
    GH_PROMPT_DISABLED=1
    GH_NO_UPDATE_NOTIFIER=1
    GH_NO_EXTENSION_UPDATE_NOTIFIER=1
    GH_TELEMETRY=0
    GIT_TERMINAL_PROMPT=0
    

    HOMEやXDG_CONFIG_HOMEを残してstored credentialを利用するのか、token-only profileにするのかも契約化が必要です。


    P1-4. 専用workerのGraphQL paginationを汎用executorへ移してはならない

    GitHub GraphQL APIのconnectionは、firstまたはlastを1〜100で指定し、pageInfo.endCursorとhasNextPageを用いて完走する必要があります。 ([GitHub Docs]5)

    現在のworkerは、gh pr list --json filesのnested connectionが100件で切れる問題に対し、changedFilesとの差を検出してcursor paginationを行い、不一致ならtransaction全体をfail-closeします。

    この処理はregistryや汎用executorの責任ではなく、scope-rollup workerのdomain logicです。統合後もworker側に残すべきです。


    P1-5. 現行Acceptance Criteriaは判断結果を機械的に検証できない

    #1580のVerification Commandsには次の問題があります。

    • AC1のgit grep "12c. scope_rollup.run"は、docs sectionの存在しか検証しない
    • AC2はIssue bodyを表示するだけで、判断値をassertしない
    • AC3のclosedByPullRequestsReferencesは実装Issueへのlinkを検証しない
    • ISSUE_NUMBER_PLACEHOLDERが残っており、そのまま実行できない
    • AC4の「close可能、または追加調査要件」は二値ではなく、終了条件として曖昧

    research issueであっても、結果はmachine-readable blockとして固定すべきです。


    推奨設計

    採用案: explicit sibling profileによるcontrol-plane統合

    scope-rollup-runner
        │
        ▼
    canonical exact invocation
    skill_runtime_exec.py
      --command-id scope_rollup.run
      --issue-number ...
      --repo ...
      --invocation-id ...
      --requested-at ...
        │
        ├─ independent exact admission policy
        ├─ registry entry validation/render
        ├─ profile-derived no-write audit
        ├─ global deadline / output caps / cancellation
        ▼
    run_scope_rollup_preflight.py
        ├─ trusted gh resolution
        ├─ inventory and pagination
        ├─ private invocation directory
        ├─ planner/verifier
        └─ SCOPE_ROLLUP_RUN_RESULT_V1
    

    重要なのは、outer control planeだけを共通化し、worker data planeは維持することです。

    registry entryには少なくとも次のprofile metadataが必要です。

    scope_rollup.run:
      execution_class: exact_scope_rollup_run
      worker_kind: specialized_python_worker
      allowed_write_roots: []
      network_effect: github_read_only
      env_profile: scope_rollup_github_readonly_v1
      launcher_policy: locked_offline_no_sync
      stdout_schema: SCOPE_ROLLUP_RUN_RESULT_V1
      max_stdout_bytes: <bounded>
      max_stderr_bytes: <bounded>
      overall_timeout_seconds: <bounded>
      cancellation_policy: staged_process_tree_v1

    registryはargv生成の正本とし、authorization policyは独立したexpected contractを持ってfail-closeする構造を維持します。「同じregistryが自分自身を認可する」構造にはしません。


    比較結果

    案 評価 判定
    独立レーン維持 現在の専用安全特性をそのまま維持できるが、registry driftと二重canonical pathが残る 暫定可。恒久案としては非推奨
    explicit sibling profile canonical entrypointを一本化しつつ専用workerを維持できる 推奨、条件付きGo
    worker処理をskill_runtime_exec.pyへ吸収 汎用executorがGitHub pagination、一時ファイル、schema、plannerまで所有し肥大化する No-Go
    現行executorへ単純分岐追加 write-root、timeout、output、launcher契約がscope profileと不整合 No-Go

    実装前提

    実装Issueの起票条件を次のように固定すべきです。

    1. #1579のregistry argv/placeholder契約が確定していること。
    2. PR #1572の扱いが確定し、skill_runtime_exec.pyの最新base SHAへrebase済みであること。
    3. #1552以降のwrite-path policyを前提に再レビューすること。
    4. implementation issueにbase_sha、依存Issue/PR、変更予定pathを記録すること。
    5. 変更中にbase SHAまたは#1572のstateが変わった場合、design reviewを再実行すること。

    最小影響ファイル

    実装IssueのAllowed Paths候補は少なくとも以下です。

    Control plane

    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    scripts/agent-guards/local_main_branch_guard.py
    .claude/hooks/worktree_scope_guard.py
    scripts/agent-guards/pretool_fastpath_classifier.py
    .claude/settings.json
    

    Caller / documentation

    .claude/agents/scope-rollup-runner.md
    .claude/skills/impl-review-loop/steps/preparation.md
    docs/dev/hook-boundaries.md
    docs/dev/agent-skill-boundaries.md
    

    Tests

    .claude/skills/issue-refinement-loop/tests/test_command_registry.py
    scripts/agent-guards/tests/test_skill_runtime_command_policy*.py
    scripts/agent-guards/tests/test_skill_runtime_exec*.py
    .claude/hooks/tests/test_worktree_scope_guard.py
    .claude/hooks/tests/test_local_main_branch_guard.py
    tests/codex/test_local_main_branch_guard.py
    tests/codex/test_scope_rollup_run_exact_executor.py
    tests/codex/test_run_scope_rollup_preflight.py
    

    PR #1500の先例からも、registry・policy・executor・両guard・settings・parity testsを横断しない変更は、split-brainを残す可能性が高いと判断できます。


    改訂Acceptance Criteria案

    SCOPE_ROLLUP_EXECUTOR_DECISION_V1:
      verdict: go | no_go | deferred
      decision:
        one_of:
          - retain_independent
          - integrate_sibling_profile
          - generic_engine_refactor
      base_sha: "<40-hex>"
      prerequisites:
        registry_contract_issue:
          number: 1579
          state: closed
        overlapping_runtime_pr:
          number: 1572
          state: merged | closed | superseded
      canonical_entrypoint: "<exact argv template>"
      legacy_direct_entrypoint: blocked | retained
      worker: scripts/agent-guards/run_scope_rollup_preflight.py
      write_policy: no_repo_writes
      launcher_policy: locked_offline_no_sync
      output_policy: bounded_streaming
      cancellation_policy: staged_process_tree
      implementation_issue: <positive-int|null>

    Acceptance Criteriaは次の内容に置き換えるべきです。

    AC1: 現行call graphと契約所有者を、argv、placeholder、execution class、write root、environment、timeout、result schemaごとに列挙する。

    AC2: 「独立維持」「sibling profile統合」「generic engine refactor」の3案を、canonical path数、安全特性、変更面積、衝突リスク、rollback可能性で比較する。

    AC3: 判断を上記machine-readable blockで固定し、base SHAと依存Issue/PRのstateを記録する。

    AC4: 統合案では次の安全特性をすべて維持する。

    • repository write root 0件
    • outer/inner双方のstdout/stderr cap
    • global deadline
    • process-tree cancellation
    • private artifact cleanup
    • uv lock/sync mutationなし
    • trusted executable/environment
    • PR filesを含むpagination完走
    • producer → executor → worker → consumerのE2E

    AC5: cutover後にcanonical invocationが1本だけ存在し、旧direct invocationがClaude/Codex双方でdenyされる。

    AC6: implementation issueにexact Allowed Paths、test matrix、dependencies、base SHA、rollback planを記載する。

    AC7: ISSUE_NUMBER_PLACEHOLDERを残さず、verification commandがdecision blockとimplementation issue番号を実際にassertする。


    必須テスト行列

    実装Issueには最低限、次を要求すべきです。

    1. registry renderとpolicy parseのpositive parity
    2. flag欠落、重複、順序変更、--flag=value、extra flag
    3. invalid repo、invalid invocation ID、calendar上無効なtimestamp
    4. Claude/Codex両guardのallow/deny parity
    5. cutover後の旧direct形状deny
    6. registry/policy mismatch時のfail-close
    7. .claude/artifacts/issue-refinement-loop/<issue>/を含む全repo path書込み拒否
    8. uv.lockと.venvが生成・変更されないこと
    9. outer stdout/stderr cap
    10. outer timeout後にchild process、process group、一時directoryが残らないこと
    11. PR変更ファイル101件以上の完走
    12. server totalと取得件数不一致のfail-close
    13. runner → outer executor → worker → parserの実subprocess E2E
    14. result payload hash、invocation ID、requested-atのend-to-end一致

    GitHubコメント用要約

    REQUEST_CHANGES — reframe_in_place
    
    調査テーマ自体は妥当ですが、現行本文は統合先を「generic registry SSOT
    path」と誤認しています。
    
    現状は以下の4層が別々に契約を所有しています。
    
    - command_registry.py: argv生成
    - skill_runtime_command_policy.py: exact admission
    - skill_runtime_exec.py: preflight.run専用の実行監督
    - run_scope_rollup_preflight.py: scope-rollup固有transaction
    
    特に、現行skill_runtime_exec.pyへscope_rollup.runを単純追加すると、
    allowed_write_roots=[]にもかかわらず
    .claude/artifacts/issue-refinement-loop/<issue>/ がsnapshot除外されるため、
    no-repo-write契約が成立しません。
    
    また、専用workerはbounded streaming、process-group kill、private directory
    cleanupを実装していますが、outer executorはcapture_output=Trueの
    subprocess.runであり、outer timeout時にworkerのfinallyや別sessionの
    child cleanupを保証できません。
    
    推奨判断は「条件付き統合」です。
    
    - skill_runtime_exec.pyをcanonical outer admission/supervision entrypointにする
    - run_scope_rollup_preflight.pyはspecialized workerとして維持する
    - profile-derived write roots、global deadline、outer output cap、
      process-tree cancellationを追加する
    - bare uv runを廃止し、lock/sync mutationを防止する
    - cutover後は旧direct invocationを明示denyする
    
    前提として#1579のregistry契約確定、PR #1572の解決、最新base SHAでの
    再レビューが必要です。実装Issueを起票する前に、Issue本文とACを上記条件へ
    reframeしてください。
    
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/researchphase/researchstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions