Skip to main content

bot_forge/planning/
mod.rs

1//! Side-effect-free component resolution and immutable execution plans.
2//!
3//! Planning performs no installation or filesystem mutation. It resolves profile inheritance,
4//! platform selectors, dependencies, conflicts, policies, and resource claims into an
5//! [`ExecutionPlan`] suitable for preview or execution.
6
7mod plan;
8mod resolver;
9
10pub use crate::planning::plan::{
11    ExecutionNode, ExecutionPlan, NodeKind, PlanPolicy, ResolvedComponent, ResourceClaim,
12    TargetPlatform, UnsupportedComponent,
13};
14pub use crate::planning::resolver::{PlanRequest, build_plan};
15
16use crate::config::load_config_with_overlays;
17use crate::error::ForgeError;
18use crate::model::InstallOptions;
19
20/// Load configuration and build an immutable plan for the selected profile.
21///
22/// # Errors
23///
24/// Returns [`ForgeError`] when configuration loading, validation, platform selection, dependency
25/// resolution, or plan construction fails.
26pub fn plan_profile(options: &InstallOptions) -> Result<ExecutionPlan, ForgeError> {
27    let loaded = load_config_with_overlays(options.config_path.as_deref(), &options.overlay_paths)?;
28    build_plan(PlanRequest {
29        document: &loaded.document,
30        origins: &loaded.origins,
31        profile: options.profile.as_str(),
32        target: TargetPlatform::host(),
33        only: &options.only,
34        exclude: &options.exclude,
35        source_root: loaded.path.as_deref().and_then(std::path::Path::parent),
36    })
37}