Org contract and archie-ui API: orgs, workspaces, members, agent assignments #307

Closed
opened 2026-10-27 13:35:47 +00:00 by sam · 0 comments
Owner

Goal

Expose orgs, workspaces, memberships and agent assignments over the State Store gRPC contract and archie-ui's HTTP API, read and write, so the dashboard can build org pages.

Context

  • Domain + store exist: internal/domain/org/store.go (Repository: CreateOrg, GetOrg, ListOrgs, CreateWorkspace, ListWorkspaces, EnsureMembership, AssignAgent, OrgForIdentity), Postgres impl internal/infrastructure/postgres/orgs.go, queries queries/orgs.sql.
  • Pattern to copy end to end: access policies. Proto proto/state/v1/state.proto (ListPolicies/PutPolicy), server internal/infrastructure/staterpc/access.go, client methods in internal/infrastructure/staterpc/client.go, HTTP internal/webui/api_access_policies.go, routes internal/webui/server.go, authorization internal/webui/authorize.go (accessRequest maps a route to action/kind).
  • The caller's org is server-derived: org.OrgFromContext(ctx) (set by the authorize wrapper).

Steps

  1. Add queries to queries/orgs.sql: ListMembers(org_id) joined with identities (id, display name, kind), RemoveMembership(identity_id, org_id, workspace_id), ListOrgAgents(org_id). task db:generate. Add matching Repository methods + Postgres impl.
  2. Proto (state/v1): ListOrgs, GetOrg, CreateOrg, ListWorkspaces, CreateWorkspace, ListMembers, SetMembership(identity_id, workspace_id optional, role), RemoveMembership, AssignAgent. Org id on every request except ListOrgs; the server ignores a request org that is not the caller's (instance-admin widening is archie-core-kgxw.6, not here). task proto:generate.
  3. staterpc server + client methods, wired where the policy RPCs are wired.
  4. HTTP routes in server.go:
    • GET /api/orgs (caller's org only for now), GET /api/orgs/{id}
    • GET, POST /api/orgs/{id}/workspaces
    • GET /api/orgs/{id}/members, PUT /api/orgs/{id}/members/{identity} body {role, workspace?}, DELETE /api/orgs/{id}/members/{identity}
    • PUT /api/orgs/{id}/agents/{identity}
      Map them in authorize.go to kind org with read/update. Roles must be one of owner, admin, developer, viewer (validate in the domain).
  5. Add api.orgs* methods to ui/src/lib/api.ts (no UI pages; that is archie-core-kgxw.3).

Out of scope

Any dashboard page. Instance admin / seeing other orgs. Workspace placement of records. OIDC subject binding.

Stop when

  • curl (shared token) can list your org, its workspaces and members, add a membership, change its role and remove it.
  • An unknown role is refused with 400 naming the role.
  • task check passes.
  • Commit feat(org): org, workspace and membership API, close the bead. Stop.

Rules for this ticket

  • Read CLAUDE.md first. Follow it: smallest change, no new binaries, no compatibility shims, comments say why briefly.
  • Do ONLY the steps below. Anything else you notice: file it with bd create (one line of why) and carry on. Do not fix it.
  • Do not refactor, rename or reformat code outside the listed files.
  • No new tests unless a step says so.
  • Run task check once at the end. If it fails twice on the same problem, stop and write what failed in a bead comment (bd comments add <id> "...") instead of looping.
  • Timebox: if you have not reached "Stop when" after the steps, stop, comment what is left, and leave the bead open.

Close reason

Closed


Imported from beads archie-core-kgxw.2 · GitHub #1277 · type feature · priority P1 · created 2026-10-05 · closed 2026-10-05

## Goal Expose orgs, workspaces, memberships and agent assignments over the State Store gRPC contract and archie-ui's HTTP API, read and write, so the dashboard can build org pages. ## Context - Domain + store exist: `internal/domain/org/store.go` (Repository: CreateOrg, GetOrg, ListOrgs, CreateWorkspace, ListWorkspaces, EnsureMembership, AssignAgent, OrgForIdentity), Postgres impl `internal/infrastructure/postgres/orgs.go`, queries `queries/orgs.sql`. - Pattern to copy end to end: access policies. Proto `proto/state/v1/state.proto` (ListPolicies/PutPolicy), server `internal/infrastructure/staterpc/access.go`, client methods in `internal/infrastructure/staterpc/client.go`, HTTP `internal/webui/api_access_policies.go`, routes `internal/webui/server.go`, authorization `internal/webui/authorize.go` (`accessRequest` maps a route to action/kind). - The caller's org is server-derived: `org.OrgFromContext(ctx)` (set by the authorize wrapper). ## Steps 1. Add queries to `queries/orgs.sql`: ListMembers(org_id) joined with identities (id, display name, kind), RemoveMembership(identity_id, org_id, workspace_id), ListOrgAgents(org_id). `task db:generate`. Add matching Repository methods + Postgres impl. 2. Proto (state/v1): ListOrgs, GetOrg, CreateOrg, ListWorkspaces, CreateWorkspace, ListMembers, SetMembership(identity_id, workspace_id optional, role), RemoveMembership, AssignAgent. Org id on every request except ListOrgs; the server ignores a request org that is not the caller's (instance-admin widening is archie-core-kgxw.6, not here). `task proto:generate`. 3. staterpc server + client methods, wired where the policy RPCs are wired. 4. HTTP routes in `server.go`: - GET /api/orgs (caller's org only for now), GET /api/orgs/{id} - GET, POST /api/orgs/{id}/workspaces - GET /api/orgs/{id}/members, PUT /api/orgs/{id}/members/{identity} body {role, workspace?}, DELETE /api/orgs/{id}/members/{identity} - PUT /api/orgs/{id}/agents/{identity} Map them in `authorize.go` to kind `org` with read/update. Roles must be one of owner, admin, developer, viewer (validate in the domain). 5. Add `api.orgs*` methods to `ui/src/lib/api.ts` (no UI pages; that is archie-core-kgxw.3). ## Out of scope Any dashboard page. Instance admin / seeing other orgs. Workspace placement of records. OIDC subject binding. ## Stop when - [ ] `curl` (shared token) can list your org, its workspaces and members, add a membership, change its role and remove it. - [ ] An unknown role is refused with 400 naming the role. - [ ] `task check` passes. - [ ] Commit `feat(org): org, workspace and membership API`, close the bead. Stop. ## Rules for this ticket - Read CLAUDE.md first. Follow it: smallest change, no new binaries, no compatibility shims, comments say why briefly. - Do ONLY the steps below. Anything else you notice: file it with `bd create` (one line of why) and carry on. Do not fix it. - Do not refactor, rename or reformat code outside the listed files. - No new tests unless a step says so. - Run `task check` once at the end. If it fails twice on the same problem, stop and write what failed in a bead comment (`bd comments add <id> "..."`) instead of looping. - Timebox: if you have not reached "Stop when" after the steps, stop, comment what is left, and leave the bead open. ### Close reason Closed --- _Imported from beads `archie-core-kgxw.2` · GitHub #1277 · type feature · priority P1 · created 2026-10-05 · closed 2026-10-05_
sam added the highfeature labels 2026-10-27 13:35:47 +00:00
sam self-assigned this 2026-10-27 13:35:47 +00:00
sam closed this issue 2026-10-27 13:35:47 +00:00
sam added a new dependency 2026-10-27 13:41:53 +00:00
sam added a new dependency 2026-10-27 13:41:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#307