Repository navigation
fix(rules): rewrite or warn on a one-element brace group in label - #14
Merged
Merged
Conversation
samc621
approved these changes
Oct 13, 2026
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
force-pushed
the
fix/label-single-brace-alternation
branch
from
October 14, 2026 06:37
090e9a0 to
96e1e58
Compare
Contributor
|
🎉 This PR is included in version 0.4.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
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.