Skip to content

Planner: task input patterns mis-match **.js, (group) and $route paths, and an invalid pattern crashes plan() #173

Closed

Description

@FredApps

What happens

DefaultCIPlanner decides whether a task is triggered by matching changed paths against the task's inputPatterns, using regexFrom in src/planner/planner.ts. That converter has three bugs:

  1. ** not next to a / matches only one path segment. **.js is the example GitHub uses in its path-filter docs. It becomes [^/]*[^/]*\.js, so it matches index.js but not src/lib/index.js. A bare ** matches top-level files only.
  2. Regex-only characters are not escaped. Only . and \ are escaped, so (, ), $, ^ and | keep their regex meaning. A Next.js route-group pattern, app/(marketing)/**, never matches app/(marketing)/about/page.tsx; it matches app/marketing/... instead. A Remix route, app/routes/$slug.tsx, never matches itself.
  3. An invalid pattern throws out of plan(). c++/** compiles to /^c++(?:/.*)?$/, which throws SyntaxError: Invalid regular expression ... Nothing to repeat. The whole plan fails instead of the one task.

Patterns reach this code from workflow-parsed pathGlobs via buildGenericTaskRegistry → analyzeCheckout, and from library callers through the exported createTaskRegistry / DefaultCIPlanner.

Impact

For bugs 1 and 2, a task whose inputs did change is reported as SKIP_CANDIDATE ("No matching changed files and task is not always-run") instead of RUN. For a planner that advises what can be skipped, that is the unsafe direction. Bug 3 turns one odd pattern into a crash of the whole plan.

Repro

const registry = createTaskRegistry([{ id: "task", command: "npm run lint", category: "lint", inputPatterns: ["**.js"] }]);
new DefaultCIPlanner(registry).plan({
  delta: { files: [{ path: "src/lib/deep/index.js", status: "modified" }] },
  impact: { fallbackRequired: false, fallbackReasons: [], affectedTests: [], evidence: [], riskSignals: [] },
  profile: { testFilePaths: [] },
} as any).tasks[0].status;
// main (40aa308): "SKIP_CANDIDATE", expected "RUN"

Failing test

tests/planner/input-patterns.test.ts in the linked PR. Output on main:

✖ `**` not next to a slash matches at any depth, as in GitHub's `**.js` path filter
    actual: 'SKIP_CANDIDATE', expected: 'RUN'
✖ regex-only characters in a pattern match themselves
    actual: 'SKIP_CANDIDATE', expected: 'RUN'
✖ a pattern that is not a valid filter triggers the task instead of throwing
  SyntaxError [Error]: Invalid regular expression: /^c++(?:/.*)?$/: Nothing to repeat
✔ existing globstar forms are unchanged

Also affected, not changed by the linked PR

  • src/research/baseline/matcher.ts has a verbatim copy of the same regexFrom, used by the research PATH baseline.
  • wildcardToRegex in src/planner/task-registry.ts has the same escaping gap (problem 2). Its only caller, InMemoryTaskRegistry.matchesInputPattern, is not on the TaskRegistry interface, so it is not reachable through the public API today.

Activity

  1. FredApps commented on Nov 17, 2026

    @FredApps
    ContributorAuthor

    Cross-reference: #178 is the same bug in the research matcher (src/research/baseline/matcher.ts), fixed by #179. #174 fixes the planner copy and now reads globs the same way as #179. Workflow on: path filters reach this matcher through #182.

  2. added a commit that references this issue on Nov 18, 2026
    a7df27c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions