Repository navigation
feat(guardrails): enforce per-bot tool guardrails with delegation messages across engines - #67
Merged
Merged
Conversation
…sages across engines
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Adds
bot.toolGuardrails: per-bot rules the harness checks on every tool call, before the tool runs. A blocked call does not run; the model gets backBlocked by bot guardrail (<id>): <message>, so the rule can tell it where the work belongs instead.Replaces the closed #66 (browser-only host policy). The browser itself is already switchable per bot (
browser: false); the actual problem is bots ignoring SOUL/MEMORY rules with any tool.Rule shape:
{ "id": "delegate-pr", "enabled": true, "tools": ["native:shell", "native:web", "mcp:browser:*"], "match": { "patterns": ["bitbucket.org", "pull-requests"], "excludePatterns": ["--dry-run"] }, "message": "PR work goes to @PRCreator (reviews to @PR Reviewer) through coordinate_bots." }tools:native:<alias|name glob>(aliasesshell,edit,write,read,web),mcp:<server|*>:<tool glob>, or*.match(optional; no match = every call of those tools):patterns(any),allPatterns(all),excludePatterns(none),fields(dot-path or key name),kindcontains(default, case-insensitive) orregex.bots.jsonare refused (guardrail-self-protection).toolScope, guardrails withmcp:selectors force the strict MCP configuration (no inherited user/project MCP servers).call_tool,use_toolwithout a valid name) fail closed.Why
BankXDev opened a Bitbucket PR in the built-in browser even though its instructions say PR work goes to PRCreator / PR Reviewer. Instructions are soft; this makes the rule a hard stop that also returns the delegation hint.
How it was verified
Before / After with the real
CodexDriverandcodex app-server0.172.0 (isolatedHOME/CODEX_HOME, a local fake Responses API issuing fixed tool calls, a fake MCP server), same script onorigin/mainand on this branch:origin/mainecho bitbucket.org/... > forbidden-shell.txtapply_patchadding a bitbucket lineopen_page(bitbucket.org/...)open_page(example.com/docs)After, MCP server log:
["https://example.com/docs"]only. Before:[".../pull-requests/7", "https://example.com/docs"]. Codexhooks/listreports the guardsessionFlags,trusted, and keeps the user's ownhooks.json/config.tomlPreToolUse hooks alongside it.pnpm typecheck,pnpm lintpass.hooks/listdoes not show the guard trusted.pnpm buildandnode scripts/bundle-server.mjspass; bundleddist-server/hooks/omb-tool-guard.jsrun directly: Bitbucket shell and MCP payloads denied,lsallowed, missing policy file denied.server-linesGermanserver.notify.stillWaiting*,store-read-ratchetWorkflowsPage.tsx) also fail onmain29c0e6aef.Limits
write_stdin,web_search,view_imagepass through PreToolUse; Windows trust key unverified. Codex appends. Command:after the reason, so the message shows a double period.native:rule refuses the turn with an explanation.mcp.jsonis outside self-protection.PATCH /api/bots/:idonly (not on create); the settings UI is a follow-up PR.toolScopenow also counts running room turns.Merge Danger
Door: two-way. Bots without
toolGuardrailstake the old paths (strictMcp/restrictedare false unless a rule is active).Blast Radius: guarded bots. Turns on a guarded bot fail closed when the engine cannot prove the guard is loaded (old Codex CLI, inherited Claude MCP config).
Checklist
pnpm typecheckand related tests pass locallydist-server/editsshell: true/ cmd.exe string-building: Claude passesargson Windows, but Codex only takes a hook command string, so on Windows it is a double-quoted argv line (untested on Windows)