mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 20:53:06 +00:00
2c48968ec6
New SessionAnnotations table (PK=tenantId, RK={sessionId}_{lane}, lanes
operator/tenantadmin/globaladmin) storing structured verdicts + notes with
server-stamped authorship and a fired-rule-id snapshot for join-free
rule-quality evaluation. Per-lane write matrix re-gated in-function with
own-tenant binding; the globaladmin lane is platform-internal and filtered
from tenant callers. Portal: SessionAnnotationsCard on session detail.
MCP: list_session_annotations (ga) + annotate_session (strictGa, GA lane
only) + annotations key in get_session_summary. Lifecycle: cascade steps
17-19, offboarding wipe, critical-backup member. Privacy page gains the
customer-entered-content line.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
84 lines
4.8 KiB
C#
84 lines
4.8 KiB
C#
using AutopilotMonitor.Shared.DataAccess;
|
|
using AutopilotMonitor.Functions.DataAccess.TableStorage;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AutopilotMonitor.Functions.DataAccess
|
|
{
|
|
/// <summary>
|
|
/// Extension methods for registering Data Access Layer services.
|
|
/// Currently registers Azure Table Storage implementations.
|
|
/// To switch to Cosmos DB, replace the implementation registrations here.
|
|
/// </summary>
|
|
public static class DataAccessServiceExtensions
|
|
{
|
|
/// <summary>
|
|
/// Registers all Data Access Layer services with Table Storage implementations.
|
|
/// </summary>
|
|
public static IServiceCollection AddTableStorageDataAccess(this IServiceCollection services)
|
|
{
|
|
// Event publisher (no-op by default; replace with Event Hub/Service Bus implementation)
|
|
services.AddSingleton<IDataEventPublisher, NullDataEventPublisher>();
|
|
|
|
// Storage initializer
|
|
services.AddSingleton<IStorageInitializer, TableStorageInitializer>();
|
|
|
|
// Repository implementations (delegate to existing TableStorageService)
|
|
services.AddSingleton<ISessionRepository, TableSessionRepository>();
|
|
services.AddSingleton<IRuleRepository, TableRuleRepository>();
|
|
services.AddSingleton<IMetricsRepository, TableMetricsRepository>();
|
|
services.AddSingleton<IMaintenanceRepository, TableMaintenanceRepository>();
|
|
services.AddSingleton<IVulnerabilityRepository, TableVulnerabilityRepository>();
|
|
services.AddSingleton<IAdminRepository, TableAdminRepository>();
|
|
services.AddSingleton<IConfigRepository, TableConfigRepository>();
|
|
services.AddSingleton<IFeedbackRepository, TableFeedbackRepository>();
|
|
services.AddSingleton<ISessionAnnotationRepository, TableSessionAnnotationRepository>();
|
|
services.AddSingleton<IBootstrapRepository, TableBootstrapRepository>();
|
|
services.AddSingleton<INotificationRepository, TableNotificationRepository>();
|
|
services.AddSingleton<ITenantNotificationRepository, TableTenantNotificationRepository>();
|
|
services.AddSingleton<ISlaTenantStatusRepository, TableSlaTenantStatusRepository>();
|
|
services.AddSingleton<IHardwareRejectionNotificationTracker, TableHardwareRejectionNotificationTracker>();
|
|
services.AddSingleton<IDeviceSecurityRepository, TableDeviceSecurityRepository>();
|
|
services.AddSingleton<IUserUsageRepository, TableUserUsageRepository>();
|
|
services.AddSingleton<IDistressReportRepository, TableDistressReportRepository>();
|
|
services.AddSingleton<IOpsEventRepository, TableOpsEventRepository>();
|
|
|
|
// V2 Decision Engine repositories (Plan §M5).
|
|
services.AddSingleton<ISignalRepository, TableSignalRepository>();
|
|
services.AddSingleton<IDecisionTransitionRepository, TableDecisionTransitionRepository>();
|
|
services.AddSingleton<IIndexTableRepository, TableIndexRepository>();
|
|
|
|
// Tenant-offboarding audit (Marker / History / ByTenant pointer).
|
|
services.AddSingleton<IOffboardingAuditRepository, TableOffboardingAuditRepository>();
|
|
// Tenant-offboarding customs archive (PR3.B): snapshot of GatherRules /
|
|
// AnalyzeRules / ImeLogPatterns rows that were wiped during Phase 2.D-archive,
|
|
// surfaced via the Global Admin /admin/customs-archive page.
|
|
services.AddSingleton<ITenantCustomsArchiveRepository, TableTenantCustomsArchiveRepository>();
|
|
|
|
// Pre-write snapshots of TenantConfiguration/AdminConfiguration rows;
|
|
// constructor dependency of TableConfigRepository's save hook.
|
|
services.AddSingleton<IConfigBackupRepository, TableConfigBackupRepository>();
|
|
|
|
// Graph add-on permission feature: per-tenant cache of Intune script display names.
|
|
services.AddSingleton<IScriptNameCacheRepository, TableScriptNameCacheRepository>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replaces the default NullDataEventPublisher with a custom implementation.
|
|
/// Call this AFTER AddTableStorageDataAccess() to override.
|
|
/// Example: services.AddEventStreaming<EventHubPublisher>();
|
|
/// </summary>
|
|
public static IServiceCollection AddEventStreaming<TPublisher>(this IServiceCollection services)
|
|
where TPublisher : class, IDataEventPublisher
|
|
{
|
|
// Remove existing registration and replace
|
|
var descriptor = services.FirstOrDefault(d => d.ServiceType == typeof(IDataEventPublisher));
|
|
if (descriptor != null)
|
|
services.Remove(descriptor);
|
|
|
|
services.AddSingleton<IDataEventPublisher, TPublisher>();
|
|
return services;
|
|
}
|
|
}
|
|
}
|