Repository navigation
Description
mezbano's .agents/hooks/d1-guard.mjs goes away with setkernel/mezbano#105. It denied a remote D1 statement that writes or changes the schema, denied a remote --file run (its SQL is not on the command line), and asked before any other remote statement. The managed deny list can hold only part of that.
What the deny list can hold (in the agent-plugins PR that links here): wrangler d1 migrations apply and wrangler d1 execute with both --remote and --file, bare and npx. Those are literal flags.
What it can't hold: SQL write detection for wrangler d1 execute --remote --command "…". Bash rules match the literal command text, with * standing in for any text (permissions docs), so:
- SQL keywords are case-insensitive (
INSERT,insert,Insert), and the docs state case-insensitive matching only for PowerShell and WebFetch rules; - spacing defeats a literal phrase (
DELETE FROM, a newline between the words); --remotebefore or after--commanddoubles every rule;- the guard covered about 12 statement shapes (insert/replace into, update … set, delete from, drop/alter/create …, pragma x =), so rules would run to about 100 and still miss forms;
- the docs warn: "Bash permission patterns that try to constrain command arguments are fragile", and point to a PreToolUse hook.
Options (Raghav's call):
- A PreToolUse hook in the
setkernelplugin, POSIX sh plusjq(the VMs have no Node): readtool_input.command; when it runswrangler d1 executewith--remote, deny it if it matches the guard's write pattern (grep -Eiq), and ask otherwise. Add tests intests/run.sh. This goes against AGENTS.md's "Org-wide denials go inpermissions.deny, not in hooks", so it needs your OK. - An
askrule in managed settings,Bash(wrangler d1 execute *--remote*)and thenpxform. Every remote statement, reads included, then needs a person's yes, even in auto mode. It's simple, but it adds prompts in every repo that probes D1.
Not confirmed (I didn't test it): what an ask, from a rule or a hook, does under sk-agent's --dangerously-skip-permissions. Check on a VM with #5 before relying on 1's ask or on 2.
3. Nothing more: the rule stays in mezbano's AGENTS.md ("never a write or DDL wrangler d1 execute --remote"), as #105 leaves it.
- Raghav picks an option
- Build it with tests, or close this issue with the reason
Refs setkernel/mezbano#52
— Claude Lead
Activity
realRaghavGupta commentedon Oct 14, 2026
Action for Raghav: reply here with 1 (plugin hook), 2 (managed
askrule) or 3 (leave it to the repo rule). #19 adds the part the deny list can hold (migrations apply, and--remotewith--file); remote--commandwrites stay unguarded by tooling until you choose.— Claude Lead
realRaghavGupta commentedon Oct 16, 2026
Recommendation (Claude Lead, 2026-10-16): option 1, a plugin hook in the setkernel plugin (
PreToolUseon Bash parsingwrangler d1 execute … --remoteand--file), because permission rules can't see the SQL and anaskrule never fires in-pruns. Pair it with the managed deny ond1 migrations applyalready in place. Raghav: reply "1" to proceed. — Claude LeadrealRaghavGupta commentedon Oct 16, 2026
Raghav (2026-10-16): 1 — a plugin hook. Implement a
PreToolUsehook in the setkernel plugin that denies remote D1 statements that write or change schema and any--filerun against--remote, with tests; keep the managed deny ond1 migrations apply. — Claude Leadrigel-setkernel commentedon Oct 16, 2026
Picked up. Working on branch
agent/18-remote-d1-sql-write-guard-permission-rul. Automated: @rigel-setkernel's agent onrigel-dev.fix(hooks): refuse SQL comments in remote D1 commands, cover vacuum i…
fix(hooks): only refuse -- comments inside quoted SQL, correct the mi…
fix(hooks): see through backslash line breaks and the raw-path quote …
fix(hooks): read the command with sed when jq is missing, so the D1 g…
Remote D1 SQL write guard: permission rules can't express it, so pick…