Files
Enterprise-Knowledge-Base/internal/application/service/session_agent_qa_scope_test.go
T
wizardchen b86efe3f92 fix(agent): harden @mention scope and simplify must_use hints
Tighten per-turn @MCP/@Skill/@tag handling after review: enforce agent
MCP/Skill whitelist, ignore mentions when selection mode is none, tag-scope
grep_chunks, and simplified English must_use lines without tool dumps.
Skip persisting scope envelopes to history rendered_content.
2026-06-29 18:09:44 +08:00

63 lines
1.4 KiB
Go

package service
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestResolvePerRequestMCPScope_SelectedIntersection(t *testing.T) {
effective, mode := resolvePerRequestMCPScope(
[]string{"mcp-b", "mcp-c"},
[]string{"mcp-a", "mcp-b"},
"selected",
false,
)
assert.Equal(t, "selected", mode)
assert.Equal(t, []string{"mcp-b"}, effective)
}
func TestResolvePerRequestMCPScope_SelectedRejectsOutsidePreset(t *testing.T) {
effective, mode := resolvePerRequestMCPScope(
[]string{"mcp-x"},
[]string{"mcp-a"},
"selected",
false,
)
assert.Empty(t, effective)
assert.Equal(t, "selected", mode)
}
func TestResolvePerRequestMCPScope_NoneRejectsMention(t *testing.T) {
effective, mode := resolvePerRequestMCPScope(
[]string{"mcp-iwiki"},
nil,
"none",
false,
)
assert.Empty(t, effective)
assert.Equal(t, "none", mode)
}
func TestResolvePerRequestMCPScope_SharedAgentBlocksOutsidePreset(t *testing.T) {
effective, mode := resolvePerRequestMCPScope(
[]string{"mcp-x"},
[]string{"mcp-a"},
"all",
true,
)
assert.Empty(t, effective)
assert.Equal(t, "all", mode)
}
func TestResolvePerRequestMCPScope_SharedAgentAllowsPreset(t *testing.T) {
effective, mode := resolvePerRequestMCPScope(
[]string{"mcp-a", "mcp-x"},
[]string{"mcp-a", "mcp-b"},
"all",
true,
)
assert.Equal(t, "selected", mode)
assert.Equal(t, []string{"mcp-a"}, effective)
}