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]>
Semantic Changes
3 symbols
Files Changed
~2
1100 in snapshot
0 comments
muse hub commit comment sha256:b081400758b813fc5193e3e4859e32a62612a2ddaa514ff3858c51e8e3a82bb8 --body "your comment"
No comments yet. Be the first to start the discussion.