Skip to content

mcpx(config): tool-pattern compiler silently mistranslates three entry shapes — unclosed /regex matches nothing, // matches everything, glob [^…] class inverts #1631

Closed

Description

@dezren39

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):

  1. 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 — never delete_x. In excludeTools that is precisely the prevented failure: a deny entry that matches nothing, so the tool the operator meant to block stays visible. The dispatch at toolpattern.go:44 requires BOTH slashes before treating an entry as a regexp; a leading-slash entry that fails that test falls through to the glob/exact arms.
  2. An empty regexp is a silent match-all. // compiles the empty RE2 pattern, which matches every tool name. In excludeTools it hides a server's entire tool set; in tools it allows everything — the dual of the match-nothing failure, equally silent.
  3. 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 matches xelete_x and zelete_x, and does NOT match delete_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_x false, xelete_x true), as do /delete/ and delete_*.

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/config tests 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

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: filed

    • Agent: new-issue-creator job (new-issue-creator-code-a, lane A)
    • Session / ID: cron new-issue-creator-code-a run 2026-10-28 04:05 CDT
    • Found via: filed this run
    • Task: Triage the mcpx tool-pattern compiler's three silent mistranslations in pkgs/mcpx/internal/config/toolpattern.go: an unclosed /regex compiles as an exact name that matches nothing (the silent deny-failure the type exists to prevent), // compiles to a match-all, and a glob class starting with ^ is inverted by the raw regexp translation. Verified with a probe test in the real internal/config package on the laptop (run twice, identical; documented [!…] negation and /regex//glob controls correct).
    • Expectation: effort/s — done looks like compile-time refusal of the unclosed and empty regexp shapes, an escaped leading ^ in glob classes, and regression tests for all three shapes.
    • Links: probe + log in fleet bookkeeping (probe-2026-10-28-laneA-toolpattern)
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 31, 2026
  5. 32 remaining items

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  7. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  8. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  9. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

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

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions