Skip to content

fix: session-manifest hook 専用 subtree を race-tolerant 除外に追加する - #1426

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-1409-skill-runtime-exec-write-path
Jul 10, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-1409-skill-runtime-exec-write-path

Conversation

@squne121

@squne121 squne121 commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

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 のみ作成 → success
  • test_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 更新 → success
  • test_existing_artifacts_dir_unrelated_update_fails — artifacts/ 既存 + artifacts/unrelated/** 更新 → unauthorized_write_path
  • test_artifacts_as_symlink_created_mid_run_fails_closed — artifacts が実行中に symlink として作成される → fail-close
  • test_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 とする。

  • 旧 pending telemetry(best-effort な agent_session_manifest artifact 生成の中間状態)は破棄する判断とする。session manifest はいずれも best-effort telemetry であり、機能的な正しさに影響しない。
  • 旧 state directory / lock / tmp ファイルの自動 migrate・自動 cleanup は実装しない(本 PR のスコープ外、別 Issue で扱う)。
  • 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 に上書き/削除されないことを確認した。
  • 既知の制約(tool 環境上の制約): 初回起動時の machine-readable diagnostic(旧 state 検出時の非 fail の stderr 通知)は .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.Popen writer process(executor の child process tree の外)を、executor 起動前に先に spawn する。
  • writer は go-file の出現を bounded poll(固定 sleep なし)で待機。
  • executor の child fixture は起動直後に go-file を作成(barrier: before-snapshot 完了後、race window が開いたことを明示)、その後 ack-file の出現を bounded poll で待機してから終了。
  • writer は go-file 確認後に対象 path へ書き込み、os.fsync で durable 化してから ack-file を作成。
  • executor の return code / stderr を検証。

既存の 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 passed
  • uv run --locked pytest .claude/hooks/tests/ — 1019 passed
  • uv 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 passed

Schema Change Applicability

  • decision: not_schema_change
  • reason: hook の出力先ディレクトリ構成(artifacts/session-manifest-runtime/ の内部レイアウト)とラッパーの内部除外ロジックの変更であり、agent_session_manifest/v1 等の公開スキーマのキー・型・consumer 契約は変更していない。

Schema Consumer Inventory

N/A
reason: schema_change ではないため対象外。

Compatibility Decision(新規セクション、REQUEST_CHANGES P2-1 対応)

  • decision: intentional_hard_cutover
  • scope: 旧 runtime state(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 は再送されない)。
  • rationale: session manifest はいずれも best-effort な監査 telemetry であり、runtime state の欠落・重複が機能的な正しさやユーザー影響に波及しない。移行コストに対して安全性上のメリットが小さいため、hard cutover を選択した。
  • non-regression evidence: test_legacy_runtime_state_present_does_not_deadlock_or_duplicate(新規)で、旧 state が残存していても deadlock なく新 subtree で正しく manifest が生成されることを確認。
  • known gap: 初回起動時の machine-readable diagnostic(.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の一覧を以下に示す。

Claim Implemented? Not controlled Evidence Follow-up
cold start で ignored 親ディレクトリ(artifacts/)が新規作成されても、artifacts/session-manifest-runtime/** のみの write は誤検知しない yes test_cold_start_peer_writes_only_race_tolerant_subtree_succeeds
cold start で artifacts/session-manifest-runtime/** と同時に artifacts/unrelated/** が作られた場合は fail-close する(leaf path を正確に報告) yes test_cold_start_peer_writes_subtree_and_unauthorized_sibling_fails
artifacts/ が既存の状態でも同様の区別(subtree=success / unrelated=fail-close)が成立する yes test_existing_artifacts_dir_hook_subtree_update_succeeds, test_existing_artifacts_dir_unrelated_update_fails
subtree 内の child self-write は stdlib mode では hook 由来の write と区別できない(既知の制約) partial stdlib race-tolerant mode では self-write と hook write を区別不能(設計上の既知制約、#1363 で解消予定) test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_mode #1363
strict_strace mode(#1363、未実装)では traced child write を fail-close すべきという mode 別契約が明文化されている yes docs/dev/agent-skill-boundaries.md(AC7/AC8、rg VC で確認)
artifacts の symlink/file による parent substitution は許可しない(折り畳み展開ロジックを悪用させない) yes test_artifacts_as_symlink_created_mid_run_fails_closed, test_artifacts_as_file_created_mid_run_fails_closed
旧 runtime state が残存していても deadlock / 重複生成が起きない(意図的 hard cutover、migration なし) yes test_legacy_runtime_state_present_does_not_deadlock_or_duplicate
executor 外で独立して動作する peer process の write は、fixed sleep でなく明示的なバリア(go-file/ack-file)で同期検証されている yes test_independent_writer_process_with_explicit_barrier_succeeds
subtree 外への self-write は引き続き fail-close する(回帰なし) yes test_self_write_outside_session_manifest_runtime_still_fails
初回起動時の legacy-state 検出 machine-readable diagnostic(.claude/hooks/*.mjs 側、best-effort な非 fail-close telemetry のみで security control ではない) no n/a 本セッションの tool 権限制約により .claude/hooks/** への Read/Edit が denied で実装不能だった(Allowed Paths 上は許可、下記 Compatibility Decision の known gap 参照)

Notes

契約実行ラッパー (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]>
@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1426 closed).

@squne121

Copy link
Copy Markdown
Owner Author
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/ 配下でも発生する問題を修正する

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 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 1 passed 0 PASS
AC2 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 1 passed 0 PASS
AC3 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 1 passed 0 PASS
AC4 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 1 passed 0 PASS
AC5 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 1 passed 0 PASS
AC6 uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py 6 passed 0 PASS
AC7 rg -n "strict_strace" docs/dev/agent-skill-boundaries.md 1 match found 0 PASS
AC8 rg -n "artifacts/session-manifest-runtime" docs/dev/agent-skill-boundaries.md 4 matches found 0 PASS

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO
  • mergeable: MERGEABLE
  • merge_state_status: BLOCKED

すべての Acceptance Criteria が満たされています。

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-probe-delete-me

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@squne121

Copy link
Copy Markdown
Owner Author

fix_delta iteration 2 対応完了

required CI check python-test(Ruff F401: import stat unused)の指摘を修正しました。

  • scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py から未使用の import stat を削除
  • ruff check --select E,F --ignore E402 scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py で violation 0 件を確認
  • uv run pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -q で 5 件全て pass を確認
  • commit: 16f0c87(PR head を更新、amend なし)

CI の python-test check の再実行結果をご確認ください。

@squne121

Copy link
Copy Markdown
Owner Author
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)"

Summary

All 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)

@squne121

Copy link
Copy Markdown
Owner Author

検証結果レポート(誤検証の訂正)

直前の test-runner 実行で誤ったブランチ上で検証が実行されたため、AC1-AC5/AC7/AC8 を誤って FAIL と報告されていました。本レポートは、正しいブランチ worktree-issue-1409-skill-runtime-exec-write-path(SHA: 16f0c8702d0b36729835af467027d9d31cf59544)上で改めて実行した正規の検証結果です。

Issue #1409: 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 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 1 passed 0 PASS
AC2 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 1 passed 0 PASS
AC3 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 1 passed 0 PASS
AC4 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 1 passed 0 PASS
AC5 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 1 passed 0 PASS
AC6 uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py 6 passed 0 PASS
AC7 rg -n "strict_strace" docs/dev/agent-skill-boundaries.md found (line 1730) 0 PASS
AC8 rg -n "artifacts/session-manifest-runtime" docs/dev/agent-skill-boundaries.md found (lines 1699, 1727-1731) 0 PASS

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO

検証実行環境

  • Branch: worktree-issue-1409-skill-runtime-exec-write-path
  • HEAD SHA: 16f0c8702d0b36729835af467027d9d31cf59544
  • PR status: MERGEABLE / CLEAN
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 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 仕様どおり)。

@squne121

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES

対象は現行 head 16f0c8702d0b36729835af467027d9d31cf59544。PR は draft・open、変更は7ファイルです。

中心となる修正目的を未達にする Blocker 1件、運用・検証上の Major 3件があります。特にBlockerは、CIが緑でもテストfixtureが実リポジトリの .gitignore を再現していないため検出されません。


1. Blocker / P1 — ignored親ディレクトリが畳まれ、cold startでは依然 artifacts/ が unauthorized 扱いになる

skill_runtime_exec.py は、前後で次のGitコマンドを実行しています。

git status
  --porcelain=v1
  --untracked-files=all
  --ignored=matching
  -z

その差分から、artifacts/session-manifest-runtime とその配下だけを除外しています。

しかし実リポジトリの .gitignore は、subtreeではなく親の artifacts/ 全体をignoreしています。

Git公式仕様上、--ignored=matching ではignore patternに一致したディレクトリ自身が表示され、その配下は表示されません。したがって新規作成されたファイルのパスは artifacts/session-manifest-runtime/... ではなく、親の artifacts/ に畳まれます。([Git]1)

現行headと同じコマンド・フィルタをGit 2.47.3の最小repoで実行した結果です。

.gitignore:
  artifacts/

作成:
  artifacts/session-manifest-runtime/events/x.json

$ git status --porcelain=v1 \
    --untracked-files=all \
    --ignored=matching

!! artifacts/

前後差分も次の結果になります。

before = set()
after  = {'artifacts/'}
new    = {'artifacts/'}
race-filter後の unauthorized = {'artifacts/'}

_is_race_tolerant_unattributable_path("artifacts/") はfalseです。登録されているprefixは artifacts/session-manifest-runtime だからです。snapshot側で artifacts/ のdirectory nodeを除外しても、独立して実行されるGit status側の判定には効きません。

発生条件

次の順序で再現します。

  1. clean cloneなどで、before snapshot時点では artifacts/ が存在しない。
  2. 先行tool call由来のasync hookが、before status後に artifacts/session-manifest-runtime/** を作る。
  3. after statusが !! artifacts/ を返す。
  4. wrapperが unauthorized_write_path=artifacts/ でfail-closeする。

実際の設定ではPostToolUse hookが async: true で動作します。Claude Code公式仕様でも、async hookは完了を待たず別のbackground processとして継続し、複数回の発火には自動deduplicationがありません。したがってこのcold-start順序は、Issue #1409が扱っているraceそのものです。 (Claude)

テストがfalse greenになる理由

新規integration testのfixtureは、実リポジトリとは異なり .gitignore に artifacts/ を含めていません。

(repo / ".gitignore").write_text(
    ".cache/\n__pycache__/\ntmp/\n"
)

このfixtureではGitがleaf pathを返すため、artifacts/session-manifest-runtime/... がprefix filterに正しく一致し、テストが通ります。つまり、テストは実hook lifecycleを動かしていても、障害を決定するGit ignore semanticsを再現していません。

必須修正

artifacts/ 自体をrace-tolerant除外へ追加してはいけません。OWNERが却下した広域blind spotを再導入します。Issue #1409も、専用subtree以外の artifacts/** を監査対象に残すことを要求しています。

実装案としては、次のいずれかが妥当です。

推奨案: artifacts/ のような「除外rootのstrict ancestor」がGit status差分に現れた場合、直ちに許可せず、先にsnapshot差分を評価します。対象がreal directoryかつnon-symlinkで、除外subtree外にsnapshot driftがない場合に限って「ignored directoryの折り畳み」と判断してstatus entryを無視します。artifacts/unrelated/** が作られた場合はsnapshot側で従来どおりfail-closeできます。

別案として、collapsed ancestorだけを対象に git status --ignored=traditional --untracked-files=all -- artifacts/ または git ls-files --others --ignored --exclude-standard -- artifacts/ でleaf pathへ展開する方法もあります。ただしrepo全体を無条件に --ignored=traditional へ変えると、大きなignored treeを個別列挙する可能性があるため、targeted fallbackに限定すべきです。Git公式仕様では、traditional と --untracked-files=all の組み合わせがignored directory内の個別ファイルを返します。(Git)

最低限、次のテストが必要です。

.gitignore に artifacts/ を含める

1. artifacts/ が存在しないcold start
   hook subtreeのみ作成              -> success

2. cold startで
   hook subtree + artifacts/unrelated -> unauthorized_write_path

3. artifacts/ が既存の状態で
   hook subtree更新                   -> success

4. artifacts/ が既存の状態で
   artifacts/unrelated更新            -> unauthorized_write_path

5. artifacts がfileまたはsymlink      -> fail-close

2. Major / P2 — storage layoutの破壊的変更にmigrationまたはcutover判断がない

このPRは単なる内部除外ロジックの変更ではなく、永続中間状態の配置を変更しています。

旧配置は概ね次の構成です。

artifacts/session-manifest-debounce/events/
artifacts/session-manifest-debounce/worker.lock

artifacts/.lock-*
artifacts/.tmp-*
artifacts/private-agent-session-manifest-*.json

新配置は次です。

artifacts/session-manifest-runtime/
  events/
  locks/
  tmp/
  manifests/

新しいdebounce flushは新しい EVENTS_DIR だけを読み、処理後にそのファイルだけを削除します。generatorのduplicate検出も新しい MANIFESTS_DIR だけを走査します。

そのため、更新時点で存在する以下の状態は引き継がれません。

  • 旧 session-manifest-debounce/events/ のpending event
  • 旧 worker.lock
  • root artifacts/ にある既存manifestを使ったduplicate判定
  • 旧 .tmp-* や .failed residue

async hookは各発火ごとに別processとなるため、checkoutや更新の瞬間に旧workerと新workerが並存する可能性もあります。([Claude]2)

telemetryがbest-effortであることを考慮すれば、必ずしも長期migration機構が必要とは限りません。しかし少なくとも次のどちらかを明示すべきです。

  1. 互換期間を設ける

    • 新 --flush が旧event directoryもdrainする
    • duplicate scanが旧root manifestも確認する
    • 旧lock/tmpを安全にcleanupする
    • 旧workerと競合しないlock orderを定義する
  2. 意図的なhard cutover

    • 旧pending telemetryを破棄する判断をPRに明記
    • 初回起動時にmachine-readable diagnosticを出す
    • 旧stateが残っていてもdeadlockや重複生成を起こさないテストを追加する

また、SESSION_MANIFEST_ARTIFACTS_DIR は従来の「manifest等を直接配置するdirectory」から「manifests/locks/tmp を作るbase directory」へ意味が変わっています。これはキーや型を変更しないとしても、外部runtime configurationの互換性変更です。少なくともCompatibility Decisionとconsumer inventoryの対象に含めるべきです。


3. Major / P2 — peer/background writeの検証が、契約で要求されたprocess barrierになっていない

Issue #1409は、実際のdebounce/generator processを別processとして起動し、ready-fileやpipeなどで「wrapperのbefore snapshot完了後」にwriterを進める、固定sleep非依存の検証を要求しています。

新しいlifecycle testはreal Node scriptsを実行していますが、writerの起動はprivileged child command自身から同期的に行われています。一方、peer/background writeを扱うテストは、依然として同じpytest process内の threading.Thread と time.sleep(0.2)、child側の sleep(0.6) に依存しています。

これは次の2つを混同しています。

  • child process tree自身によるwrite
  • wrapper外で既に動いているasync hook / peer processによるwrite

race-tolerant stdlib modeでは両者を区別できないため、機能結果だけを見ると同じです。しかし #1363 のstrict attribution modeでは、traced child writeはfail-close、tracer外のhook writeは無視、という異なる結果になる予定です。現在のテスト名と因果関係のままでは、strict mode導入時に保証対象が曖昧になります。

独立processのテストは、固定sleepなしで次のように構成できます。

1. writer processを先に起動し、OS temp上のgo-fileを待機させる
2. executorを起動する
3. executor childが起動した時点でgo-fileを作る
   (child起動はbefore snapshot完了後なのでbarrierになる)
4. writerがrepo内の対象pathを書き、ack-fileを作る
5. childはackを待って終了する
6. executorのreturn codeとreason_codeを検証する

これならwriterはexecutor childの子孫ではなく、実際のasync hookに近いpeer processです。また os.walk() はdirectory listing生成中の追加・削除を含むかどうかが未規定なので、sleepによる順序推定より明示的barrierが必要です。([Python documentation]3)


4. Major / P2 — Safety Claim MatrixをN/Aにした判断が不適切

PR本文は、変更pathが所定のpatternに一致しないことを理由にSafety Claim MatrixをN/Aとしています。しかし実際には、skill_runtime_exec.py のfail-close判定と、監査対象から除外するrootを直接変更しています。

同じguardの先行変更であるPR #1349は、人間のREQUEST_CHANGESを受けて、race-tolerant除外が生むfalse-negative apertureをSafety Claim Matrixに明示していました。Issue #1409のOWNERコメントも、本件をOSレベルのsecurity boundaryではなく、guardrailとprovenance integrityの変更として評価しています。

本PRでは少なくとも次のclaimを表にすべきです。

- cold startでignored親directoryが新規作成されても誤検知しない
- 同時にartifacts/unrelated/**が作られた場合はfail-closeする
- subtree内のchild self-writeはstdlib modeでは検出不能
- strict_strace modeではtraced child writeをfail-closeする
- symlink/fileによるparent substitutionを許可しない
- 旧runtime stateからの移行または破棄方針

今回のBlockerは、まさにこのmatrixの「cold start」「Git ignored-parent semantics」が欠落していたため、全テストPASSの自己報告をすり抜けています。


修正後に再確認すべきVC

最低限、次を追加または修正してから再レビューすべきです。

1. fixtureの.gitignoreを実repoと一致させる
2. artifacts/ absent -> hook subtree create
3. artifacts/ absent -> hook subtree + unauthorized sibling create
4. artifacts/ present -> existing/new file update
5. independent writer process + explicit barrier
6. legacy events/manifests/locksが存在するupgrade test
7. parent file/symlink substitution test
8. Safety Claim Matrixの各claimとテストを対応付ける

現行headでは、PRの主要Outcomeである「実hook書き込みを誤検知しない」がclean checkoutのraceで成立しないため、マージ不可です。

GitHub上へのreview投稿やコメント追加は行っていません。

…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]>
@squne121

Copy link
Copy Markdown
Owner Author

2026-07-10 REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/1426#issuecomment-4938768837)へ対応しました。

P1 Blocker(ignored 親ディレクトリの折り畳み)

_strict_ancestor_of_race_tolerant_root / _expand_folded_ignored_status_dir(targeted --ignored=traditional -- <dir> scan)/ _is_real_nonsymlink_dir / _expand_new_status_paths を追加し、_find_unauthorized_repo_changes の新規 status path を展開してから既存の除外フィルタを適用するよう修正しました。fixture の .gitignore に artifacts/ を追加して実リポジトリと一致させています。指摘の 5 テスト(cold start 成功/fail-close、既存 artifacts 成功/fail-close、symlink/file substitution fail-close)を新規追加し、全て PASS を確認しました。

P2 x3

  1. Compatibility Decision(意図的 hard cutover)を PR 本文に追加。旧 runtime state 残存下でも deadlock / 重複生成しないことを新規テストで確認。ただし .claude/hooks/*.mjs 側の起動時 diagnostic は、本セッションの tool 権限制約(.claude/hooks/** への Read/Edit が denied)により実装できませんでした。Allowed Paths 上は許可されている変更のため、必要であれば別途対応します。
  2. 独立 OS process(subprocess.Popen)+ go-file/ack-file による明示バリアの新規テストを追加(固定 sleep なし)。
  3. Safety Claim Matrix を実質記載(Claim / Implemented? / Not controlled / Evidence / Follow-up の 5 列)に更新しました。

検証結果

  • uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py — 13/13 PASS
  • uv run --locked pytest scripts/agent-guards/tests/ — 525 passed
  • uv run --locked pytest .claude/hooks/tests/ — 1019 passed
  • AC1〜AC8 の元 VC を再実行し全て PASS を確認
  • pnpm lint — 変更対象の .mjs に差分なし、既存 lint 結果を維持

詳細は PR 本文の REQUEST_CHANGES 対応 / Compatibility Decision / Safety Claim Matrix セクションを参照してください。

Commit: b12fe8a

@squne121

Copy link
Copy Markdown
Owner Author

TEST_VERDICT_MACHINE v1(訂正)

直前のコメントで AC7/AC8 が誤って FAIL と報告されましたが、これは誤った checkout 状態での実行によるものでした。head b12fe8ab9897778ea7ebc96e48bd43c6ba4222fe に対して独立に再検証した結果、AC1-8 すべて PASS です。この訂正が最新の正式な TEST_VERDICT です。

検証対象 head: b12fe8ab9897778ea7ebc96e48bd43c6ba4222fe

AC コマンド exit code 判定
AC1 pytest test_real_debounce_process_write_to_session_manifest_runtime_does_not_fail 0 PASS
AC2 pytest test_race_tolerant_stdlib_excludes_session_manifest_runtime_subtree 0 PASS
AC3 pytest test_self_write_outside_session_manifest_runtime_still_fails 0 PASS
AC4 pytest test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_mode 0 PASS
AC5 pytest test_real_debounce_process_lock_rename_and_failed_rename_lifecycle 0 PASS
AC6 pytest test_skill_runtime_exec_unauthorized_write_path.py (6 tests) 0 PASS
AC7 rg -n "strict_strace" docs/dev/agent-skill-boundaries.md 0 PASS (line 1730)
AC8 rg -n "artifacts/session-manifest-runtime" docs/dev/agent-skill-boundaries.md 0 PASS (lines 1699, 1727, 1728, 1731)
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 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 を追加する"

@squne121

Copy link
Copy Markdown
Owner Author

OWNER 指摘(session-manifest hook 起動時の legacy-state 検出 machine-readable diagnostic 未実装)について、follow-up Issue を起票しました。

対象: .claude/hooks/session_manifest_debounce.mjs / .claude/hooks/generate_session_manifest_from_hook.mjs の起動時に旧 layout(artifacts/session-manifest-debounce/events/、旧 worker.lock、artifacts/.lock-*、artifacts/.tmp-*、artifacts/private-agent-session-manifest-*.json)の残存を検出した場合、fail-close せずに machine-readable diagnostic を出力する追加実装です。

@squne121
squne121 marked this pull request as ready for review July 10, 2026 20:23
@squne121
squne121 merged commit 013b144 into main Jul 10, 2026
26 checks passed
@squne121
squne121 deleted the worktree-issue-1409-skill-runtime-exec-write-path branch July 10, 2026 20:24
squne121 added a commit that referenced this pull request Jul 11, 2026
)

* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する

1 participant