using Microsoft.Extensions.Logging; using StellaOps.Evidence.Core; using StellaOps.Infrastructure.Postgres.Connections; using System.Text.Json; namespace StellaOps.Evidence.Persistence.Postgres; /// /// PostgreSQL (EF Core) implementation of . /// Stores evidence records with content-addressed IDs and tenant isolation via RLS. /// public sealed partial class PostgresEvidenceStore : IEvidenceStore { private const int CommandTimeoutSeconds = 30; private readonly EvidenceDataSource _dataSource; private readonly string _tenantId; private readonly ILogger _logger; private static readonly JsonSerializerOptions _jsonOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; /// /// Creates a new PostgreSQL evidence store for the specified tenant. /// /// Evidence data source. /// Tenant identifier for RLS. /// Logger instance. public PostgresEvidenceStore( EvidenceDataSource dataSource, string tenantId, ILogger logger) { ArgumentNullException.ThrowIfNull(dataSource); ArgumentException.ThrowIfNullOrWhiteSpace(tenantId); ArgumentNullException.ThrowIfNull(logger); _dataSource = dataSource; _tenantId = tenantId; _logger = logger; } private string GetSchemaName() => EvidenceDataSource.DefaultSchemaName; }