pub struct WorkspaceSet { /* private fields */ }Expand description
An install’s many named workspaces: linked groups (multi-repo graphs) and
standalone singletons (one-repo graphs), keyed by name in stable order (ADR-0008
multi-workspace). The outer layer over Workspace: it selects which
workspace a command operates on, then hands back that Workspace to resolve
projects within it. Built from normalised config (WorkspaceSet::from_resolved)
so the serve/links selection logic is shared.
Implementations§
Source§impl WorkspaceSet
impl WorkspaceSet
Sourcepub fn from_workspaces<I>(entries: I) -> Self
pub fn from_workspaces<I>(entries: I) -> Self
Assemble a set from pre-built named workspaces — the shared core of
WorkspaceSet::from_resolved and the test constructor. With exactly one
entry, that workspace is the default (a bare selection resolves to it).
Sourcepub fn from_single(
name: impl Into<String>,
workspace: Arc<Workspace>,
linked: bool,
) -> Self
pub fn from_single( name: impl Into<String>, workspace: Arc<Workspace>, linked: bool, ) -> Self
Wrap an already-built Workspace (shared via Arc) as a one-entry set
under name, with linked recording whether that workspace is a
cross-linked multi-repo group. Used where a single Workspace is served as
the whole set — e.g. roteiro serve merges the read-only graph API over the
one workspace it already holds for its model tools and MCP router, so the
API’s flat routes resolve to it as the sole (default) workspace. The store
handles are shared, never re-opened.
Sourcepub fn from_resolved(
resolved: Vec<ResolvedWorkspace>,
) -> Result<Self, WorkspaceError>
pub fn from_resolved( resolved: Vec<ResolvedWorkspace>, ) -> Result<Self, WorkspaceError>
Build a set from normalised config groups: each group’s roots/repos are
discovered into member repo paths and opened as Workspaces. A linked
group becomes one multi-repo graph. A standalone (linked = false) group
becomes one single-repo graph per member repo — the invariant that a
standalone workspace is exactly one repo is upheld here, by splitting, so a
hand-built group can never collapse several repos into one unlinked multi-repo
graph (the config normaliser already emits standalone as per-repo singletons,
so in practice each such group has exactly one repo and the split is a no-op).
On a split, the extra members take a -2/-3 suffix off the group name. A
group that resolves to no repos is skipped, so a stale root never aborts
the whole set.
§Errors
WorkspaceError::Discover if a group’s root cannot be read, or
WorkspaceError::Git if an explicit repo path is not inside a git repo.
Sourcepub fn workspace_handles(&self) -> Vec<(String, Arc<Workspace>)>
pub fn workspace_handles(&self) -> Vec<(String, Arc<Workspace>)>
Each configured workspace as a (name, shared handle) pair, in stable name
order. The Arc<Workspace> is the very handle the set holds, so a caller can
build a per-workspace view — e.g. a tool registry confined to one
workspace’s projects — over the same lazily-opened stores, never re-opening
them. Used by serve to scope the workspace-level Ask to the selected
workspace (ADR-0008), mirroring how WorkspaceSet::select scopes the
read-only /v1/graph/workspaces/{ws}/… routes.
Sourcepub fn linked(&self, name: &str) -> Option<bool>
pub fn linked(&self, name: &str) -> Option<bool>
Whether workspace name is linked (Some(true)), standalone
(Some(false)), or unknown (None).
Sourcepub fn select(&self, name: Option<&str>) -> Result<&Workspace, WorkspaceError>
pub fn select(&self, name: Option<&str>) -> Result<&Workspace, WorkspaceError>
Select a workspace by name, or the default when name is None.
§Errors
WorkspaceError::UnknownWorkspace if named but absent,
WorkspaceError::AmbiguousWorkspace if omitted with several configured,
or WorkspaceError::Empty if none are configured.
Sourcepub fn select_name(&self, name: Option<&str>) -> Result<&str, WorkspaceError>
pub fn select_name(&self, name: Option<&str>) -> Result<&str, WorkspaceError>
The name of the workspace WorkspaceSet::select resolves for name:
the given name when present (and valid), else the sole/default workspace’s
name. Same resolution and errors as select, but returns the concrete name
— so a caller (e.g. the /follow endpoint) can report which workspace it
actually resolved in, even on a flat route where the default was implicit.
§Errors
Sourcepub fn containing(&self, cwd_repo_db: &Path) -> Option<&str>
pub fn containing(&self, cwd_repo_db: &Path) -> Option<&str>
The name of the workspace whose member repos include the repo whose graph is
cwd_repo_db (<repo>/.git/roteiro/graph.db), or None if no workspace
contains it. Used to default --workspace-name to the workspace the current
directory belongs to.