Skip to main content

aion_server/config/
runtime.rs

1//! Runtime-facing config views: [`RuntimeConfig`] and [`CliOverrides`].
2//!
3//! [`RuntimeConfig`] is the non-secret runtime slice carried in shared server
4//! state for transport adapters (produced by [`ServerConfig::into_parts`]);
5//! [`CliOverrides`] is the command-line override bundle merged after file and
6//! environment values. Both are re-exported from the `config` module so every
7//! existing `crate::config::X` path resolves identically.
8//!
9//! [`ServerConfig::into_parts`]: super::ServerConfig::into_parts
10
11use std::{net::SocketAddr, path::PathBuf, time::Duration};
12
13use super::{
14    AuthConfig, AuthoringConfig, AutoCreate, DeployConfig, DevConfig, ListenConfig, MetricsConfig,
15    NamespaceConfig, ObservabilityConfig, OpsConsoleConfig, OutboxConfig, ResolvedAssistantConfig,
16    ResolvedMcpConfig, TlsConfig, WebSocketConfig, WorkerConfig,
17};
18
19/// Command-line configuration overrides applied after file and environment values.
20#[derive(Debug, Default)]
21pub struct CliOverrides {
22    /// Optional explicit config path from `--config`.
23    pub config_path: Option<PathBuf>,
24    /// Override for `[server].listen_address`.
25    pub listen_address: Option<SocketAddr>,
26    /// Override for `[server].grpc_address`.
27    pub grpc_address: Option<SocketAddr>,
28    /// Retired `--store-url` input retained only so load-time validation can refuse it.
29    pub store_url: Option<String>,
30    /// Override for `[runtime].scheduler_threads`.
31    pub scheduler_threads: Option<usize>,
32    /// Override for `[runtime].jit_threshold`.
33    pub jit_threshold: Option<u32>,
34    /// Override for `[drain].timeout_seconds`.
35    pub drain_timeout_seconds: Option<u64>,
36    /// Additional workflow package archives loaded after config and auto-discovered packages.
37    pub workflow_packages: Vec<PathBuf>,
38    /// Override for `[authoring].gleam_path`: the external `gleam` binary that
39    /// gates the server-side authoring loop. Setting it commissions the
40    /// authoring endpoints.
41    pub gleam_path: Option<PathBuf>,
42    /// Override for `[authoring].project_root`: the built Gleam workflow
43    /// project submitted source is written into and packaged from.
44    pub authoring_project_root: Option<PathBuf>,
45}
46
47/// Runtime settings retained in shared server state for transport adapters.
48#[derive(Clone, Debug)]
49pub struct RuntimeConfig {
50    /// Listener addresses for public transports.
51    pub listen: ListenConfig,
52    /// Optional TLS material for public transports.
53    pub tls: Option<TlsConfig>,
54    /// Authentication configuration shared by transports.
55    pub auth: AuthConfig,
56    /// Ops-console asset location.
57    pub ops_console: OpsConsoleConfig,
58    /// Namespace resolver construction mode.
59    pub namespace: NamespaceConfig,
60    /// Remote worker heartbeat configuration.
61    pub worker: WorkerConfig,
62    /// WebSocket stream configuration.
63    pub websocket: WebSocketConfig,
64    /// Workflow package archives loaded into the engine at startup.
65    pub workflow_packages: Vec<PathBuf>,
66    /// Operator deploy API settings.
67    pub deploy: DeployConfig,
68    /// Server-side Gleam authoring API settings.
69    pub authoring: AuthoringConfig,
70    /// Local dev-server surface settings.
71    pub dev: DevConfig,
72    /// Durable-outbox fan-out dispatcher settings.
73    pub outbox: OutboxConfig,
74    /// Agent-observability transcript retention bounds (`[observability]`).
75    pub observability: ObservabilityConfig,
76    /// Model Context Protocol surface settings (`[mcp]`), fully resolved.
77    pub mcp: ResolvedMcpConfig,
78    /// Assistant-session settings (`[assistant]`), fully resolved. The
79    /// [`Default`] is the STOCK form — no `[assistant]` section, so no declared
80    /// account — which is what a server whose config never mentions the surface
81    /// carries, and which still serves the assistant on every harness the
82    /// catalogue ships.
83    pub assistant: ResolvedAssistantConfig,
84    /// Engine scheduler thread count.
85    pub scheduler_threads: usize,
86    /// Engine JIT compilation threshold, or [`None`] to defer to beamr's own
87    /// default. Carried as an [`Option`] because "the operator named a
88    /// threshold" and "nobody said" are different states, and only the first
89    /// may override beamr.
90    pub jit_threshold: Option<u32>,
91    /// Engine reply deadline for workflow queries. REQUIRED — carried as an
92    /// [`Option`] only so state construction can re-validate (defense in
93    /// depth, like `websocket.event_broadcast_capacity`); validated
94    /// configurations always hold [`Some`] non-zero duration.
95    pub query_timeout: Option<Duration>,
96    /// Workloop sweep interval — how often the engine checks its registered
97    /// loops for a due cadence window or an exceeded tolerance.
98    pub workloop_sweep_interval: Option<Duration>,
99    /// The engine stop's NO-PROGRESS drain bound (AE-017), from
100    /// `[runtime].stop_drain_timeout_ms`. Carried as an [`Option`] like
101    /// `query_timeout` so state construction can re-validate; validated
102    /// configurations always hold [`Some`] non-zero duration.
103    pub stop_drain_timeout: Option<Duration>,
104    /// Default namespace used by worker dispatch and unauthenticated local callers.
105    pub default_namespace: String,
106    /// Minted-on-use policy applied at the worker-registration mint hook
107    /// (`[namespaces] auto_create`). [`AutoCreate::Open`] (the default) mints an
108    /// unseen namespace durably; [`AutoCreate::Closed`] rejects it.
109    pub auto_create: AutoCreate,
110    /// Platform-wide default for a namespace's cluster-wide concurrent
111    /// in-flight-activity ceiling (`[namespaces] max_in_flight_activities`),
112    /// applied when a namespace record carries no explicit override. Carried in
113    /// runtime state so the later P2-Q2 keyed-backpressure dispatcher can read
114    /// it without reloading config. Stored-only in this slice — nothing reads it
115    /// yet.
116    pub max_in_flight_activities: u32,
117    /// Graceful drain timeout.
118    pub drain_timeout: Duration,
119    /// Metrics endpoint settings.
120    pub metrics: MetricsConfig,
121    /// Static distribution-shard assignment for this node (from `[store]
122    /// owned_shards`). Empty means own ALL shards (single-node default,
123    /// byte-identical to today); a non-empty set scopes engine recovery and
124    /// enumeration to exactly those shards. No election: assignment is static.
125    pub owned_shards: Vec<usize>,
126    /// Browser origins allowed cross-origin access to the public HTTP API (from
127    /// `[server] cors_allowed_origins`). Empty means no cross-origin access and
128    /// no `CorsLayer` is installed (secure default); a non-empty set installs
129    /// the layer scoped to exactly those origins.
130    pub cors_allowed_origins: Vec<String>,
131}