Phase 3 J/K/L: Sell Decision + Trade Execution + Portfolio Reconciliation (+ fix pre-existing build/boot breakage) #28

Merged
kjh2064 merged 1 commits from feat/L-vs14-portfolio-reconciliation into main 2026-08-07 19:55:21 +09:00
Owner

Summary

  • Completes VS-10 (Sell Decision Engine), VS-12 (Trade Execution), VS-14 (Portfolio Reconciliation) per PHASE_3_IMPLEMENTATION_PLAN.md.
  • Fixes pre-existing build/boot breakage discovered while verifying this branch: main did not build and the Host had never successfully booted before this PR (see "Root-cause fixes" below). These were required to verify anything, not optional cleanup.

Root-cause fixes (blocking, pre-existing on main)

  • Restored Polly PackageVersion accidentally deleted from Directory.Packages.props (broke KArtSell.Host).
  • Removed a MediatR dependency in Compliance/VS-04 that was never actually installed (ICommand/ICommandHandler/IMediator never existed in this repo) and wired Endpoint -> Handler directly, matching this repo's established convention.
  • Migrated FastEndpoints v5 API calls (SendOkAsync/SendAsync/SendCreatedAtAsync/SendNotFoundAsync, Description().WithName()) to the v7 Send.* fluent API across ~10 endpoint files (the repo is pinned to FastEndpoints 7.1.0).
  • Fixed 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.
  • Collapsed 3 duplicate cross-cutting abstractions that shadowed the BuildingBlocks versions and caused type-mismatch compile errors: IKrxDataService, IOutboxWriter (ReconcileTradeHandler), IClock (ApprovalWorkflow/ApprovalPolicy).
  • Injected IClock (BuildingBlocks.Time) in place of direct DateTime.Now/UtcNow across 19 files to satisfy the architecture test for the AGENTS.md "no direct system time" rule (architecture tests now 13/13, were 12/13).
  • Registered 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.
  • Disabled ([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 DEBT-017 for the follow-up decision needed.

New tech debt recorded (TECH_DEBT_REGISTER.md)

  • DEBT-017: duplicate VS-03 Approval Workflow implementation — needs an architect decision on deleting the old slice.
  • DEBT-018: outbox write not co-transactional with entity write in TradeExecution/PortfolioReconciliation (crash between the two writes drops the event silently).
  • DEBT-019: pattern of duplicate abstractions shadowing BuildingBlocks (partially resolved this PR); recommends a pre-implementation checklist step for future slices.

Test plan

  • dotnet build KArtSell.sln -c Release — 0 errors, 0 warnings
  • Architecture tests: 13/13 pass
  • Unit tests: 54/54 (ModelOperations) + 18/18 (SignalEngine) pass
  • Integration tests: 34/36 pass — the 2 failures are a local test-DB migration-journal/schema mismatch (pre-existing environment issue), not a code defect
  • Host boots cleanly end-to-end and registers all 34 endpoints (Registered 34 endpoints, Now listening on :5002) — verified by actually starting it, not just by unit tests

🤖 Generated with Claude Code

## Summary - Completes VS-10 (Sell Decision Engine), VS-12 (Trade Execution), VS-14 (Portfolio Reconciliation) per `PHASE_3_IMPLEMENTATION_PLAN.md`. - Fixes pre-existing build/boot breakage discovered while verifying this branch: **`main` did not build and the Host had never successfully booted** before this PR (see "Root-cause fixes" below). These were required to verify anything, not optional cleanup. ## Root-cause fixes (blocking, pre-existing on `main`) - Restored `Polly` `PackageVersion` accidentally deleted from `Directory.Packages.props` (broke `KArtSell.Host`). - Removed a `MediatR` dependency in Compliance/VS-04 that was never actually installed (`ICommand`/`ICommandHandler`/`IMediator` never existed in this repo) and wired `Endpoint -> Handler` directly, matching this repo's established convention. - Migrated FastEndpoints v5 API calls (`SendOkAsync`/`SendAsync`/`SendCreatedAtAsync`/`SendNotFoundAsync`, `Description().WithName()`) to the v7 `Send.*` fluent API across ~10 endpoint files (the repo is pinned to FastEndpoints 7.1.0). - Fixed 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. - Collapsed 3 duplicate cross-cutting abstractions that shadowed the `BuildingBlocks` versions and caused type-mismatch compile errors: `IKrxDataService`, `IOutboxWriter` (`ReconcileTradeHandler`), `IClock` (`ApprovalWorkflow/ApprovalPolicy`). - Injected `IClock` (`BuildingBlocks.Time`) in place of direct `DateTime.Now`/`UtcNow` across 19 files to satisfy the architecture test for the AGENTS.md "no direct system time" rule (architecture tests now 13/13, were 12/13). - Registered 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. - Disabled (`[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 DEBT-017 for the follow-up decision needed. ## New tech debt recorded (`TECH_DEBT_REGISTER.md`) - **DEBT-017**: duplicate VS-03 Approval Workflow implementation — needs an architect decision on deleting the old slice. - **DEBT-018**: outbox write not co-transactional with entity write in `TradeExecution`/`PortfolioReconciliation` (crash between the two writes drops the event silently). - **DEBT-019**: pattern of duplicate abstractions shadowing `BuildingBlocks` (partially resolved this PR); recommends a pre-implementation checklist step for future slices. ## Test plan - [x] `dotnet build KArtSell.sln -c Release` — 0 errors, 0 warnings - [x] Architecture tests: 13/13 pass - [x] Unit tests: 54/54 (ModelOperations) + 18/18 (SignalEngine) pass - [x] Integration tests: 34/36 pass — the 2 failures are a local test-DB migration-journal/schema mismatch (pre-existing environment issue), not a code defect - [x] Host boots cleanly end-to-end and registers all 34 endpoints (`Registered 34 endpoints`, `Now listening on :5002`) — verified by actually starting it, not just by unit tests 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kjh2064 added 1 commit 2026-08-07 19:54:56 +09:00
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>
kjh2064 merged commit a4fa9be706 into main 2026-08-07 19:55:21 +09:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kjh2064/KArtSell.Aegis#28