audit, advisories and doctors/setup work

This commit is contained in:
master
2026-01-13 18:53:39 +02:00
parent 9ca7cb183e
commit d7be6ba34b
811 changed files with 54242 additions and 4056 deletions

View File

@@ -11,12 +11,16 @@ using Microsoft.Extensions.Options;
using StellaOps.AdvisoryAI.Caching;
using StellaOps.AdvisoryAI.Chat;
using StellaOps.AdvisoryAI.DependencyInjection;
using StellaOps.AdvisoryAI.Explanation;
using StellaOps.AdvisoryAI.Inference;
using StellaOps.AdvisoryAI.Metrics;
using StellaOps.AdvisoryAI.Guardrails;
using StellaOps.AdvisoryAI.Outputs;
using StellaOps.AdvisoryAI.PolicyStudio;
using StellaOps.AdvisoryAI.Providers;
using StellaOps.AdvisoryAI.Queue;
using StellaOps.AdvisoryAI.Remediation;
using StellaOps.OpsMemory.Storage;
namespace StellaOps.AdvisoryAI.Hosting;
@@ -100,6 +104,8 @@ public static class ServiceCollectionExtensions
// Register deterministic providers (allow test injection)
services.TryAddSingleton<IGuidProvider>(SystemGuidProvider.Instance);
services.TryAddSingleton<StellaOps.Determinism.IGuidProvider>(
StellaOps.Determinism.SystemGuidProvider.Instance);
services.TryAddSingleton(TimeProvider.System);
services.Replace(ServiceDescriptor.Singleton<IAdvisoryTaskQueue, FileSystemAdvisoryTaskQueue>());
@@ -107,17 +113,38 @@ public static class ServiceCollectionExtensions
services.Replace(ServiceDescriptor.Singleton<IAdvisoryOutputStore, FileSystemAdvisoryOutputStore>());
services.TryAddSingleton<AdvisoryAiMetrics>();
// Explanation services (SPRINT_20251226_015_AI_zastava_companion)
services.TryAddSingleton<IEvidenceRetrievalService, NullEvidenceRetrievalService>();
services.TryAddSingleton<IExplanationPromptService, DefaultExplanationPromptService>();
services.TryAddSingleton<IExplanationInferenceClient, NullExplanationInferenceClient>();
services.TryAddSingleton<ICitationExtractor, NullCitationExtractor>();
services.TryAddSingleton<IExplanationStore, InMemoryExplanationStore>();
services.TryAddSingleton<IExplanationGenerator, EvidenceAnchoredExplanationGenerator>();
// Remediation services (SPRINT_20251226_016_AI_remedy_autopilot)
services.TryAddSingleton<IRemediationPlanner, NullRemediationPlanner>();
// Policy studio services (SPRINT_20251226_017_AI_policy_copilot)
services.TryAddSingleton<IPolicyIntentStore, InMemoryPolicyIntentStore>();
services.TryAddSingleton<IPolicyIntentParser, NullPolicyIntentParser>();
services.TryAddSingleton<IPolicyRuleGenerator, LatticeRuleGenerator>();
services.TryAddSingleton<ITestCaseSynthesizer, PropertyBasedTestSynthesizer>();
// Chat services (SPRINT_20260107_006_003 CH-005)
services.AddOptions<ConversationOptions>()
.Bind(configuration.GetSection("AdvisoryAI:Chat"))
.ValidateOnStart();
services.TryAddSingleton<IGuidGenerator, DefaultGuidGenerator>();
services.TryAddSingleton<IConversationService, ConversationService>();
services.TryAddSingleton<ConversationContextBuilder>();
services.TryAddSingleton<ChatPromptAssembler>();
services.TryAddSingleton<ChatResponseStreamer>();
services.TryAddSingleton<GroundingValidator>();
services.TryAddSingleton<ActionProposalParser>();
// Action policy gate and audit defaults (SPRINT_20260109_011_004_BE)
services.AddDefaultActionPolicyIntegration();
// Object link resolvers (SPRINT_20260109_011_002 OMCI-005)
services.TryAddSingleton<ITypedLinkResolver, OpsMemoryLinkResolver>();
services.TryAddSingleton<IObjectLinkResolver, CompositeObjectLinkResolver>();
@@ -142,6 +169,16 @@ public static class ServiceCollectionExtensions
target.RequireCitations = source.RequireCitations;
if (source.EntropyThreshold.HasValue && source.EntropyThreshold.Value >= 0)
{
target.EntropyThreshold = source.EntropyThreshold.Value;
}
if (source.EntropyMinLength.HasValue && source.EntropyMinLength.Value >= 0)
{
target.EntropyMinLength = source.EntropyMinLength.Value;
}
var defaults = target.BlockedPhrases.ToList();
var merged = new SortedSet<string>(defaults, StringComparer.OrdinalIgnoreCase);
@@ -168,15 +205,48 @@ public static class ServiceCollectionExtensions
}
}
if (merged.Count == 0)
if (merged.Count > 0)
{
return;
target.BlockedPhrases.Clear();
foreach (var phrase in merged)
{
target.BlockedPhrases.Add(phrase);
}
}
target.BlockedPhrases.Clear();
foreach (var phrase in merged)
var allowlistDefaults = target.AllowlistPatterns.ToList();
var allowlist = new SortedSet<string>(allowlistDefaults, StringComparer.OrdinalIgnoreCase);
if (source.AllowlistPatterns is { Count: > 0 })
{
target.BlockedPhrases.Add(phrase);
foreach (var pattern in source.AllowlistPatterns)
{
if (!string.IsNullOrWhiteSpace(pattern))
{
allowlist.Add(pattern.Trim());
}
}
}
if (!string.IsNullOrWhiteSpace(source.AllowlistFile))
{
var resolvedPath = ResolveGuardrailPath(source.AllowlistFile!, environment);
foreach (var pattern in GuardrailAllowlistLoader.Load(resolvedPath))
{
if (!string.IsNullOrWhiteSpace(pattern))
{
allowlist.Add(pattern.Trim());
}
}
}
if (allowlist.Count > 0)
{
target.AllowlistPatterns.Clear();
foreach (var pattern in allowlist)
{
target.AllowlistPatterns.Add(pattern);
}
}
}