oficina / base Public

Merge branch 'team-probe' into main

Merge team-probe: seeded /api/team readiness probe for Alta (team-bundle slice 2; Fable APPROVED; Paul's go 2026-11-30)
claude agent, operated by paul@keymail.dev 63e41ce18f7deb46fa30c8b104501f088102ab6c parent c20c970parent ee2b662
3 files changed, +77 −0
  • internal/web/app.go +1 −0
  • internal/web/team_probe.go +38 −0
  • internal/web/team_probe_internal_test.go +38 −0

CI passed — run details

CI log
=== build ===
CGO_ENABLED=0 go build ./...
=== vet ===
go vet ./...
=== fmt-check ===
=== staticcheck ===
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./...
=== govulncheck ===
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
No vulnerabilities found.
=== gitleaks ===
1:23PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
1:23PM INF 1 commits scanned.
1:23PM INF scanned ~2938298 bytes (2.94 MB) in 297ms
1:23PM INF no leaks found
=== budget ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 22 directories within budget
=== script-test ===
scripts/prepare-apps_test.sh
ok   releases lookup failure stops before ship
ok   app owned elsewhere stops the script
ok   apps listing failure stops before create
ok   ambiguous release dir is refused
ok   explicit version resolves the ambiguity
ok   releases match is exact, not substring
ok   shipped version is only promoted, existing app not created
ok   fresh account creates, ships, promotes to edge, enables
ok   failing promote stops the script
ok   ship is retried while uploads are rate limited
all passed
hack/fonts_test.sh
fonts_test: ok
=== test ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./...

receipt: test step 9.803s against a 60s target (the gate's other steps are not in this figure)
receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed
receipt: slow package 8.792s amadan.net/oficina/base/internal/webtest
receipt: slow package 1.052s amadan.net/oficina/base/internal/issuer
receipt: slow package 677ms amadan.net/oficina/base/internal/equipo
receipt: slow package 607ms amadan.net/oficina/base/internal/operations
receipt: slow package 224ms amadan.net/oficina/base/internal/web
receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot
receipt: slow test 1.08s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce
receipt: slow test 790ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp
receipt: slow test 620ms amadan.net/oficina/base/internal/webtest TestAskUploadStalledBodyFreesItsSlot
receipt: slow test 520ms amadan.net/oficina/base/internal/operations TestOperationsRefusals
=== native ===
strings: copy review's strings.json is not here (git-ignored); its comparison skipped
strings: 121 in the catalog, 118 used
worktree-lib_test: ok
diff --git a/internal/web/app.go b/internal/web/app.go
index 6f429c9..00a455c 100644
--- a/internal/web/app.go
+++ b/internal/web/app.go
@@ -162,6 +162,7 @@ func App(d *db.DB, cfg config.Config, mailer mail.Sender, inst Installer, logger
}
r.Get("/static/fonts/*", look.FontHandler().ServeHTTP)
r.Get("/static/*", look.Assets.Handler().ServeHTTP)
+ r.Get("/api/team", a.teamProbe)
if o := a.oficina; o != nil {
r.Get("/signin", a.oficinaSignin)
r.Get("/signin/local", a.signin)
diff --git a/internal/web/team_probe.go b/internal/web/team_probe.go
new file mode 100644
index 0000000..fe426a3
--- /dev/null
+++ b/internal/web/team_probe.go
@@ -0,0 +1,38 @@
+package web
+
+import (
+ "encoding/json"
+ "net/http"
+)
+
+// teamProbe answers GET /api/team, the readiness probe Alta reads before
+// it activates a team Base in Home's directory (oficina/alta
+// design/team-bundle, spec §1.2). Base has no Home roster mode: its owner
+// is seeded from BASE_OWNER, so it answers in the seeded mode. It names
+// the Home consumer it was configured as, and whether an owner exists yet.
+// It carries no address, name or count, and needs no session.
+//
+// A Base without Oficina ID has no consumer and is never ready: 404.
+func (a *app) teamProbe(w http.ResponseWriter, r *http.Request) {
+ if a.cfg.Home == nil || a.cfg.Home.ConsumerID == "" {
+ http.NotFound(w, r)
+ return
+ }
+ var owners int
+ if err := a.db.QueryRowContext(r.Context(), `SELECT count(*) FROM members WHERE role = 'owner'`).Scan(&owners); err != nil {
+ http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable)
+ return
+ }
+ roster := "owner-pending"
+ if owners > 0 {
+ roster = "ok"
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.Header().Set("Cache-Control", "no-store")
+ _ = json.NewEncoder(w).Encode(struct {
+ TeamMode bool `json:"team_mode"`
+ Seeded bool `json:"seeded"`
+ Consumer string `json:"consumer"`
+ Roster string `json:"roster"`
+ }{false, true, a.cfg.Home.ConsumerID, roster})
+}
diff --git a/internal/web/team_probe_internal_test.go b/internal/web/team_probe_internal_test.go
new file mode 100644
index 0000000..dca0f56
--- /dev/null
+++ b/internal/web/team_probe_internal_test.go
@@ -0,0 +1,38 @@
+package web
+
+import (
+ "encoding/json"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/home/connect"
+)
+
+// GET /api/team is Alta's readiness probe for a team Base (seeded mode).
+func TestTeamProbe(t *testing.T) {
+ probe := func(a *app) *httptest.ResponseRecorder {
+ w := httptest.NewRecorder()
+ a.teamProbe(w, httptest.NewRequest("GET", "/api/team", nil))
+ return w
+ }
+ a, _, _ := teamApp(t)
+ if w := probe(a); w.Code != 404 {
+ t.Fatalf("without Oficina ID: %d %s", w.Code, w.Body)
+ }
+ a.cfg.Home = &connect.DecodedCredentials{ConsumerID: "campbells-base"}
+ w := probe(a)
+ if w.Code != 200 || w.Header().Get("Content-Type") != "application/json" || w.Header().Get("Cache-Control") != "no-store" || strings.Contains(w.Body.String(), "@") {
+ t.Fatalf("%d %v %s", w.Code, w.Header(), w.Body)
+ }
+ var got map[string]any
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil || len(got) != 4 || got["team_mode"] != false || got["seeded"] != true || got["consumer"] != "campbells-base" || got["roster"] != "ok" {
+ t.Fatalf("%v %s", err, w.Body)
+ }
+ if _, err := a.db.Exec(`UPDATE members SET role = 'member' WHERE role = 'owner'`); err != nil {
+ t.Fatal(err)
+ }
+ if w := probe(a); !strings.Contains(w.Body.String(), `"roster":"owner-pending"`) {
+ t.Fatalf("%s", w.Body)
+ }
+}