// -----------------------------------------------------------------------------
// SourcesPlugin.cs
// Sprint: SPRINT_20260114_SOURCES_SETUP
// Task: 12.1 - Sources Doctor Plugin
// Description: Doctor plugin providing advisory source connectivity diagnostics
// -----------------------------------------------------------------------------
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Concelier.Core.Sources;
using StellaOps.Doctor.Models;
using StellaOps.Doctor.Plugins;
using StellaOps.Doctor.Plugins.Sources.Checks;
namespace StellaOps.Doctor.Plugins.Sources;
///
/// Doctor plugin for advisory data source diagnostics.
/// Provides connectivity checks for all configured CVE/advisory data sources.
///
public sealed class SourcesPlugin : IDoctorPlugin
{
///
public string PluginId => "stellaops.doctor.sources";
///
public string DisplayName => "Advisory Sources";
///
public DoctorCategory Category => DoctorCategory.Sources;
///
public Version Version => new(1, 0, 0);
///
public Version MinEngineVersion => new(1, 0, 0);
///
public bool IsAvailable(IServiceProvider services)
{
// Plugin is available if ISourceRegistry is registered
return services.GetService() is not null;
}
///
public IReadOnlyList GetChecks(DoctorPluginContext context)
{
var registry = context.Services.GetService();
if (registry is null)
{
return [];
}
var checks = new List
{
// Overall source mode configuration check
new SourceModeConfiguredCheck(),
// Mirror server checks
new MirrorServerAuthCheck(),
new MirrorServerRateLimitCheck()
};
// Generate dynamic checks for each registered source
foreach (var source in registry.GetAllSources())
{
checks.Add(new SourceConnectivityCheck(source.Id, source.DisplayName));
}
return checks;
}
///
public Task InitializeAsync(DoctorPluginContext context, CancellationToken ct)
{
// No initialization required
return Task.CompletedTask;
}
}