Skip to main content

Module workspace

Module workspace 

Source
Expand description

A workspace opened once, minting runs cheaply.

Everything a run needs but does not change divides in two, and basis once kept both halves in one RunConfig and re-resolved the lot for every prompt. ADR-0010 named the cost: a twenty-agent fan-out read AGENTS.md twenty times, resolved the model twenty times, and opened twenty copies of every MCP server the workspace configures.

So:

  • WorkspaceBuilder::open settles what belongs to the workspace — context documents, the resolved model, skills, templates, hooks, MCP connections, the command posture, the approval gate. It is async and it does real I/O, once.
  • Workspace::prepare mints one run from a RunSpec. It is not async, which is the honest signal that nothing is discovered, resolved, or connected here: a session is spawned on the runtime that already exists, and that is all.

What belongs to the process rather than to either — the provider and credential, the history store, the host’s interceptors — is a third thing, Runtime (ADR-0018). A workspace borrows one through an Arc, and a host opening many workspaces builds it once.

use basis::{CollectingSink, Workspace};

let workspace = Workspace::open("/repo").await?;

// Two runs, one discovery, driven together.
let mut first = workspace.prepare("what does this repo do?")?;
let mut second = workspace.prepare("what is not tested?")?;
let (a, b) = tokio::join!(
    first.execute(CollectingSink::default()),
    second.execute(CollectingSink::default()),
);

The free functions in crate::runrun, prepare, resume and the rest — are thin wrappers that open a workspace, mint one run from it, and drop the workspace when the run ends. There is one resolution path, and this is it.

Structs§

RunProfile
Immutable overrides for one run minted from a Workspace.
RunSpec
One run’s worth of intent, to be minted against a Workspace.
ToolRoster
Which tools the model is offered, for WorkspaceBuilder::with_tool_roster.
Workspace
One workspace, resolved: the runtime it borrows, the model, and everything discovered on disk, ready to mint runs from.
WorkspaceBuilder
How a workspace is opened.