Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
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: failParent 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-localtmp/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
.guard_shadow_log.jsonlの複数 writer、record integrity、symlink/fallback 安全性は本 Issue から除外し、hardened writer 専用 follow-up Issue で扱う。- strict syscall attribution mode は 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 の責務として維持する。本 Issue は stdlib snapshot mode の観測可能な差分だけを扱い、byte-preserving update の完全検出を主張しない。
- 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 の pytest cache exact path は本 Issue の typed policy registry 完成後に直列適用する。
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-localtmp/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
.guard_shadow_log.jsonlの exact-path exception、writer hardening、shell append fallback、JSONL integrity、rotation、symlink safety。artifacts/、artifacts/codex/、tmp/、またはリポジトリ root の directory-wide exclusion。- executor child の Allowed Write Roots の拡張、preflight wrapper の直接実行、shadow logging の無効化。
- strict syscall attribution mode、content hash による metadata-only detector の完全性拡張、または 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 の実装。
- 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 の
.pytest_cache/v/cache/nodeidspolicy。
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 -qAllowed Paths
scripts/check-codex-agents.mjsscripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/tests/test_skill_runtime_exec_subagent_ledger.pytests/test_subagent_launch_ledger_writer.pydocs/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 Safetydocs/dev/workflow.mdscripts/agent-guards/skill_runtime_exec.pyscripts/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
1 Issue = 1 PRとし、.claude/worktrees/issue-1502-runtime-guardで実装して Draft PR を作成する。- 実装前に fresh
CONTRACT_REVIEW_RESULT_V1 status: goを取得する。 - 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 は本 Issue のマージ後に同一 executor の exact policy を直列適用する。
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 まで主張しない。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 13, 2026
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は次の重要問題を扱っていません。.gitignoreと独立hook processを再現しない弱い検証契約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が並行した場合、次の競合が成立します。
さらに、一方がtruncate後・write完了前の状態を他方が読んだ場合、parse failureを空ledgerとして扱い、その空状態を正規データとして上書きする可能性を現行実装は排除していません。
Issue #1502がexact ledger pathを監査対象外にすると、この証跡欠落と破損はruntime guardからも見えなくなります。 誤検知の症状だけを消し、canonical evidenceの完全性を悪化させる構造です。
必須修正
次のどちらかが必要です。
推奨案A: prerequisite issueへ分離
案B: #1502へ統合
Allowed Pathsへ少なくとも以下を追加します。
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)
最低限の保存手順は次です。
より堅牢にするなら、各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自身による次の操作も検出不能になります。
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
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を再帰ごとpruneignored directoryがrootの祖先ならtargeted expansionを行う
ここへ単一ファイルを追加すると、現状のアルゴリズムでは動作する可能性が高いものの、
artifacts/とartifacts/codex/も「unattributable rootの祖先」として特別処理されます。これは単純なexact-path例外ではなく、ignored ancestor展開やdirectory-node判定にも影響する変更です。推奨設計
責務を分離します。
そして、次を別関数に分けます。
これにより、将来別の単一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では、実際の変更が次のように畳み込まれる可能性があります。
既存の基本テスト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)
必須テストマトリクス
Runtime Verificationは次のように分けるべきです。
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へ追加します。
文書には最低限、次を記載します。
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で検証すべきです。
Minor — Verification CommandsがACを個別に証明していない
AC1〜AC3がすべて同じコマンドです。
これでは、どのACがどのtestで証明されたかをTEST_VERDICTへ機械的に写像できません。
個別node IDに変更すべきです。
uv runには既存運用に合わせて--lockedも付けるべきです。推奨するIssue再構成
1. ledger integrityを先に解決
新規prerequisite issue:
主なAC:
2. #1502はguard attributionだけに限定
ledger writer hardening完了後、#1502で次を実装します。
最終結論
exact ledger pathだけを除外する方針自体は採用可能です。しかし、現行Issueは canonical evidenceのwriter integrityを確認せず、除外によって生じるchild tampering盲点も受け入れ条件にしていません。
特に以下の2点が解消されるまで、実装開始は拒否すべきです。
check-codex-agents.mjsのcross-process read-modify-write競合をprerequisite化または同一Issueで修正するこの2点なしにマージすると、#1502はfalse positiveを除去する代わりに、SubAgent dispatch監査のcanonical evidenceを静かに欠落・改変できる新しいfalse-negative apertureを作ります。
このレビューはGitHubへ投稿していません。ローカルでのテスト実行は、実行環境からGitHubへのDNS接続が利用できなかったため行わず、GitHub上の現行資産・履歴と公式仕様を根拠に判定しています。
squne121 commentedon Jul 13, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 13, 2026
squne121 commentedon Jul 13, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 14, 2026
Contract Review Result
squne121 commentedon Jul 16, 2026
Contract Review Result
squne121 commentedon Jul 16, 2026
判定: 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.jsonlartifacts/codex/全体を除外しない方針自体は正しいです。しかし、PR #1533 後の実装では、ledger entry を書くたびに
ensureLedgerWriter()が以下を実行します。tmp/を作成tmp/subagent-launch-ledger-writer.<pid>.<random>へccでコンパイルtmp/subagent-launch-ledger-writerへ renameキャッシュ判定はなく、
writeLedgerEntry()のたびに再コンパイルされます。C writer 側も、最終 ledger 以外に以下を作成・削除します。
subagent-launch-ledger.json.locksubagent-launch-ledger.json.tmpcold 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 から隠す設計になります。優先順位は次です。
.lock/.tmpは permanent exact-path exception にせず、bounded quiescenceで消滅を待つ。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 です。必須修正
安全な選択肢は次のいずれかです。
.guard_shadow_log.jsonlを 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502 から分離し、統一hardened writerのIssueをprerequisiteにする。O_APPEND | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOFOLLOW、fstat()によるregular-file確認、mode0600、bounded record、complete-write loop、record単位のlockを持つ。>>fallbackは禁止する。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()後に、と分類しています。
Path.is_dir()はsymlinkを追跡するため、symlink-to-fileをregular fileと区別できません。必要なのは、例えば次のようなpolicyです。
実装上は以下が必要です。
lstat().st_modeから regular / directory / symlink / FIFO / socket / device を保持する。_find_unauthorized_repo_changes()で評価する。.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要素だけです。
mtime_nsgit status側もbefore/afterのpath集合しか比較していません。したがって、既存のignored/untracked siblingについて、
os.utime(ns=...)で元のmtimeを復元するという更新を行えば、status集合、size、mtimeがすべて同じになり、guardから見えません。
よってAC3は次のどちらかへ変更する必要があります。
#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 も同水準であるべきです。最低限、次のケースを分けてください。
check-codex-agents.mjs --hook-subagent-startのcold start。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分類へ分離すべきです。
各entryに owner、producer実装、canonicality、許可する状態遷移、delete可否、strict-attribution handoffを記録する必要があります。
推奨する再契約
最も安全で実装可能性が高い再構成は次です。
.guard_shadow_log.jsonlは統一hardened writerの別Issueへ分離する。check-codex-agents.mjsのper-entry repo-local compileを廃止またはrepo外cacheへ移す。改訂ACは、少なくとも次の内容が必要です。
総括
#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実行は行えていません。
squne121 commentedon Jul 16, 2026
Contract Review Result
squne121 commentedon Jul 17, 2026
Issue #521 を無視。
fix: PR #1552 REQUEST_CHANGES 6件のP1 blockerを解消する (#1502)
実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する (#1552)
実装: 契約実行ラッパーの unauthorized_write_path 誤検知を .guard_shadow_log.jsonl 専用…