refactor: CB 게이지 저장소를 context tree → system_metrics 별도 테이블로 분리
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:
agentson
2026-02-22 11:49:03 +09:00
parent f3491e94e4
commit cdd5a218a7
4 changed files with 26 additions and 22 deletions

View File

@@ -84,14 +84,11 @@ def create_dashboard_app(db_path: str) -> FastAPI:
pnl_pct_rows = conn.execute(
"""
SELECT key, value
FROM contexts
WHERE layer = 'L6_DAILY'
AND timeframe = ?
AND key LIKE 'portfolio_pnl_pct_%'
FROM system_metrics
WHERE key LIKE 'portfolio_pnl_pct_%'
ORDER BY updated_at DESC
LIMIT 20
""",
(today,),
"""
).fetchall()
current_pnl_pct: float | None = None
if pnl_pct_rows: