Skip to content

test(rules): formally verify the command permission rules #73

Closed

Description

@furedea-agent

コマンド許可ルールを形式的に検証し,今後の編集で矛盾・効かないルール・provider 間のずれ・guard の抜け道が入らないようにする.
現状は prefix 454 件に重複や効かない allow はないため,主目的は回帰防止.
判断事項: なし.

ID 性質 手段
P4 guard が対応を謳う変形(ラッパー,クォート,bash -c,eval)で禁止が効く Hypothesis
P1 同じ prefix に別判定がない.効かない・冗長な prefix がない 全列挙(trie)
P2 allow prefix と禁止正規表現の部分的な重なりを列挙し,意図しないものを検出 Z3(文字列・正規表現)
P3 生成された Claude / Codex / Devin のルールが元と同じ判定をする 全列挙と Z3

受け入れ条件

  • P4 → P1 → P2 → P3 の順に,各性質の検査が CI で動く
  • わざと壊したルール(広げた allow,消した deny)で各検査が赤くなるテストがある
  • POSIX 正規表現から Z3 への変換器に,変換前後で同じ文字列を受理するテストがある
  • hypothesis と z3-solver を uv の test グループに固定して追加
  • 検出結果は自動修正せず一覧として報告する
前提・未確定
  • guard の抜け道の修正(別 Issue)の後に着手する
  • 判定意味: Codex は最も厳しい判定が勝つ,Claude は deny → ask → allow の最初の一致.Devin の意味と Codex の未一致時の挙動は未確認
  • 正規表現は grep -E で,後方参照や先読みは未使用.[[:space:]] と日本語を含む 1 件に注意
  • 冗長な allow 7 組(cargo fmt と cargo fmt --check など)は P1 の初回結果として報告

Activity

  1. added
    enhancement
    on Nov 5, 2026
  2. furedea-agent commented on Nov 9, 2026

    @furedea-agent
    ContributorAuthor

    実装計画 (lane: ac-73, branch: test/73-verify-rules)

    P4 → P1 → P2 → P3 の順に,性質ごとに 1 PR で進める.

    • P1 は標準ライブラリだけで書けるため,先に PR を出す.
    • P4 は hypothesis が必要.uv add --group test hypothesis は ask-rule のためユーザー実行待ち.
    • P2 / P3 は z3-solver が必要.uv add --group test z3-solver も同様にユーザー実行待ち.

    判定意味

    Claude の deny → ask → allow の最初の一致と Codex の最も厳しい判定が勝つ,は同じ結果になる.よって「一致した prefix のうち最も厳しいもの」を共通モデルにする.

    P1 の定義

    検出 条件 CI
    conflict 同一 prefix に別判定 赤
    ineffective 同じか厳しい判定の祖先 prefix を持つ allow / ask 以外の,効果のない prefix(allow が ask / deny の下,ask が deny の下) 赤
    redundant 同じ判定の祖先を持つ prefix 既知の 7 組を基準に,増えたら赤
    • deny が allow / ask の下にある例外(git branch -D など)は有効な carve-out として扱う.
    • 自動修正はせず一覧として返す.

    手順

    前提・仮定
  3. 29 remaining items

  4. furedea-agent commented on Nov 9, 2026

    @furedea-agent
    ContributorAuthor

    P1(#98),P4(#100),P2(#108),P3(#104)をマージした.Codex が出して先送りにした指摘は #107 にまとめてある.generate-forbidden-commands の欠落は furedea/agent-harness#203(#204)で直した.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions