Skip to main content

Module state

Module state 

Source
Expand description

AppState: the shared handle every request works through, plus the AgentFactory seam that turns a submitted definition into a live agent.

The state owns exactly one thing that matters for durability: an Arc<dyn EventStore>. Everything a request needs, it builds fresh from that handle. A Runtime is cheap (a store handle plus two function pointers), so the server constructs one per request rather than sharing mutable run state; there is no per-run state living in the process that a restart would lose. That is the whole kill-safety story restated: the process holds handles, the store holds truth.

§Why agent building is a seam, not baked in

Turning a definition into an Agent means parsing the agent-definition format and spawning its MCP servers. That logic already exists in the CLI (salvor-cli owns the TOML schema), and putting a copy here would give the definition format two homes. Instead the server takes an AgentFactory: a caller-supplied function from a submitted AgentDefinition to a BuiltAgent. The salvor serve command passes the CLI’s own builder, so there is one definition parser in the workspace; tests pass a factory that builds an agent with an in-process tool and a mock model, which is how the control plane is exercised over real HTTP with nothing on the network.

Structs§

AgentDefinition
A submitted agent definition: the raw bytes plus the format they are in.
AppState
The shared, cheaply cloned handle every route works through.
BuiltAgent
A live agent plus the MCP server sessions its tools hold.
ClientRunLease
The per-run lease state for a client-driven run.
RegisteredAgent
One registered agent definition.

Enums§

DefFormat
The format a submitted agent definition is written in.
LeaseRelease
What asking to drop a client-driven run’s lease came to (see release_client_run).

Constants§

DEFAULT_WAKE_INTERVAL
How often the wake sweeper looks for due timers, unless AppState::with_wake_interval says otherwise.

Type Aliases§

AgentFactory
Builds a live agent from a submitted definition.
BuildFuture
The future an AgentFactory returns.