Why: Knowledge retrieval cross-owner and conversation-card mirroring are the registered EXT-8 slice-2 items; the fields/wiring land with the acceptance reds pinned first. Evidence: mirror red (project channel still emitted with switch off); shared-retrieval red (grant yields 0 hits); SSE-scope red (grant yields non-200); rows follow on the task card. Impact: Options.DisableConvCardMirror passthrough (extension/link/app); cardsvc.MirrorConvCards (default true = current behavior); SurfaceVersion 2.3.0-experimental. Behavior unchanged. Refs: EXT-8/EXT-12 proposals; task card.
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package cardsvc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"agent-system-backend/internal/store"
|
|
core "agent-system-core"
|
|
)
|
|
|
|
// EXT-12 最小开关(红测):MirrorConvCards=false 时会话卡不镜像进项目公共流
|
|
// (不发布即不持久,重放天然不含会话卡);项目级卡不受影响;缺省 true 保持现状。
|
|
func TestConvCardMirrorSwitch(t *testing.T) {
|
|
newSvc := func(mirror bool) (*Service, *[]string) {
|
|
chans := []string{}
|
|
emit := func(convID, runID string, typ core.StreamEventType, payload any) error {
|
|
chans = append(chans, convID)
|
|
return nil
|
|
}
|
|
st, err := store.OpenSQLite(t.TempDir() + "/cards.db")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { st.Close() })
|
|
svc := New(st, emit)
|
|
svc.MirrorConvCards = mirror
|
|
return svc, &chans
|
|
}
|
|
card := core.ActivityCard{ConversationID: "c-priv", ProjectID: "p-1", Kind: core.CardKindProgress, Title: "私有过程卡"}
|
|
|
|
// 开(缺省现状):会话流 + 项目流双发。
|
|
svc, chans := newSvc(true)
|
|
if _, err := svc.Create("alice", card, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans) != 2 {
|
|
t.Fatalf("mirror on: emitted %v, want 会话流+项目流", *chans)
|
|
}
|
|
|
|
// 关:只进本人会话流,项目公共流零事件。
|
|
svc2, chans2 := newSvc(false)
|
|
if _, err := svc2.Create("alice", card, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans2) != 1 || (*chans2)[0] != "c-priv" {
|
|
t.Fatalf("mirror off: emitted %v, want 仅会话流 c-priv(项目流不得发布)", *chans2)
|
|
}
|
|
|
|
// 项目级卡(无会话归属)不受开关影响。
|
|
pc := core.ActivityCard{ProjectID: "p-1", Kind: core.CardKindProgress, Title: "项目级卡"}
|
|
if _, err := svc2.Create("alice", pc, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans2) != 2 || (*chans2)[1] != string(core.ProjectChannelKey("p-1")) {
|
|
t.Fatalf("project-level card must still publish: %v", *chans2)
|
|
}
|
|
}
|