Repository navigation
Description
Summary
CompileToolPatterns (pkgs/mcpx/internal/config/toolpattern.go) exists for one stated reason: "failing on the first entry that is not a valid pattern: a deny entry that silently matches nothing is the failure this exists to prevent." Three entry shapes still slip past it and silently mean something other than what the operator wrote — in the tools/excludeTools lists that decide which MCP tools are visible and callable (Resolve, config.go:595-599):
- An unclosed regexp is silently an exact name.
/delete(leading slash, no closing slash) compiles with no error and matches only a tool literally named/delete— neverdelete_x. InexcludeToolsthat is precisely the prevented failure: a deny entry that matches nothing, so the tool the operator meant to block stays visible. The dispatch attoolpattern.go:44requires BOTH slashes before treating an entry as a regexp; a leading-slash entry that fails that test falls through to the glob/exact arms. - An empty regexp is a silent match-all.
//compiles the empty RE2 pattern, which matches every tool name. InexcludeToolsit hides a server's entire tool set; intoolsit allows everything — the dual of the match-nothing failure, equally silent. - A glob class starting with
^is inverted. The glob translator (globRegexp,toolpattern.go:84-120) copies a character class's body into the regexp class escaping only\,[,]. Under the documented glob grammar the negation form is[!a-z], so^is an ordinary member — but a class whose first member is^(e.g.[^d]elete_*, the set {^,d}) becomes the regexp[^d], a NEGATED class: it matchesxelete_xandzelete_x, and does NOT matchdelete_x. The meaning flips.
Evidence (verified this run on main 1f0722cc)
Probe test in the real internal/config package, run in a detached laptop worktree (toolpattern.go sha256 6229ae25… identical on sandbox main and the laptop clone; probe + log in the fleet's probe records for this run, executed twice with identical output):
- A:
CompileToolPatterns(["/delete"])→err=<nil>,Match("delete_x")=false,Match("/delete")=true - B:
CompileToolPatterns(["//"])→err=<nil>,Match("anything")=true,Match("delete_all")=true - C:
CompileToolPatterns(["[^d]elete_*"])→err=<nil>,Match("delete_x")=false,Match("xelete_x")=true,Match("zelete_x")=true - Control: the documented negation
[!d]elete_*behaves correctly (delete_xfalse,xelete_xtrue), as do/delete/anddelete_*.
Existing tests (toolpattern_test.go:48-55) pin refusal for /(/, delete_[, and "" — a leading-slash entry is refused only when it happens to also end with / and fail RE2 compilation; the unclosed and empty shapes are untested.
Why it matters
These lists are the operator's guardrail over which upstream tools an agent can see and call. Shape A is the exact silent-deny-failure the type was built to prevent, reachable by the most natural typo (a missing closing slash). Shape B turns a two-character entry into a wildcard over a whole server. Shape C inverts a class for anyone who writes ^ expecting glob semantics (or porting a class from another tool). All three fail silently at config load — the moment the design says must fail loudly.
Acceptance criteria
- An entry that begins with
/but is not a complete/…/pair is a compile error naming the entry (or is otherwise refused, never silently exact) — triage pins whether a lone/is included. - The empty regexp
//is refused (or explicitly documented and tested as match-all, if triage decides it is a feature). - A glob class whose body would begin the regexp class with
^is escaped so the glob meaning (literal^member) is preserved;[!…]negation is unchanged. - Regression tests cover all three shapes plus the existing controls (
/(/,delete_[,"",/delete/,[!d]…, plain globs). - Existing
internal/configtests still pass.
Dedup / distinctness
Searched open + closed issues for ToolPatterns, tool pattern, excludeTools: no filing covers the pattern compiler's entry shapes. Adjacent: #1414/#1415/#1416 are mcpx session-resume work; #1605 is mcpx exec artifact delivery — different packages and mechanisms.
Activity
developing-today commentedon Oct 28, 2026
CODE-651
dezren39 commentedon Oct 28, 2026
🤖 Agent note · state: filed
32 remaining items
dezren39 commentedon Oct 31, 2026
🤖 Agent note · parked
final: CI time budget(run 41198649147), is still QUEUED after a full 5-minute poll — fleet CI congestion, not a PR defectfix(mcpx/config): refuse unclosed/empty regexp tool patterns; escape …
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done