fix(memory): 读侧过 status 闸 —— 软删行不再被检索、不再进面板
整理(tidy)与入库前审查(D3)都只做软动作:status 改 merged/archived, 正文一个字不改、行一行不删。因此只要有一条「能看到什么记忆」的读路径 漏了 status 闸,清理就等于白清 —— 生产库上那 10 条 merged 行就是反例。 - store.go:ListByPersona / List 加 status='active' - rules.go:ListScope / ListProject 加 status='active' - Get 刻意不过闸(撤销软合并要先读得到被吸收的行),并在注释里写明 - gateway/admin.go collectMemories 只加注释:口径只有一处,不重复过滤 验证:go build ./... + go vet 绿;memory 包全量测试绿; 新增 status_gate_test.go(4 条读路径逐条断言 + Retriever 端到端 「内容逐字相同的两条,软合并后只召回一条」+ Get 反向护栏); 用 -overlay 把闸门变异成恒真 ⇒ 5 个读路径用例与检索端到端用例全红。
This commit is contained in:
1 parent
c2e413ec38
commit
9126d653e5
4 files changed
+233
-11
No files matched your search
@@ -82,8 +82,8 @@ func (s *Store) ListScope(ctx context.Context, scope Scope, personaID string) ([
|
||||
}
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT id, persona_id, role_id, project_id, scope, kind,
|
||||
content, tags, confidence, source_conversation, created_at, updated_at,
|
||||
decay_weight FROM memory_items WHERE scope = ?
|
||||
ORDER BY created_at DESC, rowid DESC`, string(scope))
|
||||
decay_weight FROM memory_items WHERE scope = ? AND status = ?
|
||||
ORDER BY created_at DESC, rowid DESC`, string(scope), string(tidyStatusActive))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("memory: list scope items: %w", err)
|
||||
}
|
||||
@@ -103,8 +103,8 @@ func (s *Store) ListProject(ctx context.Context, projectID string) ([]MemoryItem
|
||||
}
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT id, persona_id, role_id, project_id, scope, kind,
|
||||
content, tags, confidence, source_conversation, created_at, updated_at,
|
||||
decay_weight FROM memory_items WHERE project_id = ?
|
||||
ORDER BY created_at DESC, rowid DESC`, projectID)
|
||||
decay_weight FROM memory_items WHERE project_id = ? AND status = ?
|
||||
ORDER BY created_at DESC, rowid DESC`, projectID, string(tidyStatusActive))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("memory: list project items: %w", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user