Phase C (Context) and A (Analysis) complete: - Analyzed 11 schemas, ~90 tables, 68+ enums - Identified 15 gaps (4 P0, 4 P1, 7 P2) - Detected 5 conflicts and 3 duplicities - Created validation matrix DDL vs requirements Phase P (Planning) in progress: - 7-phase execution plan with CAPVED compliance - Subtask delegation plan for parallel execution - Estimated effort: 126h (without MT4) Key findings: - GAP-002: financial.refunds missing (P0 - Stripe blocker) - GAP-003: education.instructors missing (P0) - CONF-001: transaction_type enum conflict - DUP-001: timeframe enum duplicated Deliverables created: - 01-CAPTURA.md, 02-ANALISIS.md, 03-PLANIFICACION.md - DDL-GAPS-REGISTRY.yml - DDL-CONFLICTS-REGISTRY.yml - DDL-VALIDATION-MATRIX.yml - DELEGATION-PLAN.yml Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
273 lines
10 KiB
YAML
273 lines
10 KiB
YAML
# METADATA.yml - TASK-2026-02-03-DDL-VALIDATION
|
|
# Análisis y Validación del Modelado de Datos - Trading Platform
|
|
version: "1.0.0"
|
|
created_at: "2026-02-03T10:00:00Z"
|
|
updated_at: "2026-02-03T10:00:00Z"
|
|
|
|
task:
|
|
id: "TASK-2026-02-03-DDL-VALIDATION"
|
|
title: "Análisis y Validación del Modelado de Datos"
|
|
type: "ANALYSIS"
|
|
mode: "@ANALYSIS"
|
|
project: "trading-platform"
|
|
priority: "P1"
|
|
status: "in_progress"
|
|
|
|
context:
|
|
descripcion: >
|
|
Plan de análisis y validación del modelado de base de datos para trading-platform.
|
|
Identificación de conflictos críticos, gaps DDL vs requerimientos, y limpieza
|
|
de documentación obsoleta.
|
|
|
|
metricas_iniciales:
|
|
schemas: 10
|
|
tablas: 89
|
|
enums: 65
|
|
coherencia_ddl_backend: "85%"
|
|
coherencia_ddl_requerimientos: "72%"
|
|
|
|
objetivos:
|
|
- "Resolver 3 conflictos críticos en modelado DDL"
|
|
- "Cerrar 8 gaps DDL vs requerimientos"
|
|
- "Alcanzar 90% coherencia DDL-Backend"
|
|
- "Alcanzar 85% coherencia DDL-Requerimientos"
|
|
|
|
analysis:
|
|
# CONFLICTO C1: Catálogos Duplicados
|
|
c1_catalogos:
|
|
descripcion: "trading.symbols (UUID) vs market_data.tickers (SERIAL)"
|
|
hallazgo: |
|
|
- trading.symbols: UUID, 13 columnas, incluye price_precision, min_quantity, exchange
|
|
- market_data.tickers: SERIAL, 11 columnas, incluye is_ml_enabled, polygon_ticker
|
|
- Sin FK entre ellas
|
|
- Campos similares: symbol, name, base_asset/base_currency, is_active
|
|
recomendacion: >
|
|
Consolidar en trading.symbols como tabla maestra, agregar campos ML de tickers.
|
|
market_data.tickers debería referenciar trading.symbols o deprecarse.
|
|
status: "analizado"
|
|
|
|
# CONFLICTO C2: Transacciones Paralelas
|
|
c2_transacciones:
|
|
descripcion: "financial.wallet_transactions vs investment.transactions"
|
|
hallazgo: |
|
|
- financial.wallet_transactions: 9 tipos (deposit, withdrawal, transfer_in/out, fee, refund, earning, distribution, bonus)
|
|
- investment.transactions: 3 tipos (deposit, withdrawal, distribution)
|
|
- Son sistemas complementarios, NO duplicados
|
|
- wallet_transactions = movimientos de wallet
|
|
- investment.transactions = operaciones PAMM específicas
|
|
recomendacion: >
|
|
Mantener separados pero documentar el patrón. NO son duplicados.
|
|
Agregar FK opcional de investment.transactions → wallet_transactions para trazabilidad.
|
|
status: "analizado"
|
|
|
|
# CONFLICTO C3: Enums transaction_type
|
|
c3_enums_transaction:
|
|
descripcion: "financial.transaction_type (9 valores) vs investment.transaction_type (3 valores)"
|
|
hallazgo: |
|
|
- financial.transaction_type: deposit, withdrawal, transfer_in, transfer_out, fee, refund, earning, distribution, bonus
|
|
- investment.transaction_type: deposit, withdrawal, distribution
|
|
- Diferencia intencional por dominio
|
|
recomendacion: >
|
|
MANTENER separados - son domain-specific by design.
|
|
Documentar en ADR que esto es intencional.
|
|
status: "analizado"
|
|
|
|
# CONFLICTO C4: Funciones Duplicadas
|
|
c4_funciones:
|
|
descripcion: "update_updated_at() potencialmente duplicada"
|
|
hallazgo: |
|
|
- DDL-COMPLETE-MATRIX.yml indica función en auth schema
|
|
- No se encontraron duplicados explícitos en education o portfolio
|
|
- auth tiene: update_updated_at, log_auth_event, cleanup_expired_sessions, create_user_profile_trigger
|
|
recomendacion: >
|
|
VERIFICAR existencia real de duplicados. Si existen, consolidar en public schema.
|
|
status: "requiere_verificacion"
|
|
|
|
# CONFLICTO C5: Enums Duplicados
|
|
c5_enums_duplicados:
|
|
descripcion: "risk_profile duplicado, timeframe divergente"
|
|
hallazgo: |
|
|
- investment.risk_profile: conservative, moderate, aggressive
|
|
- portfolio.risk_profile: conservative, moderate, aggressive (IDÉNTICOS)
|
|
- trading.timeframe: 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M
|
|
- market_data.timeframe: 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w (FALTA 1M)
|
|
recomendacion: |
|
|
- risk_profile: Considerar consolidar en shared/public schema
|
|
- timeframe: Agregar '1M' a market_data.timeframe para consistencia
|
|
status: "analizado"
|
|
|
|
gaps:
|
|
# GAP-EDU-001: Instructors
|
|
gap_edu_001:
|
|
tabla: "education.instructors"
|
|
descripcion: "Falta tabla dedicada para instructores"
|
|
hallazgo: |
|
|
- courses.instructor_id referencia auth.users directamente
|
|
- courses.instructor_name denormalizado para performance
|
|
- NO existe tabla instructors con bio, avatar, specialties, rating
|
|
impacto: "RF-EDU-001 parcialmente cubierto"
|
|
ddl_propuesto: |
|
|
CREATE TABLE education.instructors (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID REFERENCES auth.users(id),
|
|
bio TEXT,
|
|
avatar_url VARCHAR(500),
|
|
specialties VARCHAR[],
|
|
rating DECIMAL(3,2),
|
|
courses_count INTEGER DEFAULT 0,
|
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
status: "gap_confirmado"
|
|
|
|
# GAP-EDU-002: Course Tags
|
|
gap_edu_002:
|
|
tabla: "education.courses"
|
|
campo: "tags"
|
|
descripcion: "Campo tags faltante para búsqueda/filtrado"
|
|
hallazgo: |
|
|
- courses tiene: category_id, difficulty_level, prerequisites
|
|
- NO tiene: tags/keywords para búsqueda
|
|
ddl_propuesto: |
|
|
ALTER TABLE education.courses ADD COLUMN tags VARCHAR[] DEFAULT '{}';
|
|
CREATE INDEX idx_courses_tags ON education.courses USING GIN(tags);
|
|
status: "gap_confirmado"
|
|
|
|
# GAP-TRD-001: Price Alerts
|
|
gap_trd_001:
|
|
tabla: "trading.price_alerts"
|
|
descripcion: "Falta tabla para alertas de precio"
|
|
hallazgo: |
|
|
- trading tiene: symbols, watchlists, orders, positions
|
|
- NO tiene: price_alerts para notificaciones de usuario
|
|
ddl_propuesto: |
|
|
CREATE TABLE trading.price_alerts (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID REFERENCES auth.users(id),
|
|
symbol_id UUID REFERENCES trading.symbols(id),
|
|
condition VARCHAR(10) NOT NULL, -- above, below, equals
|
|
target_price DECIMAL(20,8) NOT NULL,
|
|
is_active BOOLEAN DEFAULT true,
|
|
triggered_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
status: "gap_confirmado"
|
|
|
|
# GAP-TRD-002: ML Overlay
|
|
gap_trd_002:
|
|
tabla: "ml.predictions"
|
|
campo: "overlay_data"
|
|
descripcion: "Campos ML overlay faltantes"
|
|
hallazgo: |
|
|
- ml.predictions tiene: model_output JSONB genérico
|
|
- NO tiene campo específico para overlay_data de charts
|
|
ddl_propuesto: |
|
|
ALTER TABLE ml.predictions ADD COLUMN overlay_data JSONB;
|
|
status: "gap_menor"
|
|
|
|
# GAP-PAY-001: Refunds
|
|
gap_pay_001:
|
|
tabla: "financial.refunds"
|
|
descripcion: "Refunds embebidos en payments, no tabla dedicada"
|
|
hallazgo: |
|
|
- financial.payments tiene: refunded, refund_amount, refund_reason, refunded_at
|
|
- Suficiente para casos simples
|
|
- Tabla dedicada necesaria para compliance y partial refunds
|
|
ddl_propuesto: |
|
|
CREATE TABLE financial.refunds (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
payment_id UUID REFERENCES financial.payments(id),
|
|
amount DECIMAL(20,8) NOT NULL,
|
|
reason VARCHAR(255),
|
|
status VARCHAR(20) DEFAULT 'pending',
|
|
stripe_refund_id VARCHAR(255),
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
processed_at TIMESTAMPTZ
|
|
);
|
|
status: "gap_confirmado"
|
|
|
|
# GAP-INV-001: Agent Executions
|
|
gap_inv_001:
|
|
tabla: "investment.agent_executions"
|
|
descripcion: "Falta tracking de ejecuciones de trading agents"
|
|
hallazgo: |
|
|
- investment tiene: products (con agent type), accounts, distributions
|
|
- NO tiene tracking de trades ejecutados por agents
|
|
ddl_propuesto: |
|
|
CREATE TABLE investment.agent_executions (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
account_id UUID REFERENCES investment.accounts(id),
|
|
agent_type VARCHAR(20) NOT NULL,
|
|
execution_type VARCHAR(20),
|
|
trade_details JSONB,
|
|
pnl DECIMAL(20,8),
|
|
executed_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
status: "gap_confirmado"
|
|
|
|
plan:
|
|
fase_1_conflictos:
|
|
status: "completada"
|
|
tareas:
|
|
- id: "C1"
|
|
descripcion: "Analizar duplicidad catálogos"
|
|
resultado: "Analizado - Recomendar consolidación en trading.symbols"
|
|
- id: "C2"
|
|
descripcion: "Analizar transacciones paralelas"
|
|
resultado: "Analizado - Son complementarios, NO duplicados"
|
|
- id: "C3"
|
|
descripcion: "Analizar enums transaction_type"
|
|
resultado: "Analizado - Intencional por dominio"
|
|
- id: "C4"
|
|
descripcion: "Verificar funciones duplicadas"
|
|
resultado: "Pendiente verificación física"
|
|
- id: "C5"
|
|
descripcion: "Analizar enums duplicados"
|
|
resultado: "risk_profile duplicado, timeframe divergente"
|
|
|
|
fase_2_gaps:
|
|
status: "en_progreso"
|
|
tareas:
|
|
- id: "GAP-EDU-001"
|
|
descripcion: "Instructors table"
|
|
status: "confirmado"
|
|
- id: "GAP-EDU-002"
|
|
descripcion: "Course tags"
|
|
status: "confirmado"
|
|
- id: "GAP-TRD-001"
|
|
descripcion: "Price alerts"
|
|
status: "confirmado"
|
|
- id: "GAP-TRD-002"
|
|
descripcion: "ML overlay"
|
|
status: "menor"
|
|
- id: "GAP-PAY-001"
|
|
descripcion: "Refunds table"
|
|
status: "confirmado"
|
|
- id: "GAP-INV-001"
|
|
descripcion: "Agent executions"
|
|
status: "confirmado"
|
|
|
|
fase_3_documentacion:
|
|
status: "pendiente"
|
|
tareas:
|
|
- "Archivar análisis obsoletos"
|
|
- "Actualizar inventarios"
|
|
- "Actualizar GAPS-TRACKING.yml"
|
|
|
|
verificacion:
|
|
ddl_integrity: "pendiente"
|
|
coherence_check: "pendiente"
|
|
|
|
traceability:
|
|
agent: "Claude Code"
|
|
session: "2026-02-03"
|
|
archivos_analizados:
|
|
- "apps/database/ddl/schemas/trading/tables/01-symbols.sql"
|
|
- "apps/database/ddl/schemas/market_data/tables/01-tickers.sql"
|
|
- "apps/database/ddl/schemas/financial/tables/02-wallet_transactions.sql"
|
|
- "apps/database/ddl/schemas/investment/tables/05-transactions.sql"
|
|
- "apps/database/ddl/schemas/education/tables/02-courses.sql"
|
|
- "apps/database/ddl/schemas/ml/tables/03-predictions.sql"
|
|
- "apps/database/ddl/schemas/financial/tables/05-payments.sql"
|
|
- "apps/database/ddl/schemas/*/00-enums.sql"
|
|
- "orchestration/analisis/coherencia/DDL-COMPLETE-MATRIX.yml"
|