feat: v2.2.173-193 — 4인 팀 운영 슬래시 13개 + ASTRA 검증 엔진 6종
4인 팀 운영 슬래시 (v2.2.173~189):
- 일과 리듬: /morning, /evening, /weekly, /standup
- 트래커 (event-sourced .astra/*.jsonl): /runway, /customers, /hire
- 작업·결정: /task, /blocked, /onesie, /decisions
- 외부 출력: /draft, /feedback
- 분석: /cohort (MoM 추세)
ASTRA 추론·검색 엔진 (v2.2.183~192):
- v2.2.183 Conflict Surface — scoring.conflictSeverity 를 [CONFLICT WARNINGS] 블록으로
서피스 + 교차-문서 발산(Jaccard) 감지
- v2.2.184 Chain-of-Verification — [VERIFICATION CHECKLIST] 답변 작성 전 그라운딩 자기 점검
(instructional, strictMode 옵션)
- v2.2.185 Actionability Scoring — 최근 슬래시 명령 + 열린 파일 신호로 검색 결과 재가중
- v2.2.186 Temporal Markers + Distillation Loop — LongTerm/Episodic 만료 필터 +
30일+ stale episode → LongTerm 'episode-digest' 승급 (수동 /memory distill + 세션 종료 자동)
- v2.2.187 Hierarchical Context Window + LLM Semantic Re-rank — 3-level 추상도 매칭
+ 토큰 예산 통과 후 LLM 1회로 의도-부합 재정렬 (opt-in)
- v2.2.190 Intent Clarification + Citation Trace — 모호 차원 감지 시 역질문 우선
+ 답변 끝 사용 출처 한 줄 정리
- v2.2.191 Post-hoc Self-Check — 답변 완료 후 별도 LLM 호출 1회로 답함/그라운딩/모순 평가,
footer 한 줄로 표시 (opt-in, semantic re-rank 와 같은 안전 fallback 패턴)
- v2.2.192 Terminology Dictionary — .astra/glossary.md 사용자 편집 파일 + Term Check
지침 통합 + /glossary init/path/reload
- v2.2.193 /help — 카테고리별 명령 목록 + 6종 verification 블록 현재 on/off
신규 모듈:
- src/retrieval/{conflictBlock,coveBlock,actionabilityScoring,hierarchicalLevel,
semanticRerank,intentClarification,citationTrace,terminologyBlock}.ts
- src/memory/distillation.ts + types.ts 에 expiresAt/promoted/episode-digest 추가
- src/agent/postHocSelfCheck.ts
- src/features/{customers,feedback,hire,runway}/*.ts (event-sourced stores)
ASTRA 검증 5종 자동 주입 (buildAstraModeSystemPrompt, casual 모드 제외):
[INTENT CLARIFICATION GUIDANCE] (답변 시작 전) → [TERMINOLOGY DICTIONARY] +
[CONFLICT WARNINGS] + [VERIFICATION CHECKLIST] (작성 중) → [CITATION TRACE] (끝)
+ 6번째: Post-hoc Self-Check footer (답변 완료 후, opt-in)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -130,7 +130,12 @@ export class EpisodicMemory {
|
||||
* 프롬프트와 관련된 에피소드를 검색합니다.
|
||||
*/
|
||||
public findRelevantEpisodes(prompt: string, limit = 3): EpisodicEntry[] {
|
||||
const episodes = this.loadAllEpisodes();
|
||||
// Temporal + Distillation 필터: 만료된 episode 와 LongTerm 으로 이미 promote 된
|
||||
// episode 는 검색에서 제외 (digest 가 LongTerm 에 있으니 중복 노출 방지).
|
||||
const now = Date.now();
|
||||
const episodes = this.loadAllEpisodes()
|
||||
.filter((ep) => !ep.expiresAt || ep.expiresAt > now)
|
||||
.filter((ep) => !ep.promoted);
|
||||
const promptLower = prompt.toLowerCase();
|
||||
const terms = promptLower
|
||||
.split(/[^a-z0-9가-힣_]+/g)
|
||||
@@ -276,6 +281,45 @@ export class EpisodicMemory {
|
||||
.map(([word]) => word);
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 episode 의 promoted 플래그를 true 로 마킹하고 LongTerm digest id 를 기록.
|
||||
* Distillation Loop 가 호출. 파일 rewrite 1회.
|
||||
*/
|
||||
public markPromoted(episodeId: string, longTermDigestId: string): boolean {
|
||||
const episodes = this.loadAllEpisodes();
|
||||
const ep = episodes.find((e) => e.id === episodeId);
|
||||
if (!ep) return false;
|
||||
ep.promoted = true;
|
||||
ep.promotedToLongTermId = longTermDigestId;
|
||||
// Find the file holding this episode and rewrite.
|
||||
try {
|
||||
const files = fs.readdirSync(this.episodeDir).filter((f) => f.endsWith('.json'));
|
||||
for (const file of files) {
|
||||
const full = path.join(this.episodeDir, file);
|
||||
try {
|
||||
const raw = fs.readFileSync(full, 'utf-8');
|
||||
const parsed = JSON.parse(raw) as EpisodicEntry;
|
||||
if (parsed.id === episodeId) {
|
||||
parsed.promoted = true;
|
||||
parsed.promotedToLongTermId = longTermDigestId;
|
||||
fs.writeFileSync(full, JSON.stringify(parsed, null, 2), 'utf-8');
|
||||
this._episodeCache = null; // dir mtime bump → cache 다음 호출에 갱신
|
||||
return true;
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Distillation 후보 — 지정 일수보다 오래되고 아직 promoted 되지 않은 episodes. */
|
||||
public findStaleEpisodes(ageThresholdDays: number): EpisodicEntry[] {
|
||||
const cutoff = Date.now() - ageThresholdDays * 24 * 60 * 60 * 1000;
|
||||
return this.loadAllEpisodes()
|
||||
.filter((ep) => !ep.promoted)
|
||||
.filter((ep) => ep.timestamp < cutoff);
|
||||
}
|
||||
|
||||
private pruneOldEpisodes(): void {
|
||||
try {
|
||||
const files = fs.readdirSync(this.episodeDir)
|
||||
|
||||
@@ -53,7 +53,13 @@ export class LongTermMemory {
|
||||
|
||||
// ─── CRUD ───
|
||||
|
||||
public addEntry(category: LongTermCategory, content: string, source: string, confidence = 0.8): LongTermEntry {
|
||||
public addEntry(
|
||||
category: LongTermCategory,
|
||||
content: string,
|
||||
source: string,
|
||||
confidence = 0.8,
|
||||
opts: { expiresAt?: number } = {},
|
||||
): LongTermEntry {
|
||||
const entry: LongTermEntry = {
|
||||
id: crypto.randomUUID(),
|
||||
category,
|
||||
@@ -62,7 +68,8 @@ export class LongTermMemory {
|
||||
confidence,
|
||||
createdAt: Date.now(),
|
||||
lastReferencedAt: Date.now(),
|
||||
referenceCount: 0
|
||||
referenceCount: 0,
|
||||
...(opts.expiresAt ? { expiresAt: opts.expiresAt } : {}),
|
||||
};
|
||||
this.store.entries.push(entry);
|
||||
// Enforce the retention cap — drop the oldest entries (by createdAt) once
|
||||
@@ -87,12 +94,32 @@ export class LongTermMemory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getAllEntries(): LongTermEntry[] {
|
||||
return [...this.store.entries];
|
||||
/** 만료된 entry 를 필터링한 활성 entries (검색·context build 가 보는 것). */
|
||||
private getActiveEntries(): LongTermEntry[] {
|
||||
const now = Date.now();
|
||||
return this.store.entries.filter((e) => !e.expiresAt || e.expiresAt > now);
|
||||
}
|
||||
|
||||
public getAllEntries(opts: { includeExpired?: boolean } = {}): LongTermEntry[] {
|
||||
return opts.includeExpired ? [...this.store.entries] : this.getActiveEntries();
|
||||
}
|
||||
|
||||
public getEntriesByCategory(category: LongTermCategory): LongTermEntry[] {
|
||||
return this.store.entries.filter((e) => e.category === category);
|
||||
return this.getActiveEntries().filter((e) => e.category === category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 entry 의 expiresAt 갱신. id 또는 id prefix (8자 이상) 로 식별.
|
||||
* 반환: 갱신된 entry 또는 null (못 찾음).
|
||||
*/
|
||||
public setExpiration(idOrPrefix: string, expiresAt: number): LongTermEntry | null {
|
||||
const match = this.store.entries.find((e) => e.id === idOrPrefix)
|
||||
|| (idOrPrefix.length >= 8 ? this.store.entries.find((e) => e.id.startsWith(idOrPrefix)) : undefined);
|
||||
if (!match) return null;
|
||||
match.expiresAt = expiresAt;
|
||||
this.dirty = true;
|
||||
this.save();
|
||||
return match;
|
||||
}
|
||||
|
||||
// ─── Context Building ───
|
||||
@@ -101,7 +128,9 @@ export class LongTermMemory {
|
||||
* 프롬프트와 관련성이 높은 Long-Term 기억을 반환합니다.
|
||||
*/
|
||||
public buildContext(currentPrompt: string, maxEntries = 10): MemoryContextResult | null {
|
||||
if (this.store.entries.length === 0) return null;
|
||||
// 만료된 entry 는 검색에서 자동 제외 — Temporal Markers 의 핵심.
|
||||
const activeEntries = this.getActiveEntries();
|
||||
if (activeEntries.length === 0) return null;
|
||||
|
||||
const promptLower = currentPrompt.toLowerCase();
|
||||
const terms = promptLower
|
||||
@@ -109,7 +138,7 @@ export class LongTermMemory {
|
||||
.filter((t) => t.length >= 2);
|
||||
|
||||
// Score entries by relevance to prompt
|
||||
const scored = this.store.entries.map((entry) => {
|
||||
const scored = activeEntries.map((entry) => {
|
||||
let score = 0;
|
||||
const contentLower = entry.content.toLowerCase();
|
||||
|
||||
@@ -134,8 +163,8 @@ export class LongTermMemory {
|
||||
.slice(0, maxEntries);
|
||||
|
||||
if (relevant.length === 0) {
|
||||
// Still include all rules and goals even without prompt match
|
||||
const alwaysInclude = this.store.entries
|
||||
// Still include all rules and goals even without prompt match — 만료 제외.
|
||||
const alwaysInclude = activeEntries
|
||||
.filter((e) => e.category === 'rule' || e.category === 'goal')
|
||||
.slice(0, 5);
|
||||
if (alwaysInclude.length === 0) return null;
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* Distillation Loop — stale Episodic Memory → Long-Term "episode-digest" 승급.
|
||||
*
|
||||
* 배경: Episodic Memory 가 무한히 누적되면 검색 노이즈. 30일+ 지난 에피소드는
|
||||
* "지금 이 순간 관련 가능성" 보다 "역사적 패턴" 가치가 커서, 디테일을 압축해
|
||||
* Long-Term 으로 옮기고 원본은 archive 하는 게 효율적.
|
||||
*
|
||||
* v1 설계 (LLM-less, 예측 가능):
|
||||
* - LLM 호출 없이 기존 EpisodicEntry 의 title/summary/keyDecisions/topics 를
|
||||
* 구조적으로 결합해 LongTerm 'episode-digest' content 생성
|
||||
* - 장점: 비용 0, 결정적·재현 가능, LM Studio 다운 시에도 동작
|
||||
* - 단점: LLM 요약보다 농축도 낮음 — 추후 strict 모드에서 LLM 패스 추가 가능
|
||||
*
|
||||
* 원본 episode 처리: 두 가지 옵션 — 사용자 설정으로 결정.
|
||||
* - 'mark-promoted' (기본): promoted=true 마킹만, 파일 보존. 검색에서 제외되나
|
||||
* 히스토리·디버깅용으로 디스크에 남음.
|
||||
* - 'archive-file': promoted 마킹 + 파일을 memory/episodes/archive/ 로 이동.
|
||||
* 디스크 정리에 더 깔끔하나 복구 시 수동.
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { EpisodicMemory } from './EpisodicMemory';
|
||||
import { LongTermMemory } from './LongTermMemory';
|
||||
import { EpisodicEntry } from './types';
|
||||
|
||||
export type DistillationArchiveMode = 'mark-promoted' | 'archive-file';
|
||||
|
||||
export interface DistillationOptions {
|
||||
/** 며칠 이상 지난 episode 를 대상으로. 기본 30. */
|
||||
ageThresholdDays: number;
|
||||
/** Archive 처리 방식. 기본 'mark-promoted'. */
|
||||
archiveMode: DistillationArchiveMode;
|
||||
/** 한 번에 처리할 최대 episode 수 (안전장치). 기본 50. */
|
||||
maxBatchSize: number;
|
||||
}
|
||||
|
||||
export const DEFAULT_DISTILLATION_OPTIONS: DistillationOptions = {
|
||||
ageThresholdDays: 30,
|
||||
archiveMode: 'mark-promoted',
|
||||
maxBatchSize: 50,
|
||||
};
|
||||
|
||||
export interface DistillationReport {
|
||||
candidateCount: number;
|
||||
promotedCount: number;
|
||||
archivedCount: number;
|
||||
longTermDigestIds: string[];
|
||||
skipped: { episodeId: string; reason: string }[];
|
||||
durationMs: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Episode → LongTerm 'episode-digest' content 변환. 결정적·LLM 없음.
|
||||
*/
|
||||
function episodeToDigestContent(ep: EpisodicEntry): string {
|
||||
const date = new Date(ep.timestamp).toISOString().slice(0, 10);
|
||||
const parts: string[] = [];
|
||||
parts.push(`[${date}] ${ep.title}`);
|
||||
if (ep.summary && ep.summary.trim()) parts.push(`요약: ${ep.summary.trim()}`);
|
||||
if (ep.keyDecisions && ep.keyDecisions.length > 0) {
|
||||
parts.push(`결정: ${ep.keyDecisions.slice(0, 5).join(' · ')}`);
|
||||
}
|
||||
if (ep.topics && ep.topics.length > 0) {
|
||||
parts.push(`토픽: ${ep.topics.slice(0, 8).join(', ')}`);
|
||||
}
|
||||
return parts.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Distillation 실행 — stale episodes 를 LongTerm digest 로 승급 + archive.
|
||||
*
|
||||
* 호출자: `/memory distill` 슬래시 명령 + 세션 종료 시 auto-trigger (선택).
|
||||
*/
|
||||
export function distillStaleEpisodes(
|
||||
episodicMemory: EpisodicMemory,
|
||||
longTermMemory: LongTermMemory,
|
||||
brainPath: string,
|
||||
options: Partial<DistillationOptions> = {},
|
||||
): DistillationReport {
|
||||
const opts: DistillationOptions = { ...DEFAULT_DISTILLATION_OPTIONS, ...options };
|
||||
const start = Date.now();
|
||||
const report: DistillationReport = {
|
||||
candidateCount: 0,
|
||||
promotedCount: 0,
|
||||
archivedCount: 0,
|
||||
longTermDigestIds: [],
|
||||
skipped: [],
|
||||
durationMs: 0,
|
||||
};
|
||||
|
||||
const candidates = episodicMemory.findStaleEpisodes(opts.ageThresholdDays).slice(0, opts.maxBatchSize);
|
||||
report.candidateCount = candidates.length;
|
||||
|
||||
if (candidates.length === 0) {
|
||||
report.durationMs = Date.now() - start;
|
||||
return report;
|
||||
}
|
||||
|
||||
const archiveDir = path.join(brainPath, 'memory', 'episodes', 'archive');
|
||||
if (opts.archiveMode === 'archive-file') {
|
||||
try { fs.mkdirSync(archiveDir, { recursive: true }); } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
for (const ep of candidates) {
|
||||
try {
|
||||
// 1. LongTerm digest entry 생성. confidence 약간 낮춤 (압축 손실 반영).
|
||||
const digestContent = episodeToDigestContent(ep);
|
||||
const digest = longTermMemory.addEntry(
|
||||
'episode-digest',
|
||||
digestContent,
|
||||
`episodic:${ep.id}`,
|
||||
0.7,
|
||||
);
|
||||
report.longTermDigestIds.push(digest.id);
|
||||
|
||||
// 2. 원본 episode 처리.
|
||||
const marked = episodicMemory.markPromoted(ep.id, digest.id);
|
||||
if (!marked) {
|
||||
report.skipped.push({ episodeId: ep.id, reason: 'markPromoted failed (file not found)' });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opts.archiveMode === 'archive-file') {
|
||||
// 파일 위치 찾아서 archive 디렉터리로 이동.
|
||||
const moved = tryMoveEpisodeFileToArchive(ep.id, path.join(brainPath, 'memory', 'episodes'), archiveDir);
|
||||
if (moved) report.archivedCount++;
|
||||
}
|
||||
report.promotedCount++;
|
||||
} catch (e: any) {
|
||||
report.skipped.push({ episodeId: ep.id, reason: e?.message || String(e) });
|
||||
}
|
||||
}
|
||||
|
||||
report.durationMs = Date.now() - start;
|
||||
return report;
|
||||
}
|
||||
|
||||
function tryMoveEpisodeFileToArchive(episodeId: string, episodeDir: string, archiveDir: string): boolean {
|
||||
try {
|
||||
const files = fs.readdirSync(episodeDir).filter((f) => f.endsWith('.json'));
|
||||
for (const file of files) {
|
||||
const full = path.join(episodeDir, file);
|
||||
try {
|
||||
const raw = fs.readFileSync(full, 'utf-8');
|
||||
const parsed = JSON.parse(raw) as EpisodicEntry;
|
||||
if (parsed.id === episodeId) {
|
||||
fs.renameSync(full, path.join(archiveDir, file));
|
||||
return true;
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Distillation 마지막 실행 시각을 저장·조회 — 자동 트리거가 *너무 자주* 안 돌도록.
|
||||
* brainPath 의 marker 파일 사용 (vscode.globalState 안 쓰는 이유: 메모리 인프라가
|
||||
* BrainProfile-scoped 라 brain 디렉터리에 두는 게 일관성 있음).
|
||||
*/
|
||||
const MARKER_FILE = 'distillation_last_run.json';
|
||||
|
||||
export interface DistillationMarker {
|
||||
timestamp: number;
|
||||
report?: Partial<DistillationReport>;
|
||||
}
|
||||
|
||||
export function getLastDistillationRun(brainPath: string): DistillationMarker | null {
|
||||
try {
|
||||
const fp = path.join(brainPath, 'memory', MARKER_FILE);
|
||||
if (!fs.existsSync(fp)) return null;
|
||||
return JSON.parse(fs.readFileSync(fp, 'utf-8')) as DistillationMarker;
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export function recordDistillationRun(brainPath: string, report: DistillationReport): void {
|
||||
try {
|
||||
const dir = path.join(brainPath, 'memory');
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
const marker: DistillationMarker = {
|
||||
timestamp: Date.now(),
|
||||
report: {
|
||||
candidateCount: report.candidateCount,
|
||||
promotedCount: report.promotedCount,
|
||||
archivedCount: report.archivedCount,
|
||||
durationMs: report.durationMs,
|
||||
},
|
||||
};
|
||||
fs.writeFileSync(path.join(dir, MARKER_FILE), JSON.stringify(marker, null, 2), 'utf-8');
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
/** 자동 트리거 게이트 — 마지막 실행 후 N일 경과 시 true. */
|
||||
export function shouldAutoDistill(brainPath: string, intervalDays: number): boolean {
|
||||
const last = getLastDistillationRun(brainPath);
|
||||
if (!last) return true;
|
||||
const elapsed = (Date.now() - last.timestamp) / (1000 * 60 * 60 * 24);
|
||||
return elapsed >= intervalDays;
|
||||
}
|
||||
+39
-2
@@ -20,6 +20,12 @@ import { ProceduralMemory } from './ProceduralMemory';
|
||||
import { EpisodicMemory } from './EpisodicMemory';
|
||||
import { MemoryExtractor } from './MemoryExtractor';
|
||||
import { MemoryContextResult, MemoryConfig } from './types';
|
||||
import {
|
||||
distillStaleEpisodes,
|
||||
shouldAutoDistill,
|
||||
recordDistillationRun,
|
||||
type DistillationArchiveMode,
|
||||
} from './distillation';
|
||||
|
||||
export { ShortTermMemory } from './ShortTermMemory';
|
||||
export { LongTermMemory } from './LongTermMemory';
|
||||
@@ -27,6 +33,17 @@ export { ProjectMemory } from './ProjectMemory';
|
||||
export { ProceduralMemory } from './ProceduralMemory';
|
||||
export { EpisodicMemory } from './EpisodicMemory';
|
||||
export { MemoryExtractor } from './MemoryExtractor';
|
||||
export {
|
||||
distillStaleEpisodes,
|
||||
getLastDistillationRun,
|
||||
recordDistillationRun,
|
||||
shouldAutoDistill,
|
||||
DEFAULT_DISTILLATION_OPTIONS,
|
||||
type DistillationOptions,
|
||||
type DistillationReport,
|
||||
type DistillationMarker,
|
||||
type DistillationArchiveMode,
|
||||
} from './distillation';
|
||||
export * from './types';
|
||||
|
||||
export class MemoryManager {
|
||||
@@ -132,11 +149,18 @@ export class MemoryManager {
|
||||
public onSessionEnd(
|
||||
sessionId: string,
|
||||
messages: Array<{ role: string; content: string; timestamp?: number }>,
|
||||
workspacePath?: string
|
||||
workspacePath?: string,
|
||||
distillationOpts?: {
|
||||
enabled: boolean;
|
||||
ageThresholdDays: number;
|
||||
intervalDays: number;
|
||||
archiveMode: DistillationArchiveMode;
|
||||
brainPath: string;
|
||||
},
|
||||
): void {
|
||||
if (!this.config.enabled) return;
|
||||
|
||||
const projectMemory = workspacePath
|
||||
const projectMemory = workspacePath
|
||||
? this.getProjectMemory(workspacePath)
|
||||
: null;
|
||||
|
||||
@@ -153,6 +177,19 @@ export class MemoryManager {
|
||||
|
||||
// Persist long-term memory
|
||||
this.longTerm.save();
|
||||
|
||||
// Auto-distillation — Distillation Loop 가 enabled 이고 interval 충족 시 stale
|
||||
// episodes 를 LongTerm digest 로 승급. 세션 종료 시점이 자연스러움 — 사용자가
|
||||
// 다음 세션 시작 전 한 번 cleanup.
|
||||
if (distillationOpts?.enabled && shouldAutoDistill(distillationOpts.brainPath, distillationOpts.intervalDays)) {
|
||||
try {
|
||||
const report = distillStaleEpisodes(this.episodic, this.longTerm, distillationOpts.brainPath, {
|
||||
ageThresholdDays: distillationOpts.ageThresholdDays,
|
||||
archiveMode: distillationOpts.archiveMode,
|
||||
});
|
||||
recordDistillationRun(distillationOpts.brainPath, report);
|
||||
} catch { /* distillation should never break session end */ }
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Direct Access (for UI & advanced features) ───
|
||||
|
||||
+26
-1
@@ -28,7 +28,12 @@ export interface ShortTermMessage {
|
||||
|
||||
// ─── ② Long-Term Memory ───
|
||||
|
||||
export type LongTermCategory = 'preference' | 'rule' | 'decision' | 'goal';
|
||||
/**
|
||||
* Long-term category.
|
||||
* - 'episode-digest' 는 Distillation Loop 가 stale episodic memory 를 long-term 으로
|
||||
* 승급시킬 때 사용. 사용자가 직접 만드는 'decision' / 'rule' 등과 시각적으로 구분.
|
||||
*/
|
||||
export type LongTermCategory = 'preference' | 'rule' | 'decision' | 'goal' | 'episode-digest';
|
||||
|
||||
export interface LongTermEntry {
|
||||
id: string;
|
||||
@@ -39,6 +44,14 @@ export interface LongTermEntry {
|
||||
createdAt: number;
|
||||
lastReferencedAt: number;
|
||||
referenceCount: number;
|
||||
/**
|
||||
* Temporal marker — 이 사실이 *유효한 마지막 시점* (epoch ms).
|
||||
* 검색·context build 단계에서 expiresAt < now 인 entry 는 자동 제외.
|
||||
* undefined 면 영구 유효 (legacy 동작).
|
||||
*
|
||||
* 사용 예: "Q3 2026 마케팅 계획은 9월 30일까지만 유효" → expiresAt = 2026-09-30 epoch.
|
||||
*/
|
||||
expiresAt?: number;
|
||||
}
|
||||
|
||||
export interface LongTermStore {
|
||||
@@ -105,6 +118,18 @@ export interface EpisodicEntry {
|
||||
timestamp: number;
|
||||
duration: number; // 세션 길이 (ms)
|
||||
messageCount: number;
|
||||
/**
|
||||
* Temporal marker — 에피소드의 *유효 마지막 시점* (epoch ms). 검색에서 자동 제외.
|
||||
* undefined 면 영구 (Distillation 이 archive 할 때까지).
|
||||
*/
|
||||
expiresAt?: number;
|
||||
/**
|
||||
* Distillation Loop 가 이 episode 를 LongTerm digest 로 promote 했음을 표시.
|
||||
* promoted=true 면 검색·context build 에서 제외 (LongTerm 에 digest 가 있으니).
|
||||
*/
|
||||
promoted?: boolean;
|
||||
/** promoted 인 경우 — 생성된 LongTerm digest entry id (역참조용). */
|
||||
promotedToLongTermId?: string;
|
||||
}
|
||||
|
||||
export interface EpisodicStore {
|
||||
|
||||
Reference in New Issue
Block a user