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:
- Template (
behaviors/{name}.json) - Base behavior definition - Common (
configs/common/behaviors/{name}.json) - Shared overrides - 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, ®istry)?;
if !result.valid {
for error in result.errors {
eprintln!("Validation error: {}", error);
}
}Structs§
- Behavior
Config - Root configuration for a behavior composition.
- Node
Config - Configuration for a single node.
- Node
Reference - Reference to a behavior node that will be instantiated at runtime.
- Validation
Result - Validation result with detailed error information
Enums§
- Composition
Config - Configuration for a composition node (sequence, selector, parallel, or leaf).
- Parallel
Policy Config - 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