Files
CHORUS/cmd/agent/main.go
anthonyrawlins 17673c38a6 fix: P2P connectivity regression + dynamic versioning system
## P2P Connectivity Fixes
- **Root Cause**: mDNS discovery was conditionally disabled in Task Execution Engine implementation
- **Solution**: Restored always-enabled mDNS discovery from working baseline (eb2e05f)
- **Result**: 9/9 Docker Swarm replicas with working P2P mesh, democratic elections, and leader consensus

## Dynamic Version System
- **Problem**: Hardcoded version "0.1.0-dev" in 1000+ builds made debugging impossible
- **Solution**: Implemented build-time version injection via ldflags
- **Features**: Shows commit hash, build date, and semantic version
- **Example**: `CHORUS-agent 0.5.5 (build: 9dbd361, 2025-09-26_05:55:55)`

## Container Compatibility
- **Issue**: Binary execution failed in Alpine due to glibc/musl incompatibility
- **Solution**: Added Ubuntu-based Dockerfile for proper glibc support
- **Benefit**: Reliable container execution across Docker Swarm nodes

## Key Changes
- `internal/runtime/shared.go`: Always enable mDNS discovery, dynamic version vars
- `cmd/agent/main.go`: Build-time version injection and display
- `p2p/node.go`: Restored working "🐝 Bzzz Node Status" logging format
- `Makefile`: Updated version to 0.5.5, proper ldflags configuration
- `Dockerfile.ubuntu`: New glibc-compatible container base
- `docker-compose.yml`: Updated to latest image tag for Watchtower auto-updates

## Verification
 P2P mesh connectivity: Peers exchanging availability broadcasts
 Democratic elections: Candidacy announcements and leader selection
 BACKBEAT integration: Beat synchronization and degraded mode handling
 Dynamic versioning: All containers show v0.5.5 with build metadata
 Task Execution Engine: All Phase 4 functionality preserved and working

Fixes P2P connectivity regression while preserving complete Task Execution Engine implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 16:05:25 +10:00

79 lines
2.7 KiB
Go

package main
import (
"fmt"
"os"
"path/filepath"
"chorus/internal/runtime"
)
// Build-time variables set by ldflags
var (
version = "0.5.0-dev"
commitHash = "unknown"
buildDate = "unknown"
)
func main() {
// Early CLI handling: print help/version without requiring env/config
for _, a := range os.Args[1:] {
switch a {
case "--help", "-h", "help":
fmt.Printf("%s-agent %s (build: %s, %s)\n\n", runtime.AppName, version, commitHash, buildDate)
fmt.Println("Usage:")
fmt.Printf(" %s [--help] [--version]\n\n", filepath.Base(os.Args[0]))
fmt.Println("CHORUS Autonomous Agent - P2P Task Coordination")
fmt.Println()
fmt.Println("This binary runs autonomous AI agents that participate in P2P task coordination,")
fmt.Println("collaborative reasoning via HMMM, and distributed decision making.")
fmt.Println()
fmt.Println("Environment (common):")
fmt.Println(" CHORUS_LICENSE_ID (required)")
fmt.Println(" CHORUS_AGENT_ID (optional; auto-generated if empty)")
fmt.Println(" CHORUS_P2P_PORT (default 9000)")
fmt.Println(" CHORUS_API_PORT (default 8080)")
fmt.Println(" CHORUS_HEALTH_PORT (default 8081)")
fmt.Println(" CHORUS_DHT_ENABLED (default true)")
fmt.Println(" CHORUS_BOOTSTRAP_PEERS (comma-separated multiaddrs)")
fmt.Println(" OLLAMA_ENDPOINT (default http://localhost:11434)")
fmt.Println()
fmt.Println("Example:")
fmt.Println(" CHORUS_LICENSE_ID=dev-123 \\")
fmt.Println(" CHORUS_AGENT_ID=chorus-agent-1 \\")
fmt.Println(" CHORUS_P2P_PORT=9000 CHORUS_API_PORT=8080 ./chorus-agent")
fmt.Println()
fmt.Println("Agent Features:")
fmt.Println(" - Autonomous task execution")
fmt.Println(" - P2P mesh networking")
fmt.Println(" - HMMM collaborative reasoning")
fmt.Println(" - DHT encrypted storage")
fmt.Println(" - UCXL context addressing")
fmt.Println(" - Democratic leader election")
fmt.Println(" - Health monitoring")
return
case "--version", "-v":
fmt.Printf("%s-agent %s (build: %s, %s)\n", runtime.AppName, version, commitHash, buildDate)
return
}
}
// Set dynamic build information
runtime.AppVersion = version
runtime.AppCommitHash = commitHash
runtime.AppBuildDate = buildDate
// Initialize shared P2P runtime
sharedRuntime, err := runtime.Initialize("agent")
if err != nil {
fmt.Fprintf(os.Stderr, "❌ Failed to initialize CHORUS agent: %v\n", err)
os.Exit(1)
}
defer sharedRuntime.Cleanup()
// Start agent mode with autonomous behaviors
if err := sharedRuntime.StartAgentMode(); err != nil {
fmt.Fprintf(os.Stderr, "❌ Agent mode failed: %v\n", err)
os.Exit(1)
}
}