Skip to content

Replace the Rust glob matcher with a clean-room implementation - #2704

Merged
somewhatabstract merged 2 commits into
mainfrom
claude/jolly-galileo-72zesp-cleanroom-glob
Nov 12, 2026
Merged

somewhatabstract merged 2 commits into
mainfrom
claude/jolly-galileo-72zesp-cleanroom-glob

Conversation

@somewhatabstract

Copy link
Copy Markdown
Owner

The Rust glob matcher (wildmatch.rs, with match_bracket_class.rs and matches_posix_class.rs) was a line-for-line port of git's wildmatch.c. That code is under git's GPL v2, so it can't ship under checksync's MIT licence.

This replaces it with glob_matches, a clean-room implementation. It was written by an agent that never saw git's code, any other glob implementation, or this repository's history. It worked only from the documented behaviour and from git's matcher run as a black box. The agent designed it from scratch:

  • It parses the pattern into tokens, then tracks which text positions the pattern can reach, one token at a time.
  • There's no recursion or backtracking, so the time taken grows with pattern length times text length.
  • Each step is a small function without nested loops.

The gitignore matching now calls glob_matches, and the port is deleted. The gitignore pattern code that calls it, which was ported from git's dir.c, gets the same treatment in the next PR. Part of #2615.

Test plan

  • glob_matches agrees with git's matcher on about 950,000 random and exhaustive cases from the clean-room agent. Separately, I checked it against the 500,000 cases I'd used earlier for the old port. Every case agreed.
  • The ignore conformance tables in ignore-vectors.json still pass, now running through the new matcher.

Generated by Claude Code

glob_matches matches a glob pattern against text with git's semantics:
`?`, `*`, a whole-folder `**`, bracket sets with ranges, negation and
POSIX classes, `\` escapes, and options for treating `/` as a folder
separator and ignoring ASCII case.

It was written without reference to git's or any other implementation,
only from the documented behaviour and git's matcher run as a black box.
It parses the pattern into tokens, then tracks which text positions the
pattern can reach, one token at a time, with no recursion or backtracking.
It agrees with git on over 1.4 million random and exhaustive cases.

Nothing calls it yet; the next commit switches over to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjLhVH1NnUc7MzCSYLd8Yn
The previous matcher, with its bracket-class and POSIX-class helpers,
was a line-for-line port of git's wildmatch.c, which is under git's
GPL v2 and can't be distributed under checksync's MIT licence. The
gitignore matching now calls glob_matches instead, and the port is
deleted. The gitignore pattern code that calls it is replaced next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjLhVH1NnUc7MzCSYLd8Yn
@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 24f0939

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e4aa2ac) to head (24f0939).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main     #2704    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           93       106    +13     
  Lines         3177      3633   +456     
  Branches      2383      2840   +457     
==========================================
+ Hits          3177      3633   +456     
Flag Coverage Δ
rust 100.00% <100.00%> (ø)
typescript 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...t/crates/checksync-core/src/advance_any_folders.rs 100.00% <100.00%> (ø)
...rates/checksync-core/src/advance_glob_positions.rs 100.00% <100.00%> (ø)
rust/crates/checksync-core/src/advance_one_byte.rs 100.00% <100.00%> (ø)
rust/crates/checksync-core/src/advance_star.rs 100.00% <100.00%> (ø)
.../crates/checksync-core/src/bracket_item_matches.rs 100.00% <100.00%> (ø)
.../crates/checksync-core/src/bracket_set_contains.rs 100.00% <100.00%> (ø)
.../crates/checksync-core/src/byte_matcher_matches.rs 100.00% <100.00%> (ø)
...es/checksync-core/src/gitignore_pattern_matches.rs 100.00% <100.00%> (ø)
rust/crates/checksync-core/src/glob_matches.rs 100.00% <100.00%> (ø)
...ust/crates/checksync-core/src/parse_bracket_set.rs 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4aa2ac...24f0939. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@somewhatabstract somewhatabstract left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@somewhatabstract
somewhatabstract merged commit b610061 into main Nov 12, 2026
20 checks passed
@somewhatabstract
somewhatabstract deleted the claude/jolly-galileo-72zesp-cleanroom-glob branch November 12, 2026 19:56
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.

2 participants