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, ResolvedMcpConfig,
16 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 `[drain].timeout_seconds`.
33 pub drain_timeout_seconds: Option<u64>,
34 /// Additional workflow package archives loaded after config and auto-discovered packages.
35 pub workflow_packages: Vec<PathBuf>,
36 /// Override for `[authoring].gleam_path`: the external `gleam` binary that
37 /// gates the server-side authoring loop. Setting it commissions the
38 /// authoring endpoints.
39 pub gleam_path: Option<PathBuf>,
40 /// Override for `[authoring].project_root`: the built Gleam workflow
41 /// project submitted source is written into and packaged from.
42 pub authoring_project_root: Option<PathBuf>,
43}
44
45/// Runtime settings retained in shared server state for transport adapters.
46#[derive(Clone, Debug)]
47pub struct RuntimeConfig {
48 /// Listener addresses for public transports.
49 pub listen: ListenConfig,
50 /// Optional TLS material for public transports.
51 pub tls: Option<TlsConfig>,
52 /// Authentication configuration shared by transports.
53 pub auth: AuthConfig,
54 /// Ops-console asset location.
55 pub ops_console: OpsConsoleConfig,
56 /// Namespace resolver construction mode.
57 pub namespace: NamespaceConfig,
58 /// Remote worker heartbeat configuration.
59 pub worker: WorkerConfig,
60 /// WebSocket stream configuration.
61 pub websocket: WebSocketConfig,
62 /// Workflow package archives loaded into the engine at startup.
63 pub workflow_packages: Vec<PathBuf>,
64 /// Operator deploy API settings.
65 pub deploy: DeployConfig,
66 /// Server-side Gleam authoring API settings.
67 pub authoring: AuthoringConfig,
68 /// Local dev-server surface settings.
69 pub dev: DevConfig,
70 /// Durable-outbox fan-out dispatcher settings.
71 pub outbox: OutboxConfig,
72 /// Agent-observability transcript retention bounds (`[observability]`).
73 pub observability: ObservabilityConfig,
74 /// Model Context Protocol surface settings (`[mcp]`), fully resolved.
75 pub mcp: ResolvedMcpConfig,
76 /// Engine scheduler thread count.
77 pub scheduler_threads: usize,
78 /// Engine reply deadline for workflow queries. REQUIRED — carried as an
79 /// [`Option`] only so state construction can re-validate (defense in
80 /// depth, like `websocket.event_broadcast_capacity`); validated
81 /// configurations always hold [`Some`] non-zero duration.
82 pub query_timeout: Option<Duration>,
83 /// Default namespace used by worker dispatch and unauthenticated local callers.
84 pub default_namespace: String,
85 /// Minted-on-use policy applied at the worker-registration mint hook
86 /// (`[namespaces] auto_create`). [`AutoCreate::Open`] (the default) mints an
87 /// unseen namespace durably; [`AutoCreate::Closed`] rejects it.
88 pub auto_create: AutoCreate,
89 /// Platform-wide default for a namespace's cluster-wide concurrent
90 /// in-flight-activity ceiling (`[namespaces] max_in_flight_activities`),
91 /// applied when a namespace record carries no explicit override. Carried in
92 /// runtime state so the later P2-Q2 keyed-backpressure dispatcher can read
93 /// it without reloading config. Stored-only in this slice — nothing reads it
94 /// yet.
95 pub max_in_flight_activities: u32,
96 /// Graceful drain timeout.
97 pub drain_timeout: Duration,
98 /// Metrics endpoint settings.
99 pub metrics: MetricsConfig,
100 /// Static distribution-shard assignment for this node (from `[store]
101 /// owned_shards`). Empty means own ALL shards (single-node default,
102 /// byte-identical to today); a non-empty set scopes engine recovery and
103 /// enumeration to exactly those shards. No election: assignment is static.
104 pub owned_shards: Vec<usize>,
105 /// Browser origins allowed cross-origin access to the public HTTP API (from
106 /// `[server] cors_allowed_origins`). Empty means no cross-origin access and
107 /// no `CorsLayer` is installed (secure default); a non-empty set installs
108 /// the layer scoped to exactly those origins.
109 pub cors_allowed_origins: Vec<String>,
110}