Skip to main content

Crate bock_ai

Crate bock_ai 

Source
Expand description

AI provider interface for the Bock transpilation pipeline (§17.8).

This crate defines the AiProvider trait and its four interaction modes — generate (Tier 1), repair (§17.7 feedback loop), optimize (Tier 3), and select (§10.8 adaptive handler strategy selection). Verification (§17.3) is deterministic and is not part of this trait; it is owned by the target profile and bock-codegen.

The crate ships a StubProvider for tests and a make_provider factory that dispatches on AiConfig::provider. Both HTTP-backed providers — OpenAiCompatProvider ("openai-compatible") and AnthropicProvider ("anthropic") — are linked.

Re-exports§

pub use cache::compute_key;
pub use cache::AiCache;
pub use cache::CacheError;
pub use cache::CacheStats;
pub use caching_provider::CachingProvider;
pub use config::AiConfig;
pub use decision::Decision;
pub use decision::DecisionType;
pub use decision::ManifestScope;
pub use error::AiError;
pub use governance::validate_production;
pub use governance::StrictnessPolicy;
pub use governance::UnpinnedEntry;
pub use governance::UnpinnedReport;
pub use manifest::ManifestError;
pub use manifest::ManifestWriter;
pub use provider::validate_select_response;
pub use provider::AiProvider;
pub use providers::AnthropicProvider;
pub use providers::OpenAiCompatProvider;
pub use request::Alternative;
pub use request::CandidateRule;
pub use request::DecisionRef;
pub use request::GenerateRequest;
pub use request::GenerateResponse;
pub use request::ModuleContext;
pub use request::OptimizationHint;
pub use request::OptimizeRequest;
pub use request::OptimizeResponse;
pub use request::RepairRequest;
pub use request::RepairResponse;
pub use request::SelectContext;
pub use request::SelectOption;
pub use request::SelectRequest;
pub use request::SelectResponse;
pub use request::TargetProfile;
pub use rules::compute_rule_id;
pub use rules::node_kind_name;
pub use rules::Provenance;
pub use rules::Rule;
pub use rules::RuleCache;
pub use rules::RuleCacheError;

Modules§

cache
Content-addressed AI response cache (§17.8).
caching_provider
Provider wrapper that adds content-addressed response caching around any AiProvider implementation.
config
AI provider configuration, parsed from the [ai] section of bock.project.
decision
Decision manifest record types (§17.4).
error
Error types for the AI provider interface.
governance
Strictness governance (§17.6) — policy layer that decides what the AI pipeline may do at each strictness level.
manifest
On-disk decision manifest reader/writer.
provider
The AiProvider trait and closed-set validation helper.
providers
HTTP-backed provider implementations (§17.8).
request
Request and response types for the four AI interaction modes defined in §17.8: Generate, Repair, Optimize, and Select.
rules
Local codegen rule cache (§17.7).

Structs§

StubProvider
Deterministic test provider that returns canned responses for all four interaction modes.

Functions§

known_providers
The list of built-in provider identifiers accepted by make_provider.
make_provider
Constructs a provider from an AiConfig.