회기 연속성과 멀티 케이스 계약을 영속화

This commit is contained in:
Yun Chan 2026-09-01 11:45:16 +09:00
parent be08c0b573
commit 72353ecd82
26 changed files with 2170 additions and 127 deletions

View file

@ -347,7 +347,8 @@ CREATE INDEX IF NOT EXISTS idx_sess_sum_emb ON app.session_summary
-- =============================================================================
-- 8. 메모리 ④ SEMANTIC (설계서 §3.5) — case_profile(evolving) + pinned_fact
-- 케이스 = (persona_id 템플릿) × (learner_id 인스턴스). 학습자별 독립 연속체.
-- 케이스 = (persona_id 템플릿) × (learner_id 인스턴스) × 시작 시점.
-- 같은 내담자도 새 사례와 이어지는 사례를 분리해 학습자별 독립 연속체를 보존한다.
-- =============================================================================
CREATE TABLE IF NOT EXISTS app.case_profile (
case_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@ -360,9 +361,10 @@ CREATE TABLE IF NOT EXISTS app.case_profile (
alliance_level REAL DEFAULT 0.2, -- 치료동맹 누적(EWMA)
case_digest TEXT NOT NULL DEFAULT '', -- 전체 궤적 8~12문장(큰그림)
digest_embedding vector(1024),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (persona_id, learner_id) -- 핵심 복합키(§3.5)
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_case_profile_learner_persona_activity
ON app.case_profile (learner_id, persona_id, updated_at DESC, case_id);
CREATE INDEX IF NOT EXISTS idx_case_learner ON app.case_profile(learner_id);
CREATE INDEX IF NOT EXISTS idx_case_emb ON app.case_profile
USING hnsw (digest_embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64);