mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 17:27:31 +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:
@ -15,9 +15,28 @@ import (
|
||||
pubsdk "github.com/JianFeeeee/hologramagentsdk/sdk"
|
||||
)
|
||||
|
||||
// newTestEvents 构造一个**已装上安全闸门**的受限事件面。
|
||||
//
|
||||
// ## ★ 为什么必须装 Guard(2026-10-29 收敛后)
|
||||
//
|
||||
// 此前 `sdk/events.go` 自己查策略(checkPublish/checkSubscribe/scrubOut),
|
||||
// 所以测试里的裸 bus 也能"看起来工作"。收敛后授权与脱敏全部归
|
||||
// `security.eventGuard`,而闸门是挂在总线上的 —— **测试不装 Guard,
|
||||
// 就等于在测一条没有执行者的策略**,于是判据会假绿。
|
||||
//
|
||||
// 这正好顺便钉住了生产装配要求:**总线必须带闸门**,否则策略不生效。
|
||||
func newTestEvents(t *testing.T, name string) (pubsdk.EventsAPI, *events.Bus) {
|
||||
t.Helper()
|
||||
bus := events.NewBus()
|
||||
// 用当前全局 Runtime 造闸门(未装配时 NewRuntime(nil) 给 Disabled Runtime,
|
||||
// 策略仍生效 —— 与生产同一条纪律:关闭凭据替换 ≠ 放开授权)。
|
||||
rt := security.RuntimeGlobal()
|
||||
if rt == nil {
|
||||
rt = security.NewRuntime(nil)
|
||||
}
|
||||
if g := security.AsEventGuard(rt); g != nil {
|
||||
bus.SetGuard(g)
|
||||
}
|
||||
return newEventsAPI(name, bus), bus
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user