wip: doctor/cli/docs/api to vector db consolidation; api hardening for descriptions, tenant, and scopes; migrations and conversions of all DALs to EF v10

This commit is contained in:
master
2026-02-23 15:30:50 +02:00
parent bd8fee6ed8
commit e746577380
1424 changed files with 81225 additions and 25251 deletions

View File

@@ -1,9 +1,11 @@
// -----------------------------------------------------------------------------
// PostgresArtifactIndexRepository.Index.cs
// Sprint: SPRINT_20260118_017_Evidence_artifact_store_unification
// Task: AS-003 - Create ArtifactStore PostgreSQL index
// Description: Index write operations for the artifact repository
// Sprint: SPRINT_20260222_077_Artifact_infrastructure_dal_to_efcore
// Task: ARTIF-EF-03 - Convert DAL repositories to EF Core
// Description: Index write operations for the artifact repository (EF Core)
// -----------------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
namespace StellaOps.Artifact.Infrastructure;
public sealed partial class PostgresArtifactIndexRepository
@@ -12,22 +14,42 @@ public sealed partial class PostgresArtifactIndexRepository
public async Task IndexAsync(ArtifactIndexEntry entry, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(entry);
await using var connection = await DataSource.OpenConnectionAsync(_tenantKey, "writer", ct)
.ConfigureAwait(false);
await using var command = CreateCommand(ArtifactIndexSql.Insert, connection);
AddParameter(command, "id", entry.Id);
AddParameter(command, "tenant_id", entry.TenantId);
AddParameter(command, "bom_ref", entry.BomRef);
AddParameter(command, "serial_number", entry.SerialNumber);
AddParameter(command, "artifact_id", entry.ArtifactId);
AddParameter(command, "storage_key", entry.StorageKey);
AddParameter(command, "artifact_type", entry.Type.ToString());
AddParameter(command, "content_type", entry.ContentType);
AddParameter(command, "sha256", entry.Sha256);
AddParameter(command, "size_bytes", entry.SizeBytes);
AddParameter(command, "created_at", entry.CreatedAt);
// The original SQL used INSERT ... ON CONFLICT DO UPDATE (multi-column conflict clause).
// Using ExecuteSqlRawAsync to preserve the exact upsert semantics per cutover strategy guidance.
await using var dbContext = await CreateWriteContextAsync(ct);
await command.ExecuteNonQueryAsync(ct).ConfigureAwait(false);
await dbContext.Database.ExecuteSqlRawAsync(
"""
INSERT INTO evidence.artifact_index (
id, tenant_id, bom_ref, serial_number, artifact_id, storage_key,
artifact_type, content_type, sha256, size_bytes, created_at
) VALUES (
{0}, {1}, {2}, {3}, {4}, {5},
{6}, {7}, {8}, {9}, {10}
)
ON CONFLICT (tenant_id, bom_ref, serial_number, artifact_id)
DO UPDATE SET
storage_key = EXCLUDED.storage_key,
artifact_type = EXCLUDED.artifact_type,
content_type = EXCLUDED.content_type,
sha256 = EXCLUDED.sha256,
size_bytes = EXCLUDED.size_bytes,
updated_at = NOW(),
is_deleted = FALSE,
deleted_at = NULL
""",
entry.Id,
entry.TenantId,
entry.BomRef,
entry.SerialNumber,
entry.ArtifactId,
entry.StorageKey,
entry.Type.ToString(),
entry.ContentType,
entry.Sha256,
entry.SizeBytes,
entry.CreatedAt.UtcDateTime,
ct).ConfigureAwait(false);
}
}