chore: checkpoint uncommitted work before session store fix

Pre-existing work-in-progress in the tree: karakeep, snippets,
skills-health and redaction ingesters, the opencode.db session sweep,
gossip and metrics changes. Checkpointed as-is so the adapter fix in the
next commit stays reviewable on its own.
This commit is contained in:
2026-11-01 13:33:36 -08:00
parent 876d2aa45f
commit edf6c03a7c
43 changed files with 6828 additions and 492 deletions
+72
View File
@@ -0,0 +1,72 @@
package noise
import "testing"
func TestIsNoisyURL(t *testing.T) {
webapps := []string{
"https://mail.google.com/mail/u/0/#inbox",
"https://calendar.google.com/calendar/u/0/r",
"https://app.privacy.com/",
"https://login.microsoftonline.com/common/oauth2",
"https://accounts.google.com/signin",
}
for _, u := range webapps {
if !IsNoisyURL(u) {
t.Errorf("expected webapp URL to be filtered: %s", u)
}
}
signals := []string{
"https://github.com/david/knox/pull/3",
"https://go.dev/blog/go1.26",
"https://git.notsosm.art/david/knox",
}
for _, u := range signals {
if IsNoisyURL(u) {
t.Errorf("expected signal URL to pass: %s", u)
}
}
}
func TestBuildPatternsEnv(t *testing.T) {
t.Setenv("KNOX_BROWSER_DENY", "example-webapp.io, Foo.Example")
found := map[string]bool{}
for _, p := range BuildPatterns() {
found[p] = true
}
if !found["example-webapp.io"] || !found["foo.example"] {
t.Fatalf("KNOX_BROWSER_DENY not applied lowercased")
}
}
func TestDenyKeywords(t *testing.T) {
kw := DenyKeywords()
// Derived from specific webapp domains.
for _, want := range []string{"privacy", "chatgpt", "kagi", "bankofamerica", "simplefin", "microsoftonline"} {
if !kw[want] {
t.Errorf("expected deny keyword %q", want)
}
}
// Generic labels and path patterns must NOT deny.
for _, bad := range []string{"google", "live", "apple", "opencode", "github"} {
if kw[bad] {
t.Errorf("generic label %q must not be a deny keyword", bad)
}
}
}
func TestIsDeniedTopic(t *testing.T) {
if !IsDeniedTopic("privacy / virtual / card") {
t.Error("expected privacy thread to be denied")
}
if IsDeniedTopic("nr-flow-validator Rego validation") {
t.Error("work thread must not be denied")
}
}
func TestDenyKeywordEnv(t *testing.T) {
t.Setenv("KNOX_THREAD_DENY", "newsletter, CouponSite")
kw := DenyKeywords()
if !kw["newsletter"] || !kw["couponsite"] {
t.Fatalf("KNOX_THREAD_DENY not applied: %v", kw)
}
}