refactor(cli): remove the last environment reads below the composition root - #205
Draft
ecalifornica wants to merge 1 commit into
Draft
refactor(cli): remove the last environment reads below the composition root#205ecalifornica wants to merge 1 commit into
ecalifornica wants to merge 1 commit into
Conversation
…n root (#184) Delete the free `home_dir()` from config.rs. Its two callers take a `&Config` already: `cmd_share::bail_no_sessions` and `share_config::resolve_remote` now use `Config::home_dir()`. Thread `&Config` into `p derive` and delete its transitional `Config::load()`. `Config::load()` runs once, in `run()`. Test cleanup: - `sync::engine::tests::with_cfg` builds a `Config` only. It drops the `$TOOLPATH_CONFIG_DIR` write and the `TEST_ENV_LOCK` hold. - Two `cmd_resume` tests drop their `$TOOLPATH_CONFIG_DIR` write and their `TEST_ENV_LOCK` hold. `$PATH` is the only variable read below the root. It is the execution environment, not configuration.
|
🔍 Preview deployed: https://d131bf56.toolpath.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Last PR of the #184 series. path-cli only.
Closes #184.
What
home_dir()inconfig.rsis deleted. Its two callers take a&Configalready:cmd_share::bail_no_sessionsgains a&Configparameter and callsConfig::home_dir.share_config::resolve_remotecallsConfig::home_dirfor the~/expansion argument.
cmd_derive::runtakes a&Configand passes it tocmd_import::run. Thep derivearm incmd_p::runpasses the&Configit already holds. Thiswas the last transitional
Config::load().Config::load()has one caller:run()inlib.rs.Audit
$PATHis the only environment variable read below the composition root:fuzzy.rs(externalfzflookup),cmd_resume.rs(harness binary lookup),and
cmd_export.rs(cursor-on-PATH check). A binary lookup is executionenvironment, not configuration, so
$PATHis not aConfigfield.CONFIG_ENV_VARSand theConfigfields are a 1:1 match, 8 for 8:APPDATA,COPILOT_HOME,HOME,PATHBASE_URL,TOOLPATH_CONFIG_DIR,TOOLPATH_QUERY_EXPLAIN,USERPROFILE,XDG_DATA_HOME. Every field has aconsumer:
appdata,copilot_home, andxdg_data_homeinproviders.rs;pathbase_urlincmd_pathbase.rs;toolpath_query_explainincmd_query.rs;toolpath_config_dir,home, anduserprofilethroughConfig::config_dirand
Config::home_dir.Behavior change
run().Tests
sync::engine::tests::with_cfgbuilds aConfigand nothing else. It dropsthe
$TOOLPATH_CONFIG_DIRwrite and theTEST_ENV_LOCKhold, so the wholesync-engine suite runs without serializing against the rest of the tests.
cmd_resume'sresolve_input_url_uses_cache_on_hit_without_refetchingdropsits
$TOOLPATH_CONFIG_DIRsave/set/restore block and itsTEST_ENV_LOCKhold. The injected
Configpins the config directory.cmd_resume'sresolve_input_unresolvable_errors_clearlydrops itsTEST_ENV_LOCKhold. It reads no environment.TEST_ENV_LOCKhas two users left: thefigment::Jailtests inconfig.rs,and the
$PATHguard incmd_resume. Its doc comment states this.tests/support/mod.rsScopedHomekeeps its$HOMEand$TOOLPATH_CONFIG_DIRwrites. The integration tests drive the CLI at itscomposition root, which reads the environment by design. Tracking: single owner for configuration #183 Phase 1 owns
removing that machinery and adding a lint.
Follow-on
crates' internal environment reads are dead weight.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.