返回 DeepSeek-Reasonix
goal_progress.go
根目录 / internal / control / goal_progress.go
1 package control
2
3 import "strings"
4
5 // mergeGoalProgressEvidence updates the bounded Goal-scoped novelty window.
6 func mergeGoalProgressEvidence(existing, observed []string) ([]string, bool) {
7 if len(existing) > maxGoalProgressEvidence {
8 existing = existing[len(existing)-maxGoalProgressEvidence:]
9 }
10 if len(observed) > maxGoalProgressEvidence {
11 observed = observed[len(observed)-maxGoalProgressEvidence:]
12 }
13 out := make([]string, 0, min(len(existing)+len(observed), maxGoalProgressEvidence))
14 seen := make(map[string]struct{}, min(len(existing)+len(observed), maxGoalProgressEvidence))
15 appendValid := func(sig string) bool {
16 sig = strings.TrimSpace(sig)
17 if sig == "" || len(sig) > 128 {
18 return false
19 }
20 if _, ok := seen[sig]; ok {
21 return false
22 }
23 seen[sig] = struct{}{}
24 out = append(out, sig)
25 return true
26 }
27 for _, sig := range existing {
28 appendValid(sig)
29 }
30 progressed := false
31 for _, sig := range observed {
32 if appendValid(sig) {
33 progressed = true
34 }
35 }
36 if len(out) > maxGoalProgressEvidence {
37 out = append([]string(nil), out[len(out)-maxGoalProgressEvidence:]...)
38 }
39 return out, progressed
40 }
41
41 lines GO