refactor: CB 게이지 저장소를 context tree → system_metrics 별도 테이블로 분리
Some checks failed
CI / test (pull_request) Has been cancelled
Some checks failed
CI / test (pull_request) Has been cancelled
대시보드 표시 전용 데이터를 AI 의사결정용 context tree에 저장하는 것은 관심사 분리 위반. system_metrics 경량 테이블을 신설하여 완전히 분리. (PR #197 코드리뷰 반영) - db.py: system_metrics 테이블 추가 (key/value/updated_at) - main.py: context_store.set_context(L6_DAILY) → db_conn.execute(system_metrics) - app.py: contexts 쿼리 → system_metrics 쿼리 - tests: _seed_cb_context를 system_metrics 삽입으로 변경 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -355,20 +355,12 @@ def test_positions_empty_when_no_trades(tmp_path: Path) -> None:
|
||||
|
||||
def _seed_cb_context(conn: sqlite3.Connection, pnl_pct: float, market: str = "KR") -> None:
|
||||
import json as _json
|
||||
from datetime import UTC, datetime
|
||||
today = datetime.now(UTC).date().isoformat()
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT OR REPLACE INTO contexts (layer, timeframe, key, value, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
"INSERT OR REPLACE INTO system_metrics (key, value, updated_at) VALUES (?, ?, ?)",
|
||||
(
|
||||
"L6_DAILY",
|
||||
today,
|
||||
f"portfolio_pnl_pct_{market}",
|
||||
_json.dumps({"pnl_pct": pnl_pct}),
|
||||
f"{today}T10:00:00+00:00",
|
||||
f"{today}T10:00:00+00:00",
|
||||
"2026-02-22T10:00:00+00:00",
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user