diff --git a/internal/store/store.go b/internal/store/store.go index f11f7e03..8f2cefe9 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -5816,10 +5816,12 @@ func truncate(s string, max int) string { func normalizeScope(scope string) string { v := strings.TrimSpace(strings.ToLower(scope)) - if v == "personal" { - return "personal" + switch v { + case "personal", "global": + return v + default: + return "project" } - return "project" } // NormalizeProject applies canonical project name normalization: diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 541cf693..549fa2a4 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -7716,6 +7716,32 @@ func TestGetDeferred_NotFound(t *testing.T) { } } +func TestNormalizeScopeHandlesGlobal(t *testing.T) { + tests := []struct { + input string + want string + }{ + {"global", "global"}, + {"Global", "global"}, + {"GLOBAL", "global"}, + {" global ", "global"}, + {"personal", "personal"}, + {"Personal", "personal"}, + {"project", "project"}, + {"Project", "project"}, + {"", "project"}, + {"unknown", "project"}, + } + for _, tc := range tests { + t.Run(tc.input, func(t *testing.T) { + got := normalizeScope(tc.input) + if got != tc.want { + t.Errorf("normalizeScope(%q) = %q, want %q", tc.input, got, tc.want) + } + }) + } +} + // TestSearchLegacyMixedCaseProject reproduces issue #146: // observations stored with a mixed-case project name (legacy data pre-normalization) // must be found when searched with a normalized (lowercase) project name.