Defer CoopConfig::validate to commands that touch probed paths (closes #202) - #212
Merged
Conversation
#202) `load_and_validate_config` ran on every CLI invocation and stat'd `kernel_path`, `firecracker_bin`, `claude.config_dir`, `codex.config_dir`, and every entry in `claude.marketplaces`. A stale or broken entry — e.g. a `claude.config_dir` pointing at a since-moved directory — would abort unrelated commands like `coop list`/`status`/ `logs` that never read those paths. Move the call into the three arms that actually consume the probed state: `setup`, `build`, `start`. `coop validate` already runs the check explicitly and is unchanged. Everything else now skips it.
Replace the standalone `warn_on_validate` helper with a witness type [[Validated]] obtainable only via `CoopConfig::validate_and_warn`. The three commands that consume the probed paths (`setup`, `build`, `start`) now take `&Validated` in their signatures, so the compiler refuses any new command path that forgets to validate first. `Validated` mirrors the `RunningInstance` pattern already used by `VmBackend::stop`: a private-field unit struct that can't be forged outside `config.rs`. `#[must_use]` keeps callers from constructing- and-dropping it by accident. `coop validate` still calls `CoopConfig::validate` directly because it routes warnings to stdout instead of `tracing::warn`.
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.
Summary
CoopConfig::validateran on every CLI invocation and stat'dkernel_path,firecracker_bin,claude.config_dir,codex.config_dir, and eachclaude.marketplacesentry. A broken entry (e.g. a staleclaude.config_dir) would abort unrelated commands likecoop list/status/logsthat never read those paths.setup,build,start.coop validatekeeps runningvalidatedirectly (it prints warnings to stdout, not via tracing) and is unchanged.CoopConfig::validate_and_warnreturns aValidatedwitness (private unit field; mirrors the existingRunningInstancepattern).cmd_build,cmd_start, andVmBackend::setuptake&Validatedso the compiler refuses any future command path that forgets to validate.list,status,logs,stop,destroy,shell,exec,push,pull,vscode,claude,codex,claude-agents,profiles,github,resize,images) no longer touch those paths.Closes #202.
Test plan
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test(589 tests pass)./tests/run-integration.sh(local, macOS/Lima)./tests/run-integration.sh --remote …(Linux/Firecracker)🤖 Generated with Claude Code