Skip to content

bug(tests): rewrite_cmd permission tests read ~/.claude/settings.json — 3/6 fail on a normal dev machine #2640

Closed

Description

@pidefrem

src/hooks/rewrite_cmd.rs's unattestable_passthrough test module calls evaluate(cmd, …) → check_command(cmd) → permissions::load_permission_rules(), which reads the host's real Claude permission rules at test time. The outcome of a command therefore depends on whoever runs the suite:

  • evaluate("git status $(rm -rf /tmp/x)") expects Passthrough, but a machine with a deny rule for rm -rf returns Deny first (deny pre-empts).
  • evaluate("git status") / "git status 2>&1" expect Ask, but a machine with an allow rule for git status returns Allow.

So 3 of 6 tests fail locally on any machine with ordinary deny/allow rules, while passing on default-config CI ("green on CI, red on my box").

evaluate mixes the permission verdict (I/O — reads host settings) with the pure rewrite decision and offers no seam to inject the verdict — unlike the permission layer's own check_command_with_rules.

Proposal: extract evaluate_with_verdict(cmd, verdict, …) so tests inject a PermissionVerdict; production keeps calling check_command. Test-only, no behavior change.

Same class as #2106 (telemetry test isolation); the fix mirrors #2603's injection helpers. Fixed by #2636.

Activity

  1. pszymkowiak commented on Jun 26, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 93%

    Summary

    Test isolation bug in rewrite_cmd.rs causes 3/6 tests to fail on machines with custom Claude permission rules; PR #2636 already open with a fix.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/rewrite_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. KuSh commented on Sep 26, 2026

    @KuSh
    Collaborator

    Fixed by #3147, shipped in v0.46.0: the rewrite tests now inject the permission verdict instead of reading ~/.claude/settings.json. Running the hooks tests with allow rules for git * and deny rules for rm -rf in the Claude settings now passes. If you still see failures on the latest version, please comment or reopen.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions