refactor(store,tools): migrate IDs from UUID to bigserial int64
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:
2026-05-03 11:43:34 +02:00
parent 9e6d05e055
commit 91239bcf4b
58 changed files with 1208 additions and 2774 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"strings"
"github.com/google/uuid"
"github.com/modelcontextprotocol/go-sdk/mcp"
"git.warky.dev/wdevs/amcs/internal/session"
@@ -59,7 +58,7 @@ func (t *SkillsTool) AddSkill(ctx context.Context, _ *mcp.CallToolRequest, in Ad
// remove_skill
type RemoveSkillInput struct {
ID uuid.UUID `json:"id" jsonschema:"skill id to remove"`
ID int64 `json:"id" jsonschema:"skill id to remove"`
}
type RemoveSkillOutput struct {
@@ -147,7 +146,7 @@ func (t *SkillsTool) AddGuardrail(ctx context.Context, _ *mcp.CallToolRequest, i
// remove_guardrail
type RemoveGuardrailInput struct {
ID uuid.UUID `json:"id" jsonschema:"guardrail id to remove"`
ID int64 `json:"id" jsonschema:"guardrail id to remove"`
}
type RemoveGuardrailOutput struct {
@@ -186,13 +185,13 @@ func (t *SkillsTool) ListGuardrails(ctx context.Context, _ *mcp.CallToolRequest,
// add_project_skill
type AddProjectSkillInput struct {
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
SkillID uuid.UUID `json:"skill_id" jsonschema:"skill id to link"`
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
SkillID int64 `json:"skill_id" jsonschema:"skill id to link"`
}
type AddProjectSkillOutput struct {
ProjectID uuid.UUID `json:"project_id"`
SkillID uuid.UUID `json:"skill_id"`
ProjectID int64 `json:"project_id"`
SkillID int64 `json:"skill_id"`
}
func (t *SkillsTool) AddProjectSkill(ctx context.Context, req *mcp.CallToolRequest, in AddProjectSkillInput) (*mcp.CallToolResult, AddProjectSkillOutput, error) {
@@ -200,17 +199,17 @@ func (t *SkillsTool) AddProjectSkill(ctx context.Context, req *mcp.CallToolReque
if err != nil {
return nil, AddProjectSkillOutput{}, err
}
if err := t.store.AddProjectSkill(ctx, project.ID, in.SkillID); err != nil {
if err := t.store.AddProjectSkill(ctx, project.NumericID, in.SkillID); err != nil {
return nil, AddProjectSkillOutput{}, err
}
return nil, AddProjectSkillOutput{ProjectID: project.ID, SkillID: in.SkillID}, nil
return nil, AddProjectSkillOutput{ProjectID: project.NumericID, SkillID: in.SkillID}, nil
}
// remove_project_skill
type RemoveProjectSkillInput struct {
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
SkillID uuid.UUID `json:"skill_id" jsonschema:"skill id to unlink"`
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
SkillID int64 `json:"skill_id" jsonschema:"skill id to unlink"`
}
type RemoveProjectSkillOutput struct {
@@ -222,7 +221,7 @@ func (t *SkillsTool) RemoveProjectSkill(ctx context.Context, req *mcp.CallToolRe
if err != nil {
return nil, RemoveProjectSkillOutput{}, err
}
if err := t.store.RemoveProjectSkill(ctx, project.ID, in.SkillID); err != nil {
if err := t.store.RemoveProjectSkill(ctx, project.NumericID, in.SkillID); err != nil {
return nil, RemoveProjectSkillOutput{}, err
}
return nil, RemoveProjectSkillOutput{Removed: true}, nil
@@ -235,7 +234,7 @@ type ListProjectSkillsInput struct {
}
type ListProjectSkillsOutput struct {
ProjectID uuid.UUID `json:"project_id"`
ProjectID int64 `json:"project_id"`
Skills []ext.AgentSkill `json:"skills"`
}
@@ -244,26 +243,26 @@ func (t *SkillsTool) ListProjectSkills(ctx context.Context, req *mcp.CallToolReq
if err != nil {
return nil, ListProjectSkillsOutput{}, err
}
skills, err := t.store.ListProjectSkills(ctx, project.ID)
skills, err := t.store.ListProjectSkills(ctx, project.NumericID)
if err != nil {
return nil, ListProjectSkillsOutput{}, err
}
if skills == nil {
skills = []ext.AgentSkill{}
}
return nil, ListProjectSkillsOutput{ProjectID: project.ID, Skills: skills}, nil
return nil, ListProjectSkillsOutput{ProjectID: project.NumericID, Skills: skills}, nil
}
// add_project_guardrail
type AddProjectGuardrailInput struct {
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
GuardrailID uuid.UUID `json:"guardrail_id" jsonschema:"guardrail id to link"`
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
GuardrailID int64 `json:"guardrail_id" jsonschema:"guardrail id to link"`
}
type AddProjectGuardrailOutput struct {
ProjectID uuid.UUID `json:"project_id"`
GuardrailID uuid.UUID `json:"guardrail_id"`
ProjectID int64 `json:"project_id"`
GuardrailID int64 `json:"guardrail_id"`
}
func (t *SkillsTool) AddProjectGuardrail(ctx context.Context, req *mcp.CallToolRequest, in AddProjectGuardrailInput) (*mcp.CallToolResult, AddProjectGuardrailOutput, error) {
@@ -271,17 +270,17 @@ func (t *SkillsTool) AddProjectGuardrail(ctx context.Context, req *mcp.CallToolR
if err != nil {
return nil, AddProjectGuardrailOutput{}, err
}
if err := t.store.AddProjectGuardrail(ctx, project.ID, in.GuardrailID); err != nil {
if err := t.store.AddProjectGuardrail(ctx, project.NumericID, in.GuardrailID); err != nil {
return nil, AddProjectGuardrailOutput{}, err
}
return nil, AddProjectGuardrailOutput{ProjectID: project.ID, GuardrailID: in.GuardrailID}, nil
return nil, AddProjectGuardrailOutput{ProjectID: project.NumericID, GuardrailID: in.GuardrailID}, nil
}
// remove_project_guardrail
type RemoveProjectGuardrailInput struct {
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
GuardrailID uuid.UUID `json:"guardrail_id" jsonschema:"guardrail id to unlink"`
Project string `json:"project,omitempty" jsonschema:"project name or id (uses active project if omitted)"`
GuardrailID int64 `json:"guardrail_id" jsonschema:"guardrail id to unlink"`
}
type RemoveProjectGuardrailOutput struct {
@@ -293,7 +292,7 @@ func (t *SkillsTool) RemoveProjectGuardrail(ctx context.Context, req *mcp.CallTo
if err != nil {
return nil, RemoveProjectGuardrailOutput{}, err
}
if err := t.store.RemoveProjectGuardrail(ctx, project.ID, in.GuardrailID); err != nil {
if err := t.store.RemoveProjectGuardrail(ctx, project.NumericID, in.GuardrailID); err != nil {
return nil, RemoveProjectGuardrailOutput{}, err
}
return nil, RemoveProjectGuardrailOutput{Removed: true}, nil
@@ -306,7 +305,7 @@ type ListProjectGuardrailsInput struct {
}
type ListProjectGuardrailsOutput struct {
ProjectID uuid.UUID `json:"project_id"`
ProjectID int64 `json:"project_id"`
Guardrails []ext.AgentGuardrail `json:"guardrails"`
}
@@ -315,12 +314,12 @@ func (t *SkillsTool) ListProjectGuardrails(ctx context.Context, req *mcp.CallToo
if err != nil {
return nil, ListProjectGuardrailsOutput{}, err
}
guardrails, err := t.store.ListProjectGuardrails(ctx, project.ID)
guardrails, err := t.store.ListProjectGuardrails(ctx, project.NumericID)
if err != nil {
return nil, ListProjectGuardrailsOutput{}, err
}
if guardrails == nil {
guardrails = []ext.AgentGuardrail{}
}
return nil, ListProjectGuardrailsOutput{ProjectID: project.ID, Guardrails: guardrails}, nil
return nil, ListProjectGuardrailsOutput{ProjectID: project.NumericID, Guardrails: guardrails}, nil
}