Skip to content

fix(agent-config): route Claude Code's PowerShell tool to gate-egress - #1131

Open
sandstream wants to merge 4 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-egress-pwsh-matcher
Open

sandstream wants to merge 4 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-egress-pwsh-matcher

Conversation

@sandstream

Copy link
Copy Markdown
Owner

What

Stacked on #1110: the base is claude/web-kit-status-sync-p6fg9a-protected-pwsh-matcher. Merge #1110 first; this PR then retargets to main.

#1110 matched gate-bash to Bash|PowerShell. The opt-in gate-egress (kit agent-config --broker-gate) was still installed with the matcher Bash, although its docs say it reads PowerShell's Invoke-WebRequest, Invoke-RestMethod and Test-NetConnection. A command Claude Code ran through its PowerShell tool, the only shell on Windows without Git Bash, never reached the egress gate.

Found while working kit-research#239 (docs/research/prismor-always-allowed-rules-vs-kit.md), next to the #1110 matcher fix.

Change

It reuses #1110's helpers in src/gate-bash-matcher.ts, now keyed on a subcommand (ShellGate = "gate-bash" | "gate-egress"). The existing gate-bash names stay as they were.

  • installBrokerGates writes Bash|PowerShell for gate-egress. On a re-run it widens a stale Bash-only egress group in place (widenGateEgressMatchers), with no second entry.
  • enforcement gate liveness fails on a stale egress matcher only where gate-egress is wired, and names kit agent-config --broker-gate as the repair. The message comes from one helper, staleShellGateDetail, for both gates.
  • src/agent-config.ts goes from 1771 to 1775 lines; the frozen limit is 1780.

Before / after

A scratch project, installInstallGate, installEnvWriteGate and installBrokerGates, then checkGateLiveness. Then the egress group is rewritten to "Bash", and installBrokerGates runs again.

Before (#1110 head 059ea7e):

matcher "Bash|PowerShell" -> gate-bash
matcher "Write|Edit|NotebookEdit" -> gate-env
matcher "Bash" -> gate-egress
matcher "Write|Edit|NotebookEdit" -> gate-fs
enforcement gate liveness: pass | PreToolUse enforcement gates wired
after downgrading gate-egress to "Bash": pass | PreToolUse enforcement gates wired
kit agent-config --broker-gate: unchanged; liveness: pass

After:

matcher "Bash|PowerShell" -> gate-bash
matcher "Write|Edit|NotebookEdit" -> gate-env
matcher "Bash|PowerShell" -> gate-egress
matcher "Write|Edit|NotebookEdit" -> gate-fs
enforcement gate liveness: pass | PreToolUse enforcement gates wired
after downgrading gate-egress to "Bash": fail | egress gate (gate-egress) matcher "Bash" does not select both of Claude Code's shell tools (Bash, PowerShell), so a command run through the missing one is not gated. Run: kit agent-config --broker-gate
kit agent-config --broker-gate: updated; liveness: pass

Tests: src/gate-egress-matcher.test.ts covers the fresh install, stale detection, repair and idempotence, and that the egress repair leaves the gate-bash group alone. src/agent-config.test.ts now expects Bash|PowerShell for the broker gate.

Harnesses

  • Covered: Claude Code, where gate-egress is wired.
  • Not covered: gate-egress is wired for Claude Code only. Codex, Cursor CLI, Gemini CLI, Copilot CLI, Antigravity, Amazon Q, Kiro, Cline, Droid, Augment, OpenCode and Aider get no egress gate, so there is no matcher there to fix.

Choice for the owner

The repair for a stale egress matcher is kit agent-config --broker-gate, not a plain kit agent-config. The egress gate is an opt-in and fails closed, so a plain run does not touch it, the same as before. The kit hooks gates SessionStart repair from #1110 covers gate-bash and gate-env only, so it does not widen the egress matcher.

Protected paths

Touches src/agent-config.ts (protected, "permissions"): protected — owner merges.

Platforms

Tested on Linux. The point of the change is Windows. CI covers Windows, but no test runs a live Claude Code PowerShell tool. macOS is unverified.

Docs and changelog


Generated by Claude Code

The opt-in gate-egress reads PowerShell's Invoke-WebRequest but was
installed with the matcher Bash, so a command Claude Code ran through its
PowerShell tool never reached it. Reuse the gate-bash matcher helpers:
install Bash|PowerShell, fail enforcement gate liveness on a stale egress
matcher where the gate is wired, and widen it in place on
kit agent-config --broker-gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r gate-egress

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 05f51a1add2c: not approved.

  • touches protected paths (permissions), which the owner approves: src/agent-config.ts
  • changes modules many others import, which the owner approves: src/check-security.ts (97 importers)

Base automatically changed from claude/web-kit-status-sync-p6fg9a-protected-pwsh-matcher to main November 27, 2026 11:27
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at bdfe259704ab: not approved.

  • checks did not pass: build-and-test, linux shard 1/4
  • touches protected paths (permissions), which the owner approves: src/agent-config.ts
  • changes modules many others import, which the owner approves: src/check-security.ts (101 importers)

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at bdfe259704ab: not approved.

  • touches protected paths (permissions), which the owner approves: src/agent-config.ts
  • changes modules many others import, which the owner approves: src/check-security.ts (101 importers)

…ress-pwsh-matcher

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 785bac771b8e: not approved.

  • touches protected paths (permissions), which the owner approves: src/agent-config.ts
  • changes modules many others import, which the owner approves: src/check-security.ts (101 importers)

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 785bac771b8e: not approved.

  • touches protected paths (permissions), which the owner approves: src/agent-config.ts
  • changes modules many others import, which the owner approves: src/check-security.ts (102 importers)

This branch has not been deployed

No deployments
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.

2 participants