Module config

Module config 

Source
Expand description

Configuration management for behavior trees

This module provides utilities for loading and validating behavior tree configurations with support for environment-specific overrides.

§Configuration Hierarchy

Behavior configurations follow a three-tier hierarchy:

  1. Template (behaviors/{name}.json) - Base behavior definition
  2. Common (configs/common/behaviors/{name}.json) - Shared overrides
  3. Environment (configs/{env}/behaviors/{name}.json) - Environment-specific overrides

§Example Structure

my-robot/
├── behaviors/
│   └── idle_wander.json          # Base template
└── configs/
    ├── dev/
    │   └── behaviors/
    │       └── idle_wander.json  # Dev overrides (faster tick rate)
    ├── production/
    │   └── behaviors/
    │       └── idle_wander.json  # Production overrides (conservative)
    └── common/
        └── behaviors/
            └── idle_wander.json  # Shared overrides

§Usage

use mecha10_behavior_runtime::config::{load_behavior_config, validate_behavior_config};
use std::path::Path;

// Load with environment-specific overrides
let config = load_behavior_config(
    "idle_wander",
    Path::new("/path/to/project"),
    "dev"
).await?;

// Validate before loading
let registry = NodeRegistry::new();
let result = validate_behavior_config(&config, &registry)?;
if !result.valid {
    for error in result.errors {
        eprintln!("Validation error: {}", error);
    }
}

Structs§

BehaviorConfig
Root configuration for a behavior composition.
NodeConfig
Configuration for a single node.
NodeReference
Reference to a behavior node that will be instantiated at runtime.
ValidationResult
Validation result with detailed error information

Enums§

CompositionConfig
Configuration for a composition node (sequence, selector, parallel, or leaf).
ParallelPolicyConfig
Policy configuration for parallel nodes.

Functions§

detect_project_root
Detect project root by looking for mecha10.json
get_current_environment
Get the current environment from environment variable
load_behavior_config
Load behavior configuration with environment-specific overrides
validate_behavior_config
Validate a behavior tree configuration