fix: 하드닝 루프 8회차 — 체결 보정·고아 감지·청산 경보·실시간/차트·리스크 가드 일괄 수정

- 스윙 체결가 확인 전 executed_price NULL + fill_sweep, 진입가 resolve(ActiveTrade↔Portfolio), 0체결/부분체결 매수 장부 원복
- DT 고아 감지(근거 한정)·0체결 매도 복원·stale 점검 확대, 시간손절 -0.3% 원복
- 폴백 손절 ATR 캐시, 거래량부족-차단 신호 매수 차단, 현금 5% 유보 재적용, MDD peak/reset 수정
- KIS 서킷브레이커 청산 우회·경보, db_worker 재큐잉 순서, heartbeat·health-watch 사이드카
- 실시간 WS 재구독·41건 우선순위·다건 프레임 분할, 차트 샘플 제거·당일봉 합성, WS 서브프로토콜 인증
- 프론트: 미관리 그룹·확인 모달·차트 실시간 반영·예수금 표시 정정
- 전문가 에이전트 6종 추가(.claude/agents)
- 유닛 스위트 2667 passed (소켓 차단 하), tsc OK

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y83Za98XsNw9zuA4FTUytN
This commit is contained in:
2026-10-10 12:17:49 +09:00
parent 5c4803b339
commit a264561576
230 changed files with 41160 additions and 2334 deletions

View File

@@ -336,15 +336,19 @@ def test_scripts_syntax(sh):
# ── 운영 스모크: 인증 필수 엔드포인트는 401 이 정상, 키 없이 200 은 노출 회귀 (2026-10-02 H-1) ──
def _smoke_against(status_by_path):
def _smoke_against(status_by_path, health=None):
"""로컬 스텁 HTTP 서버를 PROD_BASE_URL 로 두고 prod_smoke.sh 실행 (외부 네트워크 0)."""
import http.server
import threading
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
code = status_by_path.get(self.path, 404)
body = b'{"ok": 1}' if code == 200 else b'{"detail": "x"}'
if self.path == "/health" and health is not None:
import json as _j
code, body = 200, _j.dumps(health).encode()
else:
code = status_by_path.get(self.path, 404)
body = b'{"ok": 1}' if code == 200 else b'{"detail": "x"}'
self.send_response(code)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
@@ -379,6 +383,31 @@ def test_prod_smoke_fails_on_unauthenticated_leak():
assert p.returncode == 1 and "LEAK" in p.stdout
_OK_PATHS = {"/api/v1/market/indices": 200, **{a: 401 for a in _AUTH_PATHS}}
_SCHED_OK = {"swing": {"alive": True, "stale": False}}
def test_prod_smoke_degraded_reasons_only_warn():
h = {"status": "degraded", "db": "ok", "redis": "ok", "schedulers": _SCHED_OK,
"db_worker": {"alive": True}, "degraded_reasons": ["krx_data_incomplete", "dlq_manual"]}
p = _smoke_against(_OK_PATHS, h)
assert p.returncode == 0, p.stdout + p.stderr
assert "WARN HEALTH" in p.stdout and "krx_data_incomplete" in p.stdout
def test_prod_smoke_fails_on_scheduler_dead_even_if_degraded():
h = {"status": "degraded", "db": "ok", "redis": "ok",
"schedulers": {"swing": {"alive": False}}, "degraded_reasons": ["x"]}
p = _smoke_against(_OK_PATHS, h)
assert p.returncode == 1 and "FAIL HEALTH" in p.stdout
def test_prod_smoke_fails_on_db_error():
h = {"status": "degraded", "db": "error", "redis": "ok", "schedulers": _SCHED_OK, "degraded_reasons": []}
p = _smoke_against(_OK_PATHS, h)
assert p.returncode == 1 and "db error" in p.stdout
def test_prod_smoke_fails_when_down():
p = _smoke_against({"/api/v1/market/indices": 502, **{a: 502 for a in _AUTH_PATHS}})
assert p.returncode == 1