Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-9420: release Cloud guests with the commercial launch, drop FF_WORKSPACE_GUESTS (#10998)

Multica Evebac9e5b3f31e
diff --git a/packages/core/feature-flags/keys.ts b/packages/core/feature-flags/keys.ts
index 7fc99fc905..0f02e418f3 100644
--- a/packages/core/feature-flags/keys.ts
+++ b/packages/core/feature-flags/keys.ts
@@ -3,5 +3,8 @@ export const PLUGINS_V1_FLAG = "plugins_v1";
export const DOCS_V1_FLAG = "docs_v1";
export const BILLING_WORKSPACE_SUBSCRIPTIONS_FLAG =
"billing_workspace_subscriptions";
-// Guests (MUL-9420): free, seatless members limited to shared projects.
+// Guests (MUL-9420): free, seatless members limited to shared projects. Not a
+// flag of its own: the server reports whether this deployment offers adding
+// guests (always on self-host; on Cloud once billing launches), and the plan
+// then decides through the "guests" paid feature.
export const WORKSPACE_GUESTS_FLAG = "workspace_guests";
diff --git a/packages/views/settings/components/members-tab.tsx b/packages/views/settings/components/members-tab.tsx
index da29f80e83..bc2702ff49 100644
--- a/packages/views/settings/components/members-tab.tsx
+++ b/packages/views/settings/components/members-tab.tsx
@@ -629,7 +629,8 @@ export function MembersTab() {
const shareableProjects = useShareableProjects(wsId);
const projectTitles = new Map(shareableProjects.map((project) => [project.id, project.title]));
const guestCount = members.filter((m) => m.role === "guest").length;
- // Workspaces that already have guests keep seeing them if the flag goes off.
+ // Workspaces that already have guests keep seeing them where adding guests
+ // is not offered (Cloud before billing launches).
const showGuestViews = guestsEnabled || guestCount > 0;
// A guest takes no member slot, so a full workspace still invites guests.
const inviteLimited = inviteRole !== "guest";
diff --git a/server/cmd/server/guests_release_router_test.go b/server/cmd/server/guests_release_router_test.go
new file mode 100644
index 0000000000..b4779af6b5
--- /dev/null
+++ b/server/cmd/server/guests_release_router_test.go
@@ -0,0 +1,66 @@
+package main
+
+import (
+ "net/http"
+ "strings"
+ "testing"
+
+ "github.com/google/uuid"
+ "github.com/multica-ai/multica/server/internal/analytics"
+ "github.com/multica-ai/multica/server/internal/events"
+ "github.com/multica-ai/multica/server/internal/realtime"
+ dbfx "github.com/multica-ai/multica/server/internal/testutil"
+)
+
+// TestGuestsFailClosedWhenCloudPlansAreUnavailable assembles the real router
+// with a Cloud URL the plan client rejects (MUL-9420). The server is still a
+// Cloud deployment, so adding guests is refused rather than treated as
+// self-host; with no Cloud URL at all, guests are offered.
+func TestGuestsFailClosedWhenCloudPlansAreUnavailable(t *testing.T) {
+ if testPool == nil {
+ t.Skip("no database connection")
+ }
+ f := dbfx.New(testPool, testWorkspaceID, testUserID)
+ f.WorkspaceID = f.Workspace(t, "Guest release", "guest-release-"+uuid.NewString())
+ f.Member(t, f.WorkspaceID, f.UserID, "owner")
+ projectID := f.Project(t, "Guest release project")
+ f.Cleanup(t, `DELETE FROM workspace_invitation WHERE workspace_id = $1`, f.WorkspaceID)
+
+ check := func(t *testing.T, cloudURL string, wantOffered bool) {
+ t.Helper()
+ t.Setenv("MULTICA_CLOUD_URL", cloudURL)
+ router, _ := NewRouterWithOptions(testPool, realtime.NewHub(), events.New(), analytics.NoopClient{}, nil, RouterOptions{})
+
+ var config struct {
+ FeatureFlags map[string]bool `json:"feature_flags"`
+ }
+ dbfx.Call(t, router.ServeHTTP, dbfx.JSONRequest(http.MethodGet, "/api/config", nil)).Want(http.StatusOK).JSON(&config)
+ if got := config.FeatureFlags["workspace_guests"]; got != wantOffered {
+ t.Fatalf("config workspace_guests = %v, want %v", got, wantOffered)
+ }
+
+ req := dbfx.JSONRequest(http.MethodPost, "/api/workspaces/"+f.WorkspaceID+"/members", map[string]any{
+ "email": "guest-" + uuid.NewString()[:8] + "@example.test", "role": "guest", "project_ids": []string{projectID},
+ })
+ req.Header.Set("Authorization", "Bearer "+testToken)
+ req.Header.Set("X-Workspace-ID", f.WorkspaceID)
+ resp := dbfx.Call(t, router.ServeHTTP, req)
+ if wantOffered {
+ resp.Want(http.StatusCreated)
+ return
+ }
+ if resp.Code != http.StatusForbidden || !strings.Contains(resp.Body.String(), "workspace_guests_disabled") {
+ t.Fatalf("guest invite = %d %s, want 403 workspace_guests_disabled", resp.Code, resp.Body.String())
+ }
+ }
+
+ t.Run("malformed Cloud URL", func(t *testing.T) {
+ check(t, "https://cloud.example.test/?region=us", false)
+ if n := f.Count(t, `SELECT count(*) FROM workspace_invitation WHERE workspace_id = $1 AND role = 'guest'`, f.WorkspaceID); n != 0 {
+ t.Fatalf("guest invitations = %d, want none", n)
+ }
+ })
+ t.Run("self-host", func(t *testing.T) {
+ check(t, "", true)
+ })
+}
diff --git a/server/internal/featureflags/keys.go b/server/internal/featureflags/keys.go
index e282b61768..1ceb379186 100644
--- a/server/internal/featureflags/keys.go
+++ b/server/internal/featureflags/keys.go
@@ -42,13 +42,6 @@ const (
// for a deployment. It is a GLOBAL switch. Turning it off leaves existing
// doc rows untouched — they simply become unreachable until it is back on.
DocsV1 = "docs_v1"
- // WorkspaceGuests gates inviting guests and turning members into guests
- // (MUL-9420). On by default, so self-hosted servers have guests. A server
- // that predates guests treats a guest row as a full member, so a rolling
- // deploy should run with FF_WORKSPACE_GUESTS=off until every replica
- // serves this version. Existing guests keep their narrowed access either
- // way.
- WorkspaceGuests = "workspace_guests"
// agentBuilderCompat is no longer a release flag. Keep publishing the key
// as enabled so installed desktop clients that still gate the AI creation
// entry on this config decision receive the permanently enabled behavior.
@@ -100,16 +93,11 @@ func DocsV1Enabled(ctx context.Context, flags *featureflag.Service) bool {
return flags.IsEnabled(ctx, DocsV1, false)
}
-func WorkspaceGuestsEnabled(ctx context.Context, flags *featureflag.Service) bool {
- return flags.IsEnabled(ctx, WorkspaceGuests, true)
-}
-
func EvaluateFrontendPublicFlags(ctx context.Context, flags *featureflag.Service) map[string]bool {
out := make(map[string]bool, len(frontendPublicFlags)+5)
for _, key := range frontendPublicFlags {
out[key] = flags.IsEnabled(ctx, key, false)
}
- out[WorkspaceGuests] = WorkspaceGuestsEnabled(ctx, flags)
out[agentBuilderCompat] = true
out[agentSkillTogglesCompat] = true
out[resourceLabelsCompat] = true
diff --git a/server/internal/handler/config.go b/server/internal/handler/config.go
index ea9d0da2ad..8209bbd39f 100644
--- a/server/internal/handler/config.go
+++ b/server/internal/handler/config.go
@@ -154,6 +154,7 @@ func (h *Handler) GetConfig(w http.ResponseWriter, r *http.Request) {
config.VCSIntegrationAvailable = h.cfg.VCSIntegrationEnabled
config.ThemeStoreEnabled = h.ThemeStore != nil
config.FeatureFlags = featureflags.EvaluateFrontendPublicFlags(r.Context(), h.FeatureFlags)
+ config.FeatureFlags[WorkspaceGuestsConfigKey] = h.guestsReleased(r.Context())
// Only surface the build version on self-hosted deployments. The managed
// cloud is continuously deployed and its users can't choose the build, so
// the Help popover's version row would just be noise there (MUL-4108).
diff --git a/server/internal/handler/guest.go b/server/internal/handler/guest.go
index 8922f326fe..bb97f52511 100644
--- a/server/internal/handler/guest.go
+++ b/server/internal/handler/guest.go
@@ -6,6 +6,7 @@ import (
"errors"
"log/slog"
"net/http"
+ "strings"
"time"
"github.com/go-chi/chi/v5"
@@ -27,9 +28,34 @@ import (
// is better served as a member.
const maxGuestProjects = 100
-// guestsEnabled writes a 403 when new guests are switched off.
+// WorkspaceGuestsConfigKey is the client config key that tells Web, Desktop
+// and mobile whether this deployment offers adding guests (guestsReleased).
+// It is derived, not a flag of its own.
+const WorkspaceGuestsConfigKey = "workspace_guests"
+
+// guestsReleased reports whether this deployment offers adding guests. The
+// deployment mode comes from configuration, not from whether the Cloud plan
+// client came up:
+//
+// - No Cloud URL (self-host): always. There are no Cloud plans.
+// - A Cloud URL: guests are part of the commercial launch. They are offered
+// once billing_workspace_subscriptions is on, and the workspace's plan
+// then decides through the guests paid feature (requireGuestAddition).
+// When the plan client is unavailable (a malformed Cloud URL), nothing
+// could apply the plan, so adding guests is refused rather than allowed.
+func (h *Handler) guestsReleased(ctx context.Context) bool {
+ if strings.TrimSpace(h.cfg.CloudURL) == "" {
+ return true
+ }
+ if h.Features == nil {
+ return false
+ }
+ return featureflags.BillingWorkspaceSubscriptionsEnabled(ctx, h.FeatureFlags)
+}
+
+// guestsEnabled writes a 403 when this deployment does not offer guests yet.
func (h *Handler) guestsEnabled(w http.ResponseWriter, r *http.Request) bool {
- if featureflags.WorkspaceGuestsEnabled(r.Context(), h.FeatureFlags) {
+ if h.guestsReleased(r.Context()) {
return true
}
writeFeatureDisabled(w, "workspace_guests_disabled", "guests are not enabled")
@@ -37,10 +63,10 @@ func (h *Handler) guestsEnabled(w http.ResponseWriter, r *http.Request) bool {
}
// requireGuestAddition admits a write that adds a guest or widens one:
-// guests must be switched on for this deployment (the rollout flag) and
-// included in the workspace's plan (the guests paid feature). Removing a
-// guest, narrowing its projects and promoting it are never restricted, and
-// existing guests keep their access after a downgrade.
+// guests must be released on this deployment (guestsReleased) and included in
+// the workspace's plan (the guests paid feature). Removing a guest, narrowing
+// its projects and promoting it are never restricted, and existing guests
+// keep their access after a downgrade or while guests are not released.
func (h *Handler) requireGuestAddition(w http.ResponseWriter, r *http.Request, workspaceID pgtype.UUID, operation string) (featureAdmission, bool) {
if !h.guestsEnabled(w, r) {
return featureAdmission{}, false
diff --git a/server/internal/handler/guest_boundaries_test.go b/server/internal/handler/guest_boundaries_test.go
index 8072f04132..ee52e54364 100644
--- a/server/internal/handler/guest_boundaries_test.go
+++ b/server/internal/handler/guest_boundaries_test.go
@@ -544,8 +544,9 @@ func TestProjectSharingWithGuestFollowsThePlanAndFlag(t *testing.T) {
member := createPlainMember(t, f.marker+"[email protected]")
update(f.secret, map[string]any{"member_ids": []string{member}}).Want(http.StatusOK)
+ // Cloud before the commercial launch: guests are not released yet.
useGuestsFeature(t, entitlement.FeatureDecision{Action: entitlement.ActionOff})
- withFeatureFlag(t, testHandler, featureflags.WorkspaceGuests, false)
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, false)
resp := addTo(f.other, f.guest)
if resp.Code != http.StatusForbidden || !strings.Contains(resp.Body.String(), "workspace_guests_disabled") {
t.Fatalf("share with a guest while guests are off = %d %s, want 403 workspace_guests_disabled", resp.Code, resp.Body.String())
@@ -594,13 +595,12 @@ func TestGuestInvitationAcceptanceFollowsThePlanAndFlag(t *testing.T) {
wantPending("plan without guests")
useGuestsFeature(t, entitlement.FeatureDecision{Action: entitlement.ActionOff})
- withFeatureFlag(t, testHandler, featureflags.WorkspaceGuests, false)
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, false)
if resp := accept(); resp.Code != http.StatusForbidden || !strings.Contains(resp.Body.String(), "workspace_guests_disabled") {
t.Fatalf("accept with guests off = %d %s, want 403 workspace_guests_disabled", resp.Code, resp.Body.String())
}
wantPending("guests off")
- withFeatureFlag(t, testHandler, featureflags.WorkspaceGuests, true)
useGuestsFeature(t, entitlement.FeatureDecision{Action: entitlement.ActionObserve})
accept().Want(http.StatusOK)
if got := guestAttempts(t); got.observed != 1 || got.lastOperation != "accept_invitation" {
diff --git a/server/internal/handler/guest_plan_test.go b/server/internal/handler/guest_plan_test.go
index f4a9e02312..a788a03196 100644
--- a/server/internal/handler/guest_plan_test.go
+++ b/server/internal/handler/guest_plan_test.go
@@ -2,19 +2,33 @@ package handler
import (
"net/http"
+ "strings"
"testing"
"github.com/google/uuid"
"github.com/multica-ai/multica/server/internal/entitlement"
"github.com/multica-ai/multica/server/internal/entitlement/entitlementtest"
+ "github.com/multica-ai/multica/server/internal/featureflags"
"github.com/multica-ai/multica/server/internal/testutil"
)
-// useGuestsFeature points the shared handler at a stub that returns decision
-// for the guests paid feature in the test workspace.
+// useCloudURL sets the shared handler's configured Cloud URL, which is what
+// makes it a Cloud deployment for guests.
+func useCloudURL(t *testing.T, url string) {
+ t.Helper()
+ prior := testHandler.cfg.CloudURL
+ testHandler.cfg.CloudURL = url
+ t.Cleanup(func() { testHandler.cfg.CloudURL = prior })
+}
+
+// useGuestsFeature makes the shared handler a Cloud deployment after the
+// commercial launch (billing_workspace_subscriptions on) whose entitlement
+// stub returns decision for the guests paid feature in the test workspace.
func useGuestsFeature(t *testing.T, decision entitlement.FeatureDecision) {
t.Helper()
+ useCloudURL(t, "https://cloud.example.test")
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, true)
stub := entitlementtest.New()
stub.SetFeature(uuid.MustParse(testWorkspaceID), entitlement.FeatureGuests, decision)
prior := testHandler.Features
@@ -188,3 +202,73 @@ func TestGuestSeesOnlyItsOwnAttachmentsOutsideIssues(t *testing.T) {
t.Errorf("member GET attachment = %d, want 200", rec.Code)
}
}
+
+func guestsConfigFlag(t *testing.T) (bool, bool) {
+ t.Helper()
+ var config struct {
+ FeatureFlags map[string]bool `json:"feature_flags"`
+ }
+ testutil.Call(t, testHandler.GetConfig, newRequest(http.MethodGet, "/api/config", nil)).Want(http.StatusOK).JSON(&config)
+ on, ok := config.FeatureFlags[WorkspaceGuestsConfigKey]
+ return on, ok
+}
+
+// Guests ship with the commercial launch, not on a flag of their own: a
+// self-hosted server (no Cloud plans) always offers them; on Cloud they are
+// offered once billing_workspace_subscriptions is on, and the plan decides
+// from there. The old FF_WORKSPACE_GUESTS switch has no effect.
+func TestGuestsReleaseFollowsTheCommercialLaunch(t *testing.T) {
+ clearInvitationsForTestWorkspace(t)
+ f := newGuestFixture(t)
+ invite := func(suffix string) *testutil.Response {
+ req := withURLParam(newRequest(http.MethodPost, "/api/workspaces/"+testWorkspaceID+"/members",
+ CreateMemberRequest{Email: f.marker + suffix + "@multica.test", Role: "guest", ProjectIDs: []string{f.shared}}), "id", testWorkspaceID)
+ return testutil.Call(t, testHandler.CreateInvitation, req)
+ }
+
+ // Self-host: no Cloud URL. The retired key cannot turn guests off.
+ priorFeatures := testHandler.Features
+ testHandler.Features = nil
+ t.Cleanup(func() { testHandler.Features = priorFeatures })
+ useCloudURL(t, "")
+ withFeatureFlag(t, testHandler, "workspace_guests", false)
+ invite("-selfhost").Want(http.StatusCreated)
+ if on, ok := guestsConfigFlag(t); !ok || !on {
+ t.Fatalf("self-host config workspace_guests = %v (present %v), want true", on, ok)
+ }
+
+ // A Cloud URL whose plan client is unavailable: still Cloud, so adding
+ // guests is refused even with the commercial switch on.
+ useCloudURL(t, "https://cloud.example.test")
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, true)
+ if resp := invite("-noplans"); resp.Code != http.StatusForbidden || !strings.Contains(resp.Body.String(), "workspace_guests_disabled") {
+ t.Fatalf("Cloud guest invite without a plan client = %d %s, want 403 workspace_guests_disabled", resp.Code, resp.Body.String())
+ }
+ if on, _ := guestsConfigFlag(t); on {
+ t.Fatal("Cloud config workspace_guests without a plan client = true, want false")
+ }
+
+ // Cloud before the commercial launch.
+ useGuestsFeature(t, entitlement.FeatureDecision{Action: entitlement.ActionOff})
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, false)
+ resp := invite("-prelaunch")
+ if resp.Code != http.StatusForbidden || !strings.Contains(resp.Body.String(), "workspace_guests_disabled") {
+ t.Fatalf("Cloud guest invite before launch = %d %s, want 403 workspace_guests_disabled", resp.Code, resp.Body.String())
+ }
+ if on, _ := guestsConfigFlag(t); on {
+ t.Fatal("Cloud config workspace_guests before launch = true, want false")
+ }
+ // Existing guests keep their access.
+ if rec := guestRequest(t, testHandler.GetIssue, f.guest, http.MethodGet, "/api/issues/"+f.sharedIssue, nil, "id", f.sharedIssue); rec.Code != http.StatusOK {
+ t.Fatalf("existing guest before launch GET shared issue = %d, want 200", rec.Code)
+ }
+
+ // Cloud after the launch: offered, and the plan decides.
+ withFeatureFlag(t, testHandler, featureflags.BillingWorkspaceSubscriptions, true)
+ if on, _ := guestsConfigFlag(t); !on {
+ t.Fatal("Cloud config workspace_guests after launch = false, want true")
+ }
+ invite("-launched").Want(http.StatusCreated)
+ useGuestsFeature(t, entitlement.FeatureDecision{Action: entitlement.ActionEnforce})
+ wantGuestsLocked(t, invite("-locked"))
+}