node9-proxy icon indicating copy to clipboard operation
node9-proxy copied to clipboard

feat: verdict-only mode for node9 check — let Claude Code render the inline approval prompt

Open aidanWynne opened this issue 5 months ago • 0 comments

Problem

We're running a Claude Code-based agent in an enterprise environment with Node9 as the PreToolUse policy gatekeeper. On review verdicts the current flow blocks the hook process waiting for a terminal approver via node9 monitor, which:

  • Freezes the Claude session for the duration of human think time — the hook is what's waiting, and Claude is waiting on the hook.
  • Races Claude Code's 60s hook timeout — slow approval = guillotined prompt.
  • Forces the user to context-switch to a separate terminal to act on the prompt.
  • Prevents the user from asking Claude clarifying questions about the pending tool call — the conversation is stuck mid-tool-call.

Claude Code natively renders inline approval prompts when a hook emits hookSpecificOutput.permissionDecision: "ask" — the user answers at the conversation surface, no hook freeze, no timeout race, no context switch. There's no current way to surface Node9 review verdicts that way.

Proposed solution

A verdict-only path on node9 check that:

  1. Runs the full evaluator waterfall (DLP, smart rules, shields, panic mode, persistent decisions, trust sessions) — no shortcuts.
  2. For allow: exits 0 silently. (Same as today.)
  3. For block: emits permissionDecision: "deny" with the existing reason fields. (Same as today.)
  4. For review: emits permissionDecision: "ask" with the same reason payload Node9 already builds (ruleDescription, blockedByContext, etc.) — and does not dispatch to Node9 approvers. The Claude prompt is the only prompt; node9 monitor becomes read-only audit, not a parallel prompter.
  5. Still POSTs the activity entry to the daemon so node9 monitor and Flight Recorder remain a complete audit/forensics console.

Design points where I'd value your input:

  • Surface shape — flag (--ask feels closest to existing precedent: matches the literal permissionDecision: "ask" value), env var, or new subcommand. Your CLI taxonomy.

  • Default vs. opt-in — recommend shipping as opt-in (flag wired into the hook command) rather than a default-on behaviour change. The ask protocol is Claude-Code-specific, so it can't be a true global default without breaking other supported agents (Codex/Gemini/MCP); and existing approver flows (terminal/browser/cloud) shouldn't silently disappear on upgrade. Possible follow-up: have node9 init auto-wire the flag when it detects Claude Code as the agent.

  • "Allow always" suppression on the Claude prompt — Claude Code's native prompt has an "Allow always" option that would write into Claude's own settings. Where Node9 is the single source of truth for policy, splitting persistent-allow state across Node9's decisions store and Claude's settings is wrong. Proposed default: actively suppress that option in the hook output for any Node9-attributed ask (Claude Code's hook spec supports this), so the user only sees approve / deny. Users who want a "remember this" experience use node9 trust instead. Suppression applies only to Node9-attributed asks; Claude's own permission rules continue to render their normal UI (including "Allow always") for commands Node9 has no opinion on.

  • Reason-field shape for ask — happy to use whatever you'd format for the existing block path; just want to confirm permissionDecisionReason is the right place to land the Node9 attribution + rule context.

Alternatives considered

  • Wrapper around node9 explain — the hook receives the JSON payload, extracts tool/args, shells to node9 explain, regex-parses the verdict line, and emits the appropriate hook JSON itself. Implementable today with no upstream change. Rejected as the long-term answer: brittle (regex over human text that has no contract), only handles Bash-style tools cleanly, doesn't reflect runtime daemon state (paused / persistent decisions), and breaks on any release that retouches the explain output. Could work as a temporary spike but doesn't belong in a production deployment.

  • Daemon /check HTTP endpoint — same blocking-on-approver shape as the CLI; doesn't avoid the freeze.

  • Status quo: keep node9 monitor as the prompt surface. It's a hybrid in spirit today, just on a different surface. Rejected because the four downsides under Problem all bite — the freeze, timeout race, context switch, and inability to ask Claude clarifying questions are the actual UX failure modes. Documenting the tradeoff is cheaper but doesn't fix the use case.

  • Fork node9-proxy and carry a private patch. Apache-2.0 permits it; cost is small for an additive change. Held in reserve as a fallback only. Sending this upstream is the right call — the change benefits any Claude Code + Node9 user, the divergence cost of a fork compounds over time, and a fork wouldn't answer the design questions above any faster.

Additional context

Investigation findings against node9 check as currently shipped:

  • node9 check already emits Claude hook JSON for allow (silent exit 0) and block ({decision, reason, hookSpecificOutput: {hookEventName, permissionDecision: "deny", permissionDecisionReason}}). The plumbing for hook-JSON-out is in place — what's missing is the "ask" branch.
  • authorizeHeadless (src/auth/orchestrator.ts:159) always resolves review verdicts internally by dispatching to configured approvers (terminal/browser/cloud/native via the daemon's /check endpoint) and blocking until one returns. No verdict-only mode.
  • Probed the existing CLI surface — --json, --dry-run, --evaluate, --ask — none exist. Env-var surface is NODE9_PAUSED, NODE9_DEBUG, NODE9_NO_AUTO_DAEMON, NODE9_WRAPPER, NODE9_TESTING — none give verdict-only behaviour.
  • node9 explain prints a verdict (Decision: ✅ ALLOW / 🔴 REVIEW / ⛔ BLOCK) without dispatching to approvers, but only as human-readable text and only takes Bash command strings — not the full hook JSON payload covering Edit/Write/MCP tools.

Happy to test against pre-release builds or contribute integration test cases when this lands.

aidanWynne avatar Jun 16 '26 05:06 aidanWynne