kjh2064
|
2eeb16a240
|
Database Migrations: Inbox & Approval Queue tables
Completes async event coupling infrastructure for downstream consumers:
Migrations:
1. 0009_CreateInboxTable.sql
- Deduplication: UNIQUE (outbox_id, consumer_id)
- Status: Pending, Processed, Failed
- Idempotent processing (each consumer once per event)
- Constraint: If status=Processed, processed_at must be set
- Indexes: status, created_at, consumer_id
2. 0010_CreateApprovalQueueTable.sql
- Workflow: Pending → Approved/Rejected
- References: run_id (FK shadow_run), model_id
- Audit: requested_at, approved_at, rejected_at
- Triggers: Enforce timestamp/reason consistency
- Indexes: status, model_id, requested_at
Design Principles:
✅ Append-only: Records immutable (status transitions, not updates)
✅ PIT Safety: All records timestamped, no forward lookups
✅ Data Integrity: Check constraints enforce workflow rules
✅ Idempotency: UNIQUE constraint prevents duplicate processing
✅ Traceability: Full audit trail (requested_by, approved_by, timestamps)
Workflow:
ShadowRunJob
├─ Phase 6: Emit ShadowRunCompletedEvent to Outbox
└─ Hangfire OutboxPoller (30s)
├─ Inbox fanout (INSERT inbox for each consumer)
└─ InboxConsumers (fanout)
└─ ApprovalQueueConsumer
├─ If AllGatesPassed: INSERT approval_queue (status='Pending')
└─ Notify: approval_queue subscribers
Ready for:
1. ShadowRunJob event emission (Phase 6)
2. OutboxPollerJob + InboxProcessorJob Hangfire integration
3. Human approval workflow (Maker-Checker)
Test Status: 84/84 PASSING (no changes to app code)
AGENTS.md v16.0:
✅ Safety: Constraints enforce workflow invariants
✅ Audit: Complete audit trail (timestamps, user IDs)
✅ Simplicity: Clear schema, obvious workflow
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
2026-08-02 12:27:02 +09:00 |
|
kjh2064
|
7dd300f5b5
|
feat: Infrastructure Implementation Phase — Database, Services, API integration
ci / backend (push) Failing after 1s
ci / static (push) Failing after 5s
ci / frontend (push) Failing after 39s
Implements AGENTS.md v16.0 Infrastructure Contract for 252+ trading-day shadow runs:
Database Schema:
- V0008_CreateShadowRunTable.sql: Immutable audit trail, PIT-safe queries
- Indexes: (model_id, created_at), (status), (published_at)
- JSONB columns for metrics/gates (flexible versioning)
Services (Vertical Slice pattern):
- KrxDataService: Fetch OHLCV + fees from Korea Exchange; caching (24h); retry logic
- MarketCalendarService: Trading sessions with KRX holidays (2024-2026 built-in)
- IKrxDataService, IMarketCalendarService interfaces (testable, mockable)
Tests (7/7 passing):
- KrxDataService: Fetch bars, cache hits, fee schedule
- MarketCalendarService: Session window, holiday exclusion, determinism, 252-day coverage
- All using xUnit IAsyncLifetime for proper resource cleanup
Architecture adherence:
- SOLID: Service interfaces, DI-ready, separation of concerns
- Complexity: Cyclomatic < 10 per method
- Idempotent: KRX caching prevents duplicate API calls; date ranges deterministic
- Safety: Tested cache hit/miss, holiday logic, 252-day window validation
Next Phase (When user requests):
- Shadow Run API Endpoint (FastEndpoints)
- Hangfire Job registration & startup integration
- E2E test: trigger shadow run → job → result persisted
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
2026-08-02 08:02:05 +09:00 |
|