Repository navigation
Add membership service + store foundations for the Collaboration UI (#238) - #1473
mstomar125 merged 2 commits into
Conversation
…238) Groundwork (slice S1) for the collection-membership UI on top of the complete #143 backend. No visible surface yet — this is the service + reactive store the Collaboration view (S3/S4) and onboarding inbox (S5) build on. - membership-service.ts: typed wrappers over the eight pro_* membership commands plus S2's three (pro_list_invites / pro_list_requests / pro_revoke_invite) and pro_current_person. Maps the commands' snake_case DTOs to camelCase interfaces at the boundary so the rest of the frontend never sees the wire shape. - membership.svelte.ts: a Svelte 5 runes store caching per-collection roster + pending invites/requests + the caller's own identity. Derives currentUserRole(collectionId) by matching the caller's person id against the roster, so admin controls gate correctly; only fetches the admin-gated invite/request listings when the caller is an admin. Mutations refresh the affected collection. Pro-gated: every method is inert when proSync.tier !== 'pro', so the community build is behaviorally unchanged. Tests: 16 new (service arg/mapping + store role-derivation, admin gating, community-inert, mutation refresh, reset). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
REQUEST CHANGES Solid, well-documented S1 foundation — the DTO mapping and admin-gating are correct and the tests are meaningful. One free-user-mandate gap at the foundation blocks it. (I verified each line below against the file at 🔴 Mutations don't honor the store's own "community-inert" contract. Only the read path is Pro-gated:
🟡 Pin the invariant in tests. 🟡 Non-blocking:
✅ Confirmed good: snake_case→camelCase DTO mapping matches the real Rust DTOs ( Add the mutation guards + the test and I'll re-review. |
…review) Address the S1 review: only the read path (loadCollection / ensureIdentity) was Pro-gated; the 9 mutations called the pro_* commands unconditionally, breaking the store's own "every method is inert in community mode" contract — and acceptInvite / requestJoin are the S5 onboarding entry points. - Void mutations early-return in community mode; the value-returning createInvite / acceptInvite / requestJoin throw via a requirePro() guard (never a fake-success value) so none reach the service when tier !== 'pro'. - Test pins the invariant: a void mutation no-ops and the value-returning ones throw, none touching the service, when isPro === false. Also from review (non-blocking): - ensureIdentity retries while person_id is empty, so a mid-session identity bind is picked up instead of leaving currentUserRole null all session. - loadCollection commits the roster before the admin-only invite/request listings, so a listing failure no longer discards an already-fetched roster. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Addressed at 🔴 Community-inert contract on mutations — fixed. All 9 mutations now honor the contract:
🟡 Invariant pinned in tests. New case asserts a void mutation no-ops and the value-returning ones throw, none touching the service, when 🟡 Non-blocking, both fixed:
|
|
APPROVE — resolves my earlier REQUEST CHANGES (@90efb7c3). The community-inert contract is now enforced at the store boundary, not just relied on from Pro-gated callers. All 9 mutations in
Two bundled improvements, both fine:
Nit (non-blocking): a member demoted admin→non-admin keeps stale cached |
Slice S1 of the collection-membership-UI epic (NodeSpaceAI/nodespace-sync#237). Foundations only — no visible surface yet; this is the service + reactive store that the Collaboration view (S3/S4) and onboarding inbox (S5) build on, layered over the already-complete #143 membership backend.
What
services/membership-service.ts— typed, thin wrappers over the eightpro_*membership commands plus S2's three (pro_list_invites/pro_list_requests/pro_revoke_invite) andpro_current_person. The daemon enforces the ADR-037 gates server-side; these carry no authority. Maps the commands' snake_case DTOs (person_id,expires_at, …) to camelCase interfaces at the boundary so the rest of the frontend never sees the wire shape.stores/membership.svelte.ts— a Svelte 5 runes store caching, per collection, the roster + pending invites/requests, plus the caller's own identity.currentUserRole(collectionId)matches the caller's person id against the roster so admin controls gate correctly; the admin-only invite/request listings are fetched only when the caller is an admin (a non-admin call would just 403). Mutations refresh the affected collection.Pro-gated / community-inert
Every store method early-returns (or yields empty) when
proSync.tier !== 'pro', so the community build never touches the membership commands and is behaviorally unchanged.Caller identity
Consumes S2's
pro_current_person(#1472 / NodeSpaceAI/nodespace-sync#244) — fetched once and cached, cleared on sign-out viareset(). Runtime resolution of these commands depends on those S2 PRs landing; this slice's unit tests mock the boundary, so it builds and tests green independently.Tests
bun run teston the two new files — 16 passed (service arg-forwarding + snake→camel mapping; store role-derivation, admin gating, community-inert, mutation-refresh, reset).bun run quality:fix— ESLint 0/0,svelte-check0 errors.Depends (at runtime) on #239. Unblocks S3 (#240) / S4 (#241) / S5 (#242).