You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default closure is invoked unconditionally on the first line — the laziness it advertises is never exercised. Of the 19 call sites:
The single production caller (crates/cli/src/cli_args.rs) passes Default::default.
17 of 18 test callers pass Config::new, which is just Self::default().
1 test (test_current_folder_fallback_to_default) passes || Config { symlink: false, ..Config::new() } to assert that fields the loader doesn't touch survive on top of a caller-supplied starting Config.
So the closure parameter exists to support one test, the laziness is never used, and every production path passes the same thing.
Proposed shape
Keep the method name Config::current but reshape it into a builder that takes mut self. The caller builds the starting Config and the method layers .npmrc + pnpm-workspace.yaml on top of it:
Out of scope for this issue: the inner layering logic (.npmrc reads, yaml walk, GVS derivation). Only the entry shape changes — the method name stays current.
Follow-up from refactor(pacquet): replace callback-DI with capability traits #11730. That PR converted Config::current's current_dir and home_dir callback-DI parameters to direct path / trait-DI, but left default alone because it isn't a side-effect seam and converting it wasn't on the task.
Written by an agent (Claude Code, claude-opus-4-7).
Context
Config::current(pacquet/crates/config/src/lib.rs) currently has this signature:The
defaultclosure is invoked unconditionally on the first line — the laziness it advertises is never exercised. Of the 19 call sites:crates/cli/src/cli_args.rs) passesDefault::default.Config::new, which is justSelf::default().test_current_folder_fallback_to_default) passes|| Config { symlink: false, ..Config::new() }to assert that fields the loader doesn't touch survive on top of a caller-supplied starting Config.So the closure parameter exists to support one test, the laziness is never used, and every production path passes the same thing.
Proposed shape
Keep the method name
Config::currentbut reshape it into a builder that takesmut self. The caller builds the startingConfigand the method layers.npmrc+pnpm-workspace.yamlon top of it:Production becomes:
The one outlier test becomes:
Notes
.npmrcreads, yaml walk, GVS derivation). Only the entry shape changes — the method name stayscurrent.Config::current'scurrent_dirandhome_dircallback-DI parameters to direct path / trait-DI, but leftdefaultalone because it isn't a side-effect seam and converting it wasn't on the task.Written by an agent (Claude Code, claude-opus-4-7).