//! Core runtime engine for Common Agent Runtime.
//!
//! The runtime loop:
//! 1. Receive a proposal (batch of actions from a model)
//! 2. Build a DAG from state_dependencies
//! 3. Execute each level (concurrent if no ABORT actions, sequential otherwise)
//! 4. Validate, execute with idempotency + timeout + retry, commit
//! 5. On abort: rollback state to pre-proposal snapshot

pub mod agent_basics;
pub mod agent_capability;
pub mod authz;
pub mod builtin_agents;
pub mod cache;
pub mod capabilities;
pub mod checkpoint;
mod executor;
pub mod mcp;
pub mod rate_limit;
pub mod registry;
pub mod scope;
pub mod subprocess;
pub mod voice_turn;

pub use agent_basics::entries as agent_basic_entries;
pub use agent_capability::AgentCapabilityRegistry;
pub use authz::{
    AllowAllPermissions, AuthzDecision, AuthzPipeline, AuthzResult, AuthzStage, PermissionHandler,
    Restriction,
};
pub use builtin_agents::{
    agent_metadata, format_capability_payload, register_builtins, BuiltinAgent,
    CapabilityPayloadError, BUILTIN_AGENTS,
};
pub use cache::ResultCache;
pub use capabilities::CapabilitySet;
pub use checkpoint::Checkpoint;
pub use executor::{
    format_tool_result, CostBudget, FailedActionSummary, ReplanCallback, ReplanConfig,
    ReplanContext, Runtime, ToolExecutor, CANCELED_PREFIX,
};
pub use mcp::{McpServer, McpServerConfig, McpToolExecutor, McpToolInfo};
pub use rate_limit::{RateLimit, RateLimiter};
pub use registry::{ToolEntry, ToolPermission, ToolRegistry, ToolSource};
pub use scope::RuntimeScope;
pub use subprocess::{SubprocessTool, SubprocessToolExecutor};
pub use voice_turn::{
    dispatch_voice_turn, dispatch_voice_turn_sidecar_only,
    dispatch_voice_turn_sidecar_only_with_classifier,
    dispatch_voice_turn_sidecar_only_with_telemetry, dispatch_voice_turn_with_telemetry,
    DirectDataFetcher, SidecarResult, VoiceTelemetry, VoiceTurnControl, VoiceTurnError,
    VoiceTurnHandle,
};

// === Umbrella re-exports (car#205) ===
//
// car-engine is one of the published umbrella crates external Rust
// consumers cargo-add against. Re-exporting the engine-cluster
// types here lets tokhn (and future consumers) depend on a single
// crate instead of a dozen internal workspace crates. Internal
// crates stay separate for compile-time and target-gating reasons
// (CLAUDE.md forbids cargo feature flags), but they ship via
// path-deps once the publish-set trim lands in a follow-up.
//
// Re-exports are selective (not `pub use car_*::*`) so adding or
// renaming internal symbols doesn't silently leak to the
// umbrella's public surface — every type listed here is one the
// surveyed external consumer (tokhn) actually uses. Adding new
// re-exports is intentional and visible.
//
// The submodule pattern for ir / eventlog mirrors the way
// consumers reach into existing public submodules of car-memgine
// (`car_memgine::distill::*`) or car-inference
// (`car_inference::hardware::*`) — keeps grouping legible.

pub use car_ir::{
    Action, ActionProposal, ActionType, AgentOutcome, Evidence, EvidenceKind,
    FailureBehavior, OutcomeMetrics, OutcomeStatus, ProposalResult, ToolSchema,
};
pub use car_state::StateStore;
pub use car_verify::VerifyIssue;
pub use car_eventlog::{EventKind, EventLog, SpanStatus};
pub use car_policy::{PolicyCheck, PolicyEngine};
pub use car_planner::{Planner, PlannerConfig, ToolFeedback};
// car-sandbox / car-active-planner aren't re-exported here — both
// depend on car-engine, so the umbrella inclusion would cycle.
// They stay as their own publishable crates; tokhn keeps
// `use car_sandbox::*` / `use car_active_planner::*` direct.

#[cfg(test)]
mod tests;
