Skip to content

実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "#1533 後の native ledger writer の実際の write closure を root snapshot 外へ安全に移し、stable ledger final file の正規 peer 更新だけを type/transition-aware policy で扱うことで、anchor-bound preflight の false positive を解消しつつ許可外 write を fail-close する"
change_kind: code
depends_on:
  - "#1503"
preflight_scope: pr_review_only
runtime_verification_applicability: immediate
baseline_expect: fail

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: anchor-bound preflight.run.with_anchor が、fix: SubAgent ledger writer を安全化 #1533 の ledger writer が生成する正規 peer write により停止しない状態にする。
  • Desired Destination: ledger writer の build/runtime artifact、stable ledger final file、transient protocol entry、executor snapshot policy の責務を分離する。

Current Validated Scope

  • 実装: SubAgent 起動 ledger writer を cross-process safe にする #1503 / PR fix: SubAgent ledger writer を安全化 #1533 は cross-process safe な native ledger writer を導入したが、ensureLedgerWriter() が entry ごとに repo-local tmp/subagent-launch-ledger-writer* を生成・更新する。
  • writer は ledger final file に加え、subagent-launch-ledger.json.lock と subagent-launch-ledger.json.tmp を transient protocol entry として生成・削除する。
  • 現行 skill_runtime_exec.py は directory root を前提とする race-tolerant exclusion と snapshot comparison を持つため、最終 ledger だけを単純な exact string exception にしても、repo-local binary・lock/temp・non-regular substitution を正しく扱えない。

Remaining Parent Gaps

Outcome

native ledger writer の再利用可能な build artifact が repo snapshot 外で管理され、skill_runtime_exec.py が artifacts/codex/subagent-launch-ledger.json の regular create/update だけを stable peer transition として扱い、ledger の削除・symlink・directory・FIFO 化、transient lock/temp の残留、sibling write、または executable artifact の repo 内生成を fail-close する実装・実 hook integration test・SSOT が存在する状態。

In Scope

  • scripts/check-codex-agents.mjs の native ledger writer build を entry ごとの repo-local tmp/ compile/rename から分離し、repo snapshot 外の content-addressed cache または install/bootstrap 済み artifact を再利用する。repo 内の tmp/subagent-launch-ledger-writer* を telemetry exception に追加しない。
  • skill_runtime_exec.py に directory root、stable exact peer file、transient protocol entry、build/runtime executable artifact を別の型付き policy として表現する。stable exact ledger は absent -> regular と regular -> regular のみを許容し、snapshot から消去しない。
  • ledger final file の delete、symlink、directory、FIFO、socket/device への置換を fail-close にする。strict ancestor の directory mtime は正規 transition の間だけ扱い、sibling leaf path の走査を維持する。
  • ledger lock/temp は stable exception にせず bounded quiescence で消滅を待つ。timeout 後に残る lock/temp は stale residue として fail-close にする。
  • cold/warm state の実 check-codex-agents.mjs --hook-subagent-start と independent OS process/barrier を用い、ledger create/update、quiescent lock/temp、残留 lock/temp、sibling create/update/delete/rename、non-regular substitution、既存 race-tolerant root を検証する。
  • docs/dev/agent-skill-boundaries.md を directory roots / stable exact files / transient protocol entries / build-runtime executable artifacts の4分類、owner、canonicality、許可状態遷移、stdlib mode の保証限界、実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 handoff と一致させる。

Out of Scope

Acceptance Criteria

  • AC1: cold/warm の実 check-codex-agents.mjs --hook-subagent-start 経路で、ledger writer は repo 内 tmp/subagent-launch-ledger-writer* を新規作成・更新せず、peer が ledger final file を正規 create/update しても executor は false positive を返さない。
  • AC2: stable exact ledger policy は absent -> regular / regular -> regular だけを許可し、delete、symlink、directory、FIFO、socket、device への状態遷移を fail-close にする。
  • AC3: ledger lock/temp は bounded quiescence 内に消滅する場合だけ許容し、timeout 後に残る lock/temp は stale residue として fail-close になる。
  • AC4: artifacts/codex/ の sibling と repo root の sibling の create/update/delete/rename は、現行 metadata/status model で観測可能な差分について leaf path を示して fail-close する。
  • AC5: independent OS process と go/ack barrier を使う cold/warm integration test が、実 repo と同じ ignored ancestor folding、peer ledger update、non-regular parent substitution、既存 race-tolerant roots、および allowed artifact root の回帰を検証する。
  • AC6: SSOT は4分類と、stdlib snapshot mode が cooperating/trusted child の exact-ledger self-write を完全には帰属できず、byte-preserving update を完全検出しない保証限界を明記し、実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 を strict attribution handoff として参照する。

Runtime Verification Applicability

decision: immediate
reason: "障害は independent Codex hook process、ignored ancestor folding、before/after snapshot timing、transient lock/temp lifecycle の組合せで発生するため、path predicate の unit test だけでは再現できない"
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
  - AC5
execution_environment: "Linux/WSL の同一 filesystem 上で、実 check-codex-agents.mjs hook と skill_runtime_exec.py を subprocess、independent OS process、go/ack barrier で起動する"
skip_conditions: "cc または Node.js が実行環境に存在しない場合のみ。SKIP 理由と未検証 AC を PR 本文に記録する"
fallback_policy: "runtime integration を実行できない場合は PASS と扱わず human_judgment とする"
artifact_requirements:
  - "cold/warm hook integration の stdout/stderr、exit code、ledger state transition"
  - "lock/temp quiescence または stale residue の判定証跡"

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_hook_cold_and_warm_ledger_peer_write_is_quiescent -q

# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_exact_policy_rejects_nonregular_and_delete_transitions -q

# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_transient_residue_times_out_fail_closed -q

# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_siblings_remain_fail_closed_for_observable_changes -q

# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q

# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_parallel_agent_runtime_safety_documents_typed_ledger_policy -q

Allowed Paths

  • scripts/check-codex-agents.mjs
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py
  • tests/test_subagent_launch_ledger_writer.py
  • docs/dev/agent-skill-boundaries.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • stable transition enum、transient quiescence、または runtime verification evidence の変更が必要になった場合
  • repo snapshot 外の build artifact を安全に identity-bind できず、repo 内 executable を race-tolerant exception に追加しなければならない場合
  • shadow log の hardening を同一 PR に含めないと Outcome を満たせない場合

Required Skills

  • Python
  • pytest
  • Node.js
  • C17 / POSIX file locking

Required Design References

  • docs/dev/agent-skill-boundaries.md#Parallel Agent Runtime Safety
  • docs/dev/workflow.md
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/check-codex-agents.mjs

Scope Delta(任意)

scope_delta:
  status: approved_by_trusted_anchor
  anchor_comment_url: "https://github.com/squne121/loop-protocol/issues/1502#issuecomment-4991726708"
  decision: "ledger-only reframe"
  removed:
    - ".guard_shadow_log.jsonl exact-path exception"
  added:
    - "native ledger writer build artifact distribution"
    - "typed stable/transient transition policy"
    - "immediate local runtime integration evidence"
  unchanged:
    - "directory-wide exclusion is forbidden"
    - "strict attribution remains #1363"

Delivery Rule

Notes for Reviewer

  • fix: SubAgent ledger writer を安全化 #1533 の writer integrity を前提にするが、entry ごとの repo-local compile は false-positive write closure を増やすため本 Issue で解消する。
  • shadow log は canonical ledger と writer/security model が異なるため、同じ exact-path exception に入れない。hardened writer follow-up を先に ready にできない場合も、本 Issue は shadow log を除外したまま ledger-only で完結する。
  • AC4 の保証は current metadata/status model で観測可能な差分に限定する。byte-preserving update や executor child self-write の完全帰属は 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 まで主張しない。

Activity

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

    @squne121
    OwnerAuthor

    Issue本文、関連Issue/PR、現行コード、既存テスト、Node.js・Git・Python・Codex Hooksの公式仕様を照合しました。判定は REQUEST_CHANGES です。

    Issue #1502 敵対的レビュー

    判定

    REQUEST_CHANGES — 現行契約のまま実装開始すべきではない。

    artifacts/codex/subagent-launch-ledger.json だけを race-tolerant 対象にする方向性は、artifacts/codex/** 全体を除外する案よりは妥当です。しかし、現在のIssueは次の重要問題を扱っていません。

    1. canonical evidence である ledger 自体の同時更新安全性
    2. exact ledger path除外により新たに生じる child self-write の検出不能
    3. 「root用prefix除外」と「単一ファイル完全一致除外」の実装責務混在
    4. 実リポジトリの .gitignore と独立hook processを再現しない弱い検証契約
    5. Parallel Agent Runtime Safety SSOTを変えるのに、設計文書がAllowed Paths外

    Issue #1502 はopen・コメント0件で、AC1〜AC3、not_applicable判定、2ファイルだけのAllowed Pathsを持つ状態です。


    Blocker 1 — ledger writerの同時更新競合を放置したまま、検知だけ消そうとしている

    このledgerは単なるデバッグログではありません。リポジトリの設計では、event-derived SUBAGENT_LAUNCH_LEDGER_V1 を、worker self-reportに依存しない canonical evidence としています。

    一方、現行の scripts/check-codex-agents.mjs は次の構造です。

    • ledger全体を読み込む

    • JSON parseに失敗した場合は空ledgerへフォールバックする

    • launch/action配列をメモリ上で変更する

    • fs.writeFileSync() で同じファイル全体を直接上書きする

    Codexの公式仕様では、同一eventに一致する複数のcommand hookは並行起動されます。また、project-local hookはtrust済みである場合にのみ実行されます。([OpenAI Developers]1)

    Node.jsの writeFileSync() はデフォルトでflag 'w' を使い、既存ファイルをtruncateしてから書き込みます。'w' は「既存なら切り詰める」動作です。([Node.js]2)

    したがって、複数hook processが並行した場合、次の競合が成立します。

    process A: ledger version N を読む
    process B: ledger version N を読む
    process A: launch A を追加して保存
    process B: launch B を追加して保存
    結果: launch A が消える
    

    さらに、一方がtruncate後・write完了前の状態を他方が読んだ場合、parse failureを空ledgerとして扱い、その空状態を正規データとして上書きする可能性を現行実装は排除していません。

    Issue #1502がexact ledger pathを監査対象外にすると、この証跡欠落と破損はruntime guardからも見えなくなります。 誤検知の症状だけを消し、canonical evidenceの完全性を悪化させる構造です。

    必須修正

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

    推奨案A: prerequisite issueへ分離

    • ledger writerをcross-process safeにするIssueを先に起票する
    • #1502に明示的dependencyを追加する
    • prerequisite完了まで#1502は実装停止する

    案B: #1502へ統合

    Allowed Pathsへ少なくとも以下を追加します。

    scripts/check-codex-agents.mjs
    tests/check-codex-agents.test.mjs
    docs/dev/agent-skill-boundaries.md
    

    writerは、全writerが協調するexclusive lockとatomic replacementを使う必要があります。例えばNode.jsの'wx'は既存パスがある場合に失敗するため、bounded lock取得に利用できます。ただしnetwork filesystemではexclusive flagの保証に制限があるため、対応filesystemを明記すべきです。([Node.js]2)

    Linux/WSL上では、同一filesystem・同一directory内のtemporary fileを完成させてからrenameすることで、既存targetをatomicに置換できます。([man7.org]3)

    最低限の保存手順は次です。

    exclusive lock取得
    → lock取得後にledgerを再読込
    → schema検証
    → unique temporary fileへ完全なJSONを書込
    → 必要ならfsync
    → same-directory rename
    → lock解放
    

    より堅牢にするなら、各hookが共有JSONを直接更新せず、unique event fileを作成し、単一aggregatorがledgerへ集約する方式が適切です。


    Blocker 2 — exact path除外後のchild self-write盲点がACにない

    現在のrace-tolerant stdlib modeは、peer processとexecutor childをプロセス単位で帰属できません。したがってledger exact pathを除外すると、正当なhook更新だけでなく、executor child自身による次の操作も検出不能になります。

    ledgerの上書き
    ledgerの削除
    不正schemaへの置換
    過去launch evidenceの除去
    root_thread_actionsの改変
    

    Issue本文はこの制約をNotesで示唆していますが、ACはpeer write成功とsibling path失敗しか要求していません。

    これは通常のtelemetry fileより重大です。PR #767では、ledgerをroot-thread data-plane実行やspawn evidence欠落をfail-closedで検出するcanonical inputとして導入しています。

    同種の問題を扱ったIssue #1409/PR #1426では、以下が明示的に実装・検証されました。

    • peer/background writeは成功

    • 除外subtree外へのself-writeは失敗

    • 除外subtree内へのself-writeはstdlib modeのKnown Limitationとしてテスト

    • strict attribution modeへのhandoff

    • SSOT更新

    必須追加AC

    AC: executor child自身がexact ledger pathを書き換えても、
    race_tolerant_stdlib modeでは検出できないことをKnown Limitationとして固定する。
    
    AC: strict_strace modeでは、traced childによるexact ledger pathへの
    allowed_write_roots外writeをfail-closeする契約をSSOTに記載する。
    
    AC: peer hookによる更新をstrict modeでchild self-writeへ誤帰属しない。
    

    Issue #1363は、このstrict attribution modeを実装する既存のhandoff先です。

    canonical evidenceへのself-write検出不能を受容しない判断も合理的です。その場合は、#1363完了までexact ledger path除外を導入してはいけません。


    Major 3 — 「root prefix」と「exact file」を同じtupleへ混在させている

    現行の _RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS は、名前・コメント・処理ともdirectory rootを前提にしています。

    • exact matchまたはprefix matchで配下を除外

    • rootの全祖先をallowed parent directoryとして扱う

    • os.walk()時にroot directoryを再帰ごとprune

    • ignored directoryがrootの祖先ならtargeted expansionを行う

    ここへ単一ファイルを追加すると、現状のアルゴリズムでは動作する可能性が高いものの、artifacts/とartifacts/codex/も「unattributable rootの祖先」として特別処理されます。これは単純なexact-path例外ではなく、ignored ancestor展開やdirectory-node判定にも影響する変更です。

    推奨設計

    責務を分離します。

    _RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS = (
        ".claude/worktrees",
        ".claude/artifacts/issue-refinement-loop",
        "artifacts/session-manifest-runtime",
    )
    
    _RACE_TOLERANT_UNATTRIBUTABLE_EXACT_PATH_RELS = (
        "artifacts/codex/subagent-launch-ledger.json",
    )

    そして、次を別関数に分けます。

    _is_race_tolerant_root_path()
    _is_race_tolerant_exact_path()
    _is_strict_ancestor_of_race_tolerant_target()
    

    これにより、将来別の単一file例外が追加されても、directory subtree除外へ暗黙に拡張されません。


    Major 4 — Runtime Verification not_applicable とテスト契約が弱い

    Issue #1502は、AC1〜AC3で同じpytestファイル全体を3回実行し、Runtime Verificationをnot_applicableとしています。

    しかし実障害は、executorとは独立したCodex hook processがledgerを更新するタイミングとの競合です。単純なpath predicateのunit testだけでは、報告された現象を再現していません。

    さらに実リポジトリでは artifacts/ 全体がignoreされています。

    Gitの--ignored=matchingは、directory自体がignore patternに一致する場合、その配下の個別pathを表示せず、directoryだけを表示します。(Git)

    そのためcold startでは、実際の変更が次のように畳み込まれる可能性があります。

    実変更:
    artifacts/codex/subagent-launch-ledger.json
    
    git status:
    !! artifacts/
    

    既存の基本テストfixtureは .gitignore に artifacts/ を含んでいないため、そのまま流用するとこのバグを検出できません。

    対してPR #1426の統合テストは、実repoと同じartifacts/ ignore、cold/warm state、unauthorized sibling、parent symlink/file substitution、独立processと明示barrierを検証しています。

    また、Python公式仕様では、directory listing生成中にfileが追加・削除された場合、それが結果に含まれるかは未規定です。固定sleepだけのthread testはfalse-greenやflakyになり得ます。([Python documentation]5)

    必須テストマトリクス

    1. cold start:
       artifacts/が存在しない状態でpeerがledgerを作成 → success
    
    2. cold start + sibling:
       ledgerとartifacts/codex/unrelated.jsonを同時作成
       → unrelated.jsonのleaf pathでfail
    
    3. warm state:
       既存ledgerをpeerが更新 → success
    
    4. warm sibling:
       既存のartifacts/codex/unrelated.jsonを更新 → fail
    
    5. deletion:
       sibling file削除 → fail
    
    6. known limitation:
       executor child自身がledgerを更新・削除 → stdlib modeでは成功してしまうことを明示
    
    7. parent substitution:
       artifacts または artifacts/codex をsymlink/plain fileへ置換 → fail
    
    8. real concurrency:
       independent OS process + go/ack barrierでpeer updateを発生
       → fixed sleepに依存しない
    
    9. ledger integrity:
       2 processが異なるlaunch evidenceを同時追加
       → 両方残り、JSON schemaが有効
    
    10. regression:
        #1343/#1409の既存test suiteを全実行
    

    Runtime Verificationは次のように分けるべきです。

    decision: immediate
    reason: >
      path predicate単体はunit testで検証するが、報告された障害は
      independent Codex hook process、ignored ancestor folding、
      before/after snapshot timingを含むため、独立processを使った
      runtime integration testをAC1の必須証跡とする。

    Major 5 — Required Design ReferenceとAllowed Pathsが矛盾している

    Issue #1502は docs/dev/agent-skill-boundaries.md#Parallel Agent Runtime Safety をRequired Design Referenceに指定していますが、同文書をAllowed Pathsに含めていません。

    このSSOTは現在、unattributable対象を「volatile roots」として列挙し、race-tolerant stdlib modeのself-write盲点、negative test要件、strict attribution modeとの境界を定義しています。

    canonical ledgerの単一fileを新たに除外するのは、明確な安全境界変更です。コードとテストだけ変更してSSOTを更新しない構成は、PR #1426で採用した前例とも整合しません。

    必須修正

    Allowed Pathsへ追加します。

    docs/dev/agent-skill-boundaries.md
    

    文書には最低限、次を記載します。

    - exact unattributable path:
      artifacts/codex/subagent-launch-ledger.json
    
    - path ownership:
      trusted Codex SubagentStart / PreToolUse hook writer
    
    - security classification:
      canonical evidenceだがsecurity boundaryではない
    
    - race_tolerant_stdlib:
      peer writeとchild self-writeを区別できない
    
    - strict_strace:
      traced child self-writeはfail-close
      external hook writeは誤帰属しない
    
    - writer integrity:
      cross-process serializationとatomic replaceの保証範囲
    

    Major 6 — AC2の「作成または更新」だけではstatus/snapshot両経路を保証できない

    _find_unauthorized_repo_changes()は、Git statusのbefore/after set差分と、filesystem snapshot差分を組み合わせています。既にdirtyなignored pathの内容更新はstatus setに変化がなく、snapshot側だけが検出根拠になります。

    したがってAC2は、単に「ledger以外のpathを作成または更新」と書くだけでは不十分です。少なくとも次を個別node IDで検証すべきです。

    new sibling file creation
    existing sibling file content update
    existing sibling deletion
    sibling directory creation
    rename from ledger path to sibling path
    rename from sibling path to ledger path
    

    Minor — Verification CommandsがACを個別に証明していない

    AC1〜AC3がすべて同じコマンドです。

    uv run pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q

    これでは、どのACがどのtestで証明されたかをTEST_VERDICTへ機械的に写像できません。

    個別node IDに変更すべきです。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_cold_start_independent_peer_create_exact_ledger_succeeds -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_cold_start_exact_ledger_and_sibling_fails_on_sibling -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_child_self_write_exact_ledger_is_known_limitation -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -q

    uv runには既存運用に合わせて--lockedも付けるべきです。


    推奨するIssue再構成

    1. ledger integrityを先に解決

    新規prerequisite issue:

    goal: >
      SUBAGENT_LAUNCH_LEDGER_V1 writerをcross-process safeにし、
      concurrent SubagentStart / PreToolUse hook実行でも
      launch/root actionのlost update、破損、parse failureによる
      empty resetが発生しない状態にする。

    主なAC:

    - 二つの独立processが同時追記しても両eventが残る
    - 読取可能な途中状態を公開しない
    - malformed ledgerを空ledgerとして上書きしない
    - lock timeout/stale lockをfail-closedまたはbounded recoveryする
    - symlink parent/target substitutionを拒否する
    

    2. #1502はguard attributionだけに限定

    ledger writer hardening完了後、#1502で次を実装します。

    - root prefixとexact pathの別集合化
    - exact ledger pathだけpeer write除外
    - sibling pathは作成・更新・削除すべてfail
    - child self-write盲点をKnown Limitationとして固定
    - #1363 strict modeへのhandoff
    - SSOT更新
    - independent process integration test
    

    最終結論

    exact ledger pathだけを除外する方針自体は採用可能です。しかし、現行Issueは canonical evidenceのwriter integrityを確認せず、除外によって生じるchild tampering盲点も受け入れ条件にしていません。

    特に以下の2点が解消されるまで、実装開始は拒否すべきです。

    1. check-codex-agents.mjs のcross-process read-modify-write競合をprerequisite化または同一Issueで修正する
    2. exact ledger pathへのchild self-writeが検出不能になるKnown Limitationを、テスト・SSOT・strict mode handoffで明示する

    この2点なしにマージすると、#1502はfalse positiveを除去する代わりに、SubAgent dispatch監査のcanonical evidenceを静かに欠落・改変できる新しいfalse-negative apertureを作ります。

    このレビューはGitHubへ投稿していません。ローカルでのテスト実行は、実行環境からGitHubへのDNS接続が利用できなかったため行わず、GitHub上の現行資産・履歴と公式仕様を根拠に判定しています。

  3. squne121 commented on Jul 13, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_triggered"
    
    "scope_signal_guard_reason_code:new_allowed_path_layer"
    
    "指定 anchor は OWNER の REQUEST_CHANGES だが、ANCHOR_SCOPE_REFRAME_V1 の required_rerun と Allowed Paths delta 承認を含まないため #1502 の docs/test scope 拡張を自動適用できない"
    
    "ledger writer integrity の prerequisite として #1503 を作成済み: https://github.com/squne121/loop-protocol/issues/1503"
    
    "#1502 は #1503 merge 後に root-prefix と exact-path の分離、SSOT、runtime integration test を含む narrow contract へ再開する"
    
  4. squne121 commented on Jul 13, 2026

    @squne121
    OwnerAuthor
    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1502
    decision: approve_scope_delta
    allowed_path_deltas:
      - docs/dev/agent-skill-boundaries.md
    rationale: >
      #1503 で ledger writer integrity を前提として分離し、#1502 は exact ledger path の attribution 境界、Known Limitation、strict_strace handoff、および runtime integration evidence を SSOT に同期する必要があるため。
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  5. squne121 commented on Jul 13, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  6. squne121 commented on Jul 14, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-14T22:19:26Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1502
      body_sha256: "sha256:5f52937e93c13c59491c58906e2aa29ce84798e98854523f6f2586f5656354f8"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:5f52937e93c13c59491c58906e2aa29ce84798e98854523f6f2586f5656354f8","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q","command_hash":"sha256:bd7881e26a988d1bad1f715f58d56281dd397a088205c4b62265df7767bd2fc6","execution_key_hash":"sha256:a426398bbf1b4070aa048c0e28474fbb4184b08e548aa821e38d0e8d255b6cb3","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":198,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":5,"raw_command":"uv run pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q","command_hash":"sha256:bd7881e26a988d1bad1f715f58d56281dd397a088205c4b62265df7767bd2fc6","execution_key_hash":"sha256:b5b839bfde61a50115588106f44c184202484e3ea202e83bc30822605137cdfc","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":166,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":8,"raw_command":"uv run pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q","command_hash":"sha256:bd7881e26a988d1bad1f715f58d56281dd397a088205c4b62265df7767bd2fc6","execution_key_hash":"sha256:3df29dfef542aa70d45234f33f7be1fb99f2348cfcc00be741b38cd703e93d70","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":178,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  7. squne121 commented on Jul 16, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-16T09:42:31Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1502
      body_sha256: "sha256:e7b630d391c2066daba3a87ba3bba71934f256c53e6f3eff26778899118aee79"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:e7b630d391c2066daba3a87ba3bba71934f256c53e6f3eff26778899118aee79","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_peer_ledger_write_is_exact_unattributable -q","command_hash":"sha256:9040c9a331decf44124609e397b7165eca1d4ac2a26191f9263140bc4a481aab","execution_key_hash":"sha256:a4bd7beb5ddb69172e1eb6f856cff74d89e30aaec939effb657a6dbe3a721cdb","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_peer_ledger_write_is_exact_unattributable"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":301,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":5,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_peer_shadow_log_write_is_exact_unattributable -q","command_hash":"sha256:4df833a8f18d3ad6601a57f15917067f7f074051a4cbd39f02bb7a393a3ea236","execution_key_hash":"sha256:4a6d2b7d45bb3e86ed8a9df7f67f204d581c64a2d291b425af48c42561a0e3b7","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_peer_shadow_log_write_is_exact_unattributable"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":194,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":8,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_exact_unattributable_siblings_still_fail_closed -q","command_hash":"sha256:f8904970e22a28fb776b2b32804573786f47a0e3b15e70ecc363ee62a44298de","execution_key_hash":"sha256:4902bc7a29d841a74aa3723eff3cec4071d677a581a3c2d1623e53f90f2368f5","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_exact_unattributable_siblings_still_fail_closed"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":227,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":11,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_parallel_agent_runtime_safety_documents_exact_unattributable_paths -q","command_hash":"sha256:ac453f69ef53b125fa0d896b26433bdbf13b77e244ec3b550d2070d642cd027a","execution_key_hash":"sha256:eb20ed543f716808d781a490353f8d9afdf15f48ea46f895f1ca07fedb850cac","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_parallel_agent_runtime_safety_documents_exact_unattributable_paths"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":266,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":14,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_existing_race_tolerant_roots_and_allowed_artifact_write_remain_unchanged -q","command_hash":"sha256:2bc784368cd58e955914761522c6b60b7a75956c8d59f8feeb610b54ceb579e3","execution_key_hash":"sha256:8530e3a75163e3c2a56b06b28f163f1cb45f1e76ded3099bdf90692f379b7a3b","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_existing_race_tolerant_roots_and_allowed_artifact_write_remain_unchanged"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":192,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  8. squne121 commented on Jul 16, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES — 現状のまま実装着手すべきではない

    現行の #1502 は、初回レビューで指摘された「ledger writer の lost update」「directory root と exact file の混同」「sibling negative test 不足」をかなり取り込んでいます。前提 Issue #1503 も PR #1533 によりマージ済みです。ここまでは改善です。

    ただし、#1502 の最新契約レビューは 2026年7月16日 09:42 UTC、PR #1533 のマージは同日 11:01 UTC です。つまり、現行契約は依存実装が確定する前に承認されており、#1533 が実際に追加した runtime-build、lock、temporary file のライフサイクルを反映していません。関連PR検索でも、#1502 自体の実装PRはまだ確認できません。

    P0 / Blocker 1 — #1502 が除外しようとしている path 集合は、実際の writer の write closure になっていない

    #1502 は次の2ファイルだけを exact-path unattributable とする契約です。

    • artifacts/codex/subagent-launch-ledger.json
    • .guard_shadow_log.jsonl

    artifacts/codex/ 全体を除外しない方針自体は正しいです。

    しかし、PR #1533 後の実装では、ledger entry を書くたびに ensureLedgerWriter() が以下を実行します。

    1. repo-local tmp/ を作成
    2. tmp/subagent-launch-ledger-writer.<pid>.<random> へ cc でコンパイル
    3. tmp/subagent-launch-ledger-writer へ rename
    4. そのバイナリを実行

    キャッシュ判定はなく、writeLedgerEntry() のたびに再コンパイルされます。

    C writer 側も、最終 ledger 以外に以下を作成・削除します。

    • subagent-launch-ledger.json.lock

    • subagent-launch-ledger.json.tmp

    • cold start では artifacts/ と artifacts/codex/

    これは単なる transient file の見落としではありません。tmp/subagent-launch-ledger-writer は rename 後も残り、再コンパイルで mtime_ns が変化します。現行 executor は repo を os.walk() し、type・mtime・size の差を unauthorized write として返します。tmp/ は現行の race-tolerant root に含まれません。したがって peer hook が executor の before/after 区間に一度でも ledger entry を記録すると、lock/temp が消えた後でも、repo-local writer binary の更新だけで false positive が残ります。

    さらに実 repo では /tmp/ と artifacts/ が ignore されています。git status --ignored=matching は ignore pattern に一致する directory について、内部の個別pathではなく directory 自体を返すため、cold start では tmp/ や artifacts/ の folded ancestor 処理も必要です。 Git公式仕様も、matching mode では ignore pattern に一致した directory の内部pathを表示しないとしています。(Git)

    現行AC1のようにテストから最終ledgerだけを直接更新すると、テストはPASSしても本番hook経路は直りません。

    必須修正

    tmp/subagent-launch-ledger-writer* を新たな例外へ追加してはいけません。これは telemetry ではなく、後で実行される native executable です。child による置換を guard から隠す設計になります。

    優先順位は次です。

    1. native writer を repo snapshot 外の content-addressed cache へ build する、または install/bootstrap 時に事前buildする。
    2. 少なくとも ledger entry ごとの再コンパイルを廃止する。
    3. .lock / .tmp は permanent exact-path exception にせず、bounded quiescenceで消滅を待つ。
    4. timeout後も残る lock/temp は stale residue として fail-close する。
    5. cold/warm の両方で、実際の check-codex-agents.mjs --hook-subagent-start を使う integration test を追加する。

    Codex公式仕様では同一イベントの複数command hookは並行起動されます。os.walk() も走査中に追加・削除されたentryを含むかどうかを未規定としています。したがって、これは fixture 内の単純な file write ではなく、実hookと独立processを使って検証すべき runtime race です。([OpenAI Developers]2)

    P0 / Blocker 2 — shadow log は hardened ledger と同じ信頼クラスではない

    #1502 は ledger と .guard_shadow_log.jsonl を同じ「hook-owned exact file」として扱っています。しかし実装は非対称です。

    ledger は #1533 のC writerに集約され、exclusive lock、lock後の再読込、non-regular entry拒否、same-directory atomic replacementを実装しています。

    一方、shadow log には少なくとも次の異なる writer があります。

    • Node: fs.appendFileSync(...)

    • Python: open(..., "a") と write()

    • shell fallback: echo "$entry" >> "$log_file"

    特に shadow_log.py が失敗すると、hook はより安全性の低い直接shell appendへフォールバックします。fail-open は「記録を捨てて処理を継続する」であるべきで、「安全検査を省いたwriterへ降格する」であってはなりません。

    Nodeの appendFileSync は既定で append flag 'a' を使います。Linux の O_APPEND は各 write() のoffset設定とwriteを一つのatomic stepにしますが、完全なJSONL record全体の整合性を保証するものではなく、write() 自体には partial write があり得ます。現行の複数言語writer間で、record単位のserialization、最大record size、rotation、partial record recoveryは定義されていません。([Node.js]3)

    さらに、これは実装から導かれる重要な攻撃面です。現行writerは final path の symlink・FIFO・device 等を拒否していません。この状態で .guard_shadow_log.jsonl をpath名だけで無条件除外すると、executor childが同pathをsymlinkへ置換してもguardが見逃し、その後のtrusted hookがリンク先へappendする可能性があります。これは単なる「ログ改ざん」ではなく、trusted writerを使った write redirection です。

    必須修正

    安全な選択肢は次のいずれかです。

    1. 推奨: .guard_shadow_log.jsonl を 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502 から分離し、統一hardened writerのIssueをprerequisiteにする。
    2. shadow logを残すなら、全producerを単一helperへ集約する。
    3. helperは少なくとも O_APPEND | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOFOLLOW、fstat()によるregular-file確認、mode 0600、bounded record、complete-write loop、record単位のlockを持つ。
    4. unsafe path時は記録をskipする。shell >> fallbackは禁止する。
    5. symlink、dangling symlink、directory、FIFO、delete、rotation、並行writerのJSONL parseabilityをテストする。

    Linuxの openat2() には、dirfd配下からのescapeを拒否する RESOLVE_BENEATH と、全path componentのsymlink解決を拒否する RESOLVE_NO_SYMLINKS があります。O_NOFOLLOW だけではfinal componentしか保護しない点にも注意が必要です。([man7.org]4)

    P1 / Major 1 — exact-path exception は「文字列集合」ではなく「状態遷移ポリシー」でなければならない

    現行AC1/AC2が許可しているのは create/update です。exact fileのdelete、directory化、symlink化を許可する根拠はありません。しかし実装を「pathがexact setに含まれたらsnapshot/statusから除外」とすると、これらもすべて隠れます。

    しかも現行snapshotは lstat() 後に、

    "dir" if path.is_dir() else "file"

    と分類しています。Path.is_dir() はsymlinkを追跡するため、symlink-to-fileをregular fileと区別できません。

    必要なのは、例えば次のようなpolicyです。

    StableExactPeerFilePolicy
      path
      owner
      canonicality: canonical | lossy_telemetry
      allowed_transitions:
        - absent  -> regular
        - regular -> regular
      allow_delete: false
      allow_non_regular: false
      strict_attribution_handoff
    

    実装上は以下が必要です。

    • snapshotからexact pathを消さない。
    • lstat().st_mode から regular / directory / symlink / FIFO / socket / device を保持する。
    • before/afterの状態遷移を _find_unauthorized_repo_changes() で評価する。
    • exact pathのstrict ancestorについてはdirectory node自身のmtimeだけを無視し、配下のsiblingは引き続き走査する。
    • ledger .lock / .tmp は StableExactPeerFilePolicy に入れない。これらは transient protocol entry として別処理する。

    この設計にしておけば、後続 #1526 の .pytest_cache/v/cache/nodeids も同じ型付きpolicyを再利用できます。#1526 はすでに #1502 のマージ待ちで、同じexecutorへ新たなexact exceptionを追加する契約です。ここで単純なstring tupleを導入すると、例外が増えるたびにself-write blind spotが拡大します。

    P1 / Major 2 — AC3の「sibling updateはfail-close」は現在の観測方式では一般には保証できない

    現行snapshotが保持するのは、概ね次の3要素だけです。

    • file/dir
    • mtime_ns
    • size

    git status 側もbefore/afterのpath集合しか比較していません。

    したがって、既存のignored/untracked siblingについて、

    1. 同じbyte lengthで内容を書き換える
    2. os.utime(ns=...) で元のmtimeを復元する

    という更新を行えば、status集合、size、mtimeがすべて同じになり、guardから見えません。

    よってAC3は次のどちらかへ変更する必要があります。

    • 「現行metadata/status modelで観測可能なcreate/update/deleteをfail-closeする」と保証を限定する。
    • byte-preserving updateまで要求するなら、content hashまたはstrict syscall attributionを導入する。

    #1363 は strict attribution の具体的な完了保証ではありません。現在もopen、triage-requiredで、Linux-only・明示opt-in・default無効の optional follow-up です。canonical evidenceであるledgerへのchild self-writeを許容するなら、「cooperating/trusted childを前提とする」というrisk acceptanceを #1502 本文へ明記すべきです。

    P1 / Major 3 — Verification が本番経路を検証していない

    最新のautomated contract reviewは status: go ですが、5本のpytest nodeidはすべてtest file自体が存在せず、file or directory not found を expected_baseline_fail と分類しただけです。これは契約形状のチェックであり、技術的readinessの証拠ではありません。

    同種の #1409 の既存integration suiteは、以下を明示的に実施しています。

    • 実hook scriptをsubprocessとして起動

    • 実repoと同じ artifacts/ ignore条件

    • independent OS process

    • go/ack barrier

    • fixed sleepに依存しない順序固定

    • cold-start ignored ancestor folding

    • symlink/file parent substitution

    #1502 も同水準であるべきです。最低限、次のケースを分けてください。

    1. 実 check-codex-agents.mjs --hook-subagent-start のcold start。
    2. preexisting ledger / writer binaryがあるwarm start。
    3. lock/tempが正常に消えるケース。
    4. lock/tempが残留してbounded timeoutになるケース。
    5. exact final fileのregular create/update。
    6. exact final fileのdelete、symlink、directory、FIFO substitution。
    7. ledger側とrepo-root側のsibling create/update/delete/rename。
    8. existing race-tolerant rootsとactive issue artifact rootの回帰。
    9. shadow logを残す場合は、全producerの並行JSONL integrity。

    Runtime Verification Applicability は not_applicable ではなく、少なくとも immediate / local integration が妥当です。外部サービスは不要ですが、対象そのものがruntime raceだからです。

    P1 / Major 4 — SSOTが現在の実装境界と一致していない

    docs/dev/agent-skill-boundaries.md は volatile roots として .claude/artifacts/** 全体を記載していますが、実コードが除外するのは .claude/artifacts/issue-refinement-loop だけです。また .guard_shadow_log.jsonl を「root」の一覧に混在させています。

    同じ文書は一方で、NodeがC sourceを tmp/subagent-launch-ledger-writer へbuildすること、ledger writerがlock/tempを使うことを明記しています。つまりSSOT内に必要な情報は存在するのに、#1502のpath contractへ伝播していません。

    文書は少なくとも次の4分類へ分離すべきです。

    • Directory roots: subtree全体をunattributableとして扱うもの
    • Stable exact files: regular create/modifyだけを許容するもの
    • Transient protocol entries: lock/temp等、bounded quiescence対象
    • Build/runtime executable artifacts: telemetry exceptionにしてはならないもの

    各entryに owner、producer実装、canonicality、許可する状態遷移、delete可否、strict-attribution handoffを記録する必要があります。

    推奨する再契約

    最も安全で実装可能性が高い再構成は次です。

    1. #1502をledger-onlyに縮小する。
    2. .guard_shadow_log.jsonl は統一hardened writerの別Issueへ分離する。
    3. check-codex-agents.mjs のper-entry repo-local compileを廃止またはrepo外cacheへ移す。
    4. ledger final fileにはtype-awareなstable exact policyを適用する。
    5. lock/tempにはbounded quiescenceを適用し、persistent residueはfail-closeする。
    6. #1526が再利用できるtyped exact-policy registryを導入する。

    改訂ACは、少なくとも次の内容が必要です。

    AC1  実hookのcold/warm両経路でexecutorがfalse positiveを返さない
    AC2  native executable/candidateをrace-tolerant exceptionへ追加しない
    AC3  ledger lock/tempは正常完了後に消滅し、残留時はfail-closeする
    AC4  final ledgerは absent->regular / regular->regular のみ許可する
    AC5  final ledgerのdelete・symlink・directory・FIFO化はfail-closeする
    AC6  sibling create/update/delete/renameをpath別・操作別に検証する
    AC7  metadata-only detectorの保証限界とtrusted-child前提を明記する
    AC8  existing roots・ignored ancestor folding・allowed artifact rootを回帰させない
    AC9  SSOTをdirectory/stable/transient/executableの4分類へ更新する
    

    総括

    #1533 により ledger のcross-process lost updateは解消されています。しかし、その実装によって repo-local native build、dynamic candidate、persistent binary、lock、temporary file という新しいwrite surfaceが確定しました。現行 #1502 はそのうち最終ledgerしか扱っていないため、現在のACを満たしても元のruntime false positiveを解消できない可能性が高い状態です。

    加えて、shadow logをhardened ledgerと同じexact-path exceptionへ入れると、複数writerのrecord integrityだけでなく、symlink等を介したtrusted-hook write redirectionを隠す危険があります。

    したがって、必要なのは単純なexact-path tuple追加ではなく、依存PRマージ後の再refinement、runtime build配布方式の修正、type/transition-aware policy、実hook integration test、shadow logの分離またはhardened writer化です。

    検証はGitHub上の現行Issue、コメント、main上の実装、関連Issue/PR、および公式一次資料に基づく静的レビューです。実行環境のDNS制約によりrepository cloneとローカルpytest実行は行えていません。

  9. squne121 commented on Jul 16, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-16T21:53:16Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1502
      body_sha256: "sha256:2626f29e1f408570810b34b013c0abc1bcd6611b5f2fcec674bd8e7e25d8b0a1"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:2626f29e1f408570810b34b013c0abc1bcd6611b5f2fcec674bd8e7e25d8b0a1","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_hook_cold_and_warm_ledger_peer_write_is_quiescent -q","command_hash":"sha256:73b7e9d8af89d13a16fa8b9030ada9fb8c52bf3b0c603b86086307e897a1584d","execution_key_hash":"sha256:bbd9e88bf019cf29be95d97865d1716382ed6b0baf57f96aceabe195a7b53e65","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_hook_cold_and_warm_ledger_peer_write_is_quiescent"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":188,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":5,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_exact_policy_rejects_nonregular_and_delete_transitions -q","command_hash":"sha256:adfd292585a902260d0e9d9d7ed18c3d1c477e4dd299d56f03376c089d90031e","execution_key_hash":"sha256:bbd245256f3f6c6cafa6a94aec31b6c75ae3918f7bb961d20c37d6fac549727b","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_exact_policy_rejects_nonregular_and_delete_transitions"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":158,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":8,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_transient_residue_times_out_fail_closed -q","command_hash":"sha256:0fe7439e4fa9a4ec81cc66554b978f26a51179e2ea0b54497be9e3b6cc58293b","execution_key_hash":"sha256:ad8350e12f59a2b90701703c2e92815fe1dd68ae133ce03ae6ea0a23ec9569c8","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_transient_residue_times_out_fail_closed"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":169,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":11,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_siblings_remain_fail_closed_for_observable_changes -q","command_hash":"sha256:4c8fbfc4b782d6917eb34a3083dcd53bac951d62ba6901c40f6ee4f610eb05dd","execution_key_hash":"sha256:9cd77d881774a3b36cceb5f18da46c0d50986f5663b05605ba48fdc811187c39","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_ledger_siblings_remain_fail_closed_for_observable_changes"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":171,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":14,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py -q","command_hash":"sha256:e03743300b3537dcd038d49780bb846241479ed3fa6ae87e46b24575039c0e66","execution_key_hash":"sha256:cf62cea031160cfcec38eeb42c13f64f104abea0d47ef8424cd2c3b6251fa9dd","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":168,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC6","line":17,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_parallel_agent_runtime_safety_documents_typed_ledger_policy -q","command_hash":"sha256:57ee99d97152562b24e609aae381401500ec9a9a414ae4f77f10d62e1515ddf5","execution_key_hash":"sha256:82b874a627a601bfe205d3a7a8d3cfe40ff045eb698a97a3a47beb8e71a8c720","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.py::test_parallel_agent_runtime_safety_documents_typed_ledger_policy"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":158,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  10. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor

    Issue #521 を無視。

  11. added 2 commits that reference this issue on Jul 17, 2026
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