fix(memory): 堵住 knowledge 工具绕过群聊/陌生人过滤的 P0 / owner 召回 hits 如实上报 / 静默吞点补来源日志
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

This commit is contained in:
AskaEth committed 2026-10-05 11:30:51 +08:00
1 parent e792baa316
commit eeb5f26668
5 files changed
+250 -52

No files matched your search

+9
View File
@@ -7,6 +7,7 @@ import (
"log/slog"
"strings"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/loop"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/memory"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/tool"
"git.yeij.top/AskaEth/Cyrene_v2/pkg/plugins/sdk"
@@ -94,6 +95,14 @@ func (k *knowledgeTool) Execute(ctx context.Context, args any) (any, error) {
if err != nil {
return nil, fmt.Errorf("io: knowledge: retrieve: %w", err)
}
// 群聊/陌生人(受限环境)只读非敏感的共享域记忆:复用循环注入路径上的
// 同一隔离判据(loop.FilterSharedVisible),绝不另造第二套 —— 否则一旦
// 管理面板把本工具放行给群聊/陌生人,就会返回角色日常(ScopePersona,
// 主人私有)与 L4 意图记录(主人逐句原话),触碰 design/03 §5
// 「不泄露主人敏感信息」(审计 2026-10-05,P0 红线)。
if loop.SessionEnvFrom(ctx).Restricted() {
results = loop.FilterSharedVisible(results)
}
out := make([]map[string]any, 0, len(results))
for _, r := range results {
out = append(out, map[string]any{