docs(research): map db/services for self-improving loop implementation

This commit is contained in:
happybell80 2026-03-03 18:55:53 +09:00
parent 6ed96c94aa
commit 19a6995b2c
2 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,102 @@
# 260303 자기개선 루프 구현을 위한 DB/서비스 리서치
## 목적
- 로빙의 `자기개선 루프(예측-행동-평가-반성)`를 실제 서비스에 붙이기 위한 현재 자산(DB/서비스/코드)을 정리한다.
- 이미 운영 중인 컴포넌트를 재사용해 최소 변경으로 구현 가능한 경로를 제시한다.
## 요약 결론
1. `rb8001`은 이미 피드백/평가/리뷰 큐를 갖고 있어 루프의 `평가``반성` 입력 데이터가 존재한다.
2. `robeing-monitor`는 상태/로그를 저장하지만 설정 테이블(`robeing_settings`)이 미구현(TODO)이라 정책 버전 관리 계층이 비어 있다.
3. `robeing-gateway`는 모니터 서비스 프록시 경로가 있어 루프 지표를 프론트에 노출하기 좋은 진입점을 이미 보유한다.
## robeing-monitor 존재 여부
- 로컬 워크스페이스에서 `ivada/robeing-monitor` 폴더 존재 확인 완료
- 상태: 이미 존재함(추가 clone 불필요)
- 원격 참고: [robeing-monitor](https://git.ro-being.com/ivada_Ro-being/robeing-monitor.git)
## 현재 DB/서비스 자산
### 1) rb8001 (루프 데이터의 핵심 소스)
- 피드백 수집 엔드포인트:
- [`app/router/feedback_endpoint.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/router/feedback_endpoint.py)
- `POST /api/feedback/chat`
- 리뷰 큐 테이블(의도 예측/정답/상태):
- [`app/models/intent_review_model.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/models/intent_review_model.py)
- 핵심 컬럼: `predicted_intent`, `predicted_confidence`, `user_feedback`, `status`, `true_intent`
- 리뷰 큐 처리/통계:
- [`app/state/intent_review_repository.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/state/intent_review_repository.py)
- 상태 전이: `pending -> confirmed/corrected`
- IR 평가 + 피드백(학습용 데이터셋):
- [`app/state/ir_valuation_repository.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/state/ir_valuation_repository.py)
- 테이블: `ir_deck_evaluations`, `ir_deck_page_evaluations`, `ir_deck_feedback`
- 감정 예측 평가 함수:
- [`app/core/emotion/bayesian.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/core/emotion/bayesian.py)
- 함수: `evaluate_prediction()`, `should_update()`
- 일기 집계에서 피드백 루프 추출:
- [`app/services/diary/aggregator.py`](https://git.ro-being.com/ivada_Ro-being/rb8001/src/branch/main/app/services/diary/aggregator.py)
### 2) robeing-monitor (상태 저장/조회 허브)
- 개요 및 API:
- [`README.md`](https://git.ro-being.com/ivada_Ro-being/robeing-monitor/src/branch/main/README.md)
- 상태 조회/업데이트, 로그 저장, 모니터링 API
- DB 모델:
- [`app/state/database.py`](https://git.ro-being.com/ivada_Ro-being/robeing-monitor/src/branch/main/app/state/database.py)
- 테이블: `robeing`, `conversation_log`
- 주석/TODO: `robeing_settings` 테이블 미구현
- 상태 서비스:
- [`app/state/state_service.py`](https://git.ro-being.com/ivada_Ro-being/robeing-monitor/src/branch/main/app/state/state_service.py)
### 3) robeing-gateway (노출 계층)
- 모니터 프록시/설정:
- [`app/main.py`](https://git.ro-being.com/ivada_Ro-being/robeing-gateway/src/branch/main/app/main.py)
- [`app/settings.py`](https://git.ro-being.com/ivada_Ro-being/robeing-gateway/src/branch/main/app/settings.py)
- 의미:
- 루프 지표 API를 monitor에 추가하면 gateway를 통해 프론트로 안전하게 전달 가능
## 자기개선 루프 관점 매핑
### 예측 (Predict)
- 출처: 의도 분류 결과, 감정 예측 분포
- 저장 지점: `intent_review_queue.predicted_*`, 감정 예측 결과
### 행동 (Act)
- 출처: rb8001의 응답/워크플로 실행, 스킬 호출
- 저장 지점: `conversation_log`, `activity_log`(rb8001 내부 집계에서 사용)
### 평가 (Evaluate)
- 출처: `user_feedback`, `true_intent`, IR 등급 피드백, 감정 예측 오차
- 저장 지점: `intent_review_queue`, `ir_deck_feedback`, 감정 평가 함수 출력
### 반성 (Reflect)
- 현재: 부분 구현(리뷰큐 상태 전이, 일부 재학습 흐름)
- 부족: 정책 버전/실험 버전/롤백 이력을 구조적으로 남기는 저장소 부재
## 구현 시 필요한 최소 추가 설계
### A. 정책 버전 저장소(필수)
- 위치 권장: `robeing-monitor` DB
- 신규 테이블 제안:
- `robeing_policy_versions`
- 컬럼 예: `id`, `robeing_id`, `policy_type`, `version`, `config_json`, `created_at`, `is_active`
### B. 루프 실행 로그(필수)
- 신규 테이블 제안:
- `robeing_self_improvement_runs`
- 컬럼 예: `run_id`, `robeing_id`, `predict_snapshot`, `action_summary`, `evaluation_metrics`, `reflection_notes`, `created_at`
### C. 평가 지표 표준화(필수)
- 공통 지표 키를 고정:
- intent: `accuracy`, `f1`, `correction_rate`
- feedback: `up_ratio`, `down_ratio`
- emotion: `kl_divergence`, `brier_score`, `entropy_diff`
## 우선 실행 순서 (현실적)
1. `rb8001`에서 루프 관련 결과를 JSON 스냅샷으로 일단 저장(테이블 추가 전 임시 단계).
2. `robeing-monitor`에 정책 버전/루프 실행 테이블 추가.
3. `robeing-gateway`로 루프 대시보드 API 프록시 연결.
4. 주간 단위로 `정책 업데이트 -> 롤백 가능성 검증` 운영 절차 고정.
## 관련 철학 문서 연결
- [자기개선 루프 정의(용어집)](../../book/600_appendix/650_용어집.md)
- [존재형 에이전트 정의](../../book/100_philosophy/130_존재형_에이전트란_무엇인가.md)
- [자기개선 루프 설계 전개](../../book/100_philosophy/195_철학에서_설계로.md)

View File

@ -54,6 +54,7 @@
- LangGraph vs n8n 비교
- OpenClaw 아키텍처 및 로빙 적용 리서치
- [구카 평가·결정 로직 로빙 적용 리서치 (260303)](./260303_구카_평가결정_로직_로빙_적용_리서치.md)
- [자기개선 루프 구현을 위한 DB/서비스 리서치 (260303)](./260303_자기개선루프_DB_서비스_구현_리서치.md)
## 로빙을 위한 체크리스트