Repository navigation
Closed
Labels
agent/researchHandled by research agentphase/researchResearch phase issuestate/queuedQueued for implementation
Description
Source
- Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 / PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 の human review(REQUEST_CHANGES)で確定した Option B 設計判断のフォローアップ
- dedupe_key: follow-up:squne121/loop-protocol:issue/1343:strict-attribution
- OWNER レビュー: 調査: volatile peer-session root への child プロセス自己書き込みの strict attribution を検討する #1356 (comment)
Machine-Readable Contract
contract_schema_version: v1
issue_kind: research
parent_issue: none
goal_ref: 契約実行ラッパー(scripts/agent-guards/skill_runtime_exec.py)が volatile peer-session root への自プロセス書き込みを検出できない known limitation の解消方針を検討する
change_kind: research-onlyParent Issue
なし(単独調査)
Background
- Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343(実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する。PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 でマージ済み)の対応中、human review(REQUEST_CHANGES)を受けて Option B が採用された。
- 契約実行ラッパー(scripts/agent-guards/skill_runtime_exec.py。以降 wrapper と呼ぶ)の before/after スナップショット比較は、
.claude/worktrees/**と.claude/artifacts/issue-refinement-loop/**(volatile peer-session root)を監査対象から完全除外している。 _VOLATILE_PEER_SESSION_ROOT_RELSとしてこれらのパスが定義され、_snapshot_repo_paths()(os.walk()ベース)と_find_unauthorized_repo_changes()(git status差分ベース)の双方でこの volatile root を除外しているため、volatile root への self-write は構造的に検出できない。テストもこの制限を known limitation として固定している(.cache/outside.txtへの self-write は fail-close するが、volatile root への self-write は return code 0 で通る)。- 厳密な process-level file write attribution を実装する Option A は Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 のスコープでは不採用となり、必要であれば別 Issue で扱う方針だった。
- PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 レビューコメント(fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 (comment) )で、strace ベースの syscall トレースによる strict attribution 案が検討候補として挙げられている。
- 実装: 並列エージェント実行安全性を SSOT 化し、Issue contract に Required Design References を追加する #1346 / PR docs: 並列エージェント実行安全性を SSOT 化し Required Design References を追加する #1353 で
docs/dev/agent-skill-boundaries.mdに Parallel Agent Runtime Safety が SSOT 化され、Strict attribution mode と Race-tolerant stdlib mode の二段階区分が既に導入済みである。現行実装は Race-tolerant stdlib mode であり、volatile root への self-write 検出は対象外と明記されている。
Outcome
volatile peer-session root(.claude/worktrees/** 等)への child プロセス自己書き込みを厳密に attribution する方式(Option A 相当、strace ベース案含む)の実現可能性・コスト・トレードオフを整理し、採用可否と(採用する場合の)implementation Issue が起票可能な状態にする。
結論(Decision Record 参照): 条件付き採用。 Linux-only の optional strict mode(strict_strace)を prototype として実装候補にするが、現行 wrapper の default 挙動(race_tolerant_stdlib)は維持する。
In Scope
- strace 等 process-level syscall トレースによる書き込み attribution 案の技術的実現可能性の調査(Linux 依存性、CI/ローカル環境双方での動作可否、パフォーマンスコスト)
- trace 出力の parser 実装方針(何を自プロセスの書き込みと判定する具体的なロジック)の整理
- trace ログ・artifact への secret 混入を防ぐ secret-safe artifact handling 方針の検討
- strace 不可・trace 取得失敗時の fallback 方針(fail-closed とすべきか、既存の scope-excluded 方式に留めるか)の検討
- 採用可否の判断と、採用する場合の implementation Issue 起票
Out of Scope
- wrapper 本体・テストコードの実装変更
.claude/worktrees/**/.claude/artifacts/issue-refinement-loop/**以外の既存 known limitation の見直し- strict attribution 以外の unauthorized_write_path 検出ロジック全体の再設計
Decision Record
decision_record_schema: v1
decision: conditional_adopt
default_mode: race_tolerant_stdlib
strict_mode_availability:
mode_name: strict_strace
platform: linux_only
default: false
requires: strace_available_and_smoke_test_passed
unavailable_behavior: fail_closed
failure_reason_code: strict_attribution_unavailable
parse_failure_behavior: fail_closed
parser_scope:
covered_syscalls:
path_syscalls:
- open
- openat
- openat2
- creat
- mkdir
- mkdirat
- rename
- renameat
- renameat2
- unlink
- unlinkat
- symlink
- symlinkat
- link
- linkat
- truncate
- chmod
- chown
- utimensat
fd_syscalls:
- write
- pwrite64
- writev
- pwritev
- pwritev2
- ftruncate
- copy_file_range
- sendfile
fd_table_tracking:
- dup / dup2 / dup3
- close
- fcntl(F_DUPFD*)
- fork/clone 経由の fd 継承
uncovered_or_unguaranteed:
- "strace の %file trace のみでは write attribution にならない(open() の file descriptor は path 変更後も同一 open file description を参照し続けるため、O_WRONLY/O_RDWR/O_CREAT/O_TRUNC/O_APPEND 等の flag と write 系 syscall の対応付けが必須)"
- inotify は発生元 PID を含まないため不採用
- "fanotify は PID を含むが非特権利用時に機能制限があり、本 repo の Python wrapper には過剰"
secret_artifact_policy:
raw_trace_in_artifact_or_comment_or_stdout: forbidden
read_write_dump_flags: forbidden
parser_output_fields:
- normalized_repo_relative_path
- syscall_class
- access_mode
- decision
raw_trace_storage: tmp_private_dir_deleted_after_parse
debug_opt_in_persisted_trace:
allowed: true
condition: explicit_opt_in_only
redact:
- GH_TOKEN
- HOME
- absolute_temp_path
- user_name
trace_parse_failure_in_strict_mode: fail_closed
fallback_policy:
attribution_modes:
race_tolerant_stdlib:
default: true
strict_volatile_self_write_detection: false
unavailable_behavior: continue
required_notice: emit attribution_mode=race_tolerant_stdlib
strict_strace:
default: false
platform: linux_only
requires: strace_available_and_smoke_test_passed
unavailable_behavior: fail_closed
failure_reason_code: strict_attribution_unavailable
parse_failure_behavior: fail_closed
unsupported_cases:
- platform: macos
behavior: default_unsupported_no_silent_pass
- platform: windows
behavior: default_unsupported_no_silent_pass
- platform: wsl
behavior: same_as_linux_if_strace_available_else_fail_closed_for_strict_mode
- environment: ci_without_strace_installed
behavior: strict_mode_unavailable_reason_code_emitted_default_mode_unaffected
implementation_issue_required: true
implementation_issue_scope_candidate:
allowed_paths:
- scripts/agent-guards/skill_runtime_exec.py
- scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py
- docs/dev/agent-skill-boundaries.md
verification_candidates:
- parser unit tests: fixture trace で常時 green
- live strace smoke test: Linux + strace available のとき実行
- strict mode required test: strace unavailable / parse failure は fail-closed
- secret safety test: raw trace が stdout/stderr/artifact projection に出ない
- regression: race_tolerant_stdlib の既存6テストは維持
not_adopted:
- 現行 wrapper の default を strace 必須に置き換えること
- "`%file` grep だけで strict attribution と主張すること"
- raw trace を artifact / issue comment / stdout に保存すること
- strace unavailable 時に silent fallback して「strict検証済み」と扱うこと
code_comment_followup:
file: scripts/agent-guards/skill_runtime_exec.py
note: "race_tolerant_stdlib と strict_strace で volatile root の扱いが逆転するため、implementation issue でコメントを mode-aware に修正する必要がある"Acceptance Criteria
- AC1: strace ベース案を含む process-level attribution 案の技術的実現可能性(Linux 依存・CI 適用可否・パフォーマンスコスト)が本 Issue 本文に整理されている
- AC2: trace parser 方針・secret-safe artifact handling 方針・fallback 時 fail-closed 方針の 3 点それぞれについて具体的な結論または未決事項が本 Issue 本文に記載されている
- AC3: 採用可否の結論が記載され、採用する場合は implementation Issue が起票され本 Issue からリンクされている。不採用の場合はその理由が明記され、本 Issue が close 可能な状態になっている
- AC4: 採用判断が
Decision Recordとして本 Issue 本文に記録されている。必須キー: decision, default_mode, strict_mode_availability, parser_scope, secret_artifact_policy, fallback_policy, unsupported_cases, implementation_issue_required - AC5: strace 採用時の parser 対象 syscall と非対象 syscall が列挙され、「検出できる write」と「検出できない/保証しない write」が分けて記載されている
- AC6: CI/local/WSL/Linux/macOS/Windows の適用可否 matrix が記載されている。macOS/Windows は default unsupported とし、silent pass を禁止する
- AC7: implementation Issue を起票する場合、strict mode が unavailable / parse failed / trace contains unsafe raw data のときの reason_code と exit behavior が AC に含まれている
Verification Commands
# AC1
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC2
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC3
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC4
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC5
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC6
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .body
# AC7
# baseline-expect: pass
$ gh issue view 1356 --repo squne121/loop-protocol --json body -q .bodyAllowed Paths
- 読み取り専用。リポジトリ変更なし(既定)
Stop Conditions
- Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
- Allowed Paths 外への書き込みを試みた場合は即停止
- 権限不足(permission denied)により操作が完了できない場合は即停止
- 成果物の書き込みに失敗した場合(I/O エラー等)は即停止
Handoff Contract
- Current Objective: volatile peer-session root への自プロセス書き込みの strict attribution 方式の採否を決定する(決定済み: 条件付き採用、Decision Record 参照)
- Bounded Current Context: Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 / PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 の Safety Claim Matrix・known limitation・PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 レビューコメント(strace 案)・本 Issue OWNER レビューコメント(Decision Record 出典)
- Open Questions: なし(Decision Record で解消。implementation issue 側での詳細設計は残る)
- Next Action: 完了(implementation Issue 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 起票済み。close 可能)
- Artifact Refs: Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343, PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349, PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 レビューコメント(fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 (comment) ), 本 Issue OWNER レビューコメント(調査: volatile peer-session root への child プロセス自己書き込みの strict attribution を検討する #1356 (comment) ), Issue 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363(実装 Issue)
Notes for Reviewer
- severity: optional_follow_up(現時点でセキュリティインシデントは発生しておらず、既知の制限として文書化済み。緊急性は低いが、fail-closed guard の安全境界に関わるため無期限放置は避けたい)
- Relates to 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343(Closes ではない。Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 は既に CLOSED 済み)
- 本 Issue は research-only。採用可否の結論(条件付き採用)に基づき、実装 Issue 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363(Linux-only optional strict trace attribution mode 追加)を起票済み。AC3/AC7 充足済み。本 Issue は close 可能な状態。
Metadata
Metadata
Assignees
Labels
agent/researchHandled by research agentphase/researchResearch phase issuestate/queuedQueued for implementation
Activity
squne121 commentedon Jul 6, 2026
判定
#1356 は起票意図として妥当。ただし、現状の Issue 契約のまま implementation に流すと危険です。
結論から言うと、
straceベースの strict attribution は Linux 限定の任意 strict mode / 実験的実装としては採用候補ですが、現行skill_runtime_exec.pyのデフォルト動作を置き換える形で即採用するのは推奨しません。理由は、#1356 が扱う問題は「
.claude/worktrees/**等への self-write を拾うか」だけではなく、process tree の syscall attribution、FD 経由 write、trace artifact の secret 混入、CI/ローカル差異、fallback 時の fail-open 防止まで含む safety boundary だからです。#1356 自体は research-only で、AC も「Issue 本文に整理する」形式なので、まずは Decision Record 化してから implementation issue を切るべきです。確認した一次情報
#1356 は、#1343 / PR #1349 で採用された Option B の follow-up です。#1343 では volatile peer-session root への self-write は race-tolerant stdlib mode の既知制限として明示され、strict attribution は別 Issue スコープに分離されています。 #1356 には現時点でコメントはありません。
現行実装では、
_VOLATILE_PEER_SESSION_ROOT_RELSとして.claude/worktreesと.claude/artifacts/issue-refinement-loopを定義し、これらを snapshot/status の監査対象から除外しています。_snapshot_repo_paths()はos.walk()で repo を走査し、volatile root を prune します。_find_unauthorized_repo_changes()でもgit status差分から_is_volatile_peer_session_path()を除外しているため、volatile root への self-write は構造的に検出できません。テストもこの制限を明示しています。
.cache/outside.txtへの self-write はunauthorized_write_pathで fail-close しますが、.claude/worktrees/**や他 issue の.claude/artifacts/issue-refinement-loop/**への self-write は return code 0 で通ることを known limitation として固定しています。また、#1346 / PR #1353 で
docs/dev/agent-skill-boundaries.mdに Parallel Agent Runtime Safety が SSOT 化され、Strict attribution mode と Race-tolerant stdlib mode の二段階区分が追加済みです。 ドキュメント上も、現行実装は Race-tolerant stdlib mode であり、volatile root への self-write 検出は対象外と明記されています。P0:
strace -f -e trace=%fileだけでは「write attribution」にならないstraceは syscall と signal を記録でき、-fで fork/vfork/clone 由来の child process を追跡できます。%fileは filename を引数に取る syscall 群をまとめて trace できるため、候補としては妥当です。([man7.org]1)ただし
%fileは「ファイル名を参照した syscall」を見るものであって、「書き込みが発生したファイル」を完全に返すものではありません。Linux のopen()は file descriptor を返し、その file descriptor は path が削除・変更されても open file description を参照し続けます。書き込み意図はO_WRONLY/O_RDWR、O_CREAT、O_TRUNC、O_APPEND等の flag と、その後のwrite()系 syscall を対応づけて初めて判定できます。([man7.org]2)したがって parser は最低でも次を扱う必要があります。
strace自身も、subset の syscall だけを監視して user/kernel 境界について推論する場合は注意が必要だと警告しています。([man7.org]1) つまり「%fileを grep して volatile root が出たら fail」程度の実装は、strict attribution ではなく 不完全な heuristic です。P0: secret-safe artifact handling は Issue #1356 の最重要 AC に格上げすべき
straceは文字列引数を C string として表示し、デフォルトでは文字列の先頭 32 byte を出力します。([man7.org]1) さらに--read/--write系 option を使うと file descriptor の read/write データを hex/ASCII dump できます。これは secret を trace artifact に混入させる最短経路です。([man7.org]1)#1356 は secret-safe artifact handling を In Scope に入れていますが、AC は「方針を書く」だけです。ここは弱いです。採用可否判断の前に、少なくとも以下を契約化してください。
現行 wrapper は child を
subprocess.run(... capture_output=True, text=True, shell=False)で実行し、完了後に repo snapshot/status を比較しています。 ここへstraceを挟むなら、stdout/stderr の扱いと trace の扱いを明確に分離しないと、guard が守るべき境界より trace artifact の方が危険になります。P0: fallback 方針は「strict required」と「best-effort」を分けるべき
#1356 の Open Question に fallback fail-closed 方針がありますが、ここは二値ではなく mode 別に定義すべきです。
推奨はこれです。
GitHub-hosted runner は
ubuntu-latest/ubuntu-24.04等の Linux runner を使えますが、OS/runner label に依存します。GitHub Docs は public/private repo の Linux runner labels を示しており、Linux/macOS VM では passwordlesssudoが使えるため、CI で strict mode を必須にするならcommand -v strace || sudo apt-get update && sudo apt-get install -y straceのような availability step を明示すべきです。([GitHub Docs]3)P1: inotify は採用不可、fanotify は過剰
inotify は event monitoring には使えますが、event 構造体には watch descriptor、mask、cookie、name があるだけで、発生元 PID は含まれていません。([man7.org]4) つまり、今回必要な「この child process tree が書いたか」の attribution には不十分です。
fanotify はイベント metadata に PID を持ち、filesystem event の通知・interception もできます。([man7.org]5) ただし、permission event や高度な report option は capability 要件が絡み、非特権利用では機能制限があります。([man7.org]6) この repo の Python wrapper に組み込むには重すぎます。#1356 の比較対象として触れる価値はありますが、第一候補は
straceの方が現実的です。P1: 現行コードコメントは strict attribution 導入時に誤読される
skill_runtime_exec.pyのコメントは「volatile root 配下の変更は child subprocess に帰属させてはならない」と書いています。 Race-tolerant stdlib mode の説明としては成立しますが、#1356 が strict attribution を検討する文脈では逆です。strict mode なら、child 由来であると証明できた volatile root 書き込みは unauthorized として fail-close すべきです。実装 Issue を切る場合は、コメントを mode-aware に直す必要があります。
P1: #1356 の AC は「本文更新」だけでは弱い
現 AC は
gh issue view 1356 --json body -q .bodyで確認する形式です。これは research issue としては最低限ですが、今回の対象は safety boundary なので、結論が曖昧なまま close できてしまいます。最低限、#1356 に次の AC を追加した方がよいです。
推奨結論
私なら #1356 の結論はこうします。
implementation issue を切るなら、初期スコープはこの程度に絞るのが妥当です。
実装依頼プロンプトに入れるべき要点
現時点の最も危険な失敗モードは、「strace を入れたから strict attribution 済み」と過剰主張することです。#1356 は、その過剰主張を防ぐための research gate として使うべきです。
squne121 commentedon Jul 6, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 6, 2026
Close Evidence
decision: conditional_adoptrace_tolerant_stdlibのまま維持(変更なし)。strict_straceattribution mode の実装は Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 ではなく、既に起票済みの実装 Issue 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 に切り出し済み(Closes ではなく Relates to 調査: volatile peer-session root への child プロセス自己書き込みの strict attribution を検討する #1356 として紐づく)。[x]に更新した。本 Issue は research issue として close する。