Skip to main content

Crate car_builder

Crate car_builder 

Source
Expand description

Natural-language → validated Workflow manifest builder.

The Builder turns a plain-English goal into a runnable car-workflow definition: it prompts a model to emit the manifest, parses it (tolerating fences/preamble), and — crucially — validates it with car_workflow::verify_workflow rather than trusting the model. Invalid manifests are fed back to the model with their specific errors, up to a bounded number of repair attempts.

§Design: generation is injected

build_workflow is generic over an async generate(prompt) -> text closure, so this crate has no inference dependency: the car build CLI wires the real car-inference engine (a server/FFI surface is a follow-up), while tests inject a fake generator. The reusable, deterministic part — prompt → parse → verify → repair-loop — is unit-tested without a model.

valid means the manifest passed verify_workflow (graph structure + per-stage proposal verification) and, when a catalog of tools is provided, references only known tools. Semantic findings — edge-condition keys and state dependencies no stage produces — are surfaced as non-blocking warnings (and fed back as repair hints), since they can have false positives for keys produced at runtime; they do not flip valid.

use car_builder::{build_workflow, BuildRequest, ToolCatalog};
let req = BuildRequest {
    goal: "research a stock, then have a human approve the summary".into(),
    catalog: ToolCatalog::default(),
    existing: None,
    feedback: None,
    max_attempts: 3,
};
let result = build_workflow(|prompt| async move {
    // call your model here
    Ok::<_, String>(prompt) // placeholder
}, &req).await;
if result.valid { /* save result.workflow */ }

Structs§

AgentInfo
An agent the builder may wire into a workflow stage.
BuildRequest
A request to build (or update) a workflow from a goal.
BuildResult
The outcome of a build.
ToolCatalog
What the builder knows is available to compose into a workflow.
ToolInfo
A tool a proposal/agent stage may call.

Functions§

build_prompt
Build the full instruction for one generation attempt.
build_workflow
Build a validated workflow from req, repairing up to req.max_attempts.
parse_workflow
Parse model text into a Workflow, tolerating fenced/preambled output.