Skip to content

refactor: use store names as primary API identifier instead of UUIDs - #3

Merged
devigned merged 4 commits into
mainfrom
refactor/name-based-store-routing
Jun 3, 2026
Merged

refactor: use store names as primary API identifier instead of UUIDs#3
devigned merged 4 commits into
mainfrom
refactor/name-based-store-routing

Conversation

@devigned

@devigned devigned commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Store names become the primary developer-facing identifier in all API paths, replacing UUIDs. This improves DX by allowing human-readable URLs:

# Before (UUID-based)
POST /v1/stores/e4b280cc-654e-4fbd-8417-148fbe436d4d/memories

# After (name-based)
POST /v1/stores/my-project/memories

Design Decisions

  • Store names are immutable after creation (like Kubernetes resources)
  • Names are unique per tenant — enforced by unique index
  • UUIDs remain internal — database FK integrity uses UUIDs, but they never appear in API paths
  • OmsProvider trait stays UUID-based — the server/MCP layer resolves names to UUIDs at the API boundary
  • _default auto-provisioning preserved — works exactly as before

Changes

Spec (spec/oms-spec.md)

  • All store-scoped paths use {store_name} instead of {store_id}
  • Store names documented as immutable and unique per tenant
  • UpdateStoreRequest no longer accepts name changes

Core (kd6-core)

  • Added get_store_by_name() to OmsProvider trait with default implementation
  • Removed name from UpdateStoreRequest (immutable)

SQLite (kd6-sqlite)

  • New migration: unique index on (tenant_id, name)
  • Efficient get_store_by_name() override with direct indexed query
  • 5 new tests: name lookup, not-found, tenant isolation, cross-tenant names, duplicate rejection

Server (kd6-server)

  • StoreRef simplified from enum to name wrapper
  • resolve_store() uses name-based lookup
  • All route paths use {store_name} parameter
  • Integration tests use store names in URLs

MCP (kd6-mcp)

  • Tool parameters renamed store_idstore_name
  • Tools resolve stores by name instead of parsing UUIDs

Test Results

149 tests pass (20 core + 7 embed-local + 13 embed-openai + 17 MCP + 47 server + 45 SQLite)

@devigned

devigned commented Jun 3, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

devigned added 4 commits June 3, 2026 15:38
Store names become the primary developer-facing identifier in all API
paths, replacing UUIDs. This improves developer experience by allowing
human-readable URLs like /v1/stores/my-project/memories instead of
/v1/stores/e4b280cc-654e-4fbd-8417-148fbe436d4d/memories.

Design decisions:
- Store names are immutable after creation (like Kubernetes resources)
- Names are unique per tenant
- Internal UUIDs remain for database FK integrity
- OmsProvider trait gains get_store_by_name() with default implementation
- UpdateStoreRequest no longer accepts name changes

Signed-off-by: David Justice <david@justice.dev>
Add get_store_by_name() override with direct indexed query for
efficient name resolution. Add migration for unique index on
(tenant_id, name) to enforce name uniqueness per tenant.

Update update_store to no longer modify the name field (immutable).

New tests:
- get_store_by_name_returns_store
- get_store_by_name_not_found
- get_store_by_name_tenant_isolation
- same_name_different_tenants_allowed
- duplicate_name_same_tenant_rejected

Signed-off-by: David Justice <david@justice.dev>
StoreRef is now a simple name wrapper instead of UUID-or-default enum.
resolve_store() looks up stores by name via get_store_by_name(), with
auto-provisioning preserved for the _default alias.

All route paths use {store_name} parameter. Integration tests updated
to construct URLs with store names rather than UUIDs.

Signed-off-by: David Justice <david@justice.dev>
MCP tool parameters renamed from store_id to store_name. Tools now
resolve store names via get_store_by_name() instead of parsing UUIDs.
Integration tests updated accordingly.

Signed-off-by: David Justice <david@justice.dev>
@devigned
devigned force-pushed the refactor/name-based-store-routing branch from 76be898 to cb36901 Compare June 3, 2026 19:42
@devigned
devigned merged commit a847388 into main Jun 3, 2026
1 check passed
@devigned
devigned deleted the refactor/name-based-store-routing branch June 3, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant