Skip to content

fix(store): handle global scope in normalizeScope#428

Merged
Alan-TheGentleman merged 2 commits into
mainfrom
fix/normalize-scope-global
May 27, 2026
Merged

fix(store): handle global scope in normalizeScope#428
Alan-TheGentleman merged 2 commits into
mainfrom
fix/normalize-scope-global

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

Summary

  • normalizeScope() in internal/store/store.go had no case for global, silently coercing it to project via the fallthrough default.
  • Any mem_save / mem_update / CLI / HTTP call with scope: "global" stored project instead, making global observations impossible to create or upsert.
  • Fix: extend the switch to case "personal", "global": return v, accepting global as a third valid scope.

Test plan

  • TestNormalizeScopeHandlesGlobal — 10 table-driven subtests covering case/whitespace variants of global, plus unchanged behavior for personal, project, empty, and unknown inputs
  • go test ./... && go vet ./... && go build ./... clean

Closes #122

normalizeScope had no case for "global", silently coercing it to
"project". Add "global" alongside "personal" in the switch so
mem_save/mem_update/HTTP API callers can create and upsert global
observations correctly.

Closes #122
Copilot AI review requested due to automatic review settings May 27, 2026 15:12
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes internal/store scope normalization so that "global" is treated as a valid scope instead of being silently coerced to "project", restoring the ability to create/update/upsert global observations through all call paths that rely on normalizeScope().

Changes:

  • Update normalizeScope() to explicitly accept "global" (alongside "personal") and otherwise default to "project".
  • Add a table-driven unit test covering normalization behavior for "global" variants and confirming existing behavior for other inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/store/store.go Extends normalizeScope() to preserve "global" rather than defaulting it to "project".
internal/store/store_test.go Adds TestNormalizeScopeHandlesGlobal to verify "global" normalization and unchanged defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…lobal

# Conflicts:
#	internal/store/store_test.go
@Alan-TheGentleman Alan-TheGentleman merged commit e09ebd5 into main May 27, 2026
5 checks passed
@Alan-TheGentleman Alan-TheGentleman deleted the fix/normalize-scope-global branch May 27, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalizeScope() silently drops 'global' scope — no way to create or update global observations

2 participants