Background
Raised during review of PR #75 (refresh stale Cargo lockfiles before publish preflight).
Problem
discover_tracked_lockfiles currently performs three sequential I/O operations:
workspace_root.rglob("Cargo.lock") — filesystem walk to find candidate lockfiles
git ls-files — subprocess call to narrow to tracked files
(lockfile_path.parent / "Cargo.toml").exists() — per-file existence check
The first pass (rglob) is redundant because git ls-files already enumerates tracked lockfiles. Removing it reduces I/O, eliminates the early-exit guard on empty candidates, and simplifies the function.
Similarly, validate_lockfile_freshness spawns one cargo metadata process per lockfile; consider early-exit on the first stale lockfile to avoid unnecessary subprocess invocations when the caller will abort on any stale result.
Resolution
- Replace
rglob with direct reliance on git ls-files output in discover_tracked_lockfiles; keep only the target/ filter and Cargo.toml adjacency check.
- Evaluate whether
_validate_lockfile_freshness in publish_preflight.py should short-circuit after the first stale lockfile.
- Update unit tests to reflect the simpler discovery path.
References
Background
Raised during review of PR #75 (refresh stale Cargo lockfiles before publish preflight).
Problem
discover_tracked_lockfilescurrently performs three sequential I/O operations:workspace_root.rglob("Cargo.lock")— filesystem walk to find candidate lockfilesgit ls-files— subprocess call to narrow to tracked files(lockfile_path.parent / "Cargo.toml").exists()— per-file existence checkThe first pass (rglob) is redundant because
git ls-filesalready enumerates tracked lockfiles. Removing it reduces I/O, eliminates the early-exit guard on empty candidates, and simplifies the function.Similarly,
validate_lockfile_freshnessspawns onecargo metadataprocess per lockfile; consider early-exit on the first stale lockfile to avoid unnecessary subprocess invocations when the caller will abort on any stale result.Resolution
rglobwith direct reliance ongit ls-filesoutput indiscover_tracked_lockfiles; keep only thetarget/filter andCargo.tomladjacency check._validate_lockfile_freshnessinpublish_preflight.pyshould short-circuit after the first stale lockfile.References