Initial commit: AetherForge Linux (forge-mesh) v0.1.0-dev
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
33
internal/fleet/adaptive.go
Normal file
33
internal/fleet/adaptive.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package fleet
|
||||
|
||||
import "context"
|
||||
|
||||
// AdaptiveStrategy resolves tier order from phenotype learning or defaults.
|
||||
type AdaptiveStrategy struct {
|
||||
Store *Store
|
||||
}
|
||||
|
||||
// OrderForHost returns tier execution order for a host, cloning from phenotype siblings when available.
|
||||
func (a *AdaptiveStrategy) OrderForHost(ctx context.Context, hostID string) ([]int, error) {
|
||||
report, err := RunRecon()
|
||||
if err != nil {
|
||||
return defaultOrderInts(), nil
|
||||
}
|
||||
phenotype := PhenotypeFromRecon(report)
|
||||
_ = a.Store.SetHostPhenotype(ctx, hostID, ReconJSON(report), phenotype)
|
||||
return a.Store.GetAdaptiveOrder(ctx, phenotype)
|
||||
}
|
||||
|
||||
// CloneFromSibling copies winning tier order from a sibling with same phenotype.
|
||||
func (a *AdaptiveStrategy) CloneFromSibling(ctx context.Context, hostID string) ([]int, error) {
|
||||
report, err := RunRecon()
|
||||
if err != nil {
|
||||
return defaultOrderInts(), err
|
||||
}
|
||||
phenotype := PhenotypeFromRecon(report)
|
||||
order, err := a.Store.GetAdaptiveOrder(ctx, phenotype)
|
||||
if err != nil {
|
||||
return defaultOrderInts(), err
|
||||
}
|
||||
return order, nil
|
||||
}
|
||||
Reference in New Issue
Block a user