package redfishprofile

func xfusionProfile() Profile {
	return staticProfile{
		name:            "xfusion",
		priority:        20,
		safeForFallback: true,
		matchFn: func(s MatchSignals) int {
			score := 0
			if containsFold(s.ServiceRootVendor, "xfusion") {
				score += 90
			}
			for _, ns := range s.OEMNamespaces {
				if containsFold(ns, "xfusion") {
					score += 20
					break
				}
			}
			if containsFold(s.SystemManufacturer, "xfusion") || containsFold(s.ChassisManufacturer, "xfusion") {
				score += 40
			}
			return min(score, 100)
		},
		extendAcquisition: func(plan *AcquisitionPlan, _ MatchSignals) {
			ensureSnapshotMaxDocuments(plan, 120000)
			ensureSnapshotWorkers(plan, 4)
			ensurePrefetchWorkers(plan, 4)
			ensurePrefetchEnabled(plan, true)
			ensureETABaseline(plan, AcquisitionETABaseline{
				DiscoverySeconds:     10,
				SnapshotSeconds:      90,
				PrefetchSeconds:      20,
				CriticalPlanBSeconds: 30,
				ProfilePlanBSeconds:  20,
			})
			ensureRatePolicy(plan, AcquisitionRatePolicy{
				TargetP95LatencyMS:      800,
				ThrottleP95LatencyMS:    1800,
				MinSnapshotWorkers:      2,
				MinPrefetchWorkers:      1,
				DisablePrefetchOnErrors: true,
			})
			addPlanNote(plan, "xfusion ibmc acquisition extensions enabled")
		},
		applyAnalysisDirectives: func(d *AnalysisDirectives, _ MatchSignals) {
			d.EnableGenericGraphicsControllerDedup = true
		},
		refineAnalysis: func(plan *ResolvedAnalysisPlan, snapshot map[string]interface{}, discovered DiscoveredResources, _ MatchSignals) {
			if snapshotHasGPUProcessor(snapshot, discovered.SystemPaths) {
				plan.Directives.EnableProcessorGPUFallback = true
				addAnalysisNote(plan, "xfusion analysis enables processor-gpu fallback from snapshot topology")
			}
		},
	}
}
