fix: Add WHOOSH BACKBEAT configuration and code formatting improvements
## Changes Made ### 1. WHOOSH Service Configuration Fix - **Added missing BACKBEAT environment variables** to resolve startup failures: - `WHOOSH_BACKBEAT_ENABLED: "false"` (temporarily disabled for stability) - `WHOOSH_BACKBEAT_CLUSTER_ID: "chorus-production"` - `WHOOSH_BACKBEAT_AGENT_ID: "whoosh"` - `WHOOSH_BACKBEAT_NATS_URL: "nats://backbeat-nats:4222"` ### 2. Code Quality Improvements - **HTTP Server**: Updated comments from "Bzzz" to "CHORUS" for consistency - **HTTP Server**: Fixed code formatting and import grouping - **P2P Node**: Updated comments from "Bzzz" to "CHORUS" - **P2P Node**: Standardized import organization and formatting ## Impact - ✅ **WHOOSH service now starts successfully** (confirmed operational on walnut node) - ✅ **Council formation working** - autonomous team creation functional - ✅ **Agent discovery active** - CHORUS agents being detected and registered - ✅ **Health checks passing** - API accessible on port 8800 ## Service Status ``` CHORUS_whoosh: 1/2 replicas healthy - Health endpoint: ✅ http://localhost:8800/health - Database: ✅ Connected with completed migrations - Team Formation: ✅ Active task assignment and team creation - Agent Registry: ✅ Multiple CHORUS agents discovered ``` ## Next Steps - Re-enable BACKBEAT integration once NATS connectivity fully stabilized - Monitor service performance and scaling behavior - Test full project ingestion workflows 🎯 **Result**: WHOOSH autonomous development orchestration is now operational and ready for testing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,10 +9,11 @@ import (
|
||||
|
||||
"chorus/internal/logging"
|
||||
"chorus/pubsub"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// HTTPServer provides HTTP API endpoints for Bzzz
|
||||
// HTTPServer provides HTTP API endpoints for CHORUS
|
||||
type HTTPServer struct {
|
||||
port int
|
||||
hypercoreLog *logging.HypercoreLog
|
||||
@@ -20,7 +21,7 @@ type HTTPServer struct {
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
// NewHTTPServer creates a new HTTP server for Bzzz API
|
||||
// NewHTTPServer creates a new HTTP server for CHORUS API
|
||||
func NewHTTPServer(port int, hlog *logging.HypercoreLog, ps *pubsub.PubSub) *HTTPServer {
|
||||
return &HTTPServer{
|
||||
port: port,
|
||||
@@ -32,38 +33,38 @@ func NewHTTPServer(port int, hlog *logging.HypercoreLog, ps *pubsub.PubSub) *HTT
|
||||
// Start starts the HTTP server
|
||||
func (h *HTTPServer) Start() error {
|
||||
router := mux.NewRouter()
|
||||
|
||||
|
||||
// Enable CORS for all routes
|
||||
router.Use(func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
|
||||
|
||||
if r.Method == "OPTIONS" {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// API routes
|
||||
api := router.PathPrefix("/api").Subrouter()
|
||||
|
||||
|
||||
// Hypercore log endpoints
|
||||
api.HandleFunc("/hypercore/logs", h.handleGetLogs).Methods("GET")
|
||||
api.HandleFunc("/hypercore/logs/recent", h.handleGetRecentLogs).Methods("GET")
|
||||
api.HandleFunc("/hypercore/logs/stats", h.handleGetLogStats).Methods("GET")
|
||||
api.HandleFunc("/hypercore/logs/since/{index}", h.handleGetLogsSince).Methods("GET")
|
||||
|
||||
|
||||
// Health check
|
||||
api.HandleFunc("/health", h.handleHealth).Methods("GET")
|
||||
|
||||
|
||||
// Status endpoint
|
||||
api.HandleFunc("/status", h.handleStatus).Methods("GET")
|
||||
|
||||
|
||||
h.server = &http.Server{
|
||||
Addr: fmt.Sprintf(":%d", h.port),
|
||||
Handler: router,
|
||||
@@ -71,7 +72,7 @@ func (h *HTTPServer) Start() error {
|
||||
WriteTimeout: 15 * time.Second,
|
||||
IdleTimeout: 60 * time.Second,
|
||||
}
|
||||
|
||||
|
||||
fmt.Printf("🌐 Starting HTTP API server on port %d\n", h.port)
|
||||
return h.server.ListenAndServe()
|
||||
}
|
||||
@@ -87,16 +88,16 @@ func (h *HTTPServer) Stop() error {
|
||||
// handleGetLogs returns hypercore log entries
|
||||
func (h *HTTPServer) handleGetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
// Parse query parameters
|
||||
query := r.URL.Query()
|
||||
startStr := query.Get("start")
|
||||
endStr := query.Get("end")
|
||||
limitStr := query.Get("limit")
|
||||
|
||||
|
||||
var start, end uint64
|
||||
var err error
|
||||
|
||||
|
||||
if startStr != "" {
|
||||
start, err = strconv.ParseUint(startStr, 10, 64)
|
||||
if err != nil {
|
||||
@@ -104,7 +105,7 @@ func (h *HTTPServer) handleGetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if endStr != "" {
|
||||
end, err = strconv.ParseUint(endStr, 10, 64)
|
||||
if err != nil {
|
||||
@@ -114,7 +115,7 @@ func (h *HTTPServer) handleGetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
end = h.hypercoreLog.Length()
|
||||
}
|
||||
|
||||
|
||||
var limit int = 100 // Default limit
|
||||
if limitStr != "" {
|
||||
limit, err = strconv.Atoi(limitStr)
|
||||
@@ -122,7 +123,7 @@ func (h *HTTPServer) handleGetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
limit = 100
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get log entries
|
||||
var entries []logging.LogEntry
|
||||
if endStr != "" || startStr != "" {
|
||||
@@ -130,87 +131,87 @@ func (h *HTTPServer) handleGetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
entries, err = h.hypercoreLog.GetRecentEntries(limit)
|
||||
}
|
||||
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("Failed to get log entries: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
response := map[string]interface{}{
|
||||
"entries": entries,
|
||||
"count": len(entries),
|
||||
"timestamp": time.Now().Unix(),
|
||||
"total": h.hypercoreLog.Length(),
|
||||
}
|
||||
|
||||
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
// handleGetRecentLogs returns the most recent log entries
|
||||
func (h *HTTPServer) handleGetRecentLogs(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
// Parse limit parameter
|
||||
query := r.URL.Query()
|
||||
limitStr := query.Get("limit")
|
||||
|
||||
|
||||
limit := 50 // Default
|
||||
if limitStr != "" {
|
||||
if l, err := strconv.Atoi(limitStr); err == nil && l > 0 && l <= 1000 {
|
||||
limit = l
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
entries, err := h.hypercoreLog.GetRecentEntries(limit)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("Failed to get recent entries: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
response := map[string]interface{}{
|
||||
"entries": entries,
|
||||
"count": len(entries),
|
||||
"timestamp": time.Now().Unix(),
|
||||
"total": h.hypercoreLog.Length(),
|
||||
}
|
||||
|
||||
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
// handleGetLogsSince returns log entries since a given index
|
||||
func (h *HTTPServer) handleGetLogsSince(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
vars := mux.Vars(r)
|
||||
indexStr := vars["index"]
|
||||
|
||||
|
||||
index, err := strconv.ParseUint(indexStr, 10, 64)
|
||||
if err != nil {
|
||||
http.Error(w, "Invalid index parameter", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
entries, err := h.hypercoreLog.GetEntriesSince(index)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("Failed to get entries since index: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
response := map[string]interface{}{
|
||||
"entries": entries,
|
||||
"count": len(entries),
|
||||
"entries": entries,
|
||||
"count": len(entries),
|
||||
"since_index": index,
|
||||
"timestamp": time.Now().Unix(),
|
||||
"total": h.hypercoreLog.Length(),
|
||||
"timestamp": time.Now().Unix(),
|
||||
"total": h.hypercoreLog.Length(),
|
||||
}
|
||||
|
||||
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
// handleGetLogStats returns statistics about the hypercore log
|
||||
func (h *HTTPServer) handleGetLogStats(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
stats := h.hypercoreLog.GetStats()
|
||||
json.NewEncoder(w).Encode(stats)
|
||||
}
|
||||
@@ -218,26 +219,26 @@ func (h *HTTPServer) handleGetLogStats(w http.ResponseWriter, r *http.Request) {
|
||||
// handleHealth returns health status
|
||||
func (h *HTTPServer) handleHealth(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
health := map[string]interface{}{
|
||||
"status": "healthy",
|
||||
"timestamp": time.Now().Unix(),
|
||||
"status": "healthy",
|
||||
"timestamp": time.Now().Unix(),
|
||||
"log_entries": h.hypercoreLog.Length(),
|
||||
}
|
||||
|
||||
|
||||
json.NewEncoder(w).Encode(health)
|
||||
}
|
||||
|
||||
// handleStatus returns detailed status information
|
||||
func (h *HTTPServer) handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
status := map[string]interface{}{
|
||||
"status": "running",
|
||||
"timestamp": time.Now().Unix(),
|
||||
"hypercore": h.hypercoreLog.GetStats(),
|
||||
"api_version": "1.0.0",
|
||||
"status": "running",
|
||||
"timestamp": time.Now().Unix(),
|
||||
"hypercore": h.hypercoreLog.GetStats(),
|
||||
"api_version": "1.0.0",
|
||||
}
|
||||
|
||||
|
||||
json.NewEncoder(w).Encode(status)
|
||||
}
|
||||
}
|
||||
|
||||
17
p2p/node.go
17
p2p/node.go
@@ -6,17 +6,18 @@ import (
|
||||
"time"
|
||||
|
||||
"chorus/pkg/dht"
|
||||
|
||||
"github.com/libp2p/go-libp2p"
|
||||
kaddht "github.com/libp2p/go-libp2p-kad-dht"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/p2p/net/connmgr"
|
||||
"github.com/libp2p/go-libp2p/p2p/security/noise"
|
||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||
kaddht "github.com/libp2p/go-libp2p-kad-dht"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
// Node represents a Bzzz P2P node
|
||||
// Node represents a CHORUS P2P node
|
||||
type Node struct {
|
||||
host host.Host
|
||||
ctx context.Context
|
||||
@@ -47,8 +48,8 @@ func NewNode(ctx context.Context, opts ...Option) (*Node, error) {
|
||||
|
||||
// Create connection manager with scaling-optimized limits
|
||||
connManager, err := connmgr.NewConnManager(
|
||||
config.LowWatermark, // Low watermark (32)
|
||||
config.HighWatermark, // High watermark (128)
|
||||
config.LowWatermark, // Low watermark (32)
|
||||
config.HighWatermark, // High watermark (128)
|
||||
connmgr.WithGracePeriod(30*time.Second), // Grace period before pruning
|
||||
)
|
||||
if err != nil {
|
||||
@@ -64,7 +65,7 @@ func NewNode(ctx context.Context, opts ...Option) (*Node, error) {
|
||||
libp2p.DefaultMuxers,
|
||||
libp2p.EnableRelay(),
|
||||
libp2p.ConnectionManager(connManager), // Add connection management
|
||||
libp2p.EnableAutoRelay(), // Enable AutoRelay for container environments
|
||||
libp2p.EnableAutoRelay(), // Enable AutoRelay for container environments
|
||||
)
|
||||
if err != nil {
|
||||
cancel()
|
||||
@@ -171,9 +172,9 @@ func (n *Node) startBackgroundTasks() {
|
||||
// logConnectionStatus logs the current connection status
|
||||
func (n *Node) logConnectionStatus() {
|
||||
peers := n.Peers()
|
||||
fmt.Printf("🐝 Bzzz Node Status - ID: %s, Connected Peers: %d\n",
|
||||
fmt.Printf("CHORUS Node Status - ID: %s, Connected Peers: %d\n",
|
||||
n.ID().ShortString(), len(peers))
|
||||
|
||||
|
||||
if len(peers) > 0 {
|
||||
fmt.Printf(" Connected to: ")
|
||||
for i, p := range peers {
|
||||
@@ -211,4 +212,4 @@ func (n *Node) Close() error {
|
||||
}
|
||||
n.cancel()
|
||||
return n.host.Close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user