fix: restore clock and validation contracts #5

Merged
kjh2064 merged 1 commits from agent/restore-clock-contract-build into main 2026-08-06 13:39:59 +09:00
5 changed files with 16 additions and 13 deletions
@@ -208,11 +208,11 @@ public class DashboardService : IDashboardService
a.Message)).ToList(),
HealthScore = healthScore,
RiskInsights = riskInsights,
LastUpdate = _clock.UtcNow.DateTime,
LastUpdate = _clock.UtcNow.UtcDateTime,
};
// Cache result
_cache[portfolioId] = (_clock.UtcNow, response);
_cache[portfolioId] = (_clock.UtcNow.UtcDateTime, response);
return response;
}
+6 -3
View File
@@ -143,11 +143,13 @@ builder.Services.AddScoped<KArtSell.Host.Features.MarketData.IMarketDataIngestio
builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IPortfolioRebalanceService>(sp =>
new KArtSell.Host.Features.Portfolio.PortfolioRebalanceService(
sp.GetRequiredService<NpgsqlDataSource>(),
sp.GetRequiredService<IBackgroundJobClient>()));
sp.GetRequiredService<IBackgroundJobClient>(),
sp.GetRequiredService<IClock>()));
builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IRiskMetricsService>(sp =>
new KArtSell.Host.Features.Portfolio.RiskMetricsService(
sp.GetRequiredService<NpgsqlDataSource>()));
sp.GetRequiredService<NpgsqlDataSource>(),
sp.GetRequiredService<IClock>()));
// Risk & Stress (VS-06~07)
builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IStressTestService>(sp =>
@@ -162,7 +164,8 @@ builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IAlertService>(sp =>
// Dashboard (VS-08)
builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IDashboardService>(sp =>
new KArtSell.Host.Features.Portfolio.DashboardService(
sp.GetRequiredService<NpgsqlDataSource>()));
sp.GetRequiredService<NpgsqlDataSource>(),
sp.GetRequiredService<IClock>()));
// Security Master (VS-02) - Temporarily disabled: ISecurityMasterRulesStore implementation pending
// builder.Services.AddScoped<KArtSell.Host.Features.SecurityMaster.ISecurityMasterSyncHandler>(sp =>
@@ -3,7 +3,7 @@ namespace KArtSell.Modules.ModelOperations.Domain;
/// <summary>
/// VS-08 DOMAIN: Dashboard aggregation policy
/// Pure business logic for combining portfolio, risk metrics, stress, alerts into unified snapshot
/// No I/O, no DateTime.Now (all times injected)
/// No I/O; time-dependent values are supplied by callers.
/// </summary>
// Note: This policy combines results from VS-04~07 components
@@ -25,7 +25,7 @@ public sealed class MarketDataIngestionUnitTests
Guid.NewGuid(), "AAPL", DateOnly.FromDateTime(DateTime.UtcNow),
100m, 102m, 99m, 101m, 1_000_000, DateTime.UtcNow, 1, "KRX", Guid.NewGuid().ToString());
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.True(result.IsValid);
Assert.Empty(result.Errors);
@@ -38,7 +38,7 @@ public sealed class MarketDataIngestionUnitTests
Guid.NewGuid(), "AAPL", DateOnly.FromDateTime(DateTime.UtcNow),
-100m, 110m, 90m, 105m, 1_000_000, DateTime.UtcNow, 1, "KRX", Guid.NewGuid().ToString());
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.False(result.IsValid);
Assert.NotEmpty(result.Errors);
@@ -22,7 +22,7 @@ public class VS03_MarketDataPolicyTests
DataSource: "KRX",
CorrelationId: "test-123");
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.True(result.IsValid);
Assert.Empty(result.Errors);
@@ -46,7 +46,7 @@ public class VS03_MarketDataPolicyTests
DataSource: "KRX",
CorrelationId: "test-123");
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.False(result.IsValid);
Assert.Contains("Open price must be > 0", result.Errors);
@@ -69,7 +69,7 @@ public class VS03_MarketDataPolicyTests
DataSource: "KRX",
CorrelationId: "test-123");
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.False(result.IsValid);
Assert.Contains("High must be >= Low", result.Errors);
@@ -92,7 +92,7 @@ public class VS03_MarketDataPolicyTests
DataSource: "KRX",
CorrelationId: "test-123");
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.False(result.IsValid);
Assert.Contains("cannot be in the future", result.Errors[0]);
@@ -115,7 +115,7 @@ public class VS03_MarketDataPolicyTests
DataSource: "KRX",
CorrelationId: "test-123");
var result = MarketDataPolicy.ValidatePrice(price);
var result = MarketDataPolicy.ValidatePrice(price, DateOnly.FromDateTime(DateTime.UtcNow));
Assert.True(result.IsValid);
Assert.True(result.QualityScore < 80); // Quality degraded but still valid