Files
Agent-System-Backend/internal/runmgr/notice_recursion_test.go
T
weichen f1302ed5b3 Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:47:16 +00:00

47 lines
1.5 KiB
Go

package runmgr
import (
"testing"
"time"
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/store"
core "git-ssh.u1680832.nyat.app/weichen/Agent-System-Core.git"
)
// U3 真库门禁回归(job 2352 栈溢出):投递失败(会话行不存在)时旧实现的
// defer 同步再入 deliverNotices 无限自递归。修复后:单次有界返回、通知
// 保留在队列,由下一次触发或重启重投驱动。
func TestNoticeDeliveryFailureIsBounded(t *testing.T) {
runner := &gateRunner{parts: []core.Part{{Type: core.PartText, Text: "结果"}}}
c, _ := newSpawnEnv(t, runner)
c.mgr.SetWorkspaceRoot(t.TempDir())
convID := core.ID(store.NewID("cnv"))
c.mgr.enqueueNotice(convID, bgNotice{owner: c.run.Owner, name: "检索", payload: core.AgentResultPayload{Status: "completed"}})
done := make(chan struct{})
go func() {
c.mgr.deliverNotices(convID)
close(done)
}()
select {
case <-done:
case <-time.After(5 * time.Second):
t.Fatal("deliverNotices 未返回:失败重投仍在递归/自旋")
}
c.mgr.noticeMu.Lock()
queued := len(c.mgr.notices[convID])
c.mgr.noticeMu.Unlock()
if queued != 1 {
t.Fatalf("失败应保留待投通知:queued=%d", queued)
}
// 第二次触发同样有界(不因重试堆积)。
c.mgr.deliverNotices(convID)
c.mgr.noticeMu.Lock()
queued = len(c.mgr.notices[convID])
c.mgr.noticeMu.Unlock()
if queued != 1 {
t.Fatalf("重复失败不应堆积通知:queued=%d", queued)
}
}