feat(memory): M4 记忆完善(三类作用域访问规则+项目索引分层+LLM异步提取+衰减溯源+向量接入,兼容既有57用例)

This commit is contained in:
Aska committed 2026-09-06 06:15:18 +08:00
1 parent 5b37f5a551
commit d947ec41a9
10 files changed
+1349 -53

No files matched your search

+14 -4
View File
@@ -2,17 +2,27 @@ package memory
import (
"context"
"errors"
"strings"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
)
var (
// ErrNilAdapter is returned when an LLMExtractor is built or used without a
// model.Adapter to drive extraction.
ErrNilAdapter = errors.New("memory: nil model adapter")
)
// Extractor derives candidate memory items from a conversation (design §1).
//
// The production path is an LLM-driven asynchronous extractor that denoises and
// deduplicates each turn; that is deferred to milestone M4, and its integration
// point is this interface. The M2 implementation is the rule-based
// ManualExtractor, which only records what the user explicitly asks to remember.
// Two implementations exist:
//
// - LLMExtractor: asks a model.Adapter to denoise and deduplicate each turn,
// running synchronously (Extract) or on a background goroutine
// (ExtractAsync).
// - ManualExtractor: deterministic, rule-based — it only records what the user
// explicitly asks to remember ("记住 X").
type Extractor interface {
// Extract returns memory items worth persisting from conversation. ctx
// controls cancellation; a canceled context returns an error.