kjh2064 4059828abf fix: missing model_operations.models table + compliance schema breaking every fresh DB (live deploy failure)
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>
2026-08-07 20:23:56 +09:00

K-ArtSell Aegis v16.0

Reference implementation closure for governed advisory research. RESEARCH_CANDIDATE_NOT_PRODUCTION; automatic order/KIS/model activation OFF.

상태: IMPLEMENTATION_TEMPLATE / STATIC_VALIDATED / BUILD_DB_E2E_SHADOW_REHEARSAL_REQUIRED
운영 경계: RESEARCH_CANDIDATE_NOT_PRODUCTION · 투자자문형 우선 · 자동주문/KIS 제출 OFF · 자동 모델승격 OFF


📖 개발자를 위한 문서 가이드

→ 여기서 시작:

문서 색인: docs/INDEX.md

기술부채 추적: TECH_DEBT_REGISTER.md — Impact/Effort 매트릭스, 분기별 회수 목표


v16.0은 v10.0의 Baseline Preservation + Delta + Supersession + Traceability, RG-0108, PIT·불변 Evidence·26 Vertical Slice 기준과 v12.1v14.0 실행 패키지를 삭제하지 않고 보존한 누적 Delta다. 화면 수나 코드량을 생산준비도로 간주하지 않으며, Source/License → PIT/Revision/DQ → Evidence/Version Set → Sell/Reentry → Recommendation → Maker-Checker → Publish → Outcome → Reconciliation/DR의 완결성으로 판단한다.

v16.0 핵심 Delta

FE 표준화·교체 가능성

  • UI Adapter Contract v3.0과 14개 Capability를 제공한다.
  • 업무 Feature에서 PrimeVue/AG Grid 직접 import를 금지하고 shared/ui/adapter 경계 안에서만 허용한다.
  • Ks* Wrapper, CrudWorkspaceLayout, OperationsConsoleLayout, 표준 CRUD List/Form Page, URL Query Codec, 공통 13상태 Matrix를 제공한다.
  • Adapter 교체는 contract conformance, keyboard/focus/a11y, T01~T10 회귀, visual regression, bundle·license 검사와 release approval을 통과해야 한다.

BE·데이터·스케줄러 실행완결성

  • Endpoint → Application → Domain Policy → Dapper/Npgsql → Outbox/Inbox를 한 Vertical Slice로 완결한다.
  • 스케줄 실행은 scheduledFor anchor, catch-up 정책, BusinessHold, dispatch revision, correlation, version set을 보존한다.
  • 평가창은 달력 일이 아니라 MarketCalendar의 1/5/20/63/126/252 거래세션으로 성숙도를 판정한다.
  • prediction_evaluation_window, metric_cohort_definition, ui_contract_release와 append-only 보호를 Migration 0020에 추가했다.
  • J39 FeedbackCycleIntegrityAudit와 J40 EvaluationWindowIntegrityAudit는 기본 disabled다.

알고리즘·지속 모델운영

  • 매도 우선순위는 HARD_IMPAIRMENT → PORTFOLIO_SURVIVAL → DYNAMIC_PROFIT_FLOOR → CONCENTRATION/LIQUIDITY → OPPORTUNITY_COST → REENTRY_OPTION으로 고정한다.
  • 비가치훼손 매도는 ReentryWatch, 새 CycleId/Lot, 단계간격·만료·중복방지를 동반한다.
  • 모델 루프는 Freeze → Mature → Score → Diagnose → Hypothesis → Challenger → Validate → Review → Manual Activation으로 제한한다.
  • 자동 재학습·자동 승격·자동 주문을 하지 않으며 모든 활성화는 ModelCard, OOS/PBO/DSR, maker-checker, effective_at, rollback evidence를 요구한다.

실행 자료 규모

  • 상세 WBS: 576건(기존 480 + v15 Delta 96)
  • 기술부채: 124건
  • Decision Log: 80건
  • Traceability Matrix: 101건
  • FE Component Catalogue: 43건
  • Job Catalogue: 26건

먼저 읽을 문서

  1. docs/v15_0/K-ArtSell_Aegis_v15_0_실행완결성_표준UI_지속모델운영_통합고도화_제안서.docx
  2. docs/v15_0/00_EXECUTIVE_CRITICAL_PROPOSAL.md
  3. docs/v15_0/01_ROLE_BASED_BRUTAL_AUDIT.md
  4. docs/v15_0/02_FRONTEND_STANDARD_AND_ADAPTER_V3.md
  5. docs/v15_0/03_SCHEDULER_AND_CONTINUOUS_FEEDBACK.md
  6. docs/v15_0/08_DETAILED_WBS_MASTER.csv
  7. docs/v15_0/TECH_DEBT_REGISTER.csv

주요 구현 경로

  • FE Adapter/Wrapper: frontend/src/shared/ui/adapter/, frontend/src/shared/ui/components/
  • 표준 CRUD/Layout: frontend/src/shared/crud/, frontend/src/shared/ui/layouts/
  • UI 계약: contracts/ui/ui-adapter.v3.json, crud-page.v1.json, layout-regions.v1.json
  • 스케줄 계약: contracts/schedules/model-operations.v3.json
  • 모델운영 도메인: src/KArtSell.Modules.ModelOperations/Domain/
  • DB Delta: db/migrations/0020_v15_execution_and_ui_contract_hardening.sql
  • 화면/Slice 생성기: tools/scaffold_ui_screen.py, tools/scaffold_vertical_slice.py
  • 원본 첨부: attachments/current_session/, attachments/source_archives/

현재 검증 진실성

확인 완료:

  • v15 정적 패키지 검증: PASS=1 / WARN=2 / FAIL=0
  • Python 정책 Golden: 4 tests PASS
  • Scaffold 검증: 3 tests PASS
  • DOCX: 18페이지 전부 렌더·육안 확인, 접근성 감사 high=0 / medium=0 / low=0

아직 통과로 주장하지 않는 Gate:

  • .NET 10 restore/build/test
  • pnpm frozen install/typecheck/Vitest/build/Playwright
  • PostgreSQL DbUp fresh/upgrade/re-run/failure-recovery
  • Outbox/Inbox crash/replay, DR·대사 리허설
  • 최소 252거래일 Shadow, 복수 국면 OOS, PBO/DSR

위 Gate가 충족되기 전에는 생산 배포, 투자일임형, 자동주문 또는 자동 모델승격으로 해석하지 않는다.

S
Description
KArtSell.Aegis
Readme 130 MiB
Languages
JavaScript 76.1%
C# 11.9%
Vue 4.7%
TypeScript 2.5%
PowerShell 2.1%
Other 2.7%