Repository navigation
fix: session-manifest hook 専用 subtree を race-tolerant 除外に追加する - #1426
Conversation
契約実行ラッパー (scripts/agent-guards/skill_runtime_exec.py) が、
session-manifest hook (session_manifest_debounce.mjs /
generate_session_manifest_from_hook.mjs) 自身の非同期書き込みを
実行コマンドの unauthorized write と誤認し unauthorized_write_path で
fail-close するバグを修正する。
- 両 hook の出力先を repo-root 直下 artifacts/*.json から専用 subtree
artifacts/session-manifest-runtime/{events,locks,tmp,manifests}/ へ変更
- skill_runtime_exec.py の _VOLATILE_PEER_SESSION_ROOT_RELS を
_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS へ改名し、新 subtree のみを追加
(repo-root artifacts/ 全体は引き続き監査対象のまま)
- _snapshot_repo_paths の祖先ディレクトリ除外ロジックを peer root にも
適用し、新規作成された artifacts/ 自体が誤検知されないようにする
- 実際の debounce/generate hook プロセスを用いた同期型ライフサイクル
統合テストを追加 (lock 作成/削除・tmp 作成・atomic rename・
failed rename・event 削除・known-limitation self-write)
- docs/dev/agent-skill-boundaries.md に新 subtree・改名後シンボル名・
#1363 strict_strace mode との mode 別契約を追記
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1426 closed). |
TEST_VERDICT:
result: PASS
mergeable: MERGEABLE
merge_state_status: BLOCKED
branch_behind_main: false
baseline_only: false
verification_commands_pass: 8
verification_commands_fail: 0
verification_skipped_count: 0
runtime_ac_results:
- ac: AC1
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_write_to_session_manifest_runtime_does_not_fail"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: true
human_review_required: false
stop_condition_triggered: false
notes: "Real debounce process lifecycle test passed. Session-manifest hook writes to artifacts/session-manifest-runtime/ are now correctly excluded from unauthorized write checks."
- ac: AC2
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_race_tolerant_stdlib_excludes_session_manifest_runtime_subtree"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: true
human_review_required: false
stop_condition_triggered: false
notes: "Race-tolerant mode correctly excludes artifacts/session-manifest-runtime/** from unauthorized write detection."
- ac: AC3
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_outside_session_manifest_runtime_still_fails"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: true
human_review_required: false
stop_condition_triggered: false
notes: "Child commands writing outside artifacts/session-manifest-runtime/ still fail as expected (regression protection)."
- ac: AC4
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_mode"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: true
human_review_required: false
stop_condition_triggered: false
notes: "Known-limitation test confirms that child self-write to artifacts/session-manifest-runtime/ cannot be distinguished from hook writes in stdlib mode."
- ac: AC5
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_lock_rename_and_failed_rename_lifecycle"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: true
human_review_required: false
stop_condition_triggered: false
notes: "Full lifecycle test covering lock creation, metadata updates, temporary files, atomic renames, event file deletions, and failed renames with synchronization barriers."検証結果レポートIssue #1409: 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する
総合判定
すべての Acceptance Criteria が満たされています。 |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: REQUEST_CHANGES
reviewed_head_sha: "607dc22265507b13c55571dd8d53d474253ce184"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BLOCKED"
blockers:
- "required CI check `python-test`(workflow: ci) が head 607dc222...ce184 で FAILURE。原因は Ruff (E,F select, E402 ignore) の F401: scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py:29 の `import stat` が未使用(該当ファイルは AC1-AC5 用の新規テストで Allowed Paths 内)。run: https://github.com/squne121/loop-protocol/actions/runs/29096030956/job/86372696604 / ##[error]Process completed with exit code 1. と Found 1 error. [*] 1 fixable with the --fix option."
- "mergeStateStatus が BLOCKED(required check 未通過に起因)。修正後に再評価が必要。"
allowed_paths_gate:
producer_role: review_subagent
worker_report_used_as_canonical: false
status: "ok"
changed_files_source: "github_pull_request_files_api_with_previous_filename"
changed_files:
- ".claude/hooks/generate_session_manifest_from_hook.mjs"
- ".claude/hooks/session_manifest_debounce.mjs"
- ".claude/hooks/tests/test_generate_session_manifest_from_hook.py"
- ".claude/hooks/tests/test_session_manifest_debounce.py"
- "docs/dev/agent-skill-boundaries.md"
- "scripts/agent-guards/skill_runtime_exec.py"
- "scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py"
changed_file_records:
- path: ".claude/hooks/generate_session_manifest_from_hook.mjs"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: ".claude/hooks/session_manifest_debounce.mjs"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: ".claude/hooks/tests/test_generate_session_manifest_from_hook.py"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: ".claude/hooks/tests/test_session_manifest_debounce.py"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: "docs/dev/agent-skill-boundaries.md"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: "scripts/agent-guards/skill_runtime_exec.py"
status: "modified"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
- path: "scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py"
status: "added"
previous_path: null
source: "github_pull_request_files_api_with_previous_filename"
provenance_complete: true
audited_paths:
- path: ".claude/hooks/generate_session_manifest_from_hook.mjs"
path_role: "filename"
source_record_index: 0
- path: ".claude/hooks/session_manifest_debounce.mjs"
path_role: "filename"
source_record_index: 1
- path: ".claude/hooks/tests/test_generate_session_manifest_from_hook.py"
path_role: "filename"
source_record_index: 2
- path: ".claude/hooks/tests/test_session_manifest_debounce.py"
path_role: "filename"
source_record_index: 3
- path: "docs/dev/agent-skill-boundaries.md"
path_role: "filename"
source_record_index: 4
- path: "scripts/agent-guards/skill_runtime_exec.py"
path_role: "filename"
source_record_index: 5
- path: "scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py"
path_role: "filename"
source_record_index: 6
violations: []
expected_contract_fingerprint:
contract_source_kind: "issue"
source_id: "1409"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
notes: |
- Issue #1409 contract 照合: AC coverage は PR本文「## Checks」に AC1-AC8 相当のコマンド/結果が記載され、
test-runner の TEST_VERDICT(https://github.com/squne121/loop-protocol/pull/1426#issuecomment-4935825446)
でも AC1-AC8 全て PASS と報告されている。Allowed Paths 遵守も上記 allowed_paths_gate で ok(全 7 changed files が
contract の Allowed Paths 内、逸脱なし)。Schema Change Applicability(not_schema_change)/Schema Consumer
Inventory(N/A)/Safety Claim Matrix(N/A理由記載+レビュー観点明記) の表記も contract 条件を満たしている。
- しかし required CI check python-test が現行 head で FAILURE のため、TEST_VERDICT/PR_BODY_SELF_REPORT の
緑報告だけでは APPROVE できない(PR_REVIEW_JUDGE_VC_EVIDENCE_POLICY: CI_CHECK_RUN_SCOPED が blocker を示す限り
APPROVE 不可)。原因は単純な F401(未使用 import stat)であり mechanical に `ruff check --fix` で解消可能だが、
本 review subagent はファイル編集不可のため required_auto_actions には計上せず、実装側(worker)の修正コミットを
要求する blocker として記載する。
- 修正後は同一 head での CI 再実行・python-test PASS を確認してから再レビューすること。Ruff --select E,F --ignore E402 flagged F401 (unused-import) on `import stat` in test_skill_runtime_exec_session_manifest_lifecycle.py. Resolves the required `python-test` CI check failure on PR #1426.
fix_delta iteration 2 対応完了required CI check
CI の python-test check の再実行結果をご確認ください。 |
TEST_VERDICT:
result: FAIL
mergeable: MERGEABLE
merge_state_status: BLOCKED
branch_behind_main: false
baseline_only: true
verification_commands_pass: 1
verification_commands_fail: 7
verification_skipped_count: 0
runtime_ac_results:
- ac: AC1
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_write_to_session_manifest_runtime_does_not_fail"
exit_code: 4
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "test_skill_runtime_exec_session_manifest_lifecycle.py not yet created (baseline expected_fail)"
- ac: AC2
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_race_tolerant_stdlib_excludes_session_manifest_runtime_subtree"
exit_code: 4
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "test_skill_runtime_exec_session_manifest_lifecycle.py not yet created (baseline expected_fail)"
- ac: AC3
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_outside_session_manifest_runtime_still_fails"
exit_code: 4
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "test_skill_runtime_exec_session_manifest_lifecycle.py not yet created (baseline expected_fail)"
- ac: AC4
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_mode"
exit_code: 4
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "test_skill_runtime_exec_session_manifest_lifecycle.py not yet created (baseline expected_fail)"
- ac: AC5
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_lock_rename_and_failed_rename_lifecycle"
exit_code: 4
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "test_skill_runtime_exec_session_manifest_lifecycle.py not yet created (baseline expected_fail)"
- ac: AC6
command: "uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py"
exit_code: 0
status: pass
fallback_detected: false
artifact_present: false
human_review_required: false
stop_condition_triggered: false
notes: "6 passed - existing regression tests passed successfully"
- ac: AC7
command: "rg -n \"strict_strace\" docs/dev/agent-skill-boundaries.md"
exit_code: 1
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "docs/dev/agent-skill-boundaries.md does not yet contain 'strict_strace' reference (baseline expected_fail)"
- ac: AC8
command: "rg -n \"artifacts/session-manifest-runtime\" docs/dev/agent-skill-boundaries.md"
exit_code: 1
status: fail
fallback_detected: false
artifact_present: not_required
human_review_required: false
stop_condition_triggered: false
notes: "docs/dev/agent-skill-boundaries.md does not yet contain 'artifacts/session-manifest-runtime' reference (baseline expected_fail)"SummaryAll baseline-expected failures confirmed (AC1-AC5, AC7-AC8 test files/doc references not yet created). AC6 existing regression tests passed (6/6). Mergeable: MERGEABLE (GitHub status checks awaiting completion, mergeStateStatus=BLOCKED is not a merge conflict) |
検証結果レポート(誤検証の訂正)直前の test-runner 実行で誤ったブランチ上で検証が実行されたため、AC1-AC5/AC7/AC8 を誤って FAIL と報告されていました。本レポートは、正しいブランチ Issue #1409: 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する
総合判定
検証実行環境
TEST_VERDICT:
result: PASS
mergeable: MERGEABLE
merge_state_status: CLEAN
branch_behind_main: false
baseline_only: false
verification_commands_pass: 8
verification_commands_fail: 0
verification_skipped_count: 0
runtime_ac_results: [] |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "16f0c8702d0b36729835af467027d9d31cf59544"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
allowed_paths_gate:
producer_role: review_subagent
worker_report_used_as_canonical: false
status: "ok"
changed_files_source: "gh_pr_diff_name_only"
changed_files:
- ".claude/hooks/generate_session_manifest_from_hook.mjs"
- ".claude/hooks/session_manifest_debounce.mjs"
- ".claude/hooks/tests/test_generate_session_manifest_from_hook.py"
- ".claude/hooks/tests/test_session_manifest_debounce.py"
- "docs/dev/agent-skill-boundaries.md"
- "scripts/agent-guards/skill_runtime_exec.py"
- "scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py"
violations: []
expected_contract_fingerprint:
contract_source_kind: "issue"
source_id: "1409"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
notes: |
- 前回レビュー(head 607dc222)の唯一の blocker だった required CI check `python-test` の F401
(`import stat` 未使用) は head 16f0c870 で解消済み。差分は該当テストファイルの import 1行削除のみ
(git diff 607dc222..16f0c870 で確認、scope creep なし)。
- wait_ci_checks.sh で required CI 全チェック(test/build/lint/typecheck/python-test/
validate-generated-artifact)が head 16f0c870 で SUCCESS であることを確認。
ci_verdict_summary.py --expected-head-sha 16f0c870 も status: all_pass, exit 0(stale head なし)。
- TEST_VERDICT_MACHINE(訂正版、2026-07-10T13:39:55Z、branch
worktree-issue-1409-skill-runtime-exec-write-path, HEAD SHA 16f0c870 一致)で AC1-AC8 全 PASS、
verification_commands_fail: 0, verification_skipped_count: 0, fallback/SKIP/exit77 記載なし。
先行の誤ブランチ検証(FAIL 報告, 13:35:57)は本訂正コメントで明示的に superseded。
- Allowed Paths 遵守: `gh pr diff --name-only` で取得した現行 head の changed files 7件は前回レビュー時と
完全一致し、全て Issue #1409 contract の Allowed Paths 内(逸脱なし)。
- Schema Change Applicability(not_schema_change) / Schema Consumer Inventory(N/A) /
Safety Claim Matrix(N/A, LP051 非該当理由記載) は前回レビューで確認済みで変更なし。
- AC coverage は PR本文「## Checks」+ TEST_VERDICT 訂正コメントで AC1-AC8 相当が根拠付きで記載されている。
- Draft PR だが `merge_ready` 判定には影響しない(skill 仕様どおり)。
判定REQUEST_CHANGES 対象は現行 head 中心となる修正目的を未達にする Blocker 1件、運用・検証上の Major 3件があります。特にBlockerは、CIが緑でもテストfixtureが実リポジトリの 1. Blocker / P1 — ignored親ディレクトリが畳まれ、cold startでは依然
|
…tus diff (#1409) OWNER REQUEST_CHANGES (PR #1426 review 2026-07-10): the real repo .gitignore ignores artifacts/ as a whole, so git status --ignored=matching collapses a cold-start creation of artifacts/session-manifest-runtime/** into a single "!! artifacts/" entry, which was misreported as unauthorized_write_path=artifacts/ instead of being recognized as the excluded subtree. - Add _strict_ancestor_of_race_tolerant_root / _expand_folded_ignored_status_dir / _is_real_nonsymlink_dir / _expand_new_status_paths to expand a collapsed ignored-ancestor status entry into its real leaf paths via a targeted (path-restricted) `git status --ignored=traditional` scan, before applying race-tolerant-root exclusion. Expansion only happens when the collapsed entry is confirmed to be a real, non-symlink directory on disk; symlink/file parent substitution still fails closed. - Fix the test fixture's .gitignore to match the real repo (it previously omitted artifacts/, hiding this bug from the existing test suite). - Add 8 new tests: cold-start success/fail-close pairs, existing-artifacts success/fail-close pairs, symlink/file parent substitution fail-close, an independent-OS-process barrier test (go-file/ack-file, no fixed sleep) distinguishing peer-process writes from the child's own writes, and a legacy-runtime-state coexistence test verifying no deadlock or duplicate generation under the documented hard-cutover compatibility decision. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
2026-07-10 REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/1426#issuecomment-4938768837)へ対応しました。 P1 Blocker(ignored 親ディレクトリの折り畳み)
P2 x3
検証結果
詳細は PR 本文の Commit: b12fe8a |
TEST_VERDICT_MACHINE v1(訂正)直前のコメントで AC7/AC8 が誤って FAIL と報告されましたが、これは誤った checkout 状態での実行によるものでした。head 検証対象 head:
TEST_VERDICT:
result: PASS
mergeable: MERGEABLE
merge_state_status: CLEAN
branch_behind_main: false
baseline_only: false
verification_commands_pass: 8
verification_commands_fail: 0
verification_skipped_count: 0 |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
再レビュー対象: 人間 REQUEST_CHANGES(P1 Blocker + P2 Major x3、https://github.com/squne121/loop-protocol/pull/1426#issuecomment-4938768837)への fix-delta。
P1 Blocker(ignored 親ディレクトリの折り畳み): 解消を確認
_strict_ancestor_of_race_tolerant_root/_expand_folded_ignored_status_dir(bounded-- <dir>scoped scan、repo 全体--ignored=traditional化はしていない)/_is_real_nonsymlink_dir(parent substitution 対策)/_expand_new_status_pathsの実装を diff で確認。- fixture
.gitignoreにartifacts/を追加(実リポジトリと一致)した上で、test_cold_start_peer_writes_only_race_tolerant_subtree_succeeds/test_cold_start_peer_writes_subtree_and_unauthorized_sibling_fails/test_existing_artifacts_dir_*/test_artifacts_as_symlink_created_mid_run_fails_closed/test_artifacts_as_file_created_mid_run_fails_closedを独立 worktree(git worktree add)でuv run --locked pytest実行し 13/13 PASS を再現確認。cold-start 折り畳みシナリオが自己申告でなく実際にテストされている。
P2 Major(1) storage layout 移行方針: 実質充足、diagnostic のみ follow-up
- Compatibility Decision セクション(
intentional_hard_cutover)と Safety Claim Matrix を PR 本文に追加済み。test_legacy_runtime_state_present_does_not_deadlock_or_duplicateで旧 state 残存時の非 deadlock・非重複を確認。 - 未実装:
.claude/hooks/*.mjs側の起動時 machine-readable diagnostic。worker はセッション内 tool 権限で.claude/hooks/**への Read/Edit が denied だったと PR 本文で明記(Allowed Paths 上は許可対象)。この項目は Safety Claim Matrix でImplemented: noとして明示的に bounded 開示されており、best-effort な非 fail-close telemetry(security control ではない)であるため、merge blocking の P1 Blocker とは性質が異なると判断した。follow-up issue 化を推奨する。
P2 Major(2) peer/background write 検証の独立プロセス化: 解消を確認
test_independent_writer_process_with_explicit_barrier_succeeds(subprocess.Popenによる真の別プロセス + go-file/ack-file barrier、fixed sleep 不使用)を追加。独立 pytest 実行で PASS を確認。
P2 Major(3) Safety Claim Matrix: 追加を確認
- PR 本文に 10 行の Matrix を追加。
Not controlled列・evidence・follow-up の記載あり。
AC / VC 独立検証
scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py の AC1〜AC5 個別 VC、AC6(既存6テスト)、AC7/AC8(rg)を Issue #1409 記載どおりのコマンドで独立実行し全て PASS。scripts/agent-guards/tests/(525 tests)も全 PASS。
verdict: APPROVE
reviewed_head_sha: "b12fe8ab9897778ea7ebc96e48bd43c6ba4222fe"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
allowed_paths_gate:
schema: ALLOWED_PATHS_GATE_RESULT_V1
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
contract_source_kind: issue
contract_source_id: "1409"
expected_contract_fingerprint: "sha256:ea50f8c3f2004fd0b17568ce7625451043049dd88b83240e1dbea6a5dff3d69d"
contract_fingerprint_verified: true
contract_fingerprint_verification_method: "gh issue view --json body sha256, matches contract-snapshot go comment"
changed_files_source: github_pull_request_files_api_with_previous_filename
audited_paths_count: 7
violations: []
notes: "allowed_paths_review_gate.py invocation was blocked by worktree_scope_guard for this review_subagent role (expected_worktree: <skill-runtime-denied>); gate recomputed manually against GitHub Files API (status=modified/added, previous_filename=null for all 7 files, no renames) cross-checked against the 8-entry Allowed Paths list from the Issue #1409 contract at the verified fingerprint."
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests:
- title: "session-manifest hook 起動時の legacy-state 検出 machine-readable diagnostic"
reason: "PR #1426 の Safety Claim Matrix で Implemented=no と明示された best-effort telemetry。tool 権限制約により本 PR では未実装。security control ではないため merge blocker にはしないが、可観測性向上のため follow-up 推奨。"
scope_note: ".claude/hooks/session_manifest_debounce.mjs / generate_session_manifest_from_hook.mjs に、旧 runtime state(session-manifest-debounce/、artifacts/.lock-*、artifacts/.tmp-*、root manifest)検出時の非 fail-close stderr diagnostic を追加する"|
OWNER 指摘(session-manifest hook 起動時の legacy-state 検出 machine-readable diagnostic 未実装)について、follow-up Issue を起票しました。 対象: |
) * feat: session-manifest hook 起動時の legacy-state 検出 diagnostic を追加する (#1430) PR #1426 のhard cutover は旧 runtime state (artifacts/session-manifest-debounce/{events,worker.lock}, repo-root 直下の artifacts/.lock-*/.tmp-*/private-agent-session-manifest-*.json) を意図的に migrate/cleanup しない。本コミットは session_manifest_debounce.mjs と generate_session_manifest_from_hook.mjs の起動時に旧 layout の残存を検出し、 fail-close させずに固定スキーマの machine-readable diagnostic (SESSION_MANIFEST_LEGACY_STATE_V1=<single-line JSON>) を stderr へ出力する。 matcher は既存コードが生成していたファイル名文法 (SHA-256 先頭32hex の stable key, UUID 形式の tmp 名) に厳密に限定し、artifacts/ 配下の無関係な scratch prefix を 誤検出しない。 Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: session-manifest legacy-state diagnostic の実運用回帰リスクを解消する (#1430) PR #1440 レビュー(REQUEST_CHANGES)の指摘に対応し AC8-AC14 を実装した。 - AC8: legacy diagnostic の出力を finally でバッファし、既存の SESSION_MANIFEST_*_RESULT_V1 行より後に出力する(coordinator の 先頭1行採用で隠れないようにする) - AC9: paths を先頭20件に bound し total_count/truncated を追加 (spawnSync maxBuffer 超過による telemetry 消失を防止) - AC10: producer 失敗時に debounce flush loop が queued event を 削除しない(再試行可能にする) - AC11: UUID matcher を RFC4122 v4 の厳密な grammar に変更し、root manifest matcher の hook 種別を既知の hook 名に限定する - AC12: lstatSync/readdirSync(withFileTypes) で file type を区別し symlink/directory を誤検出しない。fs エラーは SESSION_MANIFEST_LEGACY_SCAN_V1 で scan_failed として区別する - AC13: artifacts/session-manifest-runtime/legacy-state-markers/ の one-shot marker で同一 residue の重複診断を抑制する - AC14: front gate (session_manifest_debounce.mjs) 自身が producer 側 legacy state も検出し、detached stdio:'ignore' worker に依存 せず観測可能にする docs/dev/hook-boundaries.md に SESSION_MANIFEST_LEGACY_STATE_V1 / SESSION_MANIFEST_LEGACY_SCAN_V1 の診断契約を追記した。 Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: PR Body Japanese Check 対応で見出しに日本語を含める Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
scripts/agent-guards/skill_runtime_exec.py) が、session-manifest hook (session_manifest_debounce.mjs/generate_session_manifest_from_hook.mjs) 自身の非同期書き込みを実行コマンドの unauthorized write と誤認しunauthorized_write_pathで fail-close する問題を修正する(実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 の修正範囲外だった穴、実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する #1409)。artifacts/全体を除外するのではなく、hook 専有の新設 subtreeartifacts/session-manifest-runtime/(events//locks//tmp//manifests/)のみを race-tolerant 除外対象に追加した。artifacts/{issue}/issue-metadata/{command-id}/を含むそれ以外のartifacts/**は引き続き監査対象。_VOLATILE_PEER_SESSION_ROOT_RELSを_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSへ改名(peer-session に限らず同一セッションの非同期 hook worker も対象であるため)。_snapshot_repo_pathsの祖先ディレクトリ除外ロジックを peer root にも適用し、新規作成されたartifacts/自体(他ルートの祖先)が誤検知されないよう修正した。REQUEST_CHANGES 対応(2026-07-10 OWNER レビュー、https://github.com/squne121/loop-protocol/pull/1426#issuecomment-4938768837)
Blocker (P1): ignored 親ディレクトリの折り畳みで cold start が誤検知される
実リポジトリの
.gitignoreはartifacts/を丸ごと ignore するため、git status --ignored=matchingは cold start(artifacts/が事前に存在しない状態)での hook subtree 作成を!! artifacts/(折り畳まれた親ディレクトリ 1 エントリ)として報告し、artifacts/session-manifest-runtimeへのレース耐性除外が効かずunauthorized_write_path=artifacts/で誤 fail-close することを確認した(scripts/agent-guards/skill_runtime_exec.pyの内部関数レベルで再現・修正前後の差分を確認済み)。修正内容:
_strict_ancestor_of_race_tolerant_root(): 新規ステータスエントリがレース耐性除外 root の strict ancestor であるかを判定する。_expand_folded_ignored_status_dir(): 折り畳まれた ignored ディレクトリを、そのディレクトリに限定した (-- <dir>)git status --ignored=traditionalで leaf path へ展開する(repo 全体を無条件に--ignored=traditionalへ変える代替案は採用していない — bounded / targeted expansion のみ)。_is_real_nonsymlink_dir(): 展開前に、対象が実在する non-symlink directory であることを確認する。symlink または plain file であれば展開せず、生の折り畳みエントリのまま fail-close 経路に流す(parent substitution 対策)。_expand_new_status_paths(): 上記を組み合わせ、_find_unauthorized_repo_changesの新規 status path 集合を展開してから既存の除外フィルタを適用する。fixture の
.gitignore修正:scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::_make_repoの.gitignoreにartifacts/を追加し、実リポジトリと一致させた(旧 fixture はartifacts/を ignore しておらず、この折り畳みバグを検出できなかった)。追加テスト(全て新規・全て PASS):
test_cold_start_peer_writes_only_race_tolerant_subtree_succeeds—artifacts/不在の cold start + hook subtree のみ作成 → successtest_cold_start_peer_writes_subtree_and_unauthorized_sibling_fails— cold start + hook subtree +artifacts/unrelated/**同時作成 →unauthorized_write_path(折り畳みエントリでなく leaf path を正確に指す)test_existing_artifacts_dir_hook_subtree_update_succeeds—artifacts/既存 + hook subtree 更新 → successtest_existing_artifacts_dir_unrelated_update_fails—artifacts/既存 +artifacts/unrelated/**更新 →unauthorized_write_pathtest_artifacts_as_symlink_created_mid_run_fails_closed—artifactsが実行中に symlink として作成される → fail-closetest_artifacts_as_file_created_mid_run_fails_closed—artifactsが実行中に plain file として作成される → fail-close重要指摘(Major, P2)3 件への対応
1. storage layout 移行方針(意図的 hard cutover):
旧配置(
artifacts/session-manifest-debounce/events/,worker.lock,artifacts/.lock-*,artifacts/.tmp-*,artifacts/private-agent-session-manifest-*.json)から新配置(artifacts/session-manifest-runtime/{events,locks,tmp,manifests}/)への移行は 意図的な hard cutover とする。test_legacy_runtime_state_present_does_not_deadlock_or_duplicate(新規)で、旧 state(legacy events/worker.lock/.lock-*/.tmp-*/root manifest)が残存していても新 subtree での real hook lifecycle が deadlock せず、新しい manifest が正しく生成されること、旧 state が silent に上書き/削除されないことを確認した。.claude/hooks/*.mjsへの実装を計画したが、本セッションの実行環境では.claude/hooks/**へのファイル編集がツール権限レベルで denied(Read/Edit 双方)であり、このセッション内では実装できなかった。これは Allowed Paths 上は許可されているが、実行環境の permission 設定によるブロックであり、必要であれば follow-up で対応する。SESSION_MANIFEST_ARTIFACTS_DIRの意味変化(旧:generate_session_manifest_from_hook.mjsの直接配置先 → 新:manifests//locks//tmp/の base directory)は 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する #1409 の元 PR(fix: session-manifest hook 専用 subtree を race-tolerant 除外に追加する #1426 初回コミット)で導入済みで、consumer は.claude/hooks/tests/の既存テストのみ(外部 consumer なし)。今回変更なし。2. peer/background write 検証の独立プロセス化:
新規テスト
test_independent_writer_process_with_explicit_barrier_succeedsを追加した。実装:subprocess.Popenwriter process(executor の child process tree の外)を、executor 起動前に先に spawn する。os.fsyncで durable 化してから ack-file を作成。既存の
threading.Thread+ 固定 sleep ベースの AC2 テストはそのまま保持("child process 自身が subtree に書く" ケースとは別軸の "peer thread が subtree に書く" ケースの回帰検証として引き続き有効)。今回追加した独立プロセス版テストが、"executor 外で既に動いている独立プロセスによる write" を厳密に検証する。3. Safety Claim Matrix:
下記のとおり更新(詳細は本 PR 本文の Safety Claim Matrix セクションを参照)。
Checks
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py— 13/13 PASS(AC1〜AC5 の実プロセス統合テスト + 本 REQUEST_CHANGES 対応の新規 8 テスト)uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py— 6/6 PASS(AC6、既存回帰なし)rg -n "strict_strace" docs/dev/agent-skill-boundaries.md— 1 hit(AC7)rg -n "artifacts/session-manifest-runtime" docs/dev/agent-skill-boundaries.md— 4 hits(AC8)uv run --locked pytest scripts/agent-guards/tests/— 525 passeduv run --locked pytest .claude/hooks/tests/— 1019 passeduv run pytest -q(repo 全体)— 既存 4 件の pre-existing failure(base branch 由来、本 PR の変更と無関係。tests/context_mode/test_fetch_strict_artifact.py、tests/test_agent_parity.py::TestB4RealRepoParity、tests/test_hook_boundaries_doc.pyの 2 件)を除き全 PASS。stash 検証で base ブランチ単体でも同一 4 件が fail することを確認済みpnpm lint(変更対象の.mjsファイルなし、対象 Python/pytest のみのため差分なし確認)uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py— 21 passedSchema Change Applicability
artifacts/session-manifest-runtime/の内部レイアウト)とラッパーの内部除外ロジックの変更であり、agent_session_manifest/v1等の公開スキーマのキー・型・consumer 契約は変更していない。Schema Consumer Inventory
N/A
reason: schema_change ではないため対象外。
Compatibility Decision(新規セクション、REQUEST_CHANGES P2-1 対応)
artifacts/session-manifest-debounce/**,artifacts/.lock-*,artifacts/.tmp-*,artifacts/private-agent-session-manifest-*.json)は新 subtree(artifacts/session-manifest-runtime/**)へ migrate しない。duplicate scan は新manifests/のみを見る(旧 root manifest は見ない、= 旧 pending telemetry は再送されない)。test_legacy_runtime_state_present_does_not_deadlock_or_duplicate(新規)で、旧 state が残存していても deadlock なく新 subtree で正しく manifest が生成されることを確認。.claude/hooks/*.mjs側での旧 state 検出通知)は、本セッションの tool 権限制約(.claude/hooks/**への Read/Edit が denied)により実装できなかった。Allowed Paths 上は許可されている変更のため、必要であれば follow-up Issue で対応する。SESSION_MANIFEST_ARTIFACTS_DIRの意味変化(direct placement → base directory): 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する #1409 初回コミットで導入済み。consumer は.claude/hooks/tests/のみで外部 consumer なし。今回の fix delta では変更なし。Safety Claim Matrix
本 PR で導入・維持する安全性claimの一覧を以下に示す。
artifacts/)が新規作成されても、artifacts/session-manifest-runtime/**のみの write は誤検知しないtest_cold_start_peer_writes_only_race_tolerant_subtree_succeedsartifacts/session-manifest-runtime/**と同時にartifacts/unrelated/**が作られた場合は fail-close する(leaf path を正確に報告)test_cold_start_peer_writes_subtree_and_unauthorized_sibling_failsartifacts/が既存の状態でも同様の区別(subtree=success / unrelated=fail-close)が成立するtest_existing_artifacts_dir_hook_subtree_update_succeeds,test_existing_artifacts_dir_unrelated_update_failstest_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_modedocs/dev/agent-skill-boundaries.md(AC7/AC8、rgVC で確認)artifactsの symlink/file による parent substitution は許可しない(折り畳み展開ロジックを悪用させない)test_artifacts_as_symlink_created_mid_run_fails_closed,test_artifacts_as_file_created_mid_run_fails_closedtest_legacy_runtime_state_present_does_not_deadlock_or_duplicatetest_independent_writer_process_with_explicit_barrier_succeedstest_self_write_outside_session_manifest_runtime_still_fails.claude/hooks/*.mjs側、best-effort な非 fail-close telemetry のみで security control ではない).claude/hooks/**への Read/Edit が denied で実装不能だった(Allowed Paths 上は許可、下記 Compatibility Decision の known gap 参照)Notes
.claude/hooks/session_manifest_debounce.mjs/.claude/hooks/generate_session_manifest_from_hook.mjsを別プロセスとして起動する統合テスト(scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py)で満たした。同期バリアは固定 sleep でなく、--flushの blocking 呼び出し(producer chain 完了まで返らない)、または go-file/ack-file による明示的バリアを用いている。artifacts/session-manifest-runtime/への self-write を hook 由来の write と区別できない(test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_modeで明示)。strict attribution(実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 strict_strace mode)への mode 別契約はdocs/dev/agent-skill-boundaries.mdに追記済み。