Instance admin: org-sys sees and manages every org on the instance #319

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

Goal

Owners of org-sys are instance admins: they see every org on the instance, can create an org with its first owner, and can edit instance policies, also when signed in through OIDC.

Context

  • Depends on archie-core-kgxw.2 (org API) and archie-core-kgxw.4 (operator person). Do not start until both are closed.
  • Today instanceOwner is true only for the shared-token system principal (internal/webui/api_access_policies.go:117-121), so with OIDC on nobody can edit instance policies.
  • Rule to implement (no new role): a principal is instance admin iff it has role owner in org-sys (org.DefaultOrgID).

Steps

  1. Add Principal.InstanceAdmin() in internal/domain/access (owner membership in DefaultOrgID). Use it in instanceOwner.
  2. GET /api/orgs returns every org for an instance admin (caller's org otherwise). GET/PUT on another org's routes allowed for instance admins only.
  3. POST /api/orgs (instance admin only): body {id, name, owner_identity}; creates the org, its default workspace and the owner membership in one State Store call.
  4. Dashboard: on the Org area (archie-core-kgxw.3) an org switcher in the header, visible to instance admins only, listing all orgs plus "New org". Viewing another org shows its members/agents/workspaces read through the same pages.
  5. Playwright screenshots at 1920x947: as instance admin (switcher visible, two orgs) and as a non-admin (no switcher).

Out of scope

Acting inside another org's resources (tasks, workflows) as an instance admin. Org deletion. OIDC settings.

Stop when

  • Instance admin lists all orgs and creates one with an owner; a non-admin gets only their org and 403 on create.
  • Instance policies editable by an org-sys owner signed in by OIDC (unit-level: principal with owner membership in org-sys passes instanceOwner).
  • task check passes.
  • Commit feat(org): instance admins manage every org, close. 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

Backend f966d07f, dashboard 14320949.


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

## Goal Owners of org-sys are **instance admins**: they see every org on the instance, can create an org with its first owner, and can edit instance policies, also when signed in through OIDC. ## Context - Depends on archie-core-kgxw.2 (org API) and archie-core-kgxw.4 (operator person). Do not start until both are closed. - Today `instanceOwner` is true only for the shared-token system principal (`internal/webui/api_access_policies.go:117-121`), so with OIDC on nobody can edit instance policies. - Rule to implement (no new role): a principal is instance admin iff it has role `owner` in org-sys (`org.DefaultOrgID`). ## Steps 1. Add `Principal.InstanceAdmin()` in `internal/domain/access` (owner membership in DefaultOrgID). Use it in `instanceOwner`. 2. GET /api/orgs returns every org for an instance admin (caller's org otherwise). GET/PUT on another org's routes allowed for instance admins only. 3. POST /api/orgs (instance admin only): body {id, name, owner_identity}; creates the org, its `default` workspace and the owner membership in one State Store call. 4. Dashboard: on the Org area (archie-core-kgxw.3) an org switcher in the header, visible to instance admins only, listing all orgs plus "New org". Viewing another org shows its members/agents/workspaces read through the same pages. 5. Playwright screenshots at 1920x947: as instance admin (switcher visible, two orgs) and as a non-admin (no switcher). ## Out of scope Acting inside another org's resources (tasks, workflows) as an instance admin. Org deletion. OIDC settings. ## Stop when - [ ] Instance admin lists all orgs and creates one with an owner; a non-admin gets only their org and 403 on create. - [ ] Instance policies editable by an org-sys owner signed in by OIDC (unit-level: principal with owner membership in org-sys passes `instanceOwner`). - [ ] `task check` passes. - [ ] Commit `feat(org): instance admins manage every org`, close. 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 Backend f966d07f, dashboard 14320949. --- _Imported from beads `archie-core-kgxw.6` · GitHub #1275 · type feature · priority P1 · created 2026-10-05 · closed 2026-10-05_
sam added the highfeature labels 2026-10-27 13:35:50 +00:00
sam self-assigned this 2026-10-27 13:35:50 +00:00
sam closed this issue 2026-10-27 13:35:50 +00:00
Author
Owner

sam wrote (originally 2026-10-05):

Backend done (commit feat(org): instance admins manage every org): Principal.InstanceAdmin (owner of org-sys, whichever org it acts in) drives instanceOwner; GET /api/orgs lists all to admins; other orgs' routes open for admins only (404 otherwise, also enforced in the State Store's orgFor); POST /api/orgs creates org + default workspace + owner in one transaction and seeds the shipped role policies; api.orgCreate added. Left: steps 4-5 (org switcher + screenshots) wait on kgxw.3's Org area, which is in progress elsewhere.

_sam wrote (originally 2026-10-05):_ Backend done (commit feat(org): instance admins manage every org): Principal.InstanceAdmin (owner of org-sys, whichever org it acts in) drives instanceOwner; GET /api/orgs lists all to admins; other orgs' routes open for admins only (404 otherwise, also enforced in the State Store's orgFor); POST /api/orgs creates org + default workspace + owner in one transaction and seeds the shipped role policies; api.orgCreate added. Left: steps 4-5 (org switcher + screenshots) wait on kgxw.3's Org area, which is in progress elsewhere.
Author
Owner

sam wrote (originally 2026-10-05):

Switcher and New org landed: instance admins pick any org on the Org area and create one with an owner; non-admins see their own org only. Access and Tokens act on the caller's own org server-side, so they are hidden while another org is viewed. Playwright at 1920x947 with a stubbed API checked admin, non-admin and create.

_sam wrote (originally 2026-10-05):_ Switcher and New org landed: instance admins pick any org on the Org area and create one with an owner; non-admins see their own org only. Access and Tokens act on the caller's own org server-side, so they are hidden while another org is viewed. Playwright at 1920x947 with a stubbed API checked admin, non-admin and create.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#319