Repository navigation
Description
Follow-up from #4127, which adds the opt-in fish wrap (hooks.wrap_fish_scripts = true) on rtk hook claude. Everything below needs the flag on; with it off, the hook answers exactly as before.
Two places rediscover from strings what the decision already knows.
1. The explicit ask is chosen by matching the rewritten command. process_claude_payload_from_decision treats any rewritten command that starts with rtk run --shell fish -c ' as a wrap. It exempts a command the agent already typed in that form. The exemption compares the typed text, so it misses when the rewrite rules normalise the start of the command. Measured with fish on PATH, the flag on, and settings allowing Bash(rtk:*) and Bash(git:*):
| typed command | rewritten | decision |
|---|---|---|
rtk run --shell fish -c 'echo ok' && git status |
rtk run --shell fish -c 'echo ok' && rtk git status |
allow (as without the flag) |
\, newline, rtk run --shell fish -c 'echo ok' && git status |
the same | ask |
The second row is only an extra prompt: a settings deny still wins over a hook's ask. But every normalisation the rewrite rules gain at the start of a command becomes another such case.
2. The attestation gate re-implements part of try_wrap. permissions::claude_hook_deny_rules_for walks the Claude settings a second time whenever a command is provably fish. It does so even when try_wrap will refuse the command anyway:
- its first word is
rtk; - it has a substitution or a file redirect;
- it has
\\,\'or&|; - its comment parses differently in the two shells;
- or the verdict is already Deny.
Measured with an unparsable ~/.claude/settings.json: rtk git status; and true prints the failed to parse permissions warning 4 times, where git status prints it 2 times. For a command that is wrapped, the verdict and the attestation also read the same files twice. One load_permission_rules_tracking call could feed both.
What would remove both:
decide_with_wrapsays when it wrapped, through a distinctHookDecisionvariant or a flag onAskRewrite. The Claude hook setsaskfrom that, andfish_script::is_wrappedplus the typed-form exemption go away.- The attestation is computed lazily, after
try_wrap's pure gates and thefishprobe pass, from the same settings read as the verdict.
Tests that should hold afterwards:
- the line-continuation row above gives
allow; - with the flag on and an unparsable settings file, a fish command
try_wraprefuses warns as often asgit status; - every wrap RTK builds still carries
"permissionDecision": "ask"(a_wrap_carries_an_explicit_ask).
Activity
rtk-wshm-sync-bot commentedon Oct 23, 2026
🔍 Automated Triage
bugmediumSummary
Fish-wrap detection in
rtk hook claudere-derives wrap state by string-matching rewritten commands and re-walks permission settings separately, causing missed exemptions and duplicate file reads; should instead propagate wrap state fromdecide_with_wrap/try_wrap.📁 Relevant files
src/hook/claude.rssrc/fish_script.rssrc/permissions.rsSuggested Actions
HookDecision/AskRewritefield sodecide_with_wrapreports wrap state directlyfish_script::is_wrappedand the typed-form exemption in favor of that explicit signalload_permission_rules_trackingread from the verdicta_wrap_carries_an_explicit_ask, line-continuationallow, duplicate-warning count) pa…Triaged automatically by wshm · This is an automated analysis, not a human review.