Skip to content

Workspaces phase 2a: the request's workspace, projects scoped (#277) - #316

Merged
antiv merged 1 commit into
mainfrom
workspaces-phase-2a
Nov 1, 2026
Merged

antiv merged 1 commit into
mainfrom
workspaces-phase-2a

Conversation

@antiv

@antiv antiv commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

First of the five PRs of phase 2 (documents/design/2.0-plan.md, Phase 2).

What changes

  • The request's workspace. RequestContext gains workspace_id, workspace_role and is_platform_admin. The workspace is the one named by X-MATE-Workspace, else workspace 1 for a platform administrator, else the caller's first membership. A missing, deleted or foreign workspace is a 404.
  • ctx.is_admin is unchanged (platform administrator only) until phase 2e. A workspace's own admin gets the dashboard API only once every route filters.
  • Projects scoped. The list and the pages' project pickers show the current workspace's projects. A new project lands in it. Update and delete of another workspace's project are a 404.
  • Project changes audited (project.create, project.update, project.delete). The delete passes workspace_id, since the project is gone (audit_service.log(..., workspace_id=...)).
  • shared/test/test_cross_workspace.py runs the real app over two workspaces:
    • every /dashboard/api GET route is called from A, and none may show B's data;
    • every route that names a row is called with B's ids, and must answer 404;
    • a write that names no row needs its own test, named in COVERED_BY_TEST.
    • NOT_YET_SCOPED lists the routes phase 2 still has to scope, and PLATFORM_ONLY the installation-wide ones. A new route is checked the day it is added.
  • Plan. Records the membership decision for users the platform creates (they join the workspace of the agent or integration that created them) and the five PRs.

Behaviour on a 1.x installation

None. Nothing creates a second workspace yet, so every request resolves to workspace 1, which holds every project. test_client_contract.py passes unchanged.

Checked

  • Full suite: 1767 tests OK.
  • Mutation check: with the project list and update unscoped, four tests of test_cross_workspace.py fail.
  • Local server:
    • Basic auth without the header lists the same 14 projects as before;
    • X-MATE-Workspace: 2 answers 404;
    • the Agents, Triggers, Integrations and Alerts pages load.

Docs

  • docs/dev/auth-and-access.md: new section "The workspace of a request", and the route table.
  • docs/dev/database-and-migrations.md: project delete keeps its workspace, and phase 2 reads the schema.
  • CLAUDE.md: dashboard routes filter by ctx.workspace_id.
  • docs/reference/api.md: regenerated.
  • Drift also lists guides tied to dashboard_server.py as a whole (agents, alerts, templates, triggers, eval, EU AI Act, template format, trigger engine). Their code is unchanged here, so they still hold. docs/user/usage-and-audit.md already says projects are audited, which is now true.

The request context resolves the workspace a dashboard request works in: the one
named by X-MATE-Workspace, else workspace 1 for a platform administrator, else the
caller's first membership. A workspace that doesn't exist, is deleted, or that the
caller isn't a member of is a 404. ctx.is_admin stays the platform administrator
until every route is scoped (phase 2e), so a workspace's own admin can't reach a
route that doesn't filter yet.

Projects are the first group scoped: the list holds the current workspace's, a new
one lands in it, and another workspace's project is a 404 on update and delete.
Project create, update and delete are audited; the delete passes the workspace, as
the project is gone.

shared/test/test_cross_workspace.py runs the real app over two workspaces. Every
/dashboard/api GET route is called from workspace A and must not show B's data;
every route that names a row is called with B's ids and must answer 404. Routes
still to do are in NOT_YET_SCOPED, which the rest of phase 2 empties.

The 2.0 plan records the membership decision for users the platform creates (end
users through /run_sse, A2A and Slack users join the workspace of the agent or
integration) and the five PRs of phase 2.
@antiv
antiv merged commit d4b9641 into main Nov 1, 2026
2 checks passed
@antiv
antiv deleted the workspaces-phase-2a branch November 1, 2026 15:14
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.

1 participant