Skip to content

feat: runtime policy-domain を adapter から分離する - #1672

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-1670-runtime-policy-domain
Jul 22, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-1670-runtime-policy-domain

Conversation

@squne121

@squne121 squne121 commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

この変更は runtime transport と policy evaluation の責務を分離します。

  • Claude Write/Edit と Codex canonical apply_patch の raw payload 解釈を adapter に閉じ、共有 policy-domain を追加しました。
  • WORKTREE_MUTATION_INTENT_V1、WORKTREE_SCOPE_BINDING_V1、WORKTREE_POLICY_DECISION_V1 を閉じた入力として検証し、unknown/ambiguous/resolution_failed を fail-closed にします。
  • no-Issue は同一値へ畳み込まず、Claude Write/Edit は deny、既存互換の Codex canonical apply_patch は allow として明示しました。

Checks

以下は実装 head に対して実行した検証結果です。

  • uv run --locked pytest tests/agent_guards/test_worktree_policy_domain.py -q: 15 passed(契約検証は成功)
  • uv run --locked pytest tests/agent_guards/test_codex_apply_patch_adapter.py -q: 21 passed(Codex adapter は成功)
  • uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -q: 234 passed(Claude guard は成功)
  • uv run --locked pytest tests/agent_guards -q: 282 passed(対象回帰試験は成功)
  • ruff、py_compile、git diff --check: pass(静的検査は成功)

AC Status(受け入れ条件の状態)

各受け入れ条件は対応する domain と adapter のテストで確認しました。

  • AC1: test_worktree_policy_domain.py の closed contract 検証で pass。
  • AC2: Claude/Codex adapter の canonical identity、alias、malformed input の回帰試験で pass。
  • AC3: 5 binding state と verified_unbound の互換判断を domain test で pass。
  • AC4: Move の両 target、Windows path flavor、relative/absolute fail-closed を focused test で pass。
  • AC5: test_worktree_policy_domain.py の adapter capture corpus(bound 内側/外側)で、Claude/Codex の decision と reason_code の一致を確認。

Allowed Paths Compliance(許可パス適合)

変更範囲は Issue contract の許可されたファイルに限定しています。

Runtime Verification Evidence(実行時検証証跡)

証跡は secret-free のサニタイズ済み capture に限定し、未検証範囲を成功扱いしません。

  • base SHA: 96095c50a577ee07ebaf423c64fc0b35863fd8e9(実装開始時点の main)
  • implementation SHA: 7af1714ba8540b3bd92133294b39993387803ce9(この変更の current head)
  • Claude Code 2.1.216: .claude/artifacts/issue-refinement-loop/1663/runtime-evidence/claude-write-wire.json、schema SANITIZED_RUNTIME_WIRE_CAPTURE_V1、sanitized digest sha256:7a6792dfc33b57b2b347bee70db61e54ba37ce0b263b6e79cb1466a4a67df6e0。
  • Codex CLI 0.145.0: .claude/artifacts/issue-refinement-loop/1663/runtime-evidence/codex-apply-patch-wire.json、schema SANITIZED_RUNTIME_WIRE_CAPTURE_V1、sanitized digest sha256:c9de2e1296733b5600d5ef9cc9c2b56d51aafae15bc51d63d295c3155f02263c。
  • current head では adapter/domain conformance と bound corpus の Claude/Codex decision/reason_code parity を tests/agent_guards で実行し、official capture の再取得は行っていません。未捕捉 channel の runtime parity は主張しません。

Schema Change Applicability

この判断は共有 policy-domain の入出力 contract を新設するためです。

  • decision: schema_change
  • policy-domain の closed contract を追加し、adapter と policy core の境界を変更します。

Schema Consumer Inventory

利用側一覧を日本語で補足します。
利用側を列挙し、raw vendor DTO を共有 policy に渡さない境界を確認します。

変更前(Before)

# before
adapter が vendor payload と worktree 判定を直接結合していた。

変更後(After)

# after
adapter は normalized intent/binding のみを shared policy へ渡す。
Consumer ファイル 更新有無 備考
scripts/agent-guards/worktree_scope_guard.py yes Claude adapter の thin emitter 化
scripts/agent-guards/codex_apply_patch_adapter.py yes Codex canonical identity の validation
tests/agent_guards/test_worktree_policy_domain.py yes closed contract と parity の回帰試験

Safety Claim Matrix

安全性主張一覧を日本語で補足します。
安全性に関する主張と、実装外に残る統制を分離して記録します。

Claim Implemented? Not controlled Evidence Follow-up
malformed/unsupported input は allow へ変換しない yes runtime 未捕捉 channel focused tests 282 passed #1663
binding の unknown/ambiguous/resolution_failed は deny yes GitHub permission/branch protection policy-domain tests #1663
hook は security boundary ではない yes CI・repository permission の enforcement #1663 ADR #1663

CI Test Performance Decision(CI性能判断)

今回の変更は CI の選択規則や実行時間最適化を変更しません。

  • Python guard test の既存 selection を維持し、CI performance lane の変更はありません。

Notes

関連 Issue と parser boundary を明示します。

@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1672 closed).

@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: "7af1714ba8540b3bd92133294b39993387803ce9"
  merge_ready: true
  mergeability:
    mergeable: "MERGEABLE"
    merge_state_status: "CLEAN"
  blockers: []
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []
  allowed_paths_gate:
    status: ok
    changed_files_source: github_pull_request_files_api_with_previous_filename

current head の CI は全成功であり、Issue #1670 の fresh contract snapshot、Allowed Paths、
AC5 の adapter-level parity、未解決 review thread 0 を確認しました。

@squne121
squne121 marked this pull request as ready for review July 22, 2026 15:00
@squne121
squne121 merged commit 2bbbe23 into main Jul 22, 2026
30 checks passed
@squne121
squne121 deleted the worktree-issue-1670-runtime-policy-domain branch July 22, 2026 15:00
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.

実装: runtime adapter と worktree policy-domain contract を分離する

1 participant