Skip to content

fix(rules): rewrite or warn on a one-element brace group in label - #14

Merged
kashyap-techsuite merged 1 commit into
mainfrom
fix/label-single-brace-alternation
Oct 14, 2026
Merged

kashyap-techsuite merged 1 commit into
mainfrom
fix/label-single-brace-alternation

Conversation

@kashyap-techsuite

Copy link
Copy Markdown
Contributor

guardrails add rewrites a one-value brace group that is a plain tool name ({Bash} -> Bash); any other value ({*}, {!Bash}) is only warned about. guardrails validate warns with the corrected spelling.

A label such as {Bash} is not an alternation: picomatch reads a brace group with no comma
and no .. range as literal braces, so the label matches only a tool named {Bash} and the
guardrail never fires on Bash. The rule still loads and lists as enabled.

core/label-braces.ts finds those groups in every composition arm. guardrails add writes
the label without the braces and prints what it rewrote (rewrote under --json).
guardrails validate warns with the corrected spelling, for a rule file and for installed
guardrails (warnings under --json). Matching is unchanged. Left alone: {A,B}, {1..3}, an
empty {}, a group of spaces, and a brace inside a [...] bracket expression. Nested groups
are unwrapped until none is left ({{Bash}} becomes Bash).

Only a group whose value is a plain tool name (letters, digits, _ . : -) is rewritten. Any
other value, such as a wildcard, a negation, an extended glob or a regex escape ({*},
{mcp__*}, {!Bash}, {@(A|B)}, {(\w)+}), is left as written, since unwrapping it could make a
guardrail that never fires match almost every tool call. add and validate warn with the
spelling instead; add lists it under warnings with --json and prints it even with --quiet.
An escaped closing brace (\}) is left alone.

The example printed when add rejects a rule, and the README section on writing a rule, say
what label accepts.

Co-Authored-By: Claude <noreply@anthropic.com>
@kashyap-techsuite
kashyap-techsuite force-pushed the fix/label-single-brace-alternation branch from 090e9a0 to 96e1e58 Compare October 14, 2026 06:37
@kashyap-techsuite
kashyap-techsuite merged commit 21dcb7c into main Oct 14, 2026
3 checks passed
@agenttrail-public-release

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.4.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants