package redfishprofile

func hpeProfile() Profile {
	return staticProfile{
		name:            "hpe",
		priority:        20,
		safeForFallback: true,
		matchFn: func(s MatchSignals) int {
			score := 0
			if containsFold(s.SystemManufacturer, "hpe") ||
				containsFold(s.SystemManufacturer, "hewlett packard") ||
				containsFold(s.ChassisManufacturer, "hpe") ||
				containsFold(s.ChassisManufacturer, "hewlett packard") {
				score += 80
			}
			for _, ns := range s.OEMNamespaces {
				if containsFold(ns, "hpe") {
					score += 30
					break
				}
			}
			if containsFold(s.ServiceRootProduct, "ilo") {
				score += 30
			}
			if containsFold(s.ManagerManufacturer, "hpe") || containsFold(s.ManagerManufacturer, "ilo") {
				score += 20
			}
			return min(score, 100)
		},
		extendAcquisition: func(plan *AcquisitionPlan, _ MatchSignals) {
			// HPE ProLiant SmartStorage RAID controller inventory is not reachable
			// via standard Redfish Storage paths — it requires the HPE OEM SmartStorage tree.
			ensureScopedPathPolicy(plan, AcquisitionScopedPathPolicy{
				SystemCriticalSuffixes: []string{
					"/SmartStorage",
					"/SmartStorageConfig",
				},
				ManagerCriticalSuffixes: []string{
					"/LicenseService",
				},
			})
			// HPE iLO responds more slowly than average BMCs under load; give the
			// ETA estimator a realistic baseline so progress reports are accurate.
			ensureETABaseline(plan, AcquisitionETABaseline{
				DiscoverySeconds:     12,
				SnapshotSeconds:      180,
				PrefetchSeconds:      30,
				CriticalPlanBSeconds: 40,
				ProfilePlanBSeconds:  25,
			})
			ensureRecoveryPolicy(plan, AcquisitionRecoveryPolicy{
				EnableProfilePlanB: true,
			})
			// HPE iLO starts throttling under high request rates.  Setting a higher
			// latency tolerance prevents the adaptive throttler from treating normal
			// iLO slowness as a reason to stall the collection.
			ensureRatePolicy(plan, AcquisitionRatePolicy{
				TargetP95LatencyMS:      1200,
				ThrottleP95LatencyMS:    2500,
				MinSnapshotWorkers:      2,
				MinPrefetchWorkers:      1,
				DisablePrefetchOnErrors: true,
			})
			addPlanNote(plan, "hpe ilo acquisition extensions enabled")
		},
	}
}
