feat(ambient): sentinel core — evidence ring, Line, deps

This commit is contained in:
2026-06-05 21:33:59 -04:00
parent b37ee40dd2
commit af3a0e2ac8
2 changed files with 201 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
// internal/ambient/sentinel_test.go
package ambient
import (
"context"
"testing"
"keel/internal/evidence"
)
func snap(title, class string) evidence.WindowSnapshot {
return evidence.WindowSnapshot{Title: title, Class: class, Health: evidence.EvidenceHealth{Available: true}}
}
func TestNewLineEmpty(t *testing.T) {
s := New(Deps{}, 0, "notify")
if s.Line() != "" {
t.Fatalf("fresh sentinel line = %q, want empty", s.Line())
}
}
func TestOnWindowRingDedupesAndCaps(t *testing.T) {
s := New(Deps{}, 0, "notify")
s.OnWindow(snap("a", "x"))
s.OnWindow(snap("a", "x")) // consecutive dup ignored
s.OnWindow(snap("b", "x"))
if got := s.recentForTest(); len(got) != 2 || got[0] != "a" || got[1] != "b" {
t.Fatalf("ring = %v, want [a b]", got)
}
for i := 0; i < recentTitlesMax+5; i++ {
s.OnWindow(snap(string(rune('A'+i)), "x"))
}
if got := s.recentForTest(); len(got) != recentTitlesMax {
t.Fatalf("ring len = %d, want %d", len(got), recentTitlesMax)
}
}
func TestOnWindowSkipsEmptyTitle(t *testing.T) {
s := New(Deps{}, 0, "notify")
s.OnWindow(snap("", "x"))
if got := s.recentForTest(); len(got) != 0 {
t.Fatalf("empty title must not enter ring, got %v", got)
}
}
var _ = context.Background