From e0d58ac31d3f22e5af3e76f71a5d5ab478b64614 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Thu, 6 Aug 2026 13:39:25 +0900 Subject: [PATCH] fix: restore clock and validation contracts --- .../Features/Portfolio/VS08_DashboardEndpoint.cs | 4 ++-- src/KArtSell.Host/Program.cs | 9 ++++++--- .../Domain/VS08_DashboardPolicy.cs | 2 +- .../MarketData/VS03_IngestionIntegrationTests.cs | 4 ++-- .../VS03_MarketDataPolicyTests.cs | 10 +++++----- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/KArtSell.Host/Features/Portfolio/VS08_DashboardEndpoint.cs b/src/KArtSell.Host/Features/Portfolio/VS08_DashboardEndpoint.cs index 69332e7a..5322a68f 100644 --- a/src/KArtSell.Host/Features/Portfolio/VS08_DashboardEndpoint.cs +++ b/src/KArtSell.Host/Features/Portfolio/VS08_DashboardEndpoint.cs @@ -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; } diff --git a/src/KArtSell.Host/Program.cs b/src/KArtSell.Host/Program.cs index fe1a4353..1f1fe102 100644 --- a/src/KArtSell.Host/Program.cs +++ b/src/KArtSell.Host/Program.cs @@ -143,11 +143,13 @@ builder.Services.AddScoped(sp => new KArtSell.Host.Features.Portfolio.PortfolioRebalanceService( sp.GetRequiredService(), - sp.GetRequiredService())); + sp.GetRequiredService(), + sp.GetRequiredService())); builder.Services.AddScoped(sp => new KArtSell.Host.Features.Portfolio.RiskMetricsService( - sp.GetRequiredService())); + sp.GetRequiredService(), + sp.GetRequiredService())); // Risk & Stress (VS-06~07) builder.Services.AddScoped(sp => @@ -162,7 +164,8 @@ builder.Services.AddScoped(sp => // Dashboard (VS-08) builder.Services.AddScoped(sp => new KArtSell.Host.Features.Portfolio.DashboardService( - sp.GetRequiredService())); + sp.GetRequiredService(), + sp.GetRequiredService())); // Security Master (VS-02) - Temporarily disabled: ISecurityMasterRulesStore implementation pending // builder.Services.AddScoped(sp => diff --git a/src/KArtSell.Modules.ModelOperations/Domain/VS08_DashboardPolicy.cs b/src/KArtSell.Modules.ModelOperations/Domain/VS08_DashboardPolicy.cs index d89575f7..a71a0dc9 100644 --- a/src/KArtSell.Modules.ModelOperations/Domain/VS08_DashboardPolicy.cs +++ b/src/KArtSell.Modules.ModelOperations/Domain/VS08_DashboardPolicy.cs @@ -3,7 +3,7 @@ namespace KArtSell.Modules.ModelOperations.Domain; /// /// 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. /// // Note: This policy combines results from VS-04~07 components diff --git a/tests/KArtSell.Integration.Tests/Features/MarketData/VS03_IngestionIntegrationTests.cs b/tests/KArtSell.Integration.Tests/Features/MarketData/VS03_IngestionIntegrationTests.cs index 28a196c7..e4bd5f7e 100644 --- a/tests/KArtSell.Integration.Tests/Features/MarketData/VS03_IngestionIntegrationTests.cs +++ b/tests/KArtSell.Integration.Tests/Features/MarketData/VS03_IngestionIntegrationTests.cs @@ -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); diff --git a/tests/KArtSell.ModelOperations.UnitTests/VS03_MarketDataPolicyTests.cs b/tests/KArtSell.ModelOperations.UnitTests/VS03_MarketDataPolicyTests.cs index 31c04ce0..2e014fae 100644 --- a/tests/KArtSell.ModelOperations.UnitTests/VS03_MarketDataPolicyTests.cs +++ b/tests/KArtSell.ModelOperations.UnitTests/VS03_MarketDataPolicyTests.cs @@ -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 -- 2.52.0