Skip to content

Commit 3b1b55c

Browse files
committed
Merge branch 'feat/polygon-lasso-4905851647628508372'
2 parents 63f6b5a + 79f3022 commit 3b1b55c

5 files changed

Lines changed: 147 additions & 0 deletions

File tree

backend-go/api/fleet.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package api
2+
3+
import (
4+
"encoding/json"
5+
"net/http"
6+
7+
"bobsgameonlinejava/backend-go/autonomous"
8+
)
9+
10+
func HandleFleetSummary(w http.ResponseWriter, r *http.Request) {
11+
w.Header().Set("Content-Type", "application/json")
12+
13+
// Get ongoing active debate telemetry
14+
debatesJSON := autonomous.GetFleetDebateSummary()
15+
16+
var debates []interface{}
17+
json.Unmarshal(debatesJSON, &debates)
18+
19+
summary := map[string]interface{}{
20+
"status": "ONLINE",
21+
"active_jobs": 0, // Placeholder
22+
"council_debates": debates,
23+
}
24+
25+
json.NewEncoder(w).Encode(summary)
26+
}

backend-go/autonomous/debate.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package autonomous
2+
3+
import (
4+
"encoding/json"
5+
"log"
6+
"time"
7+
)
8+
9+
type AgentMessage struct {
10+
Role string `json:"role"`
11+
Content string `json:"content"`
12+
Timestamp time.Time `json:"timestamp"`
13+
Tokens int `json:"tokens"`
14+
}
15+
16+
type DebateSession struct {
17+
ID string `json:"id"`
18+
Topic string `json:"topic"`
19+
Status string `json:"status"` // "ongoing", "resolved", "escalated"
20+
Messages []AgentMessage `json:"messages"`
21+
StartTime time.Time `json:"startTime"`
22+
EndTime time.Time `json:"endTime,omitempty"`
23+
}
24+
25+
var ActiveDebates = make(map[string]*DebateSession)
26+
27+
func InitiateDebate(topic string) *DebateSession {
28+
session := &DebateSession{
29+
ID: "debate_" + time.Now().Format("20060102150405"),
30+
Topic: topic,
31+
Status: "ongoing",
32+
StartTime: time.Now(),
33+
Messages: []AgentMessage{},
34+
}
35+
ActiveDebates[session.ID] = session
36+
log.Printf("[COUNCIL SUPERVISOR] Initiated debate session: %s on topic: %s", session.ID, topic)
37+
return session
38+
}
39+
40+
func AddDebateMessage(sessionID, role, content string, tokens int) {
41+
if session, exists := ActiveDebates[sessionID]; exists {
42+
msg := AgentMessage{
43+
Role: role,
44+
Content: content,
45+
Timestamp: time.Now(),
46+
Tokens: tokens,
47+
}
48+
session.Messages = append(session.Messages, msg)
49+
log.Printf("[DEBATE %s] %s: %s (%d tokens)", sessionID, role, content, tokens)
50+
}
51+
}
52+
53+
func ResolveDebate(sessionID string) {
54+
if session, exists := ActiveDebates[sessionID]; exists {
55+
session.Status = "resolved"
56+
session.EndTime = time.Now()
57+
log.Printf("[COUNCIL SUPERVISOR] Resolved debate session: %s", sessionID)
58+
}
59+
}
60+
61+
func GetFleetDebateSummary() []byte {
62+
summary := []map[string]interface{}{}
63+
for _, session := range ActiveDebates {
64+
summary = append(summary, map[string]interface{}{
65+
"id": session.ID,
66+
"topic": session.Topic,
67+
"status": session.Status,
68+
"messages": len(session.Messages),
69+
})
70+
}
71+
bytes, _ := json.Marshal(summary)
72+
return bytes
73+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package autonomous
2+
3+
import (
4+
"log"
5+
"math/rand"
6+
"time"
7+
)
8+
9+
type Plan struct {
10+
ID string
11+
Risk string // "LOW", "HIGH"
12+
Topic string
13+
}
14+
15+
func EvaluatePlan(plan Plan) {
16+
if plan.Risk == "HIGH" {
17+
log.Printf("[COUNCIL SUPERVISOR] High-risk plan detected: %s. Initiating multi-agent debate.", plan.ID)
18+
19+
session := InitiateDebate(plan.Topic)
20+
21+
// Simulate Security Architect
22+
tokensArch := rand.Intn(100) + 50
23+
AddDebateMessage(session.ID, "Security Architect", "I have reviewed the plan. The anomaly vectors look safe, but we must verify the CI hooks.", tokensArch)
24+
time.Sleep(100 * time.Millisecond) // Simulated latency
25+
26+
// Simulate Senior Engineer
27+
tokensEng := rand.Intn(100) + 50
28+
AddDebateMessage(session.ID, "Senior Engineer", "Agreed. The hooks are isolated from the main orchestrator loop. Proceeding with execution.", tokensEng)
29+
time.Sleep(100 * time.Millisecond)
30+
31+
ResolveDebate(session.ID)
32+
} else {
33+
log.Printf("[COUNCIL SUPERVISOR] Low-risk plan %s auto-approved.", plan.ID)
34+
}
35+
}

backend-go/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func main() {
1717
http.HandleFunc("/api/system/status", api.HandleSystemStatus)
1818
http.HandleFunc("/api/system/ws", api.HandleWebSocket)
1919
http.HandleFunc("/api/system/autofix", api.HandleAutofix)
20+
http.HandleFunc("/api/fleet/summary", api.HandleFleetSummary)
2021

2122
port := os.Getenv("PORT")
2223
if port == "" {

backend-go/services/shadow_pilot.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
package services
22

33
import (
4+
"fmt"
45
"log"
56
"os/exec"
7+
"time"
8+
9+
"bobsgameonlinejava/backend-go/autonomous"
610
)
711

812
func LogAnomaly(message string, details map[string]interface{}) {
913
log.Printf("[SHADOW PILOT ANOMALY] %s: %v", message, details)
1014

15+
// Evaluate via autonomous debate
16+
plan := autonomous.Plan{
17+
ID: fmt.Sprintf("fix_%d", time.Now().Unix()),
18+
Risk: "HIGH",
19+
Topic: "Resolve: " + message,
20+
}
21+
autonomous.EvaluatePlan(plan)
22+
1123
// Trigger CI auto-fix logic locally
1224
cmd := exec.Command("go", "run", "autofix/autofix.go", "--diff-source=native-diff-monitor", "--apply-heuristics")
1325
cmd.Dir = ".." // Run from backend-go

0 commit comments

Comments
 (0)