Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
07ec2b3
AI-3537: stop recording when an API key was last used
Nash0x7E2 Nov 23, 2026
d4655b1
AI-3537: drop the TLS scheme no connection is created with
Nash0x7E2 Nov 23, 2026
fdac9e3
AI-3537: stop copying the vendor call id onto the contact
Nash0x7E2 Nov 23, 2026
c0c7db3
AI-3537: stop marking a dial converted
Nash0x7E2 Nov 23, 2026
6225399
AI-3537: stop storing a recording's source and TTS options
Nash0x7E2 Nov 23, 2026
8be7c5e
AI-3537: stop recording when a guest was claimed
Nash0x7E2 Nov 23, 2026
4b468fc
AI-3537: stop reading when a chat message was received
Nash0x7E2 Nov 23, 2026
0427cd0
AI-3537: say why columns no code reads are kept
Nash0x7E2 Nov 23, 2026
5c89b32
AI-3537: docs: stop describing the key-use and TLS-scheme writes
Nash0x7E2 Nov 23, 2026
3f8aee7
AI-3537: docs(skills): say how a column is removed
Nash0x7E2 Nov 23, 2026
0b9a8af
AI-3472: docs(api): drop citations of migrations the squash removed
Nash0x7E2 Nov 23, 2026
9143295
AI-3472: docs(store): connector comments cite no removed migration
Nash0x7E2 Nov 23, 2026
f239f46
AI-3472: docs(store): episode and thread comments cite no migration
Nash0x7E2 Nov 23, 2026
fca6f9c
AI-3472: docs(store): config, audit and limit comments cite no migration
Nash0x7E2 Nov 23, 2026
3866c70
AI-3472: docs(store): data move comments cite no migration file
Nash0x7E2 Nov 23, 2026
17918aa
AI-3472: docs(store): connector comments name the repository methods
Nash0x7E2 Nov 23, 2026
0c13661
AI-3472: docs(store): channel and episode comments name the methods
Nash0x7E2 Nov 23, 2026
281008e
AI-3472: docs(store): remaining comments name the repository methods
Nash0x7E2 Nov 23, 2026
45deca5
AI-3472: docs(store): comments name the files the store was split into
Nash0x7E2 Nov 23, 2026
df060a9
AI-3472: docs(api): comments name the store's repository methods
Nash0x7E2 Nov 23, 2026
bd6d3e1
AI-3472: docs(api): comments name functions and types that exist
Nash0x7E2 Nov 23, 2026
eb634b9
AI-3472: docs(channels): comments name the store's repository methods
Nash0x7E2 Nov 23, 2026
20a8e8b
AI-3472: docs: session, phone and policy comments name store methods
Nash0x7E2 Nov 23, 2026
aab8a31
AI-3472: docs: comments stop naming functions and tests that are gone
Nash0x7E2 Nov 23, 2026
49b70a6
AI-3472: docs(skills): store.md names a file and methods that exist
Nash0x7E2 Nov 23, 2026
3f5f96d
AI-3472: docs(readme): say what the schema holds, not which migration
Nash0x7E2 Nov 23, 2026
6397156
AI-3472: docs: package notes and skills name the repository methods
Nash0x7E2 Nov 23, 2026
3eba002
AI-3472: docs(api): name DeleteUnbound, the method that reads the bin…
Nash0x7E2 Nov 23, 2026
7f145ee
AI-3472: docs(pgsealed): name the store files that exist
Nash0x7E2 Nov 23, 2026
51489d1
AI-3472: docs(tenancy): say what happened, not which migration
Nash0x7E2 Nov 23, 2026
9673ded
AI-3536: remove the unused ScheduledTaskDeliveredCall constant
Nash0x7E2 Nov 23, 2026
cf94004
AI-3536: remove BranchMessages.Delete, which only tests called
Nash0x7E2 Nov 23, 2026
11be24d
AI-3536: remove CampaignAttempts.Classified for ClassifyAndSettle
Nash0x7E2 Nov 23, 2026
97f204b
AI-3536: remove ConnectorConnections.Referenced, test DeleteUnbound
Nash0x7E2 Nov 23, 2026
737c36a
AI-3536: remove the provider-unit writes on connector connections
Nash0x7E2 Nov 23, 2026
48a7955
AI-3536: drop provider_unit_id from the connector-connection model
Nash0x7E2 Nov 23, 2026
1566af2
AI-3536: remove DataTables, which only the store's own tests called
Nash0x7E2 Nov 23, 2026
5ecc645
AI-3536: remove Limit.Covers, which only its own test called
Nash0x7E2 Nov 23, 2026
ece3491
AI-3536: remove PriceChanges.NextAt and PriceEntries.Upcoming
Nash0x7E2 Nov 23, 2026
63b9986
AI-3536: remove Recordings.Start, which only tests called
Nash0x7E2 Nov 23, 2026
f98c5df
AI-3536: fold Responses.MoveActivePath into MoveActivePathUntil
Nash0x7E2 Nov 23, 2026
53f7b92
AI-3536: remove PhoneNumbers.Release for the trunk group's release
Nash0x7E2 Nov 23, 2026
cdfba7e
AI-3536: read Daytona keys without a provider parameter
Nash0x7E2 Nov 23, 2026
f3ff6ce
AI-3536: release a reply's claim without naming its kind
Nash0x7E2 Nov 23, 2026
56ada9b
AI-3536: Limits.Delete returns only its error
Nash0x7E2 Nov 23, 2026
babb0cf
AI-3536: drop SessionValues.ReviewScore, which nothing sets
Nash0x7E2 Nov 23, 2026
ae20239
AI-3536: move redisFamilies beside the test helper that reads it
Nash0x7E2 Nov 23, 2026
42282cd
AI-3536: remove Requests.Insert, tests write through InsertMany
Nash0x7E2 Nov 23, 2026
41a05ee
AI-3536: remove RecordingRunning, which nothing sets or reads
Nash0x7E2 Nov 23, 2026
ef32bc7
AI-3536: test a late classification on the path production takes
Nash0x7E2 Nov 23, 2026
0d5b413
AI-3536: keep why a request's latency may be missing
Nash0x7E2 Nov 23, 2026
b2fdc7a
AI-3536: say why an import still empties the provider unit
Nash0x7E2 Nov 23, 2026
db19a62
AI-3536: say whose name for Daytona SelectDaytona filters on
Nash0x7E2 Nov 23, 2026
672480f
refactor(store): users on Users, one helper per small repeat (#2378)
Nash0x7E2 Nov 24, 2026
5dcd57f
Merge main into the AI-3536 branch
Nash0x7E2 Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceleration/cmd/router/forget_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ func (s *ForgetUserSuite) reachedOf(app, user, phone string) {
ExpiresAt: time.Now().Add(time.Hour)}, func() (string, error) { return phone[len(phone)-6:], nil }))
s.Require().NoError(shared.ContactMapEntries.Upsert(s.ctx, &store.ContactMapEntry{CustomerID: app, ConfigID: "agent", Kind: "sms",
Address: phone, ConversationID: "conversation", UserID: user}))
s.Require().NoError(shared.RecordUser(s.ctx, &store.User{CustomerID: app, ID: user, Kind: store.UserKindAuthenticated, Email: user}))
s.Require().NoError(shared.Users.Insert(s.ctx, &store.User{CustomerID: app, ID: user, Kind: store.UserKindAuthenticated, Email: user}))
}

// namingRows counts, for each table that reachedOf writes, the rows of app naming user.
Expand Down
28 changes: 16 additions & 12 deletions acceleration/cmd/router/prices_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/suite"

"github.com/GetStream/Vision-Agents/acceleration/internal/config"
Expand Down Expand Up @@ -359,10 +360,11 @@ func (s *PriceSyncSuite) TestReloadPutsTheFilesPricesBack() {
s.changePrice(pgStore, "own_later", own, 7, &later)
s.Require().InDelta(fileRate*3, s.rateOf(pgStore, vendor), 1e-12)
s.Require().InDelta(5.0, s.rateOf(pgStore, own), 1e-12)
s.Require().NoError(pgStore.Requests.Insert(s.ctx, &store.Request{
Modality: "llm", CustomerID: "app", Provider: vendor.Provider, Model: vendor.Model, StartedAt: time.Now(),
CostMicros: 10, Billable: true, Success: true, PriceVersion: fixed.Name,
}))
_, err := pgStore.Requests.InsertMany(s.ctx, []store.Request{{
UsageID: uuid.Must(uuid.NewV7()), Modality: "llm", CustomerID: "app", Provider: vendor.Provider, Model: vendor.Model,
StartedAt: time.Now(), CostMicros: 10, Billable: true, Success: true, PriceVersion: fixed.Name,
}})
s.Require().NoError(err)
var out bytes.Buffer

s.Require().NoError(runPricesReload(s.ctx, []string{"--development"}, s.settings, &out))
Expand All @@ -374,7 +376,7 @@ func (s *PriceSyncSuite) TestReloadPutsTheFilesPricesBack() {
seed := changes[0]
s.Equal(store.PriceChangeSeed, seed.Kind)
s.Equal(s.settings.PricesFile+", vendor.json, router dev", seed.Source)
upcoming, err := pgStore.PriceEntries.Upcoming(s.ctx, time.Now())
upcoming, err := pgStore.PriceEntries.Source().Upcoming(s.ctx, time.Now())
s.Require().NoError(err)
s.Empty(upcoming, "the scheduled change went with the rest")
active, err := pgStore.PriceEntries.Active(s.ctx, time.Now())
Expand Down Expand Up @@ -597,11 +599,12 @@ func (s *PriceSyncSuite) TestDriftLeavesOutWorkOnTheCustomersOwnKey() {
pgStore := s.started()
s.recordWithVendorCost(pgStore, "grok-4.7", 1_000, 1_000)
// Priced at the BYOK fee, at no cost at the vendor's rates: the vendor bills the customer.
s.Require().NoError(pgStore.Requests.Insert(s.ctx, &store.Request{
Modality: "llm", CustomerID: "app", Provider: "grok", Model: "grok-4.7", StartedAt: time.Now(),
_, err := pgStore.Requests.InsertMany(s.ctx, []store.Request{{
UsageID: uuid.Must(uuid.NewV7()), Modality: "llm", CustomerID: "app", Provider: "grok", Model: "grok-4.7", StartedAt: time.Now(),
CostMicros: 200, BaseCostMicros: 0, PriceVersion: "byok", BYOK: true, Billable: true, Success: true,
Attributes: map[string]string{store.VendorCostAttribute: "1000"},
}))
}})
s.Require().NoError(err)
var out bytes.Buffer

s.Require().NoError(runPricesDrift(s.ctx, []string{"--json"}, s.settings, &out))
Expand All @@ -616,11 +619,12 @@ func (s *PriceSyncSuite) TestDriftLeavesOutWorkOnTheCustomersOwnKey() {
// recordWithVendorCost records an LLM row the list priced at cost, of work the vendor said
// cost vendorCost.
func (s *PriceSyncSuite) recordWithVendorCost(router *store.Store, model string, cost, vendorCost int64) {
s.Require().NoError(router.Requests.Insert(s.ctx, &store.Request{
Modality: "llm", CustomerID: "app", Provider: "grok", Model: model, StartedAt: time.Now(),
CostMicros: cost, Billable: true, Success: true,
_, err := router.Requests.InsertMany(s.ctx, []store.Request{{
UsageID: uuid.Must(uuid.NewV7()), Modality: "llm", CustomerID: "app", Provider: "grok", Model: model,
StartedAt: time.Now(), CostMicros: cost, Billable: true, Success: true,
Attributes: map[string]string{store.VendorCostAttribute: strconv.FormatInt(vendorCost, 10)},
}))
}})
s.Require().NoError(err)
}

// forwarder is a TCP proxy to a database that can be shut, which is a database a router
Expand Down
2 changes: 1 addition & 1 deletion acceleration/cmd/router/sandboxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func customerDaytonaKeys(pgStore *store.Store, secrets *auth.Sealer) func(contex
return nil
}
return func(ctx context.Context) ([]string, error) {
rows, err := pgStore.ProviderKeys.SelectByProvider(ctx, providerkeys.Daytona)
rows, err := pgStore.ProviderKeys.SelectDaytona(ctx)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/api/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ func (s *SelfHostedAccountSuite) TestNoUsageServiceAnswersNotEnabled() {

func (s *SelfHostedAccountSuite) TestTeamsSumTheRequestsThisMonth() {
record := func(at time.Time, micros int64, team string) {
s.Require().NoError(s.store.Requests.Insert(context.Background(), &store.Request{
s.Require().NoError(insertRequest(context.Background(), s.store, &store.Request{
Modality: "llm", CustomerID: s.customerID(), OrganizationID: s.app.organization.ID, Provider: "stub", Model: "stub-llm",
StartedAt: at, CostMicros: micros, Billable: true, Success: true, UsageCategories: []string{"support", "team:" + team},
}))
Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/api/authorizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func (s *Server) completeConsent(ctx context.Context, row store.ConnectorAuthori
// the consent link works in any browser, so another person could finish it (AI-1543).
var refusal string
if manifest.OwnerEmail && connection.OwnerType == store.OwnerUser {
asserted, err := s.store.UserEmail(ctx, connection.CustomerID, connection.OwnerID)
asserted, err := s.store.Users.GetEmail(ctx, connection.CustomerID, connection.OwnerID)
if err != nil {
s.logger.Error("could not read the email a consent is checked against", "connection", row.ConnectionID, "error", err)
return consentFailed
Expand Down
4 changes: 2 additions & 2 deletions acceleration/internal/api/authorizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ func (s *AuthorizationsSuite) TestABackendSayingTheSameEmailAgainCostsNoWrite()
backend := s.serverClient.actingFor(alice).withEmail("alice@fake.example")
s.Require().Equal(http.StatusOK, backend.do(http.MethodGet, "/v1/agents/connections?owner_type=user", nil, nil))
s.Require().Equal("alice@fake.example", s.userEmail(alice))
s.Require().NoError(s.store.SetUserEmail(context.Background(), s.customerID(), alice.userID, "behind@fake.example"))
s.Require().NoError(s.store.Users.SetEmail(context.Background(), s.customerID(), alice.userID, "behind@fake.example"))

for range 3 {
s.Require().Equal(http.StatusOK, backend.do(http.MethodGet, "/v1/agents/connections?owner_type=user", nil, nil))
Expand Down Expand Up @@ -1614,7 +1614,7 @@ func (s *AuthorizationsSuite) assertNothingStored(id string) {
}

func (s *AuthorizationsSuite) userEmail(user *testClient) string {
email, err := s.store.UserEmail(context.Background(), s.customerID(), user.userID)
email, err := s.store.Users.GetEmail(context.Background(), s.customerID(), user.userID)
s.Require().NoError(err)
return email
}
Expand Down
12 changes: 2 additions & 10 deletions acceleration/internal/api/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *Server) listResponseSiblings(ctx context.Context, request *listResponse
}
}
}
rows, more := page(siblings[start:], clampLimit(value(request.Limit.ptr()), defaultSiblingLimit, maxSiblingLimit))
rows, more := page(siblings[start:], store.ClampLimit(value(request.Limit.ptr()), defaultSiblingLimit, maxSiblingLimit))
listed := ResponseSiblingPage{Items: make([]ResponseSibling, 0, len(rows)), HasMore: more}
for i, row := range rows {
active, err := s.siblingActive(ctx, customer, found.ID(), row, of)
Expand Down Expand Up @@ -186,7 +186,7 @@ func (s *Server) getResponseBranch(ctx context.Context, request *getResponseBran
return &getResponseBranchResponse{Body: listed}, nil
}

rows, more := page(shown[branchFrom(shown, after):], clampLimit(value(request.Limit.ptr()), defaultBranchLimit, maxBranchLimit))
rows, more := page(shown[branchFrom(shown, after):], store.ClampLimit(value(request.Limit.ptr()), defaultBranchLimit, maxBranchLimit))
listed.HasMore = more
for _, row := range rows {
listed.Items = append(listed.Items, branchMessageOf(row))
Expand Down Expand Up @@ -265,14 +265,6 @@ func positionAfter(at time.Time, id string, afterAt time.Time, afterID string) b
return cmp.Or(at.Compare(afterAt), strings.Compare(id, afterID)) > 0
}

// clampLimit is the page size for the limit asked for: fallback when none was, at most most.
func clampLimit(asked, fallback, most int) int {
if asked <= 0 {
return fallback
}
return min(asked, most)
}

// branchPosition is the last message of a branch page.
type branchPosition struct {
At time.Time `json:"t"`
Expand Down
6 changes: 4 additions & 2 deletions acceleration/internal/api/callhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ func (s *CallHooksSuite) TestACallOnANumberNobodyHoldsIsAcceptedAndDropped() {
func (s *CallHooksSuite) TestACallOnAReleasedNumberIsNotAnswered() {
// The number is gone, so whoever holds it now is not this customer.
s.hold("default", s.callID)
s.Require().NoError(s.store.PhoneNumbers.Release(
context.Background(), s.customerID(), s.e164, time.Now().UTC()))
group := store.TrunkGroup{CustomerID: s.customerID(), Vendor: s.numberVendor}
s.Require().NoError(s.store.StreamTrunks.InGroup(context.Background(), group, func(_ context.Context, tx *store.TrunkGroupTx) error {
return tx.ReleaseNumber(s.e164, time.Now().UTC())
}))
worker, release := s.dispatch.Register(s.customerID(), dispatch.Registration{Capacity: 1})
defer release()

Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/api/calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func (s *Server) refuseUserOutside(ctx context.Context, customerID string, bound
}
// A guest id the router minted is recorded per customer, so it is nobody else's. One only
// seen in a guest token is not: the customer signs those for any id it likes.
guest, err := s.store.Guest(ctx, customerID, userID)
guest, err := s.store.Users.GetGuest(ctx, customerID, userID)
if err != nil || !guest.Minted {
return errUserInSharedApp
}
Expand Down
14 changes: 7 additions & 7 deletions acceleration/internal/api/calls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (s *CallsSuite) TestAGuestImportedAsMintedIsNoGuestTheRouterMinted() {
s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodPost, "/v1/data/import",
`{"table":"users","row":`+row+"}\n", &written))
s.Require().Equal(int64(1), written.Tables["users"])
held, err := s.store.Guest(context.Background(), s.customerID(), imported)
held, err := s.store.Users.GetGuest(context.Background(), s.customerID(), imported)
s.Require().NoError(err, "the guest is imported")
s.False(held.Minted)

Expand Down Expand Up @@ -317,7 +317,7 @@ func (s *CallsSuite) TestATextSessionsDecisionsAreAnEmptyListNotAnError() {
func (s *CallsSuite) TestAFinishedNativeCallNamesTheConversationAndSubagentModels() {
call := s.started(store.Call{STS: "stub/stub-sts", Subagent: "stub/stub-llm"})
for modality, model := range map[string]string{"sts": "stub-sts", "llm": "stub-llm"} {
s.Require().NoError(s.store.Requests.Insert(context.Background(), &store.Request{
s.Require().NoError(insertRequest(context.Background(), s.store, &store.Request{
CustomerID: s.customerID(), AgentID: call.AgentID,
Modality: modality, Provider: "stub", Model: model,
StartedAt: s.base.Add(time.Second), Success: true,
Expand All @@ -338,7 +338,7 @@ func (s *CallsSuite) TestAFinishedNativeCallNamesTheConversationAndSubagentModel
func (s *CallsSuite) TestAFinishedCallReportsWhatItSpentAndTheSessionItWasPartOf() {
call := s.heldCall(store.Call{ID: s.utils.uuid(), CustomerID: s.customerID(), CallID: s.utils.callID(),
AgentID: "agent-" + s.utils.uuid(), StartedAt: s.base}, "", "")
s.Require().NoError(s.store.Requests.Insert(context.Background(), &store.Request{
s.Require().NoError(insertRequest(context.Background(), s.store, &store.Request{
CustomerID: s.customerID(), AgentID: call.AgentID,
Modality: "llm", Provider: "stub", Model: "stub-llm",
StartedAt: s.base.Add(time.Second),
Expand All @@ -361,7 +361,7 @@ func (s *CallsSuite) TestAFinishedCallReportsWhatItSpentAndTheSessionItWasPartOf

func (s *CallsSuite) TestACallStillRunningIsNotToldWhatItHasSpentSoFar() {
call := s.started(store.Call{})
s.Require().NoError(s.store.Requests.Insert(context.Background(), &store.Request{
s.Require().NoError(insertRequest(context.Background(), s.store, &store.Request{
CustomerID: s.customerID(), AgentID: call.AgentID,
Modality: "llm", Provider: "stub", Model: "stub-llm",
StartedAt: s.base.Add(time.Second), InputTokens: 900, Success: true,
Expand All @@ -386,7 +386,7 @@ func (s *CallsSuite) TestACallsTokensAreReadWhileItRunsByModelAndByWhatThePrompt
} {
request.CustomerID, request.AgentID = s.customerID(), call.AgentID
request.StartedAt, request.Success = s.base.Add(time.Second), true
s.Require().NoError(s.store.Requests.Insert(context.Background(), &request))
s.Require().NoError(insertRequest(context.Background(), s.store, &request))
}

var spent CallTokens
Expand All @@ -413,7 +413,7 @@ func (s *CallsSuite) TestACallsCostIsSplitByWhereItCameFrom() {
} {
request.CustomerID, request.AgentID = s.customerID(), call.AgentID
request.StartedAt, request.Success = s.base.Add(time.Second), true
s.Require().NoError(s.store.Requests.Insert(context.Background(), &request))
s.Require().NoError(insertRequest(context.Background(), s.store, &request))
}

var spent CallTokens
Expand All @@ -434,7 +434,7 @@ func (s *CallsSuite) TestTokensAreStillReadUnderTheCallsPathTheyMovedFrom() {
call := s.inSession("", store.Call{})
request := store.Request{Modality: "llm", Provider: "stub", Model: "stub-llm", InputTokens: 700, OutputTokens: 30,
CustomerID: s.customerID(), AgentID: call.AgentID, StartedAt: s.base.Add(time.Second), Success: true}
s.Require().NoError(s.store.Requests.Insert(context.Background(), &request))
s.Require().NoError(insertRequest(context.Background(), s.store, &request))

var moved, kept CallTokens
s.Require().Equal(http.StatusOK,
Expand Down
18 changes: 9 additions & 9 deletions acceleration/internal/api/guests.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *Server) newGuest(ctx context.Context, customerID string, bound streamap
guest := &store.User{
ID: userID, CustomerID: customerID, Name: name, Custom: value(body.Custom), RefreshSecretHash: hash,
}
if err := s.store.RecordGuest(ctx, guest); err != nil {
if err := s.store.Users.InsertGuest(ctx, guest); err != nil {
return nil, err
}
rendered.RefreshSecret = &secret
Expand Down Expand Up @@ -152,7 +152,7 @@ func (s *Server) returningGuest(ctx context.Context, customerID string, bound st
return s.redeemGuestSecret(ctx, customerID, bound, requested, strings.TrimSpace(value(body.RefreshSecret)))
}

held, err := s.store.Guest(ctx, customerID, requested)
held, err := s.store.Users.GetGuest(ctx, customerID, requested)
switch {
case err != nil || (!held.Minted && !s.ownApp(customerID, bound.Identity.StreamApp)):
// Not a guest this customer was handed. It may be nobody at all, or a real user, which
Expand All @@ -176,7 +176,7 @@ func (s *Server) returningGuest(ctx context.Context, customerID string, bound st
if err := s.updateGuestProfile(ctx, bound, requested, name, custom); err != nil {
return nil, err
}
if err := s.store.Guests.SetProfile(ctx, customerID, requested, name, custom); err != nil {
if err := s.store.Users.SetGuestProfile(ctx, customerID, requested, name, custom); err != nil {
return nil, err
}
}
Expand All @@ -195,9 +195,9 @@ func (s *Server) returningGuest(ctx context.Context, customerID string, bound st
// holding none, such as one minted before secrets existed; one holding a secret keeps it.
issued := true
if server {
err = s.store.Guests.SetSecret(ctx, customerID, requested, hash)
err = s.store.Users.SetGuestSecret(ctx, customerID, requested, hash)
} else {
issued, err = s.store.Guests.GiveSecret(ctx, customerID, requested, hash)
issued, err = s.store.Users.GiveGuestSecret(ctx, customerID, requested, hash)
}
if err != nil {
return nil, err
Expand Down Expand Up @@ -229,7 +229,7 @@ func (s *Server) redeemGuestSecret(ctx context.Context, customerID string, bound
if err != nil {
return nil, err
}
held, err := s.store.Guests.RotateSecret(ctx, customerID, requested, store.GuestSecretHash(secret), hash)
held, err := s.store.Users.RotateGuestSecret(ctx, customerID, requested, store.GuestSecretHash(secret), hash)
if errors.Is(err, store.ErrGuestSecretRefused) {
return nil, nil
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func (s *Server) claimGuestUser(ctx context.Context, request *claimGuestUserRequ
return nil, invalidRequest("a guest cannot be claimed by itself")
}

guest, err := s.store.Guest(ctx, customerID, guestID)
guest, err := s.store.Users.GetGuest(ctx, customerID, guestID)
if err != nil {
return nil, unknownOr(err, store.ErrNotAGuest, notFound("no such guest"))
}
Expand All @@ -316,7 +316,7 @@ func (s *Server) claimGuestUser(ctx context.Context, request *claimGuestUserRequ
return &claimGuestUserResponse{Body: ClaimGuestResult{GuestId: guestID, UserId: userID, SessionsMoved: 0}}, nil
}

moved, err := s.store.ClaimGuest(ctx, customerID, guestID, userID)
moved, err := s.store.Users.ClaimGuest(ctx, customerID, guestID, userID)
// Another claim won since the guest was read.
if errors.Is(err, store.ErrGuestClaimed) {
return nil, conflict("that guest was already claimed")
Expand All @@ -339,7 +339,7 @@ func (s *Server) claimGuestUser(ctx context.Context, request *claimGuestUserRequ
"guest", guestID, "user", userID, "error", err)
}
// Last, so a claim that stopped before here is finished by the same claim sent again.
if err := s.store.FinishGuestClaim(ctx, customerID, guestID, userID); err != nil {
if err := s.store.Users.FinishGuestClaim(ctx, customerID, guestID, userID); err != nil {
return nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions acceleration/internal/api/guests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *GuestsSuite) TestTheSameClaimArrivingTwiceIsNotAConflict() {
func (s *GuestsSuite) TestAClaimThatStoppedAfterMovingTheRowsJoinsTheChannelsWhenSentAgain() {
guest, account := s.recordGuest(), s.data.createUser()
talked := s.talked(guest)
_, err := s.store.ClaimGuest(context.Background(), s.customerID(), guest, account.userID)
_, err := s.store.Users.ClaimGuest(context.Background(), s.customerID(), guest, account.userID)
s.Require().NoError(err)
s.Require().NotContains(s.chat.Members(s.transcriptOf(talked)), account.userID)

Expand Down Expand Up @@ -669,7 +669,7 @@ func (s *GuestsSuite) mint(as *testClient, request GuestUserRequest) GuestUser {

// storedGuest is the guest's row as the store holds it.
func (s *GuestsSuite) storedGuest(id string) store.User {
held, err := s.store.Guest(context.Background(), s.customerID(), id)
held, err := s.store.Users.GetGuest(context.Background(), s.customerID(), id)
s.Require().NoError(err)
return held
}
Expand Down Expand Up @@ -699,7 +699,7 @@ func (s *GuestsSuite) assertStreamProfile(id, name string, custom map[string]any
// over HTTP would reach Stream for the token.
func (s *GuestsSuite) recordGuest() string {
id := guestPrefix + s.utils.uuid()
s.Require().NoError(s.store.RecordGuest(context.Background(), &store.User{
s.Require().NoError(s.store.Users.InsertGuest(context.Background(), &store.User{
ID: id, CustomerID: s.customerID(), Name: "Guest",
}))
return id
Expand All @@ -711,7 +711,7 @@ func (s *RouterSuite) guestSeenInAToken() string {
id := "visitor-" + s.utils.uuid()
s.signedIn(jwt.MapClaims{"user_id": id, "role": "guest"}, auth.AuthTypeJWT, guest, id).
do(http.MethodGet, "/v1/agents/calls", nil, nil)
seen, err := s.store.Guest(context.Background(), s.customerID(), id)
seen, err := s.store.Users.GetGuest(context.Background(), s.customerID(), id)
s.Require().NoError(err, "the call is what records the guest")
s.Require().False(seen.Minted)
return id
Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/api/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ func (s *Server) deleteLimit(ctx context.Context, organization string, id int64,
if audit.CustomerID == "" {
audit.CustomerID = existing.OrganizationID
}
_, err = s.store.Limits.Delete(ctx, existing.OrganizationID, id, audit)
err = s.store.Limits.Delete(ctx, existing.OrganizationID, id, audit)
if errors.Is(err, store.ErrNoLimit) {
return errNoSuchLimit
}
Expand Down
Loading
Loading