Keep action order while preventing disabled or busy actions from emitting a command. Preserve test evidence; status remains IN_PROGRESS pending predecessor acceptance.
Adopt Features/ApprovalWorkflow/ (wired into Program.cs, reachable over
HTTP) as the sole VS-26 (formerly VS-03) maker-checker approval slice.
Delete the dead, [DontRegister]'d duplicate under
ApprovalWorkflow/ (Workstream H) and its dedicated test file, which had
been misleadingly credited with "20/20 tests PASS" while being
unreachable at runtime.
- Sql.cs: fix the same Dapper DateOnly-parameter-binding bug that was
already found and fixed in the now-deleted implementation
(commit 2ccf74c) but had not been ported to this one; InsertProposalAsync
would have failed 100% of the time against a real database.
- tests/.../ApprovalWorkflow/ApprovalWorkflowTests.cs: new Handler+Sql+
real-Postgres integration coverage (create/approve/activate role
gating, maker!=checker separation of duties, evidence attachment,
DateOnly round-trip, list filtering) replacing the deleted dead-code
suite at the same path.
- ApprovalWorkflowPolicyTests.cs: extended (5->10 cases) rather than
replaced, since it already tested the kept implementation's Policy.
- Program.cs: drop the reference comment to the deleted namespace.
- TECH_DEBT_REGISTER.md: DEBT-017 marked Completed (DB verification
pending); corrected stale DEBT-023 to point at this resolution;
registered two residual gaps discovered (not introduced) by this
cleanup as DEBT-025 (no GET /approvals/{id}, evidence unreachable via
HTTP) and DEBT-026 (no wired Draft->Proposed transition, so the
approve/activate path is currently unreachable end-to-end via HTTP).
- WBS_PROGRESS_TRACKER.csv / CURRENT_ROADMAP.md: AEG-VS-26-01 kept
BLOCKED, not COMPLETED — no PostgreSQL was reachable in this session
(127.0.0.1:5432 connection refused), so the 8 new integration tests
are unverified; only the 10 pure-Policy tests were confirmed passing.
Cherry-picked cedc8d7/8c777df from docs/wbs-tracker-current-state onto
this worktree branch first, to bring in the VS-26 renumbering and
ADR-WBS-001 that this task's brief assumed already existed.
dotnet build -c Release: 0 errors/0 warnings.
dotnet test --filter "FullyQualifiedName~ApprovalWorkflow" -c Release:
10 passed (Policy, no DB), 15 failed (DB connection refused - includes
6 unrelated pre-existing tests matched by the filter substring).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Make projection and watermark visible requirements, expose stale state accessibly, and add component regression coverage. Status remains IN_PROGRESS pending predecessor and UX evidence.
Document startup-only provider switching, immutable-artifact rollback, and mandatory visual/accessibility/performance evidence. Status remains IN_PROGRESS until rehearsal and predecessor evidence exist.
Validate extensible WBS identity integrity instead of an obsolete fixed row count. Preserve actual vendor-boundary and adapter-contract evidence; status remains IN_PROGRESS pending predecessor acceptance evidence.
- scripts/dba/grant-migration-test-db-ownership.sql: for a DBA to run,
fixes the kartsell_migration_test ownership regression blocking
DbUpMigrationTests/DbUpRecoveryTests (12 tests) locally.
- docs/CURRENT/PHASE-1_APPROVAL_CHECKLIST.md +
scripts/phase1/template-approve-versionset.sql: documents/templates the
human maker-checker approval steps needed to freeze a VersionSet before
Phase 1 shadow run can be re-queued. Does not perform any approval —
every placeholder must be filled by a real, named maker and a different
named checker. No automation should insert rows into dataset_manifest /
model_version_registry / evidence_snapshot / release_evidence_bundle.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Renumbers the four 2026-08-07 slices (ApprovalWorkflow, AuditTrail,
TradeExecution, PortfolioReconciliation) to previously-unused VS-26..29,
leaving WBS_MASTER.csv's original VS-03/04/12/14 definitions (IngestMarketDataPIT,
ApplyCorporateActions, RankBuyCandidates, GenerateDailyRecommendations) untouched,
per docs/DECISIONS/ADR-WBS-001-slice-renumbering.md.
While investigating, found two things not yet resolved by this commit:
- DEBT-017 (duplicate ApprovalWorkflow implementation): the tested backend
(ApprovalWorkflow/) is [DontRegister]'d dead code; the live one
(Features/ApprovalWorkflow/, wired in Program.cs) has no dedicated tests.
AEG-VS-26-01 downgraded from COMPLETED to BLOCKED in the tracker pending an
architect decision on which implementation is canonical.
- Features/MarketData and Features/Portfolio (VS-03/04/05/08 Market Data
Ingestion Dashboard, Portfolio Rebalance, Risk Metrics, Dashboard) are a
third, already-implemented-and-tested body of work entirely absent from
WBS_PROGRESS_TRACKER.csv. Flagged in CURRENT_ROADMAP.md as a follow-up.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- scripts/dba/grant-migration-test-db-ownership.sql: for a DBA to run,
fixes the kartsell_migration_test ownership regression blocking
DbUpMigrationTests/DbUpRecoveryTests (12 tests) locally.
- docs/CURRENT/PHASE-1_APPROVAL_CHECKLIST.md +
scripts/phase1/template-approve-versionset.sql: documents/templates the
human maker-checker approval steps needed to freeze a VersionSet before
Phase 1 shadow run can be re-queued. Does not perform any approval —
every placeholder must be filled by a real, named maker and a different
named checker. No automation should insert rows into dataset_manifest /
model_version_registry / evidence_snapshot / release_evidence_bundle.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Renumbers the four 2026-08-07 slices (ApprovalWorkflow, AuditTrail,
TradeExecution, PortfolioReconciliation) to previously-unused VS-26..29,
leaving WBS_MASTER.csv's original VS-03/04/12/14 definitions (IngestMarketDataPIT,
ApplyCorporateActions, RankBuyCandidates, GenerateDailyRecommendations) untouched,
per docs/DECISIONS/ADR-WBS-001-slice-renumbering.md.
While investigating, found two things not yet resolved by this commit:
- DEBT-017 (duplicate ApprovalWorkflow implementation): the tested backend
(ApprovalWorkflow/) is [DontRegister]'d dead code; the live one
(Features/ApprovalWorkflow/, wired in Program.cs) has no dedicated tests.
AEG-VS-26-01 downgraded from COMPLETED to BLOCKED in the tracker pending an
architect decision on which implementation is canonical.
- Features/MarketData and Features/Portfolio (VS-03/04/05/08 Market Data
Ingestion Dashboard, Portfolio Rebalance, Risk Metrics, Dashboard) are a
third, already-implemented-and-tested body of work entirely absent from
WBS_PROGRESS_TRACKER.csv. Flagged in CURRENT_ROADMAP.md as a follow-up.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both docs were stale relative to 115 commits already on main (VS-03
Approval Workflow, VS-04 Audit Trail, AEG-X-009 live API integration,
Phase 3 J/K/L Sell Decision/Trade Execution/Portfolio Reconciliation),
and repeated an already-corrected false claim that Phase 1 shadow run
was RUNNING.
WBS_PROGRESS_TRACKER.csv:
- AEG-VS-03-01, AEG-VS-04-01: PLANNED/BLOCKED -> COMPLETED, with real
file paths, commit refs, and isolated test-run counts (20/20, 5/5)
as evidence.
- AEG-VS-10-01: BLOCKED -> COMPLETED (implementation), with an
explicit caveat that PBO/DSR production validation is separate and
still blocked on Phase 1 - not overclaiming past what's verified.
- Added AEG-VS-12-01 (Trade Execution) and AEG-VS-14-01 (Portfolio
Reconciliation), which had no tracker row at all despite being
merged to main.
- Flagged a real WBS_ID collision: WBS_MASTER.csv defines VS-03/04/12/14
as different, unrelated slices (IngestMarketDataPIT, ApplyCorporateActions,
RankBuyCandidates, GenerateDailyRecommendations). Per user decision,
kept the tracker's existing IDs and recorded the collision as
DECISION_REQUIRED on each affected row rather than silently
renumbering or picking a side.
- Softened AEG-VS-05-01/AEG-X-011/AEG-VS-09-01/AEG-VS-19-01 notes that
implied Phase 1 was actively counting down ("Job 976, ~50-90 days") -
corrected to say Phase 1 has not been queued.
- Re-confirmed PHASE-1-SHADOW-RUN unchanged: still no RunId/JobId
anywhere in this workspace.
CURRENT_ROADMAP.md: full rewrite. Dropped the 2026-08-03 snapshot
content, replaced with what's actually true today, and added a short
"how to re-verify this document" section (check git log divergence,
re-run tests in isolation not just as a full suite, confirm file paths
before writing COMPLETED) aimed at whoever updates this next.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The static-ctor guard added to TradeSql in the previous commit was a
symptom fix. Confirmed the same bug independently affects AuditSql:
running the Compliance test filter in isolation (no other class that
happens to touch a BuildingBlocks type first) reproduced the identical
failure mode - every snake_case column (event_type, purge_status, ...)
silently mapped to null.
Root cause: KArtSell.BuildingBlocks.Data.DapperBootstrap's
[ModuleInitializer] only runs once that assembly is actually loaded,
and a `using` directive for a BuildingBlocks namespace does not force
that load - only an executed reference to one of its types does. Any
Sql class that never actually touches a BuildingBlocks type at runtime
is exposed, and this is a property of *when* a given test/request
happens to run relative to everything else in the process, not of any
one class.
Replaced the ad-hoc TradeSql static ctor with one [ModuleInitializer]
per module assembly (KArtSell.Modules.ModelOperations,
KArtSell.Modules.SignalEngine). Every Sql/reader class lives inside its
own module's assembly, so a module initializer there is guaranteed to
run before any of them are used, independent of BuildingBlocks or
load order. Verified both KArtSell.Integration.Tests.Compliance and
.TradeExecution now pass 100% run in full isolation, not just as part
of the full suite.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- KArtSell.Host.csproj: FrontendFiles glob was evaluated at project-load
time, before pnpm build ran, so it copied stale/missing Vite-hashed
filenames every Release build. Move the glob inside the target, after
the build Exec.
- ApprovalSql/AuditSql/TradeSql: fix live-DB integration failures never
caught by unit tests: DateOnly and inet columns can't be bound/read
directly through Dapper without conversion; kis_response (jsonb) read
as JsonElement threw InvalidCastException; GdprRetention.RetentionEndsAt
was typed DateTime against a DATE column.
- TradeSql: UpdateTradeStatusAsync only ever persisted status/kis_response
/error_message, silently dropping kis_order_id, executed_quantity,
unit_price, total_amount, commission, net_proceeds and the execution/
settlement timestamps on every call. Changed it to take the Trade
aggregate so the full state transition persists.
- TradeSql: add a static ctor setting Dapper.DefaultTypeMap.
MatchNamesWithUnderscores = true. The repo's [ModuleInitializer] in
KArtSell.BuildingBlocks only fires once that assembly is actually
loaded; TradeSql/Trade never reference a BuildingBlocks type, so under
test isolation (or any host that queries a trade before touching
BuildingBlocks) every snake_case column silently mapped to null/default.
- Test fixes: seed the FK prerequisites (model_operations.models,
sell_decisions) that ApprovalWorkflowTests/TradeExecutionTests were
missing, correct a SellPriorityRanker test input to match the approved
VS-10-SLICE_SPEC age-boost threshold, and fix a GDPR redaction
assertion that called ToString() on a Dictionary instead of inspecting
its values.
12 DbUpMigrationTests failures remain and are unrelated to this fix: the
kartsell DB user isn't the owner of kartsell_migration_test, so DbUp's
fresh-database rehearsal can't DROP/CREATE it. Needs a DBA grant.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The SCP/DbMigrator deploy to the production target (178.104.200.7)
failed today with `relation "model_operations.models" does not
exist` at migration 0036 — the exact same failure I'd already hit
against a local test database, confirming this isn't environment
drift but a real, deterministic bug: no migration ever created
model_operations.models, only referenced it via FK (0036, 0038) and
queried it directly (OpenDartDailyBatchJob.cs). Migration 0037 had
the same class of bug for the `compliance` schema itself.
- Add 0035_model_operations_models.sql (must sort before 0036).
Scope is intentionally minimal — id/ticker/published_at/
correlation_id/revision, i.e. only what's actually referenced
today. The full Model Card/lifecycle schema is separate, larger
work and isn't guessed at here.
- Add `CREATE SCHEMA IF NOT EXISTS compliance;` to 0037, plus
IF NOT EXISTS on its indexes for re-run idempotency (matching the
rest of this migration set).
- Verified: full chain 0000->0040 applies to a fresh DB
("Upgrade successful") and re-run is a clean no-op
("No new scripts need to be executed").
Fixing the schema far enough to actually run queries against it
surfaced 3 more real, previously untested bugs in already-merged
code (none reachable before because the tables/schema didn't exist):
- Dapper was never configured for snake_case<->PascalCase column
mapping (`Dapper.DefaultTypeMap.MatchNamesWithUnderscores`), so
every Sql class's result-set queries were silently returning
null/default for every property instead of throwing. Fixed once,
centrally, via a `[ModuleInitializer]` in
KArtSell.BuildingBlocks/Data/DapperBootstrap.cs so it's set before
the first query regardless of entry point (Host/DbMigrator/tests).
- jsonb/inet columns written without an explicit cast
(`42804: column "x" is of type jsonb but expression is of type
text`) in AuditSql (details, ip_address), TradeSql (kis_response),
SellDecisionSql (oos_performance) — fixed with `::jsonb`/`::inet`
casts. AuditSql's jsonb read-back into Dictionary<string,object>
also needed a raw-DTO + JsonSerializer.Deserialize mapping.
- AuditSql.RedactAuditEventDetailsAsync had a literal duplicate
`SET details = ... details = ...` (invalid SQL) — nested the two
jsonb_set calls into one assignment.
Verified: dotnet build 0/0; architecture 13/13; unit 54/54+18/18;
Host boots cleanly and registers all 34 endpoints against the
now-complete schema.
New tech debt recorded: DEBT-020 (this fix), DEBT-021 (Dapper
snake_case fix), DEBT-022 (jsonb/inet casts, partial — not yet
audited beyond what surfaced), DEBT-023 (ApprovalSql.
InsertProposalAsync still fails on a raw DateOnly parameter — same
class of issue as DEBT-021, not yet fixed), DEBT-024 (TradeExecution
tests don't insert FK parent rows; one pure-logic ranker test
returned 1000 instead of 950 under the full suite, not yet
root-caused; DbUpMigrationTests fail locally on a Postgres role
permission gap unrelated to this fix).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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>
Deployment pipeline was computing version sequence (YYYY.MM.DD.N) by
counting existing vYYYY.MM.DD.* git tags, but the pipeline never created
those tags. Result: VERSION_SEQUENCE always resolved to 1, making the
"daily sequence" half of the contract decorative.
Now: After successful deployment to production, pipeline automatically
creates and pushes release tag vYYYY.MM.DD.N.SHA10 (e.g. v2026.08.07.1.abc1234567).
Uniqueness preserved even on same-day re-deploys. Permissions upgraded:
contents: read → write for tag push.
AGENTS.md: Right-Way (root cause fixed, not bandaged).
Ref: DEPLOY_FRONTEND_ARTIFACT_CONTRACT.md section "Bug Fix: Version Sequence Tagging"
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Tests now guard against accidental drop of kartsell_migration_test by throwing
when the credential source DB is the destructive rehearsal target. Distinct
credential DB (kartselldb_test) prevents config collision.
AEG-X-004 evidence consolidated: rehearsal .trx files + preflight markdown
documented. Schema 0032 (shadow_run_queued_status_contract) verified
fresh/upgrade/recovery on isolated DB.
AGENTS.md: Necessity-driven (guard against destructive accident); no new feature.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>