Skip to content

Defer CoopConfig::validate to commands that touch probed paths (closes #202) - #212

Merged
hbrodin merged 2 commits into
mainfrom
worktree-issue-202-lazy-validate
May 22, 2026
Merged

Defer CoopConfig::validate to commands that touch probed paths (closes #202)#212
hbrodin merged 2 commits into
mainfrom
worktree-issue-202-lazy-validate

Conversation

@hbrodin

@hbrodin hbrodin commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • CoopConfig::validate ran on every CLI invocation and stat'd kernel_path, firecracker_bin, claude.config_dir, codex.config_dir, and each claude.marketplaces entry. A broken entry (e.g. a stale claude.config_dir) would abort unrelated commands like coop list / status / logs that never read those paths.
  • Move the call into the three command paths that actually consume the probed state: setup, build, start. coop validate keeps running validate directly (it prints warnings to stdout, not via tracing) and is unchanged.
  • The new CoopConfig::validate_and_warn returns a Validated witness (private unit field; mirrors the existing RunningInstance pattern). cmd_build, cmd_start, and VmBackend::setup take &Validated so the compiler refuses any future command path that forgets to validate.
  • Query commands (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 --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test (589 tests pass)
  • ./tests/run-integration.sh (local, macOS/Lima)
  • ./tests/run-integration.sh --remote … (Linux/Firecracker)

🤖 Generated with Claude Code

hbrodin added 2 commits May 22, 2026 15:47
 #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`.
@hbrodin
hbrodin merged commit 9e0ea75 into main May 22, 2026
3 checks passed
@hbrodin
hbrodin deleted the worktree-issue-202-lazy-validate branch June 24, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make CoopConfig::validate lazy: stop probing the filesystem on every CLI invocation

1 participant