Skip to content

Grok --always-approve skips classifyTool; deny-tier tools run with no Guardrail #812

Closed

Description

@currentbits

Follow-up from #697 / #409. Grok is claude-stream and shares runner.js's control_request branch — the only place classifyTool runs for Claude-shaped CLIs.

Grok 1.0.5 maps asking modes to bypassPermissions + --always-approve (electron/providers.js, #578 / #549). Headless -p has no permission-prompt channel; --always-approve means the CLI never emits can_use_tool control_request. Result: deny-tier tools (e.g. curl | sh via run_terminal_command) execute with no Guardrail event.

classifyTool also does not know Grok tool names (run_terminal_command, search_replace, read_file).

Real pre-exec seam: Grok PreToolUse hooks in the isolated GROK_HOME overlay. Official docs: hooks fire before permission checks and still deny under always-approve. Hook ask is auto-approved in YOLO, so ask must be treated as deny (same as #697).

Do not weaken the Claude control_request path.

Related: #697, #409, #177, #578.

Activity

  1. added
    bug
    plan:doing
    on Sep 2, 2026
  2. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Approach on this thread: Grok -p + --always-approve never emits can_use_tool, so the Claude control_request seam cannot run classifyTool. Official grok PreToolUse hooks still deny under always-approve, so the isolated GROK_HOME overlay now registers electron/grok-guardrail-hook.js (copied next to a copy of guardrails.js).

    • deny / ask → stdout {"decision":"deny","reason":…} and exit 2. Ask is deny because YOLO auto-approves a hook ask.
    • Transcript gets the same Guardrail blocked run_terminal_command: … event as Claude.
    • classifyTool now knows grok names (run_terminal_command, search_replace, read_file).
    • CODER_GUARDRAILS=off skips the inject.
    • Claude control_request is unchanged.

    ssh/WSL still skip the overlay (#706), so they only get the after-the-fact event.

  3. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/fork-fork-solenta-guardrail-deny-ask-int-daf14a (this thread). --always-approve never emits can_use_tool; the real gate is Grok PreToolUse in the isolated GROK_HOME overlay.

    • Overlay config.toml gets [[hooks.PreToolUse]] pointing at a copied grok-guardrail-hook.js (plus guardrails.js so packaging/asar cannot break require).
    • deny and ask both emit { "decision": "deny" } and exit 2. Official docs: hook ask is auto-approved in YOLO; timeout/crash fail-open.
    • classifyTool aliases grok names (run_terminal_command, run_terminal_cmd, search_replace, read_file, …).
    • CODER_GUARDRAILS=off skips the inject. Claude control_request is unchanged.
    • Tests drive the hook and a fake grok that would have executed curl | sh with no control_request; the marker proves executed: false before any Guardrail event line.

    ssh/WSL still skip the overlay (#706). CI does not spawn live grok.

  4. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    ssh/WSL follow-up is #821: remote overlay + env GROK_HOME= on the wrap. Local isolated overlay is unchanged.

  5. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Live CLI proof (grok 1.0.13)

    Vendor contract holds. Isolated GROK_HOME overlay config.toml [[hooks.PreToolUse]] is the seam the current CLI actually loads. JSON-file fallback is not required.

    Binary: grok 1.0.13 (5e9a58528b76) [stable] at ~/.local/bin/grok.

    Setup: temp GROK_HOME with auth.json symlink only (no hooks/ link, so user ~/.grok/hooks/*.json could not fire). Overlay config.toml had:

    [[hooks.PreToolUse]]
    matcher = ""
    hooks = [
      { type = "command", command = "<probe.sh>", timeout = 10 },
    ]

    Probe wrote a marker from stdin, printed {"decision":"deny","reason":"solenta-live-proof-deny"}, exited 2.

    inspect (no model)

    GROK_HOME=<overlay> grok inspect --json listed the hook as:

    • event: pre_tool_use
    • source.type: configToml
    • source.path: $GROK_HOME/config.toml
    • configSources.layers[0]: that same overlay file

    live -p --always-approve

    GROK_HOME=<overlay> grok --always-approve --output-format streaming-messages-json \
      --disable-web-search --no-subagents --no-plan \
      --tools run_terminal_command --max-turns 4 --verbatim \
      -p 'Create CANARY.txt \u2026 use run_terminal_command \u2026'
    

    Init event: permissionMode=bypassPermissions. Model called run_terminal_command three times (printf / echo / printf into CANARY.txt).

    Check Result
    Hook fired yes, 3\times; GROK_HOOK_NAME=user:pre_tool_use[0].hooks[0]
    Deny before execute yes; debug gate hook blocked \u2026 reason=solenta-live-proof-deny then tool call denied by pre_tool_use hook
    CANARY.txt absent (tool never ran)
    Transcript tool_result is_error + Hook denied: solenta-live-proof-deny
    control_request / can_use_tool none

    JSON-file ~/.grok/hooks/*.json is a second official source (inspect lists those too). Do not write the Solenta gate through the overlay hooks/ symlink (GROK_HOME_LINKS still links the user's ~/.grok/hooks). Overlay config.toml is the live seam #812 already injects.

    Do not symlink sessions/ into a probe home: grok stale-session GC deletes through the link.

  6. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Skip-unless-env live canary is in electron/test/grok-live-hook.test.js (#826). Default suite / CI stay on the fake grok.

    GROK_LIVE=1 node --test electron/test/grok-live-hook.test.js (not CI) re-ran green on grok 1.0.13 just now: inspect listed source.type=configToml on the overlay config.toml, deny blocked run_terminal_command (~48s). Marker present, canary absent, transcript had Hook denied, no control_request.

    Isolated GROK_HOME still links auth.json only. CI=true skips even if GROK_LIVE=1 leaks.

  7. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    #827: this worktree now has the overlay inject plus a default fake-grok unit test.

    materializeGrokHome writes the live 1.0.13 config.toml shape ([[hooks.PreToolUse]] + matcher = "") and copies grok-guardrail-hook.js next to guardrails.js. The gate is not on the GROK_HOME_LINKS hooks/ symlink. Live canary stays skip-unless-GROK_LIVE. CI unchanged.

  8. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    #829: always-on fake-grok runner on this worktree.

    Fake --always-approve never emits control_request. It consults overlay GROK_HOME/config.toml [[hooks.PreToolUse]] (live 1.0.13 configToml seam), would execute curl | sh, and the marker is executed: false plus a Guardrail event.

    This checkout did not have the #827 inject; materializeGrokHome now writes the same matcher = \"\" shape and copies grok-guardrail-hook.js next to guardrails.js. Gate is not on the hooks/ symlink. Claude control_request unchanged. CI still does not set GROK_LIVE.

  9. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Live canary file is now on coder/fork-fork-fork-fork-fork-fork-fork-solen-cea26d (#831): electron/test/grok-live-hook.test.js, skip unless GROK_LIVE=1, also skip when CI=true. CI does not set GROK_LIVE. Overlay probe links auth.json only and asserts inspect source.type=configToml.

  10. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    #832 copies the overlay inject onto coder/fork-fork-fork-fork-fork-fork-fork-fork--d40e1a (from 86edef / f47cc9): materializeGrokHome writes live 1.0.13 config.toml [[hooks.PreToolUse]] matcher="" and copies grok-guardrail-hook.js. Always-on fake-grok runner is the last describe in electron/test/grok-guardrail-hook.test.js. GROK_HOME_LINKS still includes sessions and hooks. No GROK_LIVE in CI.

  11. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    The grok PreToolUse hook from the leftover worktrees is now on origin/main via #840. Leaving this open until we confirm --always-approve no longer skips classifyTool on a live grok turn.

  12. added
    plan:done
    and removed
    plan:doing
    on Sep 2, 2026
  13. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Worktree already on origin/main via #840 (ca6c5146). Closing and marking plan:done.

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

    bugplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions