Skip to content

実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Issue #1356 の Decision Record(conditional_adopt)に基づき、skill_runtime_exec.py に Linux-only optional strict_strace attribution mode を追加する"
change_kind: code

Parent Issue

none

Parent Goal Ref

Current Validated Scope

  • scripts/agent-guards/skill_runtime_exec.py に strict_strace attribution mode(Linux-only, 明示 opt-in, default 無効)を追加
  • scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py に新規テストを追加
  • 既存の race_tolerant_stdlib mode は default のまま変更しない

Remaining Parent Gaps

Outcome

scripts/agent-guards/skill_runtime_exec.py が race_tolerant_stdlib(default)と strict_strace(Linux-only, opt-in)の 2 mode を持ち、strict_strace mode では volatile peer-session root(.claude/worktrees/** 等)への child process 由来の allowed_write_roots 外 write を fail-close で検出できる状態になり、対応する pytest が全て green である状態。

In Scope

  • skill_runtime_exec.py に attribution_mode 設定(race_tolerant_stdlib / strict_strace)を追加し、default は race_tolerant_stdlib のまま維持する
  • strict_strace mode の実装:
    • strace -f -e trace=%file 相当の呼び出しで child process tree の path syscall(open/openat/openat2/creat/mkdir/mkdirat/rename/renameat/renameat2/unlink/unlinkat/symlink/symlinkat/link/linkat/truncate/chmod/chown/utimensat)と fd syscall(write/pwrite64/writev/pwritev/pwritev2/ftruncate/copy_file_range/sendfile)を追跡し、fd table(dup/dup2/dup3/close/fcntl(F_DUPFD*)、fork/clone 経由の fd 継承)を介した write attribution を行う
    • strace 不在 / smoke test 失敗時は strict_strace mode を unavailable とし、reason_code strict_attribution_unavailable で fail-closed にする(default mode には影響しない)
    • trace parse failure は strict mode では fail-closed にする
    • secret-safe artifact handling: raw trace を stdout/stderr/PR artifact/issue comment に出さない。--read/--write dump は使わない。parser 出力は normalized repo-relative path・syscall_class・access_mode・decision のみに縮約する。raw trace は tmp private dir に置き parse 後に削除する。debug opt-in 時のみ保存し、保存時も GH_TOKEN/HOME/absolute temp path/user name を redact する
    • 既存コードコメントを mode-aware に修正する(race_tolerant_stdlib では volatile root を除外、strict_strace では child 由来と証明できた volatile root write を fail-close する)
  • 新規テストファイル test_skill_runtime_exec_strict_attribution.py に以下を追加:
    • 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 に出ないことを確認)

Out of Scope

  • race_tolerant_stdlib mode のデフォルト動作変更
  • macOS/Windows での strict_strace サポート実装(unsupported のまま。silent pass にしない)
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py の allowed_write_roots 定義自体の変更
  • inotify/fanotify ベースの代替実装

Acceptance Criteria

  • AC1: skill_runtime_exec.py に attribution_mode 設定が追加され、default が race_tolerant_stdlib である
  • AC2: strict_strace mode で、.claude/worktrees/** への child process 由来の allowed_write_roots 外 write を fail-close で検出する統合テストが green である
  • AC3: strace unavailable 時に strict_strace mode が reason_code strict_attribution_unavailable で fail-closed になるテストが green である
  • AC4: trace parse failure 時に strict_strace mode が fail-closed になるテストが green である
  • AC5: raw trace が stdout/stderr/artifact に出力されないことを確認する secret safety test が green である
  • AC6: 既存の race_tolerant_stdlib mode の既存 6 テストが regression なく green のままである
  • AC7: macOS/Windows では strict_strace mode が unsupported として明示的に扱われ、silent pass しないことを確認するテストが green である

Verification Commands

# AC1
$ pnpm typecheck
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py -v
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py -v
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py -v
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py -v
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v
# AC7
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_strict_attribution.py -v

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

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

Scope Delta(任意)

N/A

Notes for Reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions