Skip to content

feat: support wildcard pattern matching for executable paths - #63

Merged
PrimeBuild-pc merged 3 commits into
PrimeBuild-pc:mainfrom
SA-Mousavichashmi:feat/wildcard-path-matching
Sep 29, 2026
Merged

PrimeBuild-pc merged 3 commits into
PrimeBuild-pc:mainfrom
SA-Mousavichashmi:feat/wildcard-path-matching

Conversation

@SA-Mousavichashmi

@SA-Mousavichashmi SA-Mousavichashmi commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds wildcard (* and ?) pattern matching support to executable path rules across persistent process rules and power plan associations.

Motivation

Packaged Windows applications (MSIX, AppX, Windows Store apps, e.g. Raycast, Slack, etc.) install into versioned directories under:

C:\Program Files\WindowsApps\<PackageName>_<Version>_<Arch>__<PublisherId>\

When these applications bundle generic child executables (such as node.exe, python.exe, or ffmpeg.exe), users face a dilemma:

  1. Matching by process name alone (e.g. node) unintentionally targets system-wide runtimes (like developer Node.js / NVM environments or scripts), altering their priority or affinity.
  2. Matching by exact executable path (string.Equals) breaks every time the application auto-updates, because the version number in the directory path changes.

With this change, users can write wildcard patterns such as:

  • *Raycast*\backend\node.exe
  • *WindowsApps\Raycast.Raycast_*_x64__*\Raycast\backend\node.exe
  • C:\Games\*\bin\game.exe

Implementation

  • Added PathPatternMatcher.cs in ThreadPilot.Helpers:
    • Fast-path: for non-wildcard paths, uses existing case-insensitive exact string comparison (zero Regex overhead).
    • Wildcard path: normalizes directory separators (/ to \) and performs case-insensitive regex pattern matching.
    • Safe trimming of trailing directory separators.
  • Updated PersistentProcessRuleMatcher.cs to use PathPatternMatcher.IsPathMatch and avoid calling Path.GetFullPath on wildcard patterns.
  • Updated ProcessPowerPlanAssociation.cs (MatchesProcess) to support pattern matching when MatchByPath is enabled.
  • Added unit tests in PersistentProcessRuleMatcherTests.cs validating:
    • Exact match compatibility (existing behavior)
    • Wildcard subpaths (*Raycast*\backend\node.exe)
    • Target rejection for non-matching paths (C:\nvm4w\nodejs\node.exe)
    • Wildcard version directory globs
    • Single-character ? wildcards
    • Forward-slash normalization

Type of Change

  • Feature
  • Performance improvement

Validation

  • Tested pattern matching logic across exact paths, glob patterns, case insensitivity, slash normalization, and negative match scenarios.
  • Verified zero breaking changes to existing exact-path and process-name configurations.
  • Verified no secrets/credentials introduced.

Security and Risk Notes

No elevation, security privilege, or credential changes. Matching remains a read-only comparison on process models against user-configured rules. Fast-path keeps non-wildcard evaluation identical in performance.

Checklist

  • Added or updated tests where relevant
  • Kept changes scoped and backwards compatible where possible

- Add PathPatternMatcher helper supporting * and ? glob matching with path separator normalization
- Update PersistentProcessRuleMatcher and ProcessPowerPlanAssociation to support pattern matching
- Add unit tests covering exact matches, glob patterns, versioned AppX paths, and negative matches

@PrimeBuild-pc PrimeBuild-pc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. The feature is valid and useful for versioned WindowsApps paths. I completed the branch by fixing the compile errors, correcting the forward-slash test pattern, replacing per-match regex evaluation with a bounded wildcard matcher, adding coverage for power-plan associations, and updating it onto main.\n\nVerified locally: Release build, scoped formatting, and 758 tests. CI DevSecOps and CodeQL pass (the first CI run hit an unrelated timing-test flake; its rerun passed).

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 82.50000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Helpers/PathPatternMatcher.cs 84.84% 2 Missing and 3 partials ⚠️
Services/PersistentProcessRuleMatcher.cs 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@PrimeBuild-pc
PrimeBuild-pc merged commit c6f74a9 into PrimeBuild-pc:main Sep 29, 2026
3 of 4 checks passed
PrimeBuild-pc added a commit that referenced this pull request Sep 29, 2026
Release metadata and notes for localized power-plan parsing (#59) and wildcard executable paths (#63).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants