pub struct ServerConfig {Show 16 fields
pub bind_addr: SocketAddr,
pub store_path: PathBuf,
pub database_url: Option<String>,
pub max_concurrent_runs_per_thread: usize,
pub api_key: Option<String>,
pub api_keys: Vec<(String, String)>,
pub event_log_capacity: usize,
pub outbox_relay_interval: Duration,
pub shutdown_grace: Duration,
pub task_pool_limits: HashMap<String, usize>,
pub task_quota: TaskQuota,
pub tenant_task_quotas: HashMap<String, TaskQuota>,
pub promotion_envelope: PromotionEnvelope,
pub candidate_evaluator: Option<Arc<dyn CandidateEvaluator>>,
pub capsule_policy_files: Vec<PathBuf>,
pub capsule_budget_ceiling: Option<ResourceBudget>,
}Expand description
Server configuration.
Checkpointing is rooted at store_path via
rusty_agent_runtime::checkpoint::JsonFileCheckpointer. Auth maps static API
keys (checked against the X-Api-Key header) to tenants: the legacy
single ServerConfig::with_api_key maps its key to the default
tenant, while ServerConfig::with_tenant_key adds (tenant, key)
pairs for multi-tenant deployments. With no keys configured the server
runs in open (dev) mode — no header required, everything lives in the
default tenant. Every tenant-scoped resource (threads + checkpoints,
assistants, crons, KV namespaces) is isolated per tenant; cross-tenant
access answers 404. With the postgres feature,
ServerConfig::with_postgres switches both the run checkpointer
(core’s PostgresCheckpointer) and the server store (assistants /
crons / threads / KV) to Postgres.
Fields§
§bind_addr: SocketAddrAddress to bind when using serve (default 0.0.0.0:8080).
store_path: PathBufRoot directory for checkpoint files
({store_path}/{thread_id}/{checkpoint_id}.json). Also roots the
JSON-file assistants/crons/threads/KV persistence. Unused for
checkpointing when database_url is set (still used as the
store_path reported by GET /info).
database_url: Option<String>Postgres connection URL. When set (requires the postgres feature —
see ServerConfig::with_postgres), checkpoints live in core’s
rusty_checkpoints table and the platform surface in the
server_assistants / server_crons / server_threads /
server_kv / server_journals tables, all auto-migrated on
connect. Connections are established lazily on first use.
max_concurrent_runs_per_thread: usizePer-thread in-flight run cap used as the enqueue queue depth (default 1). There is always at most one active run per thread.
api_key: Option<String>Static API key required via the X-Api-Key header, mapped to the
default tenant (legacy single-key mode). None (the default) with
an empty ServerConfig::api_keys is dev mode: no authentication.
api_keys: Vec<(String, String)>Additional (api_key, tenant) pairs for multi-tenant deployments
(see ServerConfig::with_tenant_key). Each key maps to exactly one
tenant; every tenant’s threads, assistants, crons, and KV namespaces
are isolated from all others (cross-tenant access answers 404).
event_log_capacity: usizePer-run SSE event-log capacity (frames retained for replay, default 1000).
outbox_relay_interval: DurationHow often the transactional-outbox relay publishes pending rows into the task queue (R0.6 wave 2b, default 250 ms). The relay is crash-safe at any interval — pending rows survive restarts and publishing dedupes on the task’s idempotency key — so this only tunes outbox-to-queue latency, not correctness.
shutdown_grace: DurationBound on graceful shutdown (R0.6 wave 2c, default
DEFAULT_SHUTDOWN_GRACE): after the shutdown signal, in-flight
requests and runs get this long to finish before the server stops
regardless. Runs stopped by the drain are resumable from their last
checkpoint, so a short grace costs a resume, never work.
task_pool_limits: HashMap<String, usize>Per-pool in-flight caps for the durable task queue (R0.6 wave 3):
pool name → maximum live leases. The claim path counts a pool’s
unexpired leases and stops handing out new ones at the cap, so
pools coexist without starving each other (a saturated GPU pool
never blocks IO-pool claims). Pools without an entry are
uncapped — the pre-wave-3 behavior. See
ServerConfig::with_pool_limit.
task_quota: TaskQuotaThe default tenant quota (R0.6 wave 3), applied to every tenant
without an entry in ServerConfig::tenant_task_quotas. All
gauges uncapped by default. See TaskQuota.
tenant_task_quotas: HashMap<String, TaskQuota>Per-tenant quota overrides (R0.6 wave 3), replacing
ServerConfig::task_quota wholesale for the named tenant (an
override is the tenant’s quota, not a patch on the default).
See ServerConfig::with_tenant_quota.
promotion_envelope: PromotionEnvelopeThe promotion envelope (R0.8 Rusty Learn, wave 3): the declared,
per-deployment standing approval the promotion gate evaluates
every promotion against. Defaults to
PromotionEnvelope::r08_default — memory-set candidates at
run/agent scope auto-promote on cleared evidence; everything else
requires an approval token. See
ServerConfig::with_promotion_envelope.
candidate_evaluator: Option<Arc<dyn CandidateEvaluator>>The candidate evaluator (R0.8 wave 3): the evaluation
composition POST /learn/candidates/{id}/evaluate drives. None
(the default) answers 409 — a deployment without an evaluator
can hold and inspect candidates, but promotion is gated on
evidence, and evidence requires an evaluator. See
ServerConfig::with_candidate_evaluator.
capsule_policy_files: Vec<PathBuf>Operator-authored Cedar policy files (R0.9 Rusty Capsules, wave
2), loaded for the default tenant at startup — the deployment’s
standing authorization, the way static API keys are its standing
authentication. Requires the capsules feature; each file is
registered under its content-derived version
(cedar-{sha256[..12]}), never activated — activation is an
explicit operator move through POST /capsule_policies/active. See
ServerConfig::with_capsule_policy_file.
capsule_budget_ceiling: Option<ResourceBudget>The tenant-wide budget ceiling (R0.9 wave 2): the outermost bound
every capsule budget composes under. Fuel, memory, wall time, and
output bytes clamp down to it; a run declaring more max_tokens
or max_cost_usd than the ceiling (or than the run’s own budget)
is refused 422 — token and cost bounds cannot be retrofitted
mid-run the way fuel can, so admission refuses the overspend. See
ServerConfig::with_capsule_budget_ceiling.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn new(bind_addr: SocketAddr, store_path: impl Into<PathBuf>) -> Self
pub fn new(bind_addr: SocketAddr, store_path: impl Into<PathBuf>) -> Self
A config with the given bind address and checkpoint store root; everything else at its default.
Sourcepub fn with_api_key(self, key: impl Into<String>) -> Self
pub fn with_api_key(self, key: impl Into<String>) -> Self
Builder-style: require an API key on every request. The key maps to
the default tenant (legacy single-tenant mode).
Sourcepub fn with_tenant_key(
self,
tenant: impl Into<String>,
key: impl Into<String>,
) -> Self
pub fn with_tenant_key( self, tenant: impl Into<String>, key: impl Into<String>, ) -> Self
Builder-style: map an API key to a tenant (multi-tenant mode). Every
request presenting key via X-Api-Key runs as tenant, fully
isolated from all other tenants. Tenant ids must match
[A-Za-z0-9._-] (1–64 chars) and must not be a reserved layout name
(assistants, crons, store, threads, latest) — they become a
path segment in the JSON-file layout and a {tenant}/ id prefix
everywhere else.
§Panics
Panics on an empty key or an invalid tenant id (configuration is a programmer error, caught at startup).
Sourcepub fn auth_enabled(&self) -> bool
pub fn auth_enabled(&self) -> bool
true when at least one API key is configured (legacy api_key or
any tenant key), i.e. requests must authenticate.
Sourcepub fn tenant_for_key(&self, key: &str) -> Option<&str>
pub fn tenant_for_key(&self, key: &str) -> Option<&str>
The tenant a presented API key maps to, or None for unknown keys.
Tenant keys are checked first (last registration wins on duplicate
keys); the legacy api_key maps to the default tenant.
Sourcepub fn with_max_concurrent_runs_per_thread(self, cap: usize) -> Self
pub fn with_max_concurrent_runs_per_thread(self, cap: usize) -> Self
Builder-style: set the per-thread enqueue queue depth cap. Values
below 1 are clamped to 1 (a zero-deep queue would reject every
enqueue run).
Sourcepub fn with_event_log_capacity(self, capacity: usize) -> Self
pub fn with_event_log_capacity(self, capacity: usize) -> Self
Builder-style: set the per-run SSE event-log capacity. Values below 16 are clamped to 16 (replay needs room for at least the metadata/updates/end frames of a minimal run).
Sourcepub fn with_outbox_relay_interval(self, interval: Duration) -> Self
pub fn with_outbox_relay_interval(self, interval: Duration) -> Self
Builder-style: set the transactional-outbox relay’s poll interval (R0.6 wave 2b). Tests can set a long interval to drive publishing deterministically; correctness never depends on the interval.
Sourcepub fn with_shutdown_grace(self, grace: Duration) -> Self
pub fn with_shutdown_grace(self, grace: Duration) -> Self
Builder-style: set the graceful-shutdown bound (R0.6 wave 2c; see
DEFAULT_SHUTDOWN_GRACE for the default’s rationale). Past this
window the server stops even if requests or runs are still in flight
— durability (checkpoint resume, lease expiry) is the backstop.
Sourcepub fn with_pool_limit(
self,
pool: impl Into<String>,
max_in_flight: usize,
) -> Self
pub fn with_pool_limit( self, pool: impl Into<String>, max_in_flight: usize, ) -> Self
Builder-style: cap the named pool’s live leases (R0.6 wave 3). The
claim path counts a pool’s unexpired leases and stops handing out
new ones at max_in_flight, so a saturated pool (GPU-bound work)
never starves the others (IO-bound work). A cap of 0 pauses the
pool: nothing is leased from it until the cap is raised. Pools
without an entry stay uncapped.
§Panics
Panics on an invalid pool name (configuration is a programmer error,
caught at startup); names must match [A-Za-z0-9._-] (1–128 chars),
the same rule the enqueue and claim paths validate.
Sourcepub fn with_task_quota(self, quota: TaskQuota) -> Self
pub fn with_task_quota(self, quota: TaskQuota) -> Self
Builder-style: set the default tenant quota for the durable task
queue (R0.6 wave 3), applied to every tenant without a
ServerConfig::with_tenant_quota override. Over quota, task
submissions answer 429 quota_exceeded. The default is uncapped on
every gauge. See TaskQuota for the gauge definitions.
Sourcepub fn with_tenant_quota(
self,
tenant: impl Into<String>,
quota: TaskQuota,
) -> Self
pub fn with_tenant_quota( self, tenant: impl Into<String>, quota: TaskQuota, ) -> Self
Builder-style: override the task quota for one tenant (R0.6 wave 3).
The override replaces ServerConfig::task_quota wholesale for
that tenant — an uncapped gauge in the override is unlimited even if
the default caps it.
§Panics
Panics on an invalid tenant id (same rule as
ServerConfig::with_tenant_key).
Sourcepub fn with_promotion_envelope(self, envelope: PromotionEnvelope) -> Self
pub fn with_promotion_envelope(self, envelope: PromotionEnvelope) -> Self
Builder-style: set the promotion envelope (R0.8 Rusty Learn, wave
3) — the declared, per-deployment standing approval the promotion
gate evaluates every promotion against. Replaces
PromotionEnvelope::r08_default.
§Panics
Panics when the envelope fails PromotionEnvelope::validate
(a canary fraction outside (0, 1], a negative improvement bar —
configuration is a programmer error, caught at startup).
Sourcepub fn with_candidate_evaluator(
self,
evaluator: Arc<dyn CandidateEvaluator>,
) -> Self
pub fn with_candidate_evaluator( self, evaluator: Arc<dyn CandidateEvaluator>, ) -> Self
Builder-style: register the candidate evaluator (R0.8 wave 3) —
the evaluation composition POST /learn/candidates/{id}/evaluate
drives. Without one the route answers 409: promotion is gated
on evidence, and evidence requires an evaluator.
Sourcepub fn with_capsule_policy_file(self, path: impl Into<PathBuf>) -> Self
pub fn with_capsule_policy_file(self, path: impl Into<PathBuf>) -> Self
Builder-style: add one operator-authored Cedar policy file (R0.9
Rusty Capsules, wave 2), loaded for the default tenant at
startup. Files are registered, never activated — moving a
tenant’s active pointer is an explicit operator move through
POST /capsule_policies/active, so a restart can never silently
change what serves. Without the capsules feature the files are
ignored (the plane’s routes answer 503 either way).
Sourcepub fn with_capsule_budget_ceiling(self, ceiling: ResourceBudget) -> Self
pub fn with_capsule_budget_ceiling(self, ceiling: ResourceBudget) -> Self
Builder-style: set the tenant-wide capsule budget ceiling (R0.9
wave 2) — the outermost bound every capsule budget composes
under. None (the default) leaves budgets bounded only by the
run’s own declaration and each capsule’s manifest.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more