package teammode import ( "encoding/json" "net/http" ) // ProbePath is the readiness probe Alta polls at provisioning step 11 // before it activates an instance in Home's directory (team-members.md §7; // Alta provision/steps.go TeamProbe). Mount Probe there for GET. const ProbePath = "/api/team" type probeBody struct { TeamMode bool `json:"team_mode"` Consumer string `json:"consumer,omitempty"` Roster string `json:"roster,omitempty"` } // Probe answers GET /api/team, unauthenticated, with only {team_mode, // consumer, roster}: whether this instance runs in team mode, the consumer // ID its verified provisioning record names, and RosterState. No account // data — no subject, role, member count, address, team ID or issuer — and // nothing that differs with who is asking. A nil Runtime (team mode off) // answers {"team_mode":false} and nothing else. Docs' and Sheets' probe, // byte for byte. func Probe(t *Runtime) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := probeBody{} if t != nil { body = probeBody{TeamMode: true, Consumer: t.bindings.Consumer, Roster: t.RosterState(r.Context())} } raw, err := json.Marshal(body) if err != nil { http.Error(w, "Unavailable.", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json; charset=utf-8") // Readiness changes from one second to the next; a cached "ok" // would let Alta activate an instance whose roster has gone stale. w.Header().Set("Cache-Control", "no-store") w.Header().Set("X-Content-Type-Options", "nosniff") _, _ = w.Write(raw) }) }