mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 01:07:35 +00:00
feat: 段页式记忆流转、coldcontext 重命名与安全治理
记忆层: - MemoryBlock 承载 FrameTS/PageSeq/PageKind/BlockRole/CallID - coldcontext 归档与回填按完整页传递,工具调用参数和配对键不丢失 - 召回先估算总 token,超预算时按全局页相似度标记 inactive - inactive 仅是 context 渲染期状态,不落盘、不进入 coldcontext,Prune 后重置 - Peek/确认/Remove 两阶段召回,失败保留冷上下文副本 - stablemem 记录 last_recalled_at,删块连带清理边 命名: - internal/memory/document → internal/memory/coldcontext - Doc/DocEvent/DocHit → ColdDoc/ColdEvent/ColdHit - ContextToColdContext/RecentColdContexts/FindColdContexts - 保留既有 JSON 标签、doc_ 文件前缀与 doc_count 状态键,兼容存量数据 安全治理: - 工具策略门禁、安全配置、事件总线发布者身份与入站脱敏 - 声明式 SecurityAPI 与 QQ owner/guest profile - 日志保留策略与相关 e2e/回归判据 验证:go build ./...、go vet ./...、go test ./...(62 包); 生产副本 e2e:7013 块迁移后 ID/向量/指纹 0 变化、0 缺失。
This commit is contained in:
@ -87,5 +87,35 @@ func (g *eventGuard) ScrubPayload(eventType events.EventType, payload map[string
|
||||
return out
|
||||
}
|
||||
|
||||
// ScrubInbound 对**入向**载荷逐字段清洗(投递给订阅者之前)。
|
||||
//
|
||||
// 与 ScrubPayload 对称,但用的是 Inbound 方向:
|
||||
// 外部模块写进载荷的明文凭据在这里被换回别名。
|
||||
//
|
||||
// 为何必须在总线上做(而不是订阅方的适配层):
|
||||
// 总线是**唯一的投递点**,而订阅入口有四五条。在适配层做就只好每条
|
||||
// 各自实现一遍(实际就是这么发生的:sdk 侧曾有一份 scrubIn),
|
||||
// 漏一条就是漏一条路径。安全模块持有总线 ⇒ 在这里做一次就覆盖全部。
|
||||
func (g *eventGuard) ScrubInbound(eventType events.EventType, payload map[string]interface{}) map[string]interface{} {
|
||||
if g.rt == nil || payload == nil {
|
||||
return payload
|
||||
}
|
||||
out := make(map[string]interface{}, len(payload))
|
||||
for k, v := range payload {
|
||||
if s, ok := v.(string); ok && s != "" {
|
||||
clean, n := g.rt.ScrubInbound(Inspection{
|
||||
Direction: DirectionInbound,
|
||||
Stage: "event:" + string(eventType),
|
||||
}, s)
|
||||
if n > 0 {
|
||||
out[k] = clean
|
||||
continue
|
||||
}
|
||||
}
|
||||
out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// 编译期确认实现了 events.Guard。
|
||||
var _ events.Guard = (*eventGuard)(nil)
|
||||
|
||||
Reference in New Issue
Block a user