Skip to content

feat(workspaces): named groups of repos for federation - #2

Open
spuentesp wants to merge 1 commit into
mainfrom
feat/workspaces
Open

feat(workspaces): named groups of repos for federation#2
spuentesp wants to merge 1 commit into
mainfrom
feat/workspaces

Conversation

@spuentesp

Copy link
Copy Markdown
Owner

Summary

Implements the Lain Workspaces feature (spec at `docs/superpowers/specs/2026-08-12-lain-workspaces-design.md`, plan at `docs/superpowers/plans/2026-08-12-lain-workspaces.md`). A workspace is a named subset of repos from `repos.yaml` that the federation engine indexes as a coherent unit, switchable on server restart via `--workspace ` (or `--workspace auto` reading `~/.config/lain/active_workspace`).

What ships

  • Workspace types + loader in `src/federation/workspace.rs`: `WorkspacesFile` (YAML), `WorkspaceSpec`, `WorkspaceSourceConfig`, `WorkspaceSource` trait, `WorkspaceDirSource` and `WorkspaceCloneSource` impls, `WorkspaceIndex`, `filter_repos_by_workspace` helper. 17 unit tests.
  • ActiveWorkspace pointer at `~/.config/lain/active_workspace` (in `src/state.rs`) + `resolve_active_workspace` lookup helper. 6 unit tests.
  • `load_federation_with_workspace` in `src/federation/loader.rs` + new `build_source_for` per-repo builder in `src/federation/config.rs`. Builds a workspace-aware federation the same way as `load_federation` but with a per-repo data subdir (so workspace restarts that swap the member set don't clobber state).
  • `--workspace` flag wiring in `src/cmds/server.rs` + `LainServer::with_federation_and_workspaces` constructor in `src/server/mod.rs` so workspace MCP tools are registered.
  • 4 new MCP tools in `src/mcp/federation_tools.rs`: `list_workspaces`, `get_active_workspace`, `get_workspace`, `get_workspace_graph` (the 4th gated on workspace being active).
  • `lain workspaces` CLI subcommand in `src/cmds/workspaces.rs` with 10 actions: `create`, `add`, `remove`, `import`, `init`, `list`, `show`, `use`, `current`, `forget`.
  • Federation dashboard (`src/mcp/federation_dashboard.html`): 3 new sections — active workspace panel (name + member table), config panel (paths + counts), per-workspace D3 force-directed graph view (with substring filter, color by repo_id, dashed lines for cross-repo Calls).
  • `get_agent_strategy` in `src/tools.rs` gets a new "Workspace mode" section documenting the 4 new tools + the `repo_id` resolution rule when scoped.
  • `GraphBackend` trait gets a new `all_edges()` method (for `get_workspace_graph` bulk-edge reads).
  • `tests/workspace_e2e.rs` with 6 integration tests (2 pure-validation pass, 3 require `rust-analyzer`).
  • `tests/e2e/workspace_e2e.sh` nightly e2e that exercises all 4 workspace tools + the workspace switch restart.
  • `docs/FEDERATION.md` + `README.md` updated with a Workspaces section + pointer.

Test results

  • 492/492 lib tests pass.
  • `workspace_e2e.sh` passes all 5 assertions (list_workspaces, get_active_workspace, get_workspace for cross-workspace query, get_workspace_graph, and the ab→bc restart verification).
  • `federation_e2e.sh` still passes (3 famous repos, no regression).
  • 2/2 pure-validation `workspace_e2e.rs` tests pass.
  • 4 `workspace_e2e.rs` tests + 3 `federation_integration.rs` tests are deferred to a working env (need `rust-analyzer` for `RepoIndex::index().await`; the same env-block documented in the test-gap fix).

Critical prerequisite

This PR cannot land before the test-gap fix's PR 1 (Pass A + Pass B in `project_repo`) merges — that was the explicit prerequisite captured in both the spec and the plan. The workspace's headline cross-repo `Calls` semantic depends on the test-gap fix producing those edges. PR 2 of workspaces (dashboard + e2e + docs + agent strategy) is safe to land independently.

Migration / rollout

`repos.yaml` schema unchanged. The federation tool set gains 4 new tools (`list_workspaces`, `get_active_workspace`, `get_workspace`, `get_workspace_graph`); the 6 existing tools are unchanged. Federation mode without a workspaces.yaml is identical to today — operators opt into workspaces by adding a file and passing `--workspace ` (or setting the active workspace pointer).

Copilot AI lite review requested due to automatic review settings August 12, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants