fabro/lib/components/fabro-workflow/tests/materialize_run.rs
Bryan Helmkamp 82bcafcfca
Port fabro-workflow, hooks, validate, and store to the lithos types
Workflow LLM handlers build lithos requests, bill from lithos usage and
cost, and classify failures from lithos `ErrorKind`. Model resolution and
fallback use the fabro-llm selection and catalog helpers. Validation
rules read the lithos catalog, and store fixtures use the new
`BilledModelUsage` shape.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-09 17:26:57 -06:00

71 lines
2.1 KiB
Rust

use fabro_graphviz::graph::Graph;
use fabro_graphviz::parser;
use fabro_llm::test_support::test_catalog;
use fabro_types::settings::InterpString;
use fabro_types::settings::run::{PullRequestSettings, RunGoal, RunModelSettings, RunNamespace};
use fabro_types::{WorkflowSettings, provider_ids};
use fabro_workflow::run_materialization::materialize_run;
fn graph(source: &str) -> Graph {
parser::parse(source).expect("graph should parse")
}
#[test]
fn materialize_run_applies_graph_and_catalog_defaults() {
let source = r#"digraph Test {
graph [goal="Build feature"]
start [shape=Mdiamond]
exit [shape=Msquare]
start -> exit
}"#;
let settings = WorkflowSettings {
run: RunNamespace {
model: RunModelSettings {
name: Some("sonnet".to_string()),
..RunModelSettings::default()
},
pull_request: Some(PullRequestSettings {
enabled: false,
..PullRequestSettings::default()
}),
..RunNamespace::default()
},
..WorkflowSettings::default()
};
let materialized = materialize_run(settings, &graph(source), &test_catalog(), &[
provider_ids::anthropic(),
])
.unwrap();
let resolved = &materialized.run;
assert_eq!(resolved.model.name.as_deref(), Some("claude-sonnet-5"));
assert_eq!(resolved.model.provider.as_deref(), Some("anthropic"));
assert_eq!(
materialized.run.goal.as_ref(),
Some(&RunGoal::Inline(InterpString::parse("Build feature")))
);
assert!(resolved.pull_request.is_none());
}
#[test]
fn materialize_run_uses_configured_provider_defaults() {
let source = r#"digraph Test {
graph [goal="Build feature"]
start [shape=Mdiamond]
exit [shape=Msquare]
start -> exit
}"#;
let materialized = materialize_run(
WorkflowSettings::default(),
&graph(source),
&test_catalog(),
&[provider_ids::openai()],
)
.unwrap();
let resolved = &materialized.run;
assert_eq!(resolved.model.provider.as_deref(), Some("openai"));
}