Skip to content

refactor: remove runtime_dir from LifecycleError variants; thread via CLI adapter layer #136

Description

@coderabbitai

Summary

LifecycleError::LaunchDaemon and LifecycleError::StartupFailed in crates/weaver-cli/src/lifecycle/error.rs carry a runtime_dir: PathBuf field whose sole purpose is to let crates/weaver-cli/src/actionable_guidance.rs derive the weaverd.health path for CLI guidance output.

This violates the domain/adapter boundary: the lifecycle domain error type is carrying CLI adapter context. The runtime directory is already available in the CLI layer (via RuntimePaths) at the call sites that call spawn_daemon, poll_spawned_child, and try_auto_start_daemon; it does not need to travel through the error value to reach write_startup_guidance.

Required refactoring

  1. Remove runtime_dir: PathBuf from LifecycleError::LaunchDaemon and LifecycleError::StartupFailed.
  2. Update spawn_daemon and poll_spawned_child to drop the runtime_dir argument they accepted solely to set this field.
  3. Pass runtime_dir separately through the CLI adapter layer (e.g., as an additional argument to write_startup_guidance, or by making the caller derive health_path before calling guidance functions) rather than extracting it from the error.
  4. Update crates/weaver-cli/src/actionable_guidance.rs, crates/weaver-cli/src/lifecycle/utils.rs, and crates/weaver-cli/src/lifecycle/spawning.rs accordingly.
  5. Update unit tests in crates/weaver-cli/src/tests/unit/actionable_guidance.rs.

Context

Identified during review of PR #128 (Define local daemon observability). The runtime_dir field was threaded through error variants in that PR to improve actionable guidance output; this issue tracks the follow-up architectural cleanup.

Raised by @leynos.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions