ask catch-all overrides more specific allow rules for same command
Summary
A bare ask <cmd> rule overrides more specific allow <cmd> <subcommand> rules for the same command, regardless of config ordering. I'd expect the more specific rule to win.
Repro
Config (~/.dippy/config):
allow systemctl status
ask systemctl
Test:
echo '{"tool_name":"Bash","tool_input":{"command":"systemctl status foo"}}' | dippy
Expected: allow (matches allow systemctl status)
Actual: ask (matches ask systemctl, ignoring the more specific allow rule)
Additional observations
- Order doesn't matter β
allow systemctl statusbefore or afterask systemctlgives the same result. - Removing the
askline fixes it β withoutask systemctl, theallow systemctl statusrule matches correctly, andsystemctl restart foofalls through to the defaultask. - Other subcommand rules work fine when there's no catch-all
ask/denyfor the same base command (e.g.allow typst compileworks perfectly). - This also affects
denycatch-alls overriding specificallowrules (same pattern).
Use case
This matters for commands like systemctl where you want to allow read-only subcommands (status, show, list-timers, is-active, is-enabled) but prompt for mutating ones (restart, daemon-reload, enable, disable).
Dippy v0.2.7
Thanks for the detailed repro β that helped. I dug into the matcher and I think this is working as designed, though I'll admit the design is a footgun here. Dippy uses last-match-wins (like gitconfig): when two rules both match, the one later in the config wins, regardless of which is more specific. So in your config the broad ask systemctl comes after allow systemctl status and clobbers it β reading top-to-bottom it looks like "allow status, ask the rest," but the order makes the ask win.
Flipping the two lines gives exactly the behavior you're after β broad rule first, specific exception last:
ask systemctl
allow systemctl status
I verified this end-to-end: systemctl status foo β allow, systemctl restart foo β ask. (Same pattern works with deny systemctl as the broad rule.)
The one thing I couldn't reproduce is your note that order made no difference β in my testing, swapping the two lines flips the result every time. The one way I can get "reordering doesn't help" is if the rules live in different files: project .dippy rules always take precedence over your user ~/.dippy/config, regardless of line order within either file. So if ask systemctl is in one file and allow systemctl status in the other, scope wins and reordering won't matter. Could you check whether your two rules are in the same file or split across user/project? That'd tell me whether you're hitting the ordering thing or the scope thing.
Either way, you've surfaced a real rough edge β allow specific / ask broad reads like "specific wins" to most people, and last-match-wins quietly does the opposite.