b1e38ac374
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>
57 lines
2.7 KiB
SQL
57 lines
2.7 KiB
SQL
-- Migration 0036: Approval workflow schema (VS-03)
|
|
-- Creates tables for model activation approval gates with maker-checker separation
|
|
|
|
CREATE TABLE IF NOT EXISTS model_operations.approval_proposals (
|
|
id UUID PRIMARY KEY,
|
|
model_id UUID NOT NULL REFERENCES model_operations.models(id),
|
|
status VARCHAR(50) NOT NULL,
|
|
created_by VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
justification TEXT NOT NULL,
|
|
effective_at DATE NOT NULL,
|
|
proposed_at TIMESTAMPTZ,
|
|
approved_by VARCHAR(255),
|
|
approved_at TIMESTAMPTZ,
|
|
approval_notes TEXT,
|
|
activated_by VARCHAR(255),
|
|
activated_at TIMESTAMPTZ,
|
|
published_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
revision INT NOT NULL DEFAULT 1,
|
|
correlation_id UUID NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_approval_proposals_model_id ON model_operations.approval_proposals(model_id);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_proposals_status ON model_operations.approval_proposals(status);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_proposals_created_by ON model_operations.approval_proposals(created_by);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_proposals_approved_by ON model_operations.approval_proposals(approved_by);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_proposals_correlation_id ON model_operations.approval_proposals(correlation_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS model_operations.approval_evidence (
|
|
id UUID PRIMARY KEY,
|
|
approval_proposal_id UUID NOT NULL REFERENCES model_operations.approval_proposals(id),
|
|
evidence_type VARCHAR(50) NOT NULL,
|
|
evidence_url TEXT NOT NULL,
|
|
reviewer_comment TEXT,
|
|
published_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
correlation_id UUID NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_approval_evidence_proposal_id ON model_operations.approval_evidence(approval_proposal_id);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_evidence_type ON model_operations.approval_evidence(evidence_type);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_evidence_correlation_id ON model_operations.approval_evidence(correlation_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS model_operations.approval_events (
|
|
id UUID PRIMARY KEY,
|
|
approval_proposal_id UUID NOT NULL REFERENCES model_operations.approval_proposals(id),
|
|
event_type VARCHAR(50) NOT NULL,
|
|
actor_email VARCHAR(255) NOT NULL,
|
|
event_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
details JSONB,
|
|
published_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
correlation_id UUID NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_approval_events_proposal_id ON model_operations.approval_events(approval_proposal_id);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_events_type ON model_operations.approval_events(event_type);
|
|
CREATE INDEX IF NOT EXISTS ix_approval_events_correlation_id ON model_operations.approval_events(correlation_id);
|