pub fn parse_intent_block(
header_name: Option<&str>,
content: &str,
) -> Result<IntentDef, ConfigError>Expand description
Parses an intent YAML fence block into an IntentDef.
The function deserializes content as YAML, determines the intent name using
the fence header if present (erroring on conflicts or absence), validates the
intent configuration, and converts it into an IntentDef.
§Errors
Returns a ConfigError when:
- YAML deserialization fails (
ConfigError::YamlParse), - both a header name and a payload name are provided (
ConfigError::NameConflict), - no name is provided (
ConfigError::MissingName), - or other validation failures occur.
§Examples
use cellstate_pipeline::parse_intent_block;
let yaml = r#"
goals:
- "maximize_customer_retention"
- "minimize_churn"
autonomy_level: collaborator
drift_threshold: 0.9
"#;
let def = parse_intent_block(Some("customer_success"), yaml).expect("should parse");
assert_eq!(def.name, "customer_success");
assert_eq!(def.goals.len(), 2);