Reserve the label oficina for the suite's canonical apps
A new team may not take the label oficina, and ordinary add-apps and retire refuse it too: it names the suite's own canonical apps (docs.oficina.works and the rest), which Home adopts as an existing team on its own signed existing_team scope (Home #103, merged d36a413), and it is already their dashboard team. CreateTeam, AddApps and RetireApps refuse it as label-reserved before anything is planned or recorded. Matches Home's own refusal on ordinary create-team, add-apps and native seed. Reviewed by Claude Fable 5.1 (claude-fable-5-1), oficina/alta #2, APPROVED at ab61885 (four mutations killed); CI green at 996df91. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from reserve-oficina into main.
4 files changed,
+36
−0
internal/web/words.go+1 −0provision/apps.go+7 −0provision/engine.go+12 −0provision/engine_test.go+16 −0
CI passed — run details
diff --git a/internal/web/words.go b/internal/web/words.go| index b963b43..486a269 100644 |
| --- a/internal/web/words.go |
| +++ b/internal/web/words.go |
| @@ -56,6 +56,7 @@ var words = map[string]string{ |
| "transient": "Something went wrong. Alta will try again.", |
| "guard": "Alta's own guard refused a request", |
| "label-used": "That label has been used before. Labels are never reused.", |
| + "label-reserved": "That label is reserved for the suite's own apps.", |
| "label-shape": "A label is 3–32 lower-case letters, digits and hyphens, starting with a letter", |
| "name-shape": "Give the team a name", |
| "owner-shape": "That is not a plain email address", |
diff --git a/provision/apps.go b/provision/apps.go| index 5c24e1d..8c14c7d 100644 |
| --- a/provision/apps.go |
| +++ b/provision/apps.go |
| @@ -18,6 +18,13 @@ import ( |
| // Home's ValidLabel, so every derived host stays well inside DNS limits. |
| var LabelPattern = regexp.MustCompile(`^[a-z][a-z0-9-]{1,30}[a-z0-9]$`) |
| +// ReservedLabels are never offered to a new team. "oficina" names the |
| +// suite's own canonical apps (docs.oficina.works and the rest), which Home |
| +// adopts as an existing team on its own path (Home discussion 103), and is |
| +// the dashboard team the canonical apps already carry; a new team under it |
| +// would claim their name. |
| +var ReservedLabels = map[string]bool{"oficina": true} |
| + |
| // PublicDomain is the only public suffix Home's directory admits for a |
| // team instance (internal/home directoryRouteAllowed). |
| const PublicDomain = "oficina.works" |
diff --git a/provision/engine.go b/provision/engine.go| index 6e721dd..226fd33 100644 |
| --- a/provision/engine.go |
| +++ b/provision/engine.go |
| @@ -160,6 +160,8 @@ func (e *Engine) CreateTeam(ctx context.Context, in NewTeam) (int64, error) { |
| switch { |
| case !LabelPattern.MatchString(in.Label): |
| return 0, fail("label-shape") |
| + case ReservedLabels[in.Label]: |
| + return 0, fail("label-reserved") |
| case !homeop.TeamName(in.Name): |
| return 0, fail("name-shape") |
| case !homeop.OwnerAddress(in.Owner): |
| @@ -198,6 +200,13 @@ func (e *Engine) CreateTeam(ctx context.Context, in NewTeam) (int64, error) { |
| // new plan of kind add-apps"). |
| func (e *Engine) AddApps(ctx context.Context, label string, apps []string) (int64, error) { |
| apps = SortApps(apps) |
| + // Home's adoption of the canonical apps is its own signed scope |
| + // (existing_team on the plan, Home discussion 103); an ordinary |
| + // add-apps under the reserved label is refused there, so it is refused |
| + // here before anything is planned or recorded. |
| + if ReservedLabels[label] { |
| + return 0, fail("label-reserved") |
| + } |
| t, err := e.cfg.Store.Team(ctx, label) |
| if err != nil { |
| return 0, fail("no-team") |
| @@ -262,6 +271,9 @@ func (e *Engine) resumeCreate(ctx context.Context, t Team, apps []string) (int64 |
| // RetireApps starts a deprovision run (§9). typed must equal the label. |
| func (e *Engine) RetireApps(ctx context.Context, label string, apps []string, typed string) (int64, error) { |
| apps = SortApps(apps) |
| + if ReservedLabels[label] { |
| + return 0, fail("label-reserved") |
| + } |
| if typed != label { |
| return 0, fail("label-mismatch") |
| } |
diff --git a/provision/engine_test.go b/provision/engine_test.go| index 51f3868..78785f2 100644 |
| --- a/provision/engine_test.go |
| +++ b/provision/engine_test.go |
| @@ -313,6 +313,22 @@ func TestLabelsAreNeverReused(t *testing.T) { |
| if !errors.As(err, &fl) || fl.Code != "label-used" { |
| t.Fatalf("reused label: %v", err) |
| } |
| + // "oficina" is the canonical apps' team, adopted on Home's own path, |
| + // never a new team's label; refused before anything is recorded. |
| + if _, err := e.CreateTeam(h.ctx(), NewTeam{Label: "oficina", Name: "Oficina", Owner: ownerCanary, Apps: []string{"docs"}}); !errors.As(err, &fl) || fl.Code != "label-reserved" { |
| + t.Fatalf("reserved label: %v", err) |
| + } |
| + if used, err := h.store.LabelUsed(h.ctx(), "oficina"); err != nil || used { |
| + t.Fatalf("a refused reserved label was recorded: %v %v", used, err) |
| + } |
| + // Ordinary add-apps and retire refuse it too: adopting the canonical |
| + // apps is Home's own signed scope, never an ordinary plan under the label. |
| + if _, err := e.AddApps(h.ctx(), "oficina", []string{"docs"}); !errors.As(err, &fl) || fl.Code != "label-reserved" { |
| + t.Fatalf("add-apps under the reserved label: %v", err) |
| + } |
| + if _, err := e.RetireApps(h.ctx(), "oficina", []string{"docs"}, "oficina"); !errors.As(err, &fl) || fl.Code != "label-reserved" { |
| + t.Fatalf("retire under the reserved label: %v", err) |
| + } |
| // Alta's label rule is tighter than Home's. |
| for _, bad := range []string{"a", "Lagged", "-lag", "lag-", strings.Repeat("a", 33), "la_g"} { |
| if _, err := e.CreateTeam(h.ctx(), NewTeam{Label: bad, Name: "x", Owner: ownerCanary, Apps: []string{"docs"}}); !errors.As(err, &fl) || fl.Code != "label-shape" { |