Skip to content

gate: AskUserQuestion hook asks the daemon, via rt gate fork-check - #391

Merged
m4ttheweric merged 6 commits into
mainfrom
gate-fork-run-pane
Sep 24, 2026
Merged

m4ttheweric merged 6 commits into
mainfrom
gate-fork-run-pane

Conversation

@m4ttheweric

@m4ttheweric m4ttheweric commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

What broke

A pipeline pane ran rt gate ask, got presentation: "form", and could never show the form. gate-fork.sh kept its own idea of "this pane's gate": an exact match on the launch subject, then a grep for a run: gate whose origin.worktree equals the cwd. The daemon had filed the gate under run:<id> (the session's run), and that run records no worktree, so both branches missed and the hook denied. Its deny text also told the agent to background rt gate wait whatever the presentation was, so the agent parked on a form gate.

What changed

  • New daemon verb gate:fork-check. Rules, cheapest first: an open or parked gate on the launch subject; an open form gate on any subject asked from this pane, with executor not gone and a nudge session matching the caller's hook or env session id; an open run: gate for this worktree; an open gate on the subject gate:ask's own resolver gives either session. No rule counts a pane-attention gate. Anything else is a deny.
  • New hidden command rt gate fork-check (the hook endpoint). It reads Claude Code's hook stdin (session_id, cwd), HERDR_PANE_ID and RT_GATE_SUBJECT, and prints the hook JSON. A daemon that is down, or too old to know the verb, gets an allow, same as before.
  • gate-fork.sh now only drains stdin, allows when rt is missing or gives no verdict, and passes the payload to rt gate fork-check. The tray bundle copies it at build time, as before.
  • Deny text now follows the protocol: run rt gate ask, then act on the presentation. form: ask it here with AskUserQuestion (now allowed). wait: background rt gate wait <id>.
  • The gate_ask MCP tool description gives the same form/wait split instead of always saying to background rt gate wait.

Tests

  • gate-fork-check-handler.test.ts: the real case (a form gate asked from this pane with no worktree allows); explicit-subject form gates allow; a stale pane id (executor gone) and a reused pane id under another session deny; differing hook and env session ids still match; wait gates and pane-attention gates (on the launch subject, a worktree run subject, or the resolved subject) deny; the pane column fallback; launch subject open or parked allows; a parked resolved run subject denies; cheap rules never walk run DBs.
  • gate-fork-check-cli.test.ts: payload building, degraded allows, and the deny text.
  • gate-fork-hook.test.ts: rewritten for the thin script (stdin hand-off, 256 KB payload, rt missing, rt errors, old-rt usage text, empty output).
  • e2e gate-fork-check-cli.test.ts: real daemon, compiled binary and the shipped script. Pane rule: the asking pane and session allow, so does a hook session id that differs from the env id gate ask stamped; another pane or the same pane under another session deny. Session rule: rt runs run-start plus a subject-less rt gate ask, then a relaunched pane on that session allows.
  • agent-hooks.test.ts pins the hook's 10s timeout; gate-wrappers.test.ts covers the gateForkCheck wrapper.
  • lib/mcp/__tests__/tools.test.ts: checks the gate_ask description's form/wait split.
  • Also green: tsc, full unit suite (9144 pass, 0 fail), gate e2e files, docs:check, picker:check, repo-purity.sh.

🤖 Generated with Claude Code

m4ttheweric and others added 3 commits September 23, 2026 19:29
… resolver

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 85 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f40902df-eab4-4f0a-9fe7-00081731e70f

📥 Commits

Reviewing files that changed from the base of the PR and between 18664a6 and dceffc4.

📒 Files selected for processing (18)
  • commands/__tests__/gate-fork-check-cli.test.ts
  • commands/gate.ts
  • docs/superpowers/specs/2026-09-11-executor-reconciler-design.md
  • e2e/tests/gate-fork-check-cli.test.ts
  • lib/__tests__/agent-hooks.test.ts
  • lib/__tests__/gate-fork-hook.test.ts
  • lib/agent-hooks.ts
  • lib/command-tree-def.ts
  • lib/daemon/__tests__/gate-fork-check-handler.test.ts
  • lib/daemon/handlers/gate.ts
  • lib/mcp/__tests__/tools.test.ts
  • lib/mcp/tools.ts
  • packages/rt-client/src/client.ts
  • packages/rt-client/src/commands.ts
  • packages/rt-client/src/index.ts
  • packages/rt-client/test/gate-wrappers.test.ts
  • scripts/hooks/gate-fork.sh
  • website/docs/guides/daemon.mdx

Comment @coderabbitai help to get the list of available commands.

m4ttheweric and others added 3 commits September 23, 2026 19:42
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ssion

Pane ids are reused and a dead pane's gate stays open, so the pane rule
now skips gone or dead-pane gates, requires the nudge session to match,
and counts form gates on any subject. Parked counts for the launch
subject only; cheap rules run before the run DB walk; the hook entry
gets a 10s timeout.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The pane rule matches the nudge session on either the hook payload's id
or CLAUDE_CODE_SESSION_ID (the one gate ask stamps), and the session rule
resolves both. A pane-attention gate never allows a form under any rule.
The dead-pane delivery check is dropped: no open row carries a delivery
outcome.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@m4ttheweric
m4ttheweric merged commit ff6a70b into main Sep 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant