refactor(store,tools): migrate IDs from UUID to bigserial int64
Some checks failed
CI / build-and-test (push) Failing after -31m12s
Some checks failed
CI / build-and-test (push) Failing after -31m12s
All internal entity lookups now use bigserial primary keys (int64) while GUIDs are retained for external/public identification. Updated store functions (TouchProject, UpdateThoughtMetadata, AddThoughtAttachment) to query by id instead of guid, added GetThoughtByID, changed semanticSearch and all tool helpers to use *int64 project IDs, and updated retry/backfill workers to use int64 thought IDs throughout.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
|
||||
"git.warky.dev/wdevs/amcs/internal/session"
|
||||
@@ -64,7 +63,7 @@ func (t *ChatHistoryTool) SaveChatHistory(ctx context.Context, req *mcp.CallTool
|
||||
h.Metadata = map[string]any{}
|
||||
}
|
||||
if project != nil {
|
||||
h.ProjectID = &project.ID
|
||||
h.ProjectID = &project.NumericID
|
||||
}
|
||||
|
||||
saved, err := t.store.SaveChatHistory(ctx, h)
|
||||
@@ -77,7 +76,7 @@ func (t *ChatHistoryTool) SaveChatHistory(ctx context.Context, req *mcp.CallTool
|
||||
// get_chat_history
|
||||
|
||||
type GetChatHistoryInput struct {
|
||||
ID string `json:"id,omitempty" jsonschema:"UUID of the saved chat history"`
|
||||
ID string `json:"id,omitempty" jsonschema:"numeric id of the saved chat history"`
|
||||
SessionID string `json:"session_id,omitempty" jsonschema:"original session_id — returns the most recent history for that session"`
|
||||
}
|
||||
|
||||
@@ -91,9 +90,9 @@ func (t *ChatHistoryTool) GetChatHistory(ctx context.Context, _ *mcp.CallToolReq
|
||||
}
|
||||
|
||||
if in.ID != "" {
|
||||
id, err := uuid.Parse(in.ID)
|
||||
id, err := parseID(in.ID)
|
||||
if err != nil {
|
||||
return nil, GetChatHistoryOutput{}, errInvalidField("id", "invalid id", "must be a valid UUID")
|
||||
return nil, GetChatHistoryOutput{}, errInvalidField("id", "invalid id", "must be a valid numeric id")
|
||||
}
|
||||
h, found, err := t.store.GetChatHistory(ctx, id)
|
||||
if err != nil {
|
||||
@@ -145,7 +144,7 @@ func (t *ChatHistoryTool) ListChatHistories(ctx context.Context, req *mcp.CallTo
|
||||
return nil, ListChatHistoriesOutput{}, err
|
||||
}
|
||||
if project != nil {
|
||||
filter.ProjectID = &project.ID
|
||||
filter.ProjectID = &project.NumericID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +161,7 @@ func (t *ChatHistoryTool) ListChatHistories(ctx context.Context, req *mcp.CallTo
|
||||
// delete_chat_history
|
||||
|
||||
type DeleteChatHistoryInput struct {
|
||||
ID uuid.UUID `json:"id" jsonschema:"UUID of the chat history to delete"`
|
||||
ID string `json:"id" jsonschema:"numeric id of the chat history to delete"`
|
||||
}
|
||||
|
||||
type DeleteChatHistoryOutput struct {
|
||||
@@ -170,7 +169,11 @@ type DeleteChatHistoryOutput struct {
|
||||
}
|
||||
|
||||
func (t *ChatHistoryTool) DeleteChatHistory(ctx context.Context, _ *mcp.CallToolRequest, in DeleteChatHistoryInput) (*mcp.CallToolResult, DeleteChatHistoryOutput, error) {
|
||||
deleted, err := t.store.DeleteChatHistory(ctx, in.ID)
|
||||
id, err := parseID(in.ID)
|
||||
if err != nil {
|
||||
return nil, DeleteChatHistoryOutput{}, errInvalidField("id", "invalid id", "must be a valid numeric id")
|
||||
}
|
||||
deleted, err := t.store.DeleteChatHistory(ctx, id)
|
||||
if err != nil {
|
||||
return nil, DeleteChatHistoryOutput{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user