canic-core 0.69.3

Canic — a canister orchestration and management toolkit for the Internet Computer
Documentation
//! Module: workflow::pool::controllers
//!
//! Responsibility: compute controller sets for parked pool canisters.
//! Does not own: authorization, state mutation, or IC management calls.
//! Boundary: workflow helper deriving controller inputs from config and runtime identity.

use crate::{
    InternalError,
    ops::{config::ConfigOps, ic::IcOps},
    workflow::pool::PoolWorkflow,
    workflow::prelude::*,
};

/// Return the parked controller set for pool canisters.
///
/// Mechanical helper used by workflow when creating or resetting
/// pool canisters.
///
/// Guarantees:
/// - Includes all configured controllers from `Config`
/// - Always includes the root canister as a controller
/// - Deduplicates the root if already present
/// - Does not include a direct parent until a pool canister is allocated
///
/// This function:
/// - Does NOT perform authorization checks
/// - Does NOT mutate state
/// - Does NOT make IC calls
///
/// Policy decisions about *who* should control pool canisters
/// are assumed to be encoded in configuration.
impl PoolWorkflow {
    pub fn pool_controllers() -> Result<Vec<Principal>, InternalError> {
        let mut controllers = ConfigOps::controllers()?;

        let root = IcOps::canister_self();
        if !controllers.contains(&root) {
            controllers.push(root);
        }

        Ok(controllers)
    }
}