MCPcopy Create free account
hub / github.com/astercloud/aster / DeleteMemoryWithLineage

Method DeleteMemoryWithLineage

pkg/memory/lineage.go:199–217  ·  view source on GitHub ↗

DeleteMemoryWithLineage 删除记忆及其派生记忆。

(ctx context.Context, memoryID string, cascade bool)

Source from the content-addressed store, hash-verified

197
198// DeleteMemoryWithLineage 删除记忆及其派生记忆。
199func (lm *LineageManager) DeleteMemoryWithLineage(ctx context.Context, memoryID string, cascade bool) ([]string, error) {
200 var deletedIDs []string
201
202 if cascade {
203 // 级联删除:包括所有派生记忆
204 derivedIDs := lm.graph.GetDerivedMemories(memoryID)
205 deletedIDs = append([]string{memoryID}, derivedIDs...)
206 } else {
207 // 仅删除当前记忆
208 deletedIDs = []string{memoryID}
209 }
210
211 // 从谱系图中移除
212 for _, id := range deletedIDs {
213 lm.graph.RemoveMemory(id)
214 }
215
216 return deletedIDs, nil
217}
218
219// RevokeDataSource 撤销数据源权限。
220// 删除所有派生自该数据源的记忆。

Calls 2

GetDerivedMemoriesMethod · 0.80
RemoveMemoryMethod · 0.80