Skip to main content

Module runtime

Module runtime 

Source
Expand description

The process-scoped substrate every workspace borrows.

ADR-0018’s split. Workspace used to conflate two lifetimes: half its configuration was process infrastructure — a privately built mentra runtime, provider and credential resolution, the history store policy, the host’s interceptors — and half was repository discovery. A host opening N workspaces paid the process costs N times. This module is the noun the first half was missing.

  • Runtime owns mentra’s runtime, the provider/credential/base-URL and model policy, the history store policy, and the host’s interceptors. Build one with Runtime::builder, share it with WorkspaceBuilder::with_runtime.
  • Workspace keeps what the repository says — context, skills, templates, hooks, .mcp.json — and borrows the runtime through an Arc. MCP connections stay workspace-owned: minted from repository config, dead with the workspace.
  • Workspace::open(path) is unchanged sugar that builds a private default runtime bound to that path. The one-repository host never sees this module; only the N-repository host reaches for it.
use std::sync::Arc;
use basis::{Runtime, Workspace};

let runtime = Arc::new(Runtime::builder().build()?);
let one = Workspace::builder("/repo/one").with_runtime(Arc::clone(&runtime)).open().await?;
let two = Workspace::builder("/repo/two").with_runtime(runtime).open().await?;

Structs§

Runtime
One process’s substrate: mentra’s runtime plus the resolution policy and host guards that were fixed when it was built.
RuntimeBuilder
How a runtime is built.