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, format_tool_result_for_model, is_command_tool, parse_rendered_output,
59    parse_tool_output, render_tool_output, truncate_keeping_ends, validate_proposal_action_ids,
60    CostBudget, FailedActionSummary, ReplanCallback, ReplanConfig, ReplanContext, Runtime,
61    ToolExecution, ToolExecutor, TransactionCheckMode, CANCELED_PREFIX, ELIDED_MARKER,
62    MODEL_OBSERVATION_FORMAT,
63};
64pub use flow::{
65    builtin_tool_labels, load_tool_labels, tool_output_is_external, FlowLoadError,
66    InformationFlowGate, ToolLabelConfig, NET_SEND,
67};
68pub use goal::GoalGather;
69pub use mcp::{McpServer, McpServerConfig, McpSession, McpToolExecutor, McpToolInfo};
70pub use messaging::{MessageReceipt, MessageSink, OutboundMessage, Recipient};
71pub use rate_limit::{RateLimit, RateLimiter};
72pub use registry::{ToolEntry, ToolPermission, ToolRegistry, ToolSource};
73pub use scope::RuntimeScope;
74pub use skill_ceiling::{SkillCeilingGate, SKILL_CONTEXT_KEY};
75pub use subprocess::{SubprocessTool, SubprocessToolExecutor};
76pub use substrate::{
77    CommandOutput, LocalSubstrate, McpSubstrate, PathState, Substrate,
78    SUBSTRATE_TRANSPORT_ERR_PREFIX,
79};
80pub use taint::TaintLedger;
81pub use verify_gate::StaticVerificationGate;
82pub use voice_turn::{
83    dispatch_voice_turn, dispatch_voice_turn_sidecar_only,
84    dispatch_voice_turn_sidecar_only_with_classifier,
85    dispatch_voice_turn_sidecar_only_with_telemetry, dispatch_voice_turn_with_telemetry,
86    DirectDataFetcher, SidecarResult, VoiceTelemetry, VoiceTurnControl, VoiceTurnError,
87    VoiceTurnHandle,
88};
89
90// === Umbrella re-exports (car#205) ===
91//
92// car-engine is one of the published umbrella crates external Rust
93// consumers cargo-add against. Re-exporting the engine-cluster
94// types here lets tokhn (and future consumers) depend on a single
95// crate instead of a dozen internal workspace crates. Internal
96// crates stay separate for compile-time and target-gating reasons
97// (CLAUDE.md forbids cargo feature flags), but they ship via
98// path-deps once the publish-set trim lands in a follow-up.
99//
100// Re-exports are selective (not `pub use car_*::*`) so adding or
101// renaming internal symbols doesn't silently leak to the
102// umbrella's public surface — every type listed here is one the
103// surveyed external consumer (tokhn) actually uses. Adding new
104// re-exports is intentional and visible.
105//
106// The submodule pattern for ir / eventlog mirrors the way
107// consumers reach into existing public submodules of car-memgine
108// (`car_memgine::distill::*`) or car-inference
109// (`car_inference::hardware::*`) — keeps grouping legible.
110
111pub use car_eventlog::{EventKind, EventLog, SpanStatus};
112pub use car_ir::{
113    Action, ActionProposal, ActionType, AgentOutcome, Evidence, EvidenceKind, FailureBehavior,
114    OutcomeMetrics, OutcomeStatus, ProposalResult, ToolSchema,
115};
116pub use car_planner::{Planner, PlannerConfig, ToolFeedback};
117pub use car_policy::{
118    ApprovalDecision, ApprovalLedger, ApprovalRecord, GateDecision, PermissionGate, PermissionTier,
119    PolicyCheck, PolicyEngine, RiskClassifier,
120};
121pub use car_state::StateStore;
122pub use car_validator::validate_tool_output;
123pub use car_verify::VerifyIssue;
124// car-sandbox / car-active-planner aren't re-exported here — both
125// depend on car-engine, so the umbrella inclusion would cycle.
126// They stay as their own publishable crates; tokhn keeps
127// `use car_sandbox::*` / `use car_active_planner::*` direct.
128
129#[cfg(test)]
130mod tests;