Skip to content

Cargo workspace member globs ignore [...] character classes, so members = ["crates/[ab]*"] expands to no members #1833

Open

Description

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: bug (with a duplication root cause). Register ID: A02.

Problem

utils/cargo_workspace.rs expands [workspace] members globs with its own matcher. wildcard_match (L425-L436) supports only * and ?, and treats [ as a literal character. Cargo expands members with the glob crate, which supports [abc], [a-z] and [!x] classes.

The crate already has a segment matcher that handles classes: workspace_globs::segment_glob_matches (L680-L692),```` used for the npm-family and pnpm workspaces. A third matcher, fnmatch in `utils/hatch_workspace.rs`, implements Python's fnmatch.

Proof (executed on main @ b291caa). I added a scratch test in a throwaway worktree. The root Cargo.toml has members = ["crates/[ab]*"], and crates/{alpha,beta,gamma} each hold a Cargo.toml. The result:

AUDIT members=[]

Cargo resolves alpha and beta. Every caller of member_manifests / member_manifests_in therefore misses those members:

Proposed change

  • Delete wildcard_match and its test wildcard_matching.
  • In expand_from (L419), call workspace_globs::segment_glob_matches on char slices instead.
  • Before switching, check that char_class accepts cargo's [!x] negation spelling. Add ! if it accepts only ^.
  • Placement follow-up for the refactor sweep, not needed for this fix: the generic glob walk (DirTree, DiskTree, MemoryTree, expand_glob_bounded, join_rel) belongs in utils/workspace_globs.rs, not in the cargo module. pnpm_workspace.rs already imports it from here.

Size: 1 file, about +3/−20.

Acceptance criteria

  • A unit test with members = ["crates/[ab]*"] asserts the alpha and beta manifests are found and gamma is not.
  • The existing cargo_workspace tests pass, including the memo-equivalence test.

Activity

  1. mikolalysenko commented on Oct 30, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue (shared root cause: cargo_workspace expands member globs with its own */?-only matcher instead of workspace_globs' segment matcher). Branch: agent/fix-cargo-member-glob-classes. Claim-ID: 2026-10-30T00:20:55Z-455f0f


    Generated by Claude Code

  2. mikolalysenko commented on Oct 30, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Draft PR: #1866


    Generated by Claude Code

  3. added 3 commits that reference this issue on Oct 30, 2026
    a7a938d
    54c38da
    d177158
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

    agent:claimedagent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)bugSomething isn't workingpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions