//! Phase 67.D — agent-loop tools for dispatching driver goals.
//!
//! Layered as:
//!
//! - `policy_gate` (this step) — pure-function admission check.
//! - `program_phase` / `dispatch_followup` (67.E.1, 67.E.2) — tool
//!   handlers that build a `Goal` and ask the orchestrator to spawn.
//! - `chain` / `agent_control` / `agent_query` / `admin` / `hooks`
//!   (67.E.x onwards) — the rest of the multi-agent surface.

pub mod admin;
pub mod agent_control;
pub mod agent_query;
pub mod away_summary;
pub mod chain;
pub mod dispatch_followup;
pub mod event_forwarder;
pub mod hooks;
pub mod policy_gate;
pub mod program_phase;
pub mod shutdown_drain;
pub mod subjects;
pub mod tool_names;

pub use away_summary::{build_digest, try_compose_away_digest, AwaySummaryError};
pub use shutdown_drain::{drain_running_goals, DrainReport};

pub use admin::{
    evict_completed, flush_agent_queue, set_concurrency_cap, AdminError, EvictCompletedInput,
    EvictCompletedOutput, FlushAgentQueueOutput, SetConcurrencyCapInput, SetConcurrencyCapOutput,
};
pub use agent_control::{
    ask_user_question, cancel_agent, pause_agent, rearm_ask_user_timeouts, resume_agent,
    update_budget, AgentControlError, AskUserQuestionInput, AskUserQuestionOutput,
    CancelAgentInput, CancelAgentOutput, PauseAgentInput, PauseAgentOutput, UpdateBudgetInput,
    UpdateBudgetOutput,
};
pub use agent_query::{
    agent_hooks_list, agent_logs_tail, agent_status, agent_turns_tail, list_agents,
    AgentHooksListInput, AgentLogsTailInput, AgentStatusInput, AgentTurnsTailInput,
    ListAgentsInput,
};
pub use chain::{
    program_phase_chain, program_phase_parallel, ProgramPhaseChainInput, ProgramPhaseChainOutput,
    ProgramPhaseParallelInput, ProgramPhaseParallelOutput,
};
pub use hooks::HookRegistry;
pub use subjects::{
    registry_snapshot_subject, DispatchDeniedPayload, DispatchSpawnedPayload, DispatchTelemetry,
    HookDispatchedPayload, HookFailedPayload, NoopTelemetry,
};

pub use hooks::{
    CompletionHook, DefaultHookDispatcher, DispatchPhaseChainer, HookAction, HookDispatcher,
    HookError, HookIdempotencyStore, HookPayload, HookRegistryStore, HookStoreError,
    HookTransition, HookTrigger, IdempotencyError, NatsHookPublisher, NoopNatsHookPublisher,
    SqliteHookRegistryStore,
};

pub use dispatch_followup::{
    dispatch_followup_call, followup_phase_id, DispatchFollowupInput, DispatchFollowupOutput,
};
pub use event_forwarder::EventForwarder;
pub use program_phase::{
    program_phase_dispatch, BudgetOverride, ProgramPhaseError, ProgramPhaseInput,
    ProgramPhaseOutput,
};

pub use policy_gate::{DispatchDenied, DispatchGate, DispatchRequest};
pub use tool_names::{
    allowed_tool_names, should_register, ToolGroup, ADMIN_TOOL_NAMES, READ_TOOL_NAMES,
    WRITE_TOOL_NAMES,
};
