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 `[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 /// Engine scheduler thread count.
79 pub scheduler_threads: usize,
80 /// Engine JIT compilation threshold, or [`None`] to defer to beamr's own
81 /// default. Carried as an [`Option`] because "the operator named a
82 /// threshold" and "nobody said" are different states, and only the first
83 /// may override beamr.
84 pub jit_threshold: Option<u32>,
85 /// Engine reply deadline for workflow queries. REQUIRED — carried as an
86 /// [`Option`] only so state construction can re-validate (defense in
87 /// depth, like `websocket.event_broadcast_capacity`); validated
88 /// configurations always hold [`Some`] non-zero duration.
89 pub query_timeout: Option<Duration>,
90 /// Default namespace used by worker dispatch and unauthenticated local callers.
91 pub default_namespace: String,
92 /// Minted-on-use policy applied at the worker-registration mint hook
93 /// (`[namespaces] auto_create`). [`AutoCreate::Open`] (the default) mints an
94 /// unseen namespace durably; [`AutoCreate::Closed`] rejects it.
95 pub auto_create: AutoCreate,
96 /// Platform-wide default for a namespace's cluster-wide concurrent
97 /// in-flight-activity ceiling (`[namespaces] max_in_flight_activities`),
98 /// applied when a namespace record carries no explicit override. Carried in
99 /// runtime state so the later P2-Q2 keyed-backpressure dispatcher can read
100 /// it without reloading config. Stored-only in this slice — nothing reads it
101 /// yet.
102 pub max_in_flight_activities: u32,
103 /// Graceful drain timeout.
104 pub drain_timeout: Duration,
105 /// Metrics endpoint settings.
106 pub metrics: MetricsConfig,
107 /// Static distribution-shard assignment for this node (from `[store]
108 /// owned_shards`). Empty means own ALL shards (single-node default,
109 /// byte-identical to today); a non-empty set scopes engine recovery and
110 /// enumeration to exactly those shards. No election: assignment is static.
111 pub owned_shards: Vec<usize>,
112 /// Browser origins allowed cross-origin access to the public HTTP API (from
113 /// `[server] cors_allowed_origins`). Empty means no cross-origin access and
114 /// no `CorsLayer` is installed (secure default); a non-empty set installs
115 /// the layer scoped to exactly those origins.
116 pub cors_allowed_origins: Vec<String>,
117}