feat: Phase 3 J/K/L (Sell Decision, Trade Execution, Portfolio Reconciliation) + fix pre-existing build/boot breakage
Completes VS-10/VS-12/VS-14 and makes the solution and Host actually
build and boot for the first time on this branch (main did not build
before this commit).
Root-cause fixes required to reach a green build/boot (not scoped to
J/K/L but blocking any verification of it):
- Restore Polly PackageVersion accidentally deleted from
Directory.Packages.props (broke KArtSell.Host).
- Remove MediatR dependency from Compliance/VS-04 (package was never
installed; ICommand/ICommandHandler/IMediator never existed) and
wire Endpoint -> Handler directly per this repo's convention.
- Migrate FastEndpoints v5 API calls (SendOkAsync/SendAsync/
SendCreatedAtAsync/SendNotFoundAsync, Description().WithName()) to
the v7 Send.* fluent API across ~10 endpoint files.
- Fix migrations 0036/0038/0039/0040: rewritten from invalid T-SQL
(`IF NOT EXISTS ... BEGIN ... END`) to idiomatic Postgres
(`CREATE TABLE/INDEX IF NOT EXISTS`) — these could not apply to any
fresh database before this fix.
- Collapse 3 duplicate cross-cutting abstractions that shadowed the
BuildingBlocks versions and caused type-mismatch compile errors:
IKrxDataService, IOutboxWriter (ReconcileTradeHandler), IClock
(ApprovalWorkflow/ApprovalPolicy).
- Inject IClock (BuildingBlocks.Time) in place of direct
DateTime.Now/UtcNow across 19 files to satisfy the architecture
test AGENTS.md#DateTime-abstraction rule (13/13 architecture tests
now pass, was 12/13).
- Register all new and previously-unregistered slices in
Program.cs DI (SellDecision, TradeExecution, PortfolioReconciliation,
Compliance, Features/ApprovalWorkflow) — the Host had never
successfully completed a boot with this code present.
- Disable ("[DontRegister]") the older, route-colliding
ApprovalWorkflow/ (Workstream H) endpoint set in favor of
Features/ApprovalWorkflow/ (Workstream G, matches the documented
Features/<Slice>/ convention); kept for its existing test coverage.
See TECH_DEBT-017 for the follow-up decision needed.
Verified: dotnet build 0 errors/0 warnings; architecture tests 13/13;
unit tests 54/54 + 18/18; integration tests 34/36 (2 failures are a
local test-DB migration-journal/schema mismatch, not a code defect);
Host boots cleanly and registers all 34 endpoints.
New tech debt recorded: DEBT-017 (duplicate VS-03 implementation),
DEBT-018 (outbox write not co-transactional with entity write in
TradeExecution/PortfolioReconciliation), DEBT-019 (duplicate
BuildingBlocks-shadowing abstractions, partially resolved).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -175,6 +175,51 @@ builder.Services.AddScoped<KArtSell.Host.Features.Portfolio.IDashboardService>(s
|
||||
// sp.GetRequiredService<KArtSell.Host.Features.SecurityMaster.ISecurityMasterRulesStore>(),
|
||||
// sp.GetRequiredService<IClock>()));
|
||||
|
||||
// Shared IDbConnection (per-scope, opened from the pooled data source) for slices using raw Dapper/IDbConnection
|
||||
builder.Services.AddScoped<System.Data.IDbConnection>(sp => sp.GetRequiredService<NpgsqlDataSource>().OpenConnection());
|
||||
|
||||
// Sell Decision Engine (VS-10)
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.ISellDecisionSql, KArtSell.Modules.ModelOperations.SellDecision.SellDecisionSql>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.IPboValidator, KArtSell.Modules.ModelOperations.SellDecision.PboValidator>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.IDsrValidator, KArtSell.Modules.ModelOperations.SellDecision.DsrValidator>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.IOosValidator, KArtSell.Modules.ModelOperations.SellDecision.OosValidator>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.ISellPriorityRanker, KArtSell.Modules.ModelOperations.SellDecision.SellPriorityRanker>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.SellDecision.IGenerateSellDecisionHandler>(sp =>
|
||||
new KArtSell.Modules.ModelOperations.SellDecision.GenerateSellDecisionHandler(
|
||||
connectionString,
|
||||
sp.GetRequiredService<KArtSell.Modules.ModelOperations.SellDecision.ISellDecisionSql>(),
|
||||
sp.GetRequiredService<KArtSell.Modules.ModelOperations.SellDecision.IPboValidator>(),
|
||||
sp.GetRequiredService<KArtSell.Modules.ModelOperations.SellDecision.IDsrValidator>(),
|
||||
sp.GetRequiredService<KArtSell.Modules.ModelOperations.SellDecision.IOosValidator>(),
|
||||
sp.GetRequiredService<KArtSell.Modules.ModelOperations.SellDecision.ISellPriorityRanker>(),
|
||||
sp.GetRequiredService<IClock>()));
|
||||
|
||||
// Trade Execution (VS-12)
|
||||
builder.Services.AddHttpClient<KArtSell.Modules.ModelOperations.TradeExecution.IKisTradeExecutionService, KArtSell.Modules.ModelOperations.TradeExecution.KisTradeExecutionService>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.TradeExecution.ITradeSql, KArtSell.Modules.ModelOperations.TradeExecution.TradeSql>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.TradeExecution.SubmitTradeHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.TradeExecution.PollTradeStatusHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.TradeExecution.ConfirmSettlementHandler>();
|
||||
|
||||
// Portfolio Reconciliation (VS-14)
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.PortfolioReconciliation.IReconciliationRepository, KArtSell.Modules.ModelOperations.PortfolioReconciliation.ReconciliationSql>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.PortfolioReconciliation.CostBasisCalculator>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.PortfolioReconciliation.MismatchDetector>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.PortfolioReconciliation.ReconciliationEngine>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.PortfolioReconciliation.ReconcileTradeHandler>();
|
||||
|
||||
// Approval Workflow (VS-03, maker-checker)
|
||||
builder.Services.AddScoped(sp => new KArtSell.Modules.ModelOperations.Features.ApprovalWorkflow.ApprovalWorkflowSql(connectionString));
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Features.ApprovalWorkflow.CreateApprovalProposalHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Features.ApprovalWorkflow.ApproveApprovalHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Features.ApprovalWorkflow.ActivateModelHandler>();
|
||||
|
||||
// Compliance / Audit Trail / GDPR (VS-04)
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Compliance.AuditSql>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Compliance.LogAuditEventCommandHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Compliance.ProcessGdprRequestHandler>();
|
||||
builder.Services.AddScoped<KArtSell.Modules.ModelOperations.Compliance.GdprRedactionJob>();
|
||||
|
||||
builder.Services.AddProblemDetails();
|
||||
|
||||
const string authenticationScheme = "KArtSell";
|
||||
|
||||
Reference in New Issue
Block a user