pub struct ServerConfig {Show 23 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 revision_gate_evaluator: Option<Arc<dyn RevisionGateEvaluator>>,
pub default_environment_tag: Option<EnvironmentTag>,
pub capsule_policy_files: Vec<PathBuf>,
pub capsule_budget_ceiling: Option<ResourceBudget>,
pub broker_handle_ttl: Duration,
pub oauth_provider: Option<Arc<dyn OAuthProvider>>,
pub broker_refresh_window: Duration,
pub broker_sweep_interval: Option<Duration>,
pub artifact_sweep_interval: Option<Duration>,
}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.
revision_gate_evaluator: Option<Arc<dyn RevisionGateEvaluator>>The revision gate evaluator (R0.12 wave 4): the release-gate
composition promotions into a gated environment drive. None
(the default) fails closed — a promotion into an environment
declaring a gate answers 409, because a gate that cannot run
is a gate that did not pass. See
ServerConfig::with_revision_gate_evaluator.
default_environment_tag: Option<EnvironmentTag>The deployment’s default environment tag (R0.11 Extension Plane,
wave 2): the promotion target a run resolves against when its
registry binding declares no environment of its own. None (the
default) resolves the untagged surface — the pre-R0.11 behavior.
This is declared configuration: a run’s environment is its
binding’s tag or this default, never an invented per-run guess.
See ServerConfig::with_default_environment_tag.
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.
broker_handle_ttl: DurationThe credential handle TTL (R0.11 Extension Plane, wave 3): how
long one issued handle stays valid, default 300 seconds — “handles
live for minutes”: short enough that expiry is routine, long
enough that a run’s burst of provider calls reuses one issuance.
Revocation never waits on this — resolution reads the connection’s
live state, so a revoked connection fails at the next call
regardless. See ServerConfig::with_broker_handle_ttl.
oauth_provider: Option<Arc<dyn OAuthProvider>>The OAuth provider (R0.11 Extension Plane, wave 4): the
deployment’s token-endpoint seam. Plugging one in enables the
whole lifecycle — authorization-code exchange on
POST /connections and POST /connections/{id}/consent,
refresh-at-resolution for due tokens, and the sweeper. None
(the default) means no lifecycle: the exchange endpoints answer
409 (the evaluator-absent precedent) and OAuth connections
serve their sealed material unchanged, exactly as static kinds
do. See ServerConfig::with_oauth_provider.
broker_refresh_window: DurationThe OAuth refresh window (R0.11 wave 4), default 300 seconds: a
token expiring within this horizon — scaled per connection by a
deterministic jitter in [0.5, 1.0), so a fleet registered
together does not stampede the provider together — is rotated
before it is served. See
ServerConfig::with_broker_refresh_window.
broker_sweep_interval: Option<Duration>The broker sweep interval (R0.11 wave 4), default None (off):
how often the background sweeper runs the refresh lifecycle over
every connection. Off is safe — resolution runs the same
lifecycle, so no sweeper degrades to refresh-at-use, never to
expiry; the sweeper exists so idle connections are fresh before
the next call asks. See ServerConfig::with_broker_sweep_interval.
artifact_sweep_interval: Option<Duration>The artifact retention sweep interval (R0.12 wave 2), default
None (off): how often the background sweeper evaluates every
artifact address in the deployment against its declared
retention. Off is safe — POST /artifacts/sweep and the release
act’s prune tail run the same evaluation, so no sweeper degrades
to operator-triggered passes, never to unprotected pruning. See
ServerConfig::with_artifact_sweep_interval.
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_revision_gate_evaluator(
self,
evaluator: Arc<dyn RevisionGateEvaluator>,
) -> Self
pub fn with_revision_gate_evaluator( self, evaluator: Arc<dyn RevisionGateEvaluator>, ) -> Self
Builder-style: register the revision gate evaluator (R0.12 wave
4) — the release-gate composition promotions into gated
environments drive. Without one a gated promotion answers 409:
the gate fails closed, so an unavailable evaluator is a refusal,
never a skip.
Sourcepub fn with_default_environment_tag(self, tag: impl Into<String>) -> Self
pub fn with_default_environment_tag(self, tag: impl Into<String>) -> Self
Builder-style: declare the deployment’s default environment tag
(R0.11 wave 2) — the promotion target a registry-bound run
resolves against when its binding names no environment. None
(the default) resolves the untagged surface. The tag is validated
at construction (the same rules the wire applies), so no
deployment can declare a default its own pointers could never
carry.
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.
Sourcepub fn with_broker_handle_ttl(self, ttl: Duration) -> Self
pub fn with_broker_handle_ttl(self, ttl: Duration) -> Self
Builder-style: set the credential handle TTL (R0.11 wave 3). The TTL bounds how long one issuance is reused, not how long a revocation takes to bite — resolution reads live state, so a revoked connection fails at the very next call.
Sourcepub fn with_oauth_provider(self, provider: Arc<dyn OAuthProvider>) -> Self
pub fn with_oauth_provider(self, provider: Arc<dyn OAuthProvider>) -> Self
Builder-style: plug the OAuth provider (R0.11 wave 4) — the
deployment’s token-endpoint seam. One plug enables the whole
lifecycle: authorization-code exchange on the connection routes,
refresh-at-resolution, and the sweeper. Without it the exchange
endpoints answer 409 and OAuth connections serve static
material.
Sourcepub fn with_broker_refresh_window(self, window: Duration) -> Self
pub fn with_broker_refresh_window(self, window: Duration) -> Self
Builder-style: the OAuth refresh window (R0.11 wave 4). Tokens expiring within this horizon (deterministically jittered per connection) rotate before they serve.
Sourcepub fn with_broker_sweep_interval(self, interval: Duration) -> Self
pub fn with_broker_sweep_interval(self, interval: Duration) -> Self
Builder-style: run the broker sweeper on this interval (R0.11 wave 4). Off by default; meaningful only with an OAuth provider plugged in (without one there is nothing to sweep).
Sourcepub fn with_artifact_sweep_interval(self, interval: Duration) -> Self
pub fn with_artifact_sweep_interval(self, interval: Duration) -> Self
Builder-style: run the artifact retention sweeper on this interval
(R0.12 wave 2). Off by default; POST /artifacts/sweep and the
release act’s prune tail run the same evaluation, so a stopped
sweeper degrades to operator-triggered passes, never to
unprotected pruning.