gabriel / musehub public
fix patch fix/231-org-bootstrap-admin-promotion #1 / 1
AI Agent gabriel · 2 days ago · Oct 22, 2026 · Diff

fix: auto-promote org's bootstrap member to admin (musehub#231)

Audit: filed as its own ticket during musehub#226's regression pass, where 3 tests in test_identity_repo_phase4.py::TestRemoveOrgMember failed with a 403 on DELETE /api/orgs/{org}/members/{handle}. Confirmed via shelf isolation this was pre-existing and unrelated to #226.

Root cause: _assert_org_write_access's bootstrap exception lets anyone add an org's first member at any weight (admin/write/read) while the org has zero members. But every subsequent membership change requires an existing admin member. If that first member is added with weight="write" or "read" (as the test's _add_member helper defaults to), the org becomes permanently locked — no one, including the creator, can ever add a second member or remove the first one again.

Design decision (confirmed via AskUserQuestion): auto-promote the bootstrap (first) member to weight="admin" regardless of the requested weight, rather than rejecting non-admin bootstrap requests with 400 — structurally impossible to lock an org this way, matches the existing docstring's stated intent ("nobody could ever become the org's first admin").

TDD: wrote test_bootstrap_first_member_is_auto_promoted_to_admin first, confirmed genuine RED. Implemented the fix in add_org_member (check existing_members before the write-access assertion; force weight="admin" when the org has zero members). Confirmed GREEN: 21/21 in test_identity_repo_phase4.py, including the 3 previously-failing TestRemoveOrgMember tests and the new bootstrap test. Re-confirmed RED/ GREEN via muse-dev shelf save/pop isolation on musehub_orgs.py alone.

Regression: 244 passed across 15 identity/graph-domain test files plus phase4's own 21 — no regressions.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

sha256:b081400758b813fc5193e3e4859e32a62612a2ddaa514ff3858c51e8e3a82bb8 sha
+1 ~2 symbols
2 changed · 1100 in snapshot files
sha256:095bcb4a360f9d4e1116aed3b715a4a26c949d9cc5d079019456a3bc11af8d50 snapshot
+1
symbol added
~2
symbols modified
2
files changed
1100
files in snapshot
0
dead code introduced
Semantic Changes 3 symbols
~ tests/test_identity_repo_phase4.py .py 1 symbol added, 1 symbol modified
+ test_bootstrap_first_member_is_auto_promoted_to_admin method async_method test_bootstrap_first_member_is_auto_promoted_to_admin L229–248
Files Changed
~2
1100 in snapshot
← Older Oldest on fix/231-org-bootstrap-admin-promotion
All commits
Newer → Latest on fix/231-org-bootstrap-admin-promotion

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:b081400758b813fc5193e3e4859e32a62612a2ddaa514ff3858c51e8e3a82bb8 --body "your comment"