Skip to main content

car_engine/
lib.rs

1#![recursion_limit = "256"]
2
3//! Core runtime engine for Common Agent Runtime.
4//!
5//! The runtime loop:
6//! 1. Receive a proposal (batch of actions from a model)
7//! 2. Build a DAG from state_dependencies
8//! 3. Execute each level (concurrent if no ABORT actions, sequential otherwise)
9//! 4. Validate, execute with idempotency + timeout + retry, commit
10//! 5. On abort: rollback state to pre-proposal snapshot
11
12pub mod admission;
13pub mod agent_basics;
14pub mod agent_capability;
15pub mod authz;
16pub mod builtin_agents;
17pub mod cache;
18pub mod capabilities;
19pub mod checkpoint;
20mod executor;
21pub mod flow;
22pub mod goal;
23pub mod intent_gate;
24pub mod mcp;
25pub mod messaging;
26pub mod rate_limit;
27pub mod registry;
28pub mod scope;
29pub mod skill_ceiling;
30pub mod spawn;
31pub mod subprocess;
32pub mod substrate;
33pub mod taint;
34pub mod tool_handles;
35pub mod verify_gate;
36pub mod voice_turn;
37/// Windows `cmd.exe` over-long-`PATH` repair. Lives in its own zero-dep leaf
38/// crate (`car-winenv`) so low-level crates like `car-registry` can use it
39/// without pulling in car-engine; re-exported here so existing
40/// `car_engine::win_env::…` call sites keep working unchanged.
41pub use car_winenv as win_env;
42
43pub use admission::{AdmissionDecision, AdmissionGate, GateContext, GateOutcome};
44pub use agent_basics::entries as agent_basic_entries;
45pub use agent_capability::AgentCapabilityRegistry;
46pub use authz::{
47    AllowAllPermissions, AuthzDecision, AuthzPipeline, AuthzResult, AuthzStage, PermissionHandler,
48    Restriction, TierPermissionHandler,
49};
50pub use builtin_agents::{
51    agent_metadata, format_capability_payload, register_builtins, BuiltinAgent,
52    CapabilityPayloadError, BUILTIN_AGENTS,
53};
54pub use cache::ResultCache;
55pub use capabilities::CapabilitySet;
56pub use checkpoint::Checkpoint;
57pub use executor::{
58    format_tool_result, validate_proposal_action_ids, CostBudget, FailedActionSummary,
59    ReplanCallback, ReplanConfig, ReplanContext, Runtime, ToolExecution, ToolExecutor,
60    TransactionCheckMode, CANCELED_PREFIX,
61};
62pub use flow::{
63    builtin_tool_labels, load_tool_labels, tool_output_is_external, FlowLoadError,
64    InformationFlowGate, ToolLabelConfig, NET_SEND,
65};
66pub use goal::GoalGather;
67pub use mcp::{McpServer, McpServerConfig, McpSession, McpToolExecutor, McpToolInfo};
68pub use messaging::{MessageReceipt, MessageSink, OutboundMessage, Recipient};
69pub use rate_limit::{RateLimit, RateLimiter};
70pub use registry::{ToolEntry, ToolPermission, ToolRegistry, ToolSource};
71pub use scope::RuntimeScope;
72pub use skill_ceiling::{SkillCeilingGate, SKILL_CONTEXT_KEY};
73pub use subprocess::{SubprocessTool, SubprocessToolExecutor};
74pub use substrate::{
75    CommandOutput, LocalSubstrate, McpSubstrate, PathState, Substrate,
76    SUBSTRATE_TRANSPORT_ERR_PREFIX,
77};
78pub use taint::TaintLedger;
79pub use verify_gate::StaticVerificationGate;
80pub use voice_turn::{
81    dispatch_voice_turn, dispatch_voice_turn_sidecar_only,
82    dispatch_voice_turn_sidecar_only_with_classifier,
83    dispatch_voice_turn_sidecar_only_with_telemetry, dispatch_voice_turn_with_telemetry,
84    DirectDataFetcher, SidecarResult, VoiceTelemetry, VoiceTurnControl, VoiceTurnError,
85    VoiceTurnHandle,
86};
87
88// === Umbrella re-exports (car#205) ===
89//
90// car-engine is one of the published umbrella crates external Rust
91// consumers cargo-add against. Re-exporting the engine-cluster
92// types here lets tokhn (and future consumers) depend on a single
93// crate instead of a dozen internal workspace crates. Internal
94// crates stay separate for compile-time and target-gating reasons
95// (CLAUDE.md forbids cargo feature flags), but they ship via
96// path-deps once the publish-set trim lands in a follow-up.
97//
98// Re-exports are selective (not `pub use car_*::*`) so adding or
99// renaming internal symbols doesn't silently leak to the
100// umbrella's public surface — every type listed here is one the
101// surveyed external consumer (tokhn) actually uses. Adding new
102// re-exports is intentional and visible.
103//
104// The submodule pattern for ir / eventlog mirrors the way
105// consumers reach into existing public submodules of car-memgine
106// (`car_memgine::distill::*`) or car-inference
107// (`car_inference::hardware::*`) — keeps grouping legible.
108
109pub use car_eventlog::{EventKind, EventLog, SpanStatus};
110pub use car_ir::{
111    Action, ActionProposal, ActionType, AgentOutcome, Evidence, EvidenceKind, FailureBehavior,
112    OutcomeMetrics, OutcomeStatus, ProposalResult, ToolSchema,
113};
114pub use car_planner::{Planner, PlannerConfig, ToolFeedback};
115pub use car_policy::{
116    ApprovalDecision, ApprovalLedger, ApprovalRecord, GateDecision, PermissionGate, PermissionTier,
117    PolicyCheck, PolicyEngine, RiskClassifier,
118};
119pub use car_state::StateStore;
120pub use car_validator::validate_tool_output;
121pub use car_verify::VerifyIssue;
122// car-sandbox / car-active-planner aren't re-exported here — both
123// depend on car-engine, so the umbrella inclusion would cycle.
124// They stay as their own publishable crates; tokhn keeps
125// `use car_sandbox::*` / `use car_active_planner::*` direct.
126
127#[cfg(test)]
128mod tests;