aion_server/config/sections.rs
1//! Typed `[section]` sub-configurations that make up [`ServerConfig`].
2//!
3//! Each struct/enum here maps one `[section]` (or nested value) of the server
4//! TOML surface, with its `serde` attributes, `Default` impl, and the small
5//! amount of per-section validation that belongs with the type
6//! ([`WebSocketConfig::validate`]). They are re-exported from the `config`
7//! module so every existing `crate::config::X` path resolves identically.
8//!
9//! [`ServerConfig`]: super::ServerConfig
10
11use std::{net::SocketAddr, path::PathBuf, time::Duration};
12
13use serde::{Deserialize, Deserializer, de};
14
15use crate::error::ServerError;
16
17use super::{
18 config_error,
19 defaults::{
20 CLUSTER_BROADCAST_CAPACITY_REQUIRED, DEFAULT_GRPC_ADDRESS, DEFAULT_HTTP_ADDRESS,
21 DEFAULT_MAX_IN_FLIGHT_ACTIVITIES, DEFAULT_MCP_DISCOVER_TTL_MS,
22 DEFAULT_MCP_TASK_POLL_INTERVAL_MS, DEFAULT_MCP_TOOLS_LIST_TTL_MS,
23 DEFAULT_OBSERVABILITY_MAX_EVENT_BYTES, DEFAULT_OBSERVABILITY_MAX_STREAM_EVENTS,
24 EVENT_BROADCAST_CAPACITY_REQUIRED, MCP_TASK_POLL_INTERVAL_REQUIRED,
25 OBSERVABILITY_MAX_EVENT_BYTES_REQUIRED, OBSERVABILITY_MAX_STREAM_EVENTS_REQUIRED,
26 },
27};
28
29/// Public transport listener addresses from `[server]`.
30#[derive(Clone, Debug, Deserialize)]
31#[serde(default, deny_unknown_fields)]
32pub struct ServerSection {
33 /// HTTP/JSON and dashboard listener.
34 pub listen_address: SocketAddr,
35 /// gRPC API and worker-protocol listener.
36 pub grpc_address: SocketAddr,
37 /// Browser origins allowed to make cross-origin (CORS) requests to the
38 /// public HTTP API. Empty (the default) is the SECURE default: no
39 /// cross-origin request is permitted and no `CorsLayer` is installed, so a
40 /// same-origin deployment behaves byte-identically to before this field
41 /// existed. When set, each entry is an exact origin (scheme + host + port,
42 /// e.g. `http://localhost:5173`) the browser dashboard is served from; the
43 /// router then answers preflight and emits `Access-Control-Allow-Origin`
44 /// for exactly those origins. There is no wildcard/allow-all default
45 /// (ADR-001): cross-origin access is an explicit operator decision, and the
46 /// layer never pairs `Any` with credentials.
47 #[serde(default)]
48 pub cors_allowed_origins: Vec<String>,
49}
50
51/// Supported event-store backend names.
52///
53/// Deliberately NOT `Deserialize`. `StoreConfigWire` parses the operator's
54/// spelling itself, case-insensitively, so that the file door and the
55/// `AION_STORE_BACKEND` door accept exactly the same set — a derived
56/// `rename_all = "lowercase"` impl was a second, case-SENSITIVE parser for the
57/// same value that nothing called and that disagreed with the one that runs.
58#[derive(Clone, Copy, Debug, Eq, PartialEq)]
59pub enum StoreBackend {
60 /// In-memory store for local development.
61 Memory,
62 /// haematite durable store (single-node, shardable).
63 Haematite,
64}
65
66/// A store-selection input that named the retired libSQL backend.
67///
68/// Recorded at parse/overlay time and refused by `ServerConfig::validate`, which
69/// names the input it found and prescribes haematite. Recorded rather than
70/// refused on the spot so all five doors converge on ONE refusal with one
71/// remedy, instead of five differently-worded errors from five parsers.
72#[derive(Clone, Copy, Debug, Eq, PartialEq)]
73pub(crate) enum RetiredStoreInput {
74 /// `backend = "libsql"` in the config file's `[store]` section.
75 Backend,
76 /// `AION_STORE_BACKEND=libsql` in the environment.
77 BackendEnvironment,
78 /// `url = ...` in the config file's `[store]` section.
79 Url,
80 /// The `AION_STORE_URL` environment variable.
81 Environment,
82 /// The `--store-url` command-line flag.
83 Flag,
84}
85
86/// Event-store backend configuration from `[store]`.
87#[derive(Clone, Debug)]
88pub struct StoreConfig {
89 /// Selected backing store implementation.
90 pub backend: StoreBackend,
91 pub(crate) retired_input: Option<RetiredStoreInput>,
92 /// Static distribution-shard assignment for this node (multi-shard
93 /// active-active). When empty (the default) the node owns ALL shards — the
94 /// single-node default, byte-identical to today. When set, the engine boot
95 /// path scopes recovery and enumeration to exactly these shards. The
96 /// single-shard memory backend ignores the assignment; it is meaningful only
97 /// for a sharded backend. No election is performed: assignment is static
98 /// config.
99 pub owned_shards: Vec<usize>,
100 /// Filesystem data directory for the haematite backend. Required when
101 /// `backend = haematite`; ignored by every other backend. The directory is
102 /// opened if it already holds a haematite database, otherwise created.
103 pub data_dir: Option<String>,
104 /// Number of haematite shards to create on a fresh database. Defaults to 64.
105 ///
106 /// This is an IMMUTABLE virtual-shard count: nodes own shard *ranges* and
107 /// routing is `BLAKE3(key) % shard_count` with no reshard path, so a
108 /// single-node deployment can later grow into a cluster WITHOUT a data
109 /// migration — but only up to `shard_count` nodes, and the value is fixed
110 /// at create.
111 ///
112 /// The default was briefly 4096 on the premise that lazy shard-actor
113 /// materialization (haematite >= 0.4.0) made a high count ~free. That
114 /// premise fails in practice (#187): aion-server's boot restores
115 /// packages/routes/namespaces via full-prefix scans, which materialize
116 /// EVERY shard, and haematite 0.4.0 then fans each commit out to every
117 /// materialized shard with an unconditional fsync — ~2 fsyncs x 4096 per
118 /// logical commit — blowing the 5s shard-actor timeout and bricking
119 /// deploy/start/timers/outbox on a fresh server. Re-raise only after
120 /// haematite makes commit O(dirty shards) and the scaffold e2es pass at
121 /// the new default. Set explicitly (config or `AION_STORE_SHARD_COUNT`)
122 /// to override. Ignored by every other backend, and ignored when opening
123 /// an existing haematite database (the on-disk shard count wins).
124 pub shard_count: usize,
125 /// Optional distributed-cluster membership for the haematite backend (SS-2).
126 ///
127 /// Absent (the default) selects the SINGLE-NODE haematite path, byte-identical
128 /// to today: no endpoint is bound, no shard is elected, the store owns
129 /// everything locally. Present selects the DISTRIBUTED path: the boot path
130 /// binds a replication endpoint, builds a quorum membership from `members` +
131 /// `peers`, and the engine boot path elects (`acquire_shard_and_serve`) this
132 /// node's `owned_shards` before recovery. Ignored by every non-haematite
133 /// backend.
134 pub cluster: Option<ClusterConfig>,
135 /// The byte ceiling the haematite node caches may hold.
136 /// **Required; no default** — the haematite boot path refuses to start
137 /// without it. Ignored by every other backend (only haematite has a node
138 /// cache), which is why it is required where it is USED rather than at
139 /// parse time: a `memory` deployment is not asked to rule on a cache it does
140 /// not have.
141 ///
142 /// A node is not a fixed-size thing — under byte-aware chunking a leaf
143 /// reaches the ~96KB class — so a cache bounded only by `max_entries`
144 /// carries a standing footprint of `entries x (whatever a node weighs)`,
145 /// unbounded in bytes by construction. This is the missing bound, and
146 /// haematite 0.8.2 refuses a `DatabaseConfig` that does not carry it.
147 ///
148 /// Deserialized through haematite's own wire shape, so there is exactly one
149 /// parser for this value estate-wide:
150 ///
151 /// ```toml
152 /// [store]
153 /// node_cache_budget = { bytes = 1073741824 } # 1 GiB
154 /// # or, the pre-budget behaviour said out loud:
155 /// node_cache_budget = "unlimited"
156 /// ```
157 ///
158 /// Absent fails startup with [`STORE_NODE_CACHE_BUDGET_REQUIRED`]; a zero
159 /// byte count is refused by haematite at parse time (a zero ceiling admits
160 /// nothing, which is "disable the cache" and must be spelled differently).
161 ///
162 /// [`STORE_NODE_CACHE_BUDGET_REQUIRED`]: super::STORE_NODE_CACHE_BUDGET_REQUIRED
163 pub node_cache_budget: Option<haematite::NodeCacheBudget>,
164 /// RETIRED (2026-08-24) and ignored: boot now waits indefinitely for the
165 /// data-directory writer lock — a kernel-released flock whose holder is
166 /// either live mid-handover or already gone, so a patience ceiling only
167 /// converted slow handovers into refused boots. Kept so a configuration
168 /// that still carries the key stays LEGAL (warned, never refused) and
169 /// existing estates boot unchanged.
170 pub lock_acquisition_patience_ms: Option<u64>,
171 /// RETIRED (2026-08-24) and ignored, with `lock_acquisition_patience_ms`:
172 /// the wait's internal probe cadence is an implementation constant, not
173 /// configuration. Kept only so the key stays legal in existing files.
174 pub lock_acquisition_retry_cadence_ms: Option<u64>,
175}
176
177#[derive(Default, Deserialize)]
178#[serde(default, deny_unknown_fields)]
179struct StoreConfigWire {
180 backend: Option<String>,
181 /// Retired: recorded so `validate` can refuse it. Kept on the wire — and
182 /// NOT left to `deny_unknown_fields` — so an operator carrying a 0.15
183 /// config is told the key is retired and what replaces it, rather than
184 /// getting an unknown-field parse error that names no remedy.
185 url: Option<String>,
186 owned_shards: Vec<usize>,
187 data_dir: Option<String>,
188 shard_count: Option<usize>,
189 cluster: Option<ClusterConfig>,
190 node_cache_budget: Option<haematite::NodeCacheBudget>,
191 lock_acquisition_patience_ms: Option<u64>,
192 lock_acquisition_retry_cadence_ms: Option<u64>,
193}
194
195impl<'de> Deserialize<'de> for StoreConfig {
196 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
197 where
198 D: Deserializer<'de>,
199 {
200 let wire = StoreConfigWire::deserialize(deserializer)?;
201 let mut config = Self::default();
202 if let Some(backend) = wire.backend.as_deref() {
203 match backend.to_ascii_lowercase().as_str() {
204 "memory" => config.backend = StoreBackend::Memory,
205 "haematite" => config.backend = StoreBackend::Haematite,
206 "libsql" => config.retired_input = Some(RetiredStoreInput::Backend),
207 _ => {
208 return Err(de::Error::custom(
209 "store.backend must be one of: memory, haematite",
210 ));
211 }
212 }
213 }
214 if wire.url.is_some() && config.retired_input.is_none() {
215 config.retired_input = Some(RetiredStoreInput::Url);
216 }
217 config.owned_shards = wire.owned_shards;
218 config.data_dir = wire.data_dir;
219 if let Some(shard_count) = wire.shard_count {
220 config.shard_count = shard_count;
221 }
222 config.cluster = wire.cluster;
223 config.node_cache_budget = wire.node_cache_budget;
224 config.lock_acquisition_patience_ms = wire.lock_acquisition_patience_ms;
225 config.lock_acquisition_retry_cadence_ms = wire.lock_acquisition_retry_cadence_ms;
226 Ok(config)
227 }
228}
229
230/// Distributed-cluster membership for the haematite backend, from `[store.cluster]`.
231///
232/// This is the minimal, well-defaulted seam that turns the single-node haematite
233/// store into a distributed one (SS-2). A "cluster of one" — `node_id` set,
234/// `members` either empty or naming only `node_id`, and no `peers` — is a valid,
235/// non-flaky configuration: election self-quorums (quorum denominator 1) and the
236/// node boots through the production builder as the fenced owner of its shards.
237#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
238#[serde(deny_unknown_fields)]
239pub struct ClusterConfig {
240 /// This node's globally-unique distribution name (e.g. `node-0@127.0.0.1`).
241 /// Used as the local endpoint name and the local membership identity.
242 pub node_id: String,
243 /// The replication endpoint listen address this node binds for peer
244 /// quorum/election traffic (e.g. `127.0.0.1:7000`).
245 pub bind_address: SocketAddr,
246 /// The FULL cluster membership by node id — the quorum DENOMINATOR. Never the
247 /// reachable subset. May be empty or omit peers for a cluster of one, in which
248 /// case it is treated as `[node_id]` (denominator 1). `node_id` is always
249 /// counted in the denominator whether or not it appears here.
250 #[serde(default)]
251 pub members: Vec<String>,
252 /// Dialable peers (name + address) this node connects to for replication. A
253 /// cluster of one leaves this empty. Peers not in `members` do not inflate the
254 /// quorum denominator.
255 #[serde(default)]
256 pub peers: Vec<ClusterPeer>,
257 /// SS-5b automatic-failover poll interval in milliseconds: how often the
258 /// cluster supervisor checks each watched peer's replication liveness.
259 /// Defaults to [`DEFAULT_FAILOVER_POLL_INTERVAL_MS`] when omitted.
260 ///
261 /// [`DEFAULT_FAILOVER_POLL_INTERVAL_MS`]: super::DEFAULT_FAILOVER_POLL_INTERVAL_MS
262 #[serde(default)]
263 pub failover_poll_interval_ms: Option<u64>,
264 /// SS-5b debounce: the number of CONSECUTIVE polls a peer must be observed
265 /// disconnected before its shards are adopted, so a transient blip does not
266 /// trigger a disruptive failover. Defaults to
267 /// [`DEFAULT_FAILOVER_CONFIRMATIONS`] when omitted; must be at least one.
268 ///
269 /// [`DEFAULT_FAILOVER_CONFIRMATIONS`]: super::DEFAULT_FAILOVER_CONFIRMATIONS
270 #[serde(default)]
271 pub failover_confirmations: Option<u32>,
272}
273
274/// One dialable cluster peer: its distribution name and replication address.
275#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
276#[serde(deny_unknown_fields)]
277pub struct ClusterPeer {
278 /// The peer's globally-unique distribution name (matches its `node_id`).
279 pub name: String,
280 /// The peer's replication endpoint address to dial.
281 pub address: SocketAddr,
282 /// The peer's gRPC client-API address, for request forwarding (R-2/R-3).
283 /// This is DISTINCT from `address` (the replication/quorum endpoint): a
284 /// forwarded client `signal`/`query`/`cancel` is dialed here, not on the
285 /// replication port. Absent (the default) means the peer is not
286 /// forwardable — its shards still resolve to a remote owner, but routing
287 /// falls back to returning the typed `NotOwner` instead of forwarding (R-3).
288 #[serde(default)]
289 pub grpc_address: Option<SocketAddr>,
290 /// The distribution shards this peer owns. Empty (the default) means the
291 /// operator did not declare the peer's shards, so the SS-5b cluster
292 /// supervisor cannot adopt them automatically when the peer dies — automatic
293 /// failover for a peer requires its `owned_shards` to be declared here so the
294 /// survivor knows exactly which shards to elect + resume. Declaring them does
295 /// not change replication or quorum; it only tells the supervisor what to
296 /// adopt on this peer's death.
297 #[serde(default)]
298 pub owned_shards: Vec<usize>,
299}
300
301/// Engine runtime settings from `[runtime]`.
302#[derive(Clone, Debug, Deserialize)]
303#[serde(default, deny_unknown_fields)]
304pub struct RuntimeSection {
305 /// Number of scheduler worker threads.
306 pub scheduler_threads: usize,
307 /// JIT compilation threshold: recorded calls to one
308 /// `(module, function, arity)` before beamr compiles it.
309 ///
310 /// Absent means beamr applies its own default; the server invents no value.
311 /// Read `aion::RuntimeConfig::jit_threshold` before setting it — a large
312 /// value defers compilation past any realistic workload but is **not** a
313 /// JIT off-switch.
314 pub jit_threshold: Option<u32>,
315 /// Engine reply deadline for workflow queries, in milliseconds.
316 /// REQUIRED — the server always mounts `/workflows/query`, so the query
317 /// reply deadline must be an explicit operator decision; there is no
318 /// default. The engine builder is equally explicit-no-default.
319 pub query_timeout_ms: Option<u64>,
320}
321
322/// Graceful drain settings from `[drain]`.
323#[derive(Clone, Debug, Deserialize)]
324#[serde(default, deny_unknown_fields)]
325pub struct DrainConfig {
326 /// Maximum drain duration in seconds.
327 pub timeout_seconds: u64,
328}
329
330/// Authentication configuration applied at adapter boundaries.
331#[derive(Clone, Debug, Deserialize)]
332#[serde(default, deny_unknown_fields)]
333pub struct AuthConfig {
334 /// Whether authentication is enabled.
335 pub enabled: bool,
336 /// JWKS URL used by AO-006 auth validation.
337 pub jwks_url: Option<String>,
338 /// JWKS refresh interval in seconds.
339 pub jwks_refresh_seconds: u64,
340}
341
342/// Metrics endpoint settings from `[metrics]`.
343#[derive(Clone, Debug, Deserialize)]
344#[serde(default, deny_unknown_fields)]
345pub struct MetricsConfig {
346 /// Whether metrics are exposed.
347 pub enabled: bool,
348}
349
350/// Namespace defaults from `[namespaces]`.
351#[derive(Clone, Debug, Deserialize)]
352#[serde(default, deny_unknown_fields)]
353pub struct NamespacesConfig {
354 /// Default namespace used for local callers and worker dispatch.
355 pub default: String,
356 /// Minted-on-use policy: whether referencing an unseen namespace at worker
357 /// registration durably mints it ([`AutoCreate::Open`], the zero-config
358 /// default) or is rejected ([`AutoCreate::Closed`]).
359 pub auto_create: AutoCreate,
360 /// Platform-wide default for a namespace's **cluster-wide** concurrent
361 /// in-flight-activity ceiling, applied when a namespace record carries no
362 /// explicit `max_in_flight_activities` override (Control-Plane Phase 2,
363 /// P2-Q1). This is the GENEROUS platform default, NOT a low hard cap: it is
364 /// a cluster-wide tenant contract (never "per-node × N"), so a tenant is
365 /// promised ≈this many concurrent activities across the whole cluster.
366 /// Defaults to [`DEFAULT_MAX_IN_FLIGHT_ACTIVITIES`].
367 ///
368 /// **Stored-only in this slice.** Nothing enforces it yet — the outbox
369 /// dispatcher's keyed backpressure (P2-Q2) consults it in a later slice.
370 ///
371 /// [`DEFAULT_MAX_IN_FLIGHT_ACTIVITIES`]: super::DEFAULT_MAX_IN_FLIGHT_ACTIVITIES
372 pub max_in_flight_activities: u32,
373}
374
375/// Minted-on-use namespace policy (Control-Plane Phase 1).
376///
377/// Governs what happens when a worker registers for a namespace that has no
378/// durable registry record. Defaults to [`AutoCreate::Open`] to preserve the
379/// zero-ceremony, no-pre-provision model: a namespace comes into being on first
380/// reference.
381#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Eq)]
382#[serde(rename_all = "snake_case")]
383pub enum AutoCreate {
384 /// A worker registering for an unseen namespace durably mints it (an
385 /// idempotent upsert through the registry). Zero-config default.
386 #[default]
387 Open,
388 /// A worker registering for a namespace with no durable registry record is
389 /// rejected; the namespace is never created at the registration hook. The
390 /// escape hatch for locked-down deployments is an explicit create
391 /// (`POST /namespaces`).
392 Closed,
393}
394
395/// Public transport listener addresses retained for existing adapter code.
396#[derive(Clone, Debug, Deserialize)]
397#[serde(default, deny_unknown_fields)]
398pub struct ListenConfig {
399 /// gRPC API and worker-protocol listener.
400 pub grpc: SocketAddr,
401 /// HTTP/JSON and dashboard listener.
402 pub http: SocketAddr,
403}
404
405/// TLS certificate and private-key material.
406#[derive(Clone, Debug, Deserialize)]
407#[serde(deny_unknown_fields)]
408pub struct TlsConfig {
409 /// Certificate chain path supplied by the operator.
410 pub certificate_chain_path: PathBuf,
411 /// Private-key path supplied by the operator.
412 pub private_key_path: PathBuf,
413}
414
415/// Static ops-console asset configuration.
416#[derive(Clone, Debug, Deserialize)]
417#[serde(default, deny_unknown_fields)]
418pub struct OpsConsoleConfig {
419 /// Operator-selected bundle source.
420 pub source: OpsConsoleAssetSource,
421}
422
423/// Static ops-console bundle source.
424#[derive(Clone, Debug, Deserialize)]
425pub enum OpsConsoleAssetSource {
426 /// Serve the built bundle from an operator-supplied directory.
427 FileSystem {
428 /// Directory containing `index.html` and built asset files.
429 asset_path: PathBuf,
430 },
431 /// Serve the compile-time embedded bundle.
432 Embedded,
433}
434
435/// Namespace resolver construction mode.
436#[derive(Clone, Debug, Deserialize)]
437#[serde(default, deny_unknown_fields)]
438pub struct NamespaceConfig {
439 /// Deployment-selected namespace mapping mode.
440 pub mode: NamespaceMode,
441}
442
443/// Supported namespace mapping modes.
444#[derive(Clone, Debug, Deserialize)]
445pub enum NamespaceMode {
446 /// All authorized namespaces share the configured engine instance.
447 SharedEngine,
448 /// Namespace authorization is disabled only for single-tenant deployments.
449 SingleTenant {
450 /// The only namespace accepted by the deployment.
451 namespace: String,
452 },
453}
454
455/// Remote worker heartbeat configuration.
456#[derive(Clone, Debug, Deserialize)]
457#[serde(default, deny_unknown_fields)]
458pub struct WorkerConfig {
459 /// Window after which a silent worker is considered lost.
460 #[serde(with = "duration_millis")]
461 pub heartbeat_window: Duration,
462 /// R1 queue-service policies and clocks (`[worker.queue_service]`).
463 ///
464 /// Absent, every queue is served `strict` with no clocks: structural
465 /// unservability refuses, everything else waits — loudly, typed, and
466 /// queryable. Writing a deadline is how an operator declares how long a
467 /// dispatch may wait; writing a `durable_pending` override is how a queue
468 /// declares that its runs park rather than refuse.
469 #[serde(default)]
470 pub queue_service: crate::worker::queue_service::QueueServiceConfig,
471}
472
473/// WebSocket stream configuration.
474#[derive(Clone, Debug, Deserialize)]
475#[serde(default, deny_unknown_fields)]
476pub struct WebSocketConfig {
477 /// Per-connection outbound buffer bound.
478 pub outbound_buffer_bound: usize,
479 /// Capacity of the engine-global event broadcast channel that backs
480 /// `/events/stream`. REQUIRED — the server always mounts the streaming
481 /// endpoint, so streaming capacity must be an explicit operator decision;
482 /// there is no default. Lag is filter-blind, so size this for global event
483 /// volume across all namespaces, not per-subscription volume.
484 pub event_broadcast_capacity: Option<usize>,
485 /// Capacity of the deployment-global cluster topology/ownership broadcast
486 /// channel that backs the WS3 `cluster` subscription on `/events/stream`.
487 /// REQUIRED with the same non-zero startup guard as
488 /// [`Self::event_broadcast_capacity`]: the cluster channel uses the same
489 /// lag -> one-error-frame -> close contract, which has no defined buffer to
490 /// lag against unless a capacity is configured. Cluster events are low-rate
491 /// (peer/shard/worker topology deltas), so this is typically far smaller
492 /// than the workflow event capacity.
493 pub cluster_broadcast_capacity: Option<usize>,
494}
495
496impl WebSocketConfig {
497 /// Validate the three unconditionally-mounted WebSocket seams: the
498 /// per-connection buffer bound, the workflow event broadcast capacity, and
499 /// the WS3 cluster broadcast capacity. The two broadcast capacities are
500 /// explicit-no-default with a non-zero guard, since both back a lag ->
501 /// one-error-frame -> close contract that needs a defined buffer to lag
502 /// against.
503 pub(super) fn validate(&self) -> Result<(), ServerError> {
504 if self.outbound_buffer_bound == 0 {
505 return config_error("websocket.outbound_buffer_bound must be greater than zero");
506 }
507 match self.event_broadcast_capacity {
508 None | Some(0) => return config_error(EVENT_BROADCAST_CAPACITY_REQUIRED),
509 Some(_) => {}
510 }
511 match self.cluster_broadcast_capacity {
512 None | Some(0) => return config_error(CLUSTER_BROADCAST_CAPACITY_REQUIRED),
513 Some(_) => {}
514 }
515 Ok(())
516 }
517}
518
519/// Model Context Protocol surface settings from `[mcp]`.
520///
521/// The surface is DARK by default: with `enabled = false` (or the section
522/// absent) the `/mcp` route is not mounted and the path is a plain 404. An MCP
523/// endpoint hands a model the ability to start and cancel durable executions,
524/// so commissioning it is an explicit operator decision, never a side effect of
525/// upgrading.
526///
527/// `allowed_origins` is EMPTY by default and empty means "no browser origin".
528/// A programmatic client sends no `Origin` header and is unaffected; a page in
529/// a browser always sends one, so the empty list refuses every browser-borne
530/// request. That is the DNS-rebinding defence the transport requires, and it is
531/// a real policy rather than an unset value.
532#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq)]
533#[serde(default, deny_unknown_fields)]
534pub struct McpConfig {
535 /// Whether the `/mcp` endpoint is mounted. Defaults to false.
536 pub enabled: bool,
537 /// Browser origins permitted to reach the MCP endpoint. Empty permits none.
538 pub allowed_origins: Vec<String>,
539 /// `ttlMs` on the `server/discover` result.
540 ///
541 /// Defaults to [`DEFAULT_MCP_DISCOVER_TTL_MS`] when omitted and
542 /// `enabled = true`, so switching the surface on does not force sizing two
543 /// cache lifetimes first.
544 ///
545 /// [`DEFAULT_MCP_DISCOVER_TTL_MS`]: super::DEFAULT_MCP_DISCOVER_TTL_MS
546 pub discover_ttl_ms: Option<u64>,
547 /// `ttlMs` on the `tools/list` result. Defaults to
548 /// [`DEFAULT_MCP_TOOLS_LIST_TTL_MS`].
549 ///
550 /// [`DEFAULT_MCP_TOOLS_LIST_TTL_MS`]: super::DEFAULT_MCP_TOOLS_LIST_TTL_MS
551 pub tools_list_ttl_ms: Option<u64>,
552 /// The `pollIntervalMs` advertised on a created task. Defaults to
553 /// [`DEFAULT_MCP_TASK_POLL_INTERVAL_MS`].
554 ///
555 /// A hint to the client and nothing more: no server behaviour depends on
556 /// it. There is no task lifetime beside it, because an MCP task here is a
557 /// projection of a durable run and has nothing to expire.
558 ///
559 /// [`DEFAULT_MCP_TASK_POLL_INTERVAL_MS`]: super::DEFAULT_MCP_TASK_POLL_INTERVAL_MS
560 pub task_poll_interval_ms: Option<u64>,
561}
562
563impl McpConfig {
564 /// Refuse a zero poll interval at startup.
565 ///
566 /// Only meaningful when the surface is enabled: a dark surface's knobs are
567 /// never read, so refusing a boot over one would be refusing over a value
568 /// nothing uses.
569 ///
570 /// # Errors
571 ///
572 /// [`ServerError::Config`] when an explicitly-set interval is zero. A zero
573 /// poll interval is a busy loop, not a fast one, and the operator is told
574 /// so rather than being handed one.
575 pub(super) fn validate(&self) -> Result<(), ServerError> {
576 if !self.enabled {
577 return Ok(());
578 }
579 if self.task_poll_interval_ms == Some(0) {
580 return config_error(MCP_TASK_POLL_INTERVAL_REQUIRED);
581 }
582 Ok(())
583 }
584
585 /// Resolve every omitted knob to its default.
586 ///
587 /// A zero poll interval resolves to the DEFAULT rather than to zero.
588 /// [`Self::validate`] has already refused it on any loaded configuration,
589 /// so this arm is reachable only from a hand-constructed config that
590 /// skipped validation — and for that case a documented default is the safe
591 /// direction, where a literal zero would be a busy loop.
592 #[must_use]
593 pub fn resolved(&self) -> ResolvedMcpConfig {
594 ResolvedMcpConfig {
595 enabled: self.enabled,
596 allowed_origins: self.allowed_origins.clone(),
597 discover_ttl_ms: self.discover_ttl_ms.unwrap_or(DEFAULT_MCP_DISCOVER_TTL_MS),
598 tools_list_ttl_ms: self
599 .tools_list_ttl_ms
600 .unwrap_or(DEFAULT_MCP_TOOLS_LIST_TTL_MS),
601 task_poll_interval_ms: self
602 .task_poll_interval_ms
603 .filter(|value| *value > 0)
604 .unwrap_or(DEFAULT_MCP_TASK_POLL_INTERVAL_MS),
605 }
606 }
607}
608
609impl Default for ResolvedMcpConfig {
610 /// The dark surface: not mounted, no origin permitted, every lifetime at
611 /// its documented default. This is what an embedder that never configures
612 /// MCP gets, and it serves nothing.
613 fn default() -> Self {
614 McpConfig::default().resolved()
615 }
616}
617
618/// The `[mcp]` section with every omitted knob resolved.
619///
620/// Held in [`RuntimeConfig`](super::RuntimeConfig) so the mount reads settled
621/// values rather than re-deriving defaults at each composition point.
622#[derive(Clone, Debug, PartialEq, Eq)]
623pub struct ResolvedMcpConfig {
624 /// Whether the `/mcp` endpoint is mounted.
625 pub enabled: bool,
626 /// Browser origins permitted to reach the endpoint.
627 pub allowed_origins: Vec<String>,
628 /// `ttlMs` on `server/discover`.
629 pub discover_ttl_ms: u64,
630 /// `ttlMs` on `tools/list`.
631 pub tools_list_ttl_ms: u64,
632 /// Advertised client poll interval for a task.
633 pub task_poll_interval_ms: u64,
634}
635
636/// Agent-observability transcript settings from `[observability]`: retention
637/// bounds, and the transcript drain's flush policy.
638///
639/// The two RETENTION knobs default (they guard the durable `O` keyspace against
640/// unbounded growth): `max_event_bytes` truncates one oversized transcript event
641/// before it is persisted, and `max_stream_events` caps how many events one
642/// `(workflow, activity, attempt)` stream retains (one marker record is
643/// persisted at the cap; live streaming continues).
644///
645/// The two FLUSH knobs have **no default and are required** — see
646/// [`Self::max_batch_events`].
647#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq)]
648#[serde(default, deny_unknown_fields)]
649pub struct ObservabilityConfig {
650 /// Ceiling on one persisted transcript event's serialized size, bytes.
651 pub max_event_bytes: usize,
652 /// Ceiling on retained events per `(workflow, activity, attempt)` stream.
653 pub max_stream_events: u64,
654 /// Maximum transcript events the drain commits in ONE durable append.
655 /// **Required; no default** — the server refuses to start without it.
656 ///
657 /// Every durable commit re-persists its whole containing storage leaf as a
658 /// new permanent blob, so committing one event at a time made the store cost
659 /// of a run linear in event COUNT: measured 2026-08-17, a 136 KB status
660 /// sweep left 73.7 MB of permanent store (540x) and a single 2,359-byte
661 /// append bought a 2,303,416-byte blob. Batching divides that count by (up
662 /// to) this number.
663 ///
664 /// There is deliberately no shipped value: the trade between store cost and
665 /// how many events one refused commit can lose is the operator's, and an
666 /// invented default would silently make it for them. Absent or zero fails
667 /// startup with [`OBSERVABILITY_MAX_BATCH_EVENTS_REQUIRED`], the same
668 /// explicit-no-default guard `websocket.cluster_broadcast_capacity` uses.
669 ///
670 /// [`OBSERVABILITY_MAX_BATCH_EVENTS_REQUIRED`]: super::OBSERVABILITY_MAX_BATCH_EVENTS_REQUIRED
671 pub max_batch_events: Option<usize>,
672 /// How long, in milliseconds, the drain may hold a PARTIAL batch open
673 /// waiting for it to fill. **Required; no default** — but `0` is a valid,
674 /// meaningful setting: never wait, commit whatever is already queued.
675 ///
676 /// This is the only knob here that touches durability timing. Transcript
677 /// events already wait in an in-memory queue before they are committed, and
678 /// everything queued there is lost if the process dies; this value bounds
679 /// how much LONGER an event may wait, and therefore how much transcript a
680 /// kill-9 can cost. It buys commits: at `0` only events that genuinely
681 /// arrived together share a commit. The `O` keyspace is observability, never
682 /// workflow replay authority, which is why the trade is offered at all.
683 ///
684 /// Absent fails startup with [`OBSERVABILITY_MAX_BATCH_HOLD_MS_REQUIRED`].
685 ///
686 /// [`OBSERVABILITY_MAX_BATCH_HOLD_MS_REQUIRED`]: super::OBSERVABILITY_MAX_BATCH_HOLD_MS_REQUIRED
687 pub max_batch_hold_ms: Option<u64>,
688}
689
690impl ObservabilityConfig {
691 /// The default retention bounds with the REQUIRED flush policy stated.
692 ///
693 /// For an embedder that builds its `ServerConfig` in code rather than from
694 /// a file: [`Default`] deliberately leaves the flush policy unruled (so a
695 /// server built from it refuses to start), and this is how such a caller
696 /// states its ruling in one line. `max_batch_hold_ms` of `0` means the drain
697 /// never holds a partial batch open.
698 #[must_use]
699 pub fn with_flush_policy(max_batch_events: usize, max_batch_hold_ms: u64) -> Self {
700 Self {
701 max_batch_events: Some(max_batch_events),
702 max_batch_hold_ms: Some(max_batch_hold_ms),
703 ..Self::default()
704 }
705 }
706
707 /// Validate the retention bounds: both must be positive — a zero event
708 /// ceiling truncates every event to nothing and a zero stream cap retains
709 /// no transcript at all, so each is a genuine misconfiguration caught at
710 /// startup with an operator-facing message (the `WebSocketConfig` pattern).
711 pub(super) fn validate(&self) -> Result<(), ServerError> {
712 if self.max_event_bytes == 0 {
713 return config_error(OBSERVABILITY_MAX_EVENT_BYTES_REQUIRED);
714 }
715 if self.max_stream_events == 0 {
716 return config_error(OBSERVABILITY_MAX_STREAM_EVENTS_REQUIRED);
717 }
718 // The FLUSH policy is deliberately not checked here. Both retention
719 // bounds have documented defaults, so an omitted value is a resolved
720 // value and this function can decide it at parse time; the flush policy
721 // has no default at all, and a parsed `ServerConfig` is not yet a
722 // running server (embedders and `aion config` inspect one without
723 // booting). It is required where it is USED — at publisher
724 // construction on the server boot path, `state.rs`'s
725 // `required_transcript_batch_policy` — which is the same seam
726 // `websocket.cluster_broadcast_capacity` is finally required at, and
727 // which fails startup loudly, naming the missing key.
728 Ok(())
729 }
730}
731
732impl Default for ObservabilityConfig {
733 /// The retention bounds fall back to their documented defaults; the flush
734 /// policy does NOT — `None` here is "the operator has not ruled", which the
735 /// boot path turns into a refusal to start, not into a guess.
736 fn default() -> Self {
737 Self {
738 max_event_bytes: DEFAULT_OBSERVABILITY_MAX_EVENT_BYTES,
739 max_stream_events: DEFAULT_OBSERVABILITY_MAX_STREAM_EVENTS,
740 max_batch_events: None,
741 max_batch_hold_ms: None,
742 }
743 }
744}
745
746/// Operator deploy API settings from `[deploy]`.
747///
748/// The deploy surface is dark by default: with `enabled = false` (or the
749/// section absent) neither the `/deploy/*` HTTP routes nor the gRPC
750/// `DeployService` are mounted, so a workflow server that is not a deploy
751/// target exposes no deploy attack surface at all.
752#[derive(Clone, Debug, Default, Deserialize)]
753#[serde(default, deny_unknown_fields)]
754pub struct DeployConfig {
755 /// Whether the deploy surface is mounted. Defaults to false.
756 pub enabled: bool,
757 /// Upload-size ceiling for `.aion` archives, in bytes. Defaults to
758 /// [`DEFAULT_DEPLOY_MAX_ARCHIVE_BYTES`] when omitted and `enabled = true`,
759 /// so turning deploy on does not force sizing a security ceiling; the
760 /// operator overrides it for their packages.
761 ///
762 /// [`DEFAULT_DEPLOY_MAX_ARCHIVE_BYTES`]: super::DEFAULT_DEPLOY_MAX_ARCHIVE_BYTES
763 pub max_archive_bytes: Option<u64>,
764 /// Inflate ceiling for uploaded archive contents, in bytes: the total
765 /// decompressed size of all archive entries an upload may extract to
766 /// (DEFLATE bombs inflate ~1000:1 past `max_archive_bytes`). Defaults to
767 /// [`DEFAULT_DEPLOY_MAX_INFLATED_BYTES`] when omitted and `enabled = true`;
768 /// must be at least `max_archive_bytes`.
769 ///
770 /// [`DEFAULT_DEPLOY_MAX_INFLATED_BYTES`]: super::DEFAULT_DEPLOY_MAX_INFLATED_BYTES
771 pub max_inflated_bytes: Option<u64>,
772}
773
774/// Local dev-server surface settings from `[dev]`.
775///
776/// The dev surface is dark by default, gated on `enabled`: with it false (the
777/// section absent or `enabled = false`) the `/dev/*` routes are not mounted,
778/// the engine installs the bare production activity dispatcher (no mocking
779/// decorator), and nothing dev-specific is ever reachable. Setting `enabled =
780/// true` mounts the dev endpoints and installs the per-run activity-mock
781/// decorator — a development affordance, never on in production. It adds no
782/// arbitrary defaults (ADR-001): the only knob is the on/off gate.
783#[derive(Clone, Debug, Default, Deserialize)]
784#[serde(default, deny_unknown_fields)]
785pub struct DevConfig {
786 /// Whether the local dev-server surface is mounted. Defaults to false.
787 pub enabled: bool,
788}
789
790/// Durable-outbox fan-out dispatcher settings from `[outbox]`.
791///
792/// The outbox dispatcher is dark by default, gated on `enabled`: with it false
793/// (the section absent or `enabled = false`) the non-replayed background task
794/// that claims pending outbox rows and dispatches them to connected workers is
795/// never spawned, so default server behaviour is unchanged and the live
796/// workflow dispatch path is the only dispatch path. Setting `enabled = true`
797/// commissions the dispatcher; its operational knobs below — poll interval,
798/// claim batch size, retry budget, and the backoff curve — are pure tuning, so
799/// each resolves to a sane default when omitted rather than forcing the
800/// operator to hand-author tuning values just to turn the feature on. An
801/// explicitly set value (including a misconfigured `0`) is still validated.
802///
803/// Scope: this Phase-2 dispatcher dispatches claimed rows and marks each row's
804/// terminal outbox state (done / retry / failed). Routing the worker completion
805/// back into workflow history through the Recorder is Phase 3 and is not wired
806/// here; with the flag off there is no behavioural difference at all.
807#[derive(Clone, Debug, Default, Deserialize)]
808#[serde(default, deny_unknown_fields)]
809pub struct OutboxConfig {
810 /// Whether the outbox dispatcher background task is spawned. Defaults to
811 /// false, leaving the dispatcher dark and server behaviour unchanged.
812 pub enabled: bool,
813 /// Interval between successive claim sweeps, in milliseconds. Defaults to
814 /// [`DEFAULT_OUTBOX_POLL_INTERVAL_MS`] when omitted and `enabled = true`;
815 /// override to size the poll cadence for fan-out volume and latency budget.
816 ///
817 /// [`DEFAULT_OUTBOX_POLL_INTERVAL_MS`]: super::DEFAULT_OUTBOX_POLL_INTERVAL_MS
818 pub poll_interval_ms: Option<u64>,
819 /// Maximum number of pending rows claimed per sweep. Defaults to
820 /// [`DEFAULT_OUTBOX_BATCH_SIZE`] when omitted and `enabled = true`.
821 ///
822 /// [`DEFAULT_OUTBOX_BATCH_SIZE`]: super::DEFAULT_OUTBOX_BATCH_SIZE
823 pub batch_size: Option<u32>,
824 /// Dispatch attempts before a row is dead-lettered to `failed`. Defaults to
825 /// [`DEFAULT_OUTBOX_MAX_ATTEMPTS`] when omitted and `enabled = true`. Must
826 /// be at least one.
827 ///
828 /// [`DEFAULT_OUTBOX_MAX_ATTEMPTS`]: super::DEFAULT_OUTBOX_MAX_ATTEMPTS
829 pub max_attempts: Option<u32>,
830 /// Base retry backoff applied to the first retry, in milliseconds. Defaults
831 /// to [`DEFAULT_OUTBOX_BACKOFF_BASE_MS`] when omitted and `enabled = true`.
832 /// Successive retries multiply this by `backoff_multiplier` raised to the
833 /// prior-attempt count, capped at `backoff_max_ms`.
834 ///
835 /// [`DEFAULT_OUTBOX_BACKOFF_BASE_MS`]: super::DEFAULT_OUTBOX_BACKOFF_BASE_MS
836 pub backoff_base_ms: Option<u64>,
837 /// Geometric growth factor applied to the backoff per prior attempt.
838 /// Defaults to [`DEFAULT_OUTBOX_BACKOFF_MULTIPLIER`] when omitted and
839 /// `enabled = true`. Must be at least one so backoff never shrinks.
840 ///
841 /// [`DEFAULT_OUTBOX_BACKOFF_MULTIPLIER`]: super::DEFAULT_OUTBOX_BACKOFF_MULTIPLIER
842 pub backoff_multiplier: Option<u32>,
843 /// Upper bound on a single retry's backoff, in milliseconds. Defaults to
844 /// [`DEFAULT_OUTBOX_BACKOFF_MAX_MS`] when omitted and `enabled = true`. Must
845 /// be at least `backoff_base_ms`.
846 ///
847 /// [`DEFAULT_OUTBOX_BACKOFF_MAX_MS`]: super::DEFAULT_OUTBOX_BACKOFF_MAX_MS
848 pub backoff_max_ms: Option<u64>,
849 /// Interval between live stale-claim reconciliation sweeps, in milliseconds. When both
850 /// reconciliation knobs are absent the live sweep remains dark; setting either knob opts into
851 /// reconciliation and requires both values to be positive.
852 pub reconcile_interval_ms: Option<u64>,
853 /// Age after which a durable `claimed` outbox row is considered stranded, in milliseconds. The
854 /// reconciler re-arms only rows with `claimed_at` older than this threshold, preserving their
855 /// attempt count.
856 pub reconcile_stale_after_ms: Option<u64>,
857 /// Wire transport the dispatcher uses to place a claimed row with a worker.
858 /// Defaults to [`OutboxTransport::Liminal`] whenever the `liminal-transport`
859 /// Cargo feature is compiled (the default ablative-stack build), so an
860 /// outbox-enabled server uses the liminal cross-node transport out of the box;
861 /// a slim build without that feature defaults to [`OutboxTransport::Grpc`].
862 /// Selecting `liminal` in a build without the feature is a configuration error
863 /// surfaced at spawn. The transport only matters when `outbox.enabled = true`.
864 pub transport: OutboxTransport,
865 /// Address (`host:port`) the aion-server LISTENS on for inbound liminal
866 /// worker connections, used only when `transport = liminal`. REQUIRED in that
867 /// mode; ignored otherwise.
868 ///
869 /// The aion-server HOSTS the liminal listener: a remote `LiminalActivityWorker`
870 /// connects IN to this address and self-registers in-band, so the server's
871 /// [`ConnectionSupervisor`](liminal_server::server::connection::ConnectionSupervisor)
872 /// owns the worker's connection and can push a dispatch out on it
873 /// (`push_to_connection`). This replaces the superseded 13-0 spike's
874 /// client-connect address: the dispatcher no longer *connects out* to publish
875 /// to a channel — it pushes to a connected worker the server already owns.
876 ///
877 /// The dispatch *channel* is not configured here: it is derived per-row from
878 /// each row's durable `(namespace, task_queue)` via `dispatch_channel_name`
879 /// (NSTQ-5), so one listener fans different worker pools out by selection.
880 pub liminal_listen_address: Option<String>,
881}
882
883/// Wire transport selected for outbox dispatch.
884///
885/// `liminal` (the default whenever the `liminal-transport` feature is compiled —
886/// which it is in the default ablative-stack build) routes the dispatch over the
887/// liminal cross-node bus. `grpc` keeps the connected-worker registry path. A
888/// slim build compiled WITHOUT `liminal-transport` falls back to `grpc` as the
889/// default so the default is always constructible under the active feature set.
890#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Deserialize)]
891#[serde(rename_all = "lowercase")]
892pub enum OutboxTransport {
893 /// Dispatch over the in-process connected-worker gRPC registry. The default
894 /// in a slim build compiled WITHOUT `liminal-transport`, which cannot
895 /// construct the liminal path.
896 // The default variant is feature-selected: gRPC when the liminal transport is
897 // absent (it is the only constructible path), liminal otherwise.
898 #[cfg_attr(not(feature = "liminal-transport"), default)]
899 Grpc,
900 /// Dispatch over the liminal cross-node bus (requires `liminal-transport`).
901 /// The out-of-box default whenever `liminal-transport` is compiled (the
902 /// default ablative-stack feature set), so an outbox-enabled server uses the
903 /// ablative messaging transport without extra configuration.
904 #[cfg_attr(feature = "liminal-transport", default)]
905 Liminal,
906}
907
908/// Server-side authoring settings from `[authoring]`.
909///
910/// The AWL studio is on by default, rooted at `<AION_HOME>/authoring`, so a
911/// stock `aion server` provides its document, layout, check, deploy, revision,
912/// run, and scaffold surfaces without preliminary configuration. Operators can
913/// override it explicitly.
914///
915/// Only the separate Gleam authoring loop remains dark by default: without
916/// `gleam_path`, `/authoring/*` is not mounted and nothing invokes `gleam`
917/// (CN7). Setting `gleam_path` commissions that loop and makes `project_root`
918/// required.
919#[derive(Clone, Debug, Default, Deserialize)]
920#[serde(default, deny_unknown_fields)]
921pub struct AuthoringConfig {
922 /// Path to the external `gleam` binary the toolchain spawns. `None`
923 /// (the default) leaves only the Gleam authoring loop dark; setting it gates
924 /// the `/authoring/*` endpoints on. There is no default binary — the
925 /// operator names it explicitly.
926 pub gleam_path: Option<PathBuf>,
927 /// Built Gleam workflow project root submitted source is written into and
928 /// packaged from. REQUIRED when `gleam_path` is set; no default (house
929 /// rule) — a Gleam project needs `gleam.toml`, the `aion_flow` dependency,
930 /// `workflow.toml`, and `schemas/`, so the operator provisions and names
931 /// the project root.
932 pub project_root: Option<PathBuf>,
933 /// Root directory exposed by the full AWL studio surface. The merged server
934 /// loader defaults this to `<AION_HOME>/authoring` after config and
935 /// environment overlays. `authoring.workspace_dir` or
936 /// `AION_AUTHORING_WORKSPACE_DIR` therefore overrides it explicitly.
937 pub workspace_dir: Option<PathBuf>,
938}
939
940impl Default for ServerSection {
941 fn default() -> Self {
942 Self {
943 listen_address: DEFAULT_HTTP_ADDRESS,
944 grpc_address: DEFAULT_GRPC_ADDRESS,
945 cors_allowed_origins: Vec::new(),
946 }
947 }
948}
949
950impl Default for StoreConfig {
951 fn default() -> Self {
952 Self {
953 // The ablative stack is the out-of-box durable default: an empty
954 // config selects the haematite backend. The merged loader fills
955 // `<AION_HOME>/data`; `memory` remains an explicit dev choice.
956 backend: StoreBackend::Haematite,
957 retired_input: None,
958 owned_shards: Vec::new(),
959 data_dir: None,
960 // NOT a default: `None` is "the operator has not ruled", which the
961 // haematite boot path turns into a refusal to start, not a guess.
962 node_cache_budget: None,
963 lock_acquisition_patience_ms: None,
964 lock_acquisition_retry_cadence_ms: None,
965 // 64, NOT 4096 (#187): raising the default to 4096 bricked every
966 // fresh server — engine boot's scan_prefix materializes every
967 // shard, then each haematite 0.4.0 commit fans out one thread +
968 // fsync PER MATERIALIZED SHARD (~8k fsyncs/commit), blowing the
969 // 5s shard-actor timeout on deploy/start/timers/outbox. Re-raise
970 // only after haematite makes commit O(dirty shards) and the
971 // scaffold e2es pass at the new default (see #187 fix plan).
972 shard_count: 64,
973 cluster: None,
974 }
975 }
976}
977
978impl Default for RuntimeSection {
979 fn default() -> Self {
980 Self {
981 scheduler_threads: 1,
982 // Absent on purpose, for a different reason than the deadline
983 // below: this one is deferred to beamr's own default rather than
984 // demanded from the operator. The server must not name a
985 // compilation threshold it did not choose.
986 jit_threshold: None,
987 // Deliberately absent: validation fails loudly until the operator
988 // sets the workflow query reply deadline for the deployment.
989 query_timeout_ms: None,
990 }
991 }
992}
993
994impl Default for DrainConfig {
995 fn default() -> Self {
996 Self {
997 timeout_seconds: 30,
998 }
999 }
1000}
1001
1002impl Default for AuthConfig {
1003 fn default() -> Self {
1004 Self {
1005 enabled: false,
1006 jwks_url: None,
1007 jwks_refresh_seconds: 300,
1008 }
1009 }
1010}
1011
1012impl Default for MetricsConfig {
1013 fn default() -> Self {
1014 Self { enabled: true }
1015 }
1016}
1017
1018impl Default for NamespacesConfig {
1019 fn default() -> Self {
1020 Self {
1021 default: "default".to_owned(),
1022 auto_create: AutoCreate::default(),
1023 max_in_flight_activities: DEFAULT_MAX_IN_FLIGHT_ACTIVITIES,
1024 }
1025 }
1026}
1027
1028impl Default for ListenConfig {
1029 fn default() -> Self {
1030 Self {
1031 grpc: DEFAULT_GRPC_ADDRESS,
1032 http: DEFAULT_HTTP_ADDRESS,
1033 }
1034 }
1035}
1036
1037impl Default for OpsConsoleConfig {
1038 fn default() -> Self {
1039 Self {
1040 source: OpsConsoleAssetSource::Embedded,
1041 }
1042 }
1043}
1044
1045impl Default for NamespaceConfig {
1046 fn default() -> Self {
1047 Self {
1048 mode: NamespaceMode::SharedEngine,
1049 }
1050 }
1051}
1052
1053impl Default for WorkerConfig {
1054 fn default() -> Self {
1055 Self {
1056 heartbeat_window: Duration::from_secs(30),
1057 queue_service: crate::worker::queue_service::QueueServiceConfig::default(),
1058 }
1059 }
1060}
1061
1062impl Default for WebSocketConfig {
1063 fn default() -> Self {
1064 Self {
1065 outbound_buffer_bound: 32,
1066 // Deliberately absent: validation fails loudly until the operator
1067 // sizes the engine-global broadcast channel for the deployment.
1068 event_broadcast_capacity: None,
1069 // Deliberately absent for the same reason: the cluster channel has
1070 // no defined lag buffer until sized.
1071 cluster_broadcast_capacity: None,
1072 }
1073 }
1074}
1075
1076mod duration_millis {
1077 use std::time::Duration;
1078
1079 use serde::{Deserialize, Deserializer};
1080
1081 pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
1082 where
1083 D: Deserializer<'de>,
1084 {
1085 let millis = u64::deserialize(deserializer)?;
1086 Ok(Duration::from_millis(millis))
1087 }
1088}