481359ddb2
Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2.7 KiB
2.7 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec | |
|---|---|---|---|---|---|---|---|
| 04-management-api | Management API, roles, and user directory | todo | 2 |
|
plan.md | ../../specs/workspaces/requirements/org-units.md |
Task 04: Management API, Roles, and User Directory
Acceptance
PATCH /api/v1/workspaces/{id}acceptsvisibility, gated onworkspace.manage.POST /api/v1/workspaces/visibility/bulksets visibility across the caller's own workspaces, for the one-time opt-in.PATCH /api/v1/orgs/current/settingsacceptsdefault_workspace_visibility, gated onorg.settings.manage.GET/PUT/DELETE /api/v1/workspaces/{id}/members[/{userId}]list, add-or- re-role, and remove, gated onworkspace.read/member.manage.PUTis idempotent and carries the workspace role.POST /api/v1/workspaces/{id}/transfer-ownershipmoves the accountable owner, demotes the previous owner tocollaborator, and updatesworkspaces.owner_idin the same transaction. A target with no row is refused.- Removing the last
ownerrow, or the row matchingowner_id, is refused with a distinct code. - Setting
visibility = 'org'on a workspace owned by aguestis refused. - Adding a nonexistent, disabled, or already-present user returns 400 with a distinct code per case and writes nothing.
PATCH /api/v1/users/{id}accepts the four org roles, gated onorg.members.manage, with the last-owner and self-change guards.GET /api/v1/users/directoryreturns only id and display name for active users. A pinning test over the response field set fails if email, role, or status is ever added.- Workspace DTOs carry
visibility,member_count,viewer_role, andscopes;GET /api/v1/auth/mecarriesorg_scopes.
Verification
go test ./internal/task/... ./internal/user/... ./internal/auth/... -run 'TestVisibility|TestMember|TestTransferOwnership|TestUserDirectory|TestRoleChange'go test ./internal/user/... -run TestUserDirectoryFieldSet
Files Likely Touched
apps/backend/internal/task/handlers/workspace_handlers.goapps/backend/internal/task/service/service_members.goapps/backend/internal/task/dto/dto.goapps/backend/internal/user/handlers/handlers.go,internal/user/dto/dto.goapps/backend/internal/auth/httpapi/handlers.go
Inputs
- Spec: API surface, Permissions, Failure modes;
roles-and-scopes.mdPermissions. - Patterns: existing workspace handler shapes; the no-existence-leak rule for anything reachable cross-user.
Output Contract
Report the error-code matrix, the directory field pinning test and the mutation proving it fails, RED/GREEN commands, and set this task plus its plan checkbox to done.