Changeset 0.34.0 (#208)

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
2026-03-20 00:02:37 +00:00
committed by xcaliber
parent ed3e9363f2
commit d16bb93177
20 changed files with 5623 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ type Stores struct {
ExtData ExtDataStore // v0.29.2: Extension namespaced table catalog
Tickets TicketStore // v0.32.0: WS auth tickets (PG-backed for cross-pod)
RateLimits RateLimitStore // v0.32.0: Distributed rate limiting
Export ExportStore // v0.34.0: Data portability batch reads + GDPR ops
}
// =========================================
@@ -1193,6 +1194,162 @@ type PresenceStore interface {
GetStatuses(ctx context.Context, userIDs []string, threshold time.Time) (map[string]string, error)
}
// =========================================
// EXPORT STORE (v0.34.0)
// =========================================
// ExportStore provides batch-read queries for data export, import,
// and GDPR operations. These methods are optimized for bulk retrieval
// without N+1 queries. Embeddings are excluded at query level.
type ExportStore interface {
// ── User-scoped export ──
// UserChannels returns all channels owned by userID.
UserChannels(ctx context.Context, userID string) ([]models.Channel, error)
// UserMessages returns all non-deleted messages in the given channels, ordered by created_at ASC.
UserMessages(ctx context.Context, channelIDs []string) ([]models.Message, error)
// UserChannelParticipants returns participants for the given channels.
UserChannelParticipants(ctx context.Context, channelIDs []string) ([]models.ChannelParticipant, error)
// UserChannelModels returns channel_models for the given channels.
UserChannelModels(ctx context.Context, channelIDs []string) ([]models.ChannelModel, error)
// UserChannelCursors returns cursors for the user in the given channels.
UserChannelCursors(ctx context.Context, userID string, channelIDs []string) ([]models.ChannelCursor, error)
// UserNotes returns all notes owned by userID.
UserNotes(ctx context.Context, userID string) ([]models.Note, error)
// UserNoteLinks returns note_links with source_note_id for the given note IDs.
UserNoteLinks(ctx context.Context, noteIDs []string) ([]models.ExportNoteLink, error)
// UserMemories returns active memories for userID (scope=user).
UserMemories(ctx context.Context, userID string) ([]models.Memory, error)
// UserProjects returns personal-scope projects owned by userID.
UserProjects(ctx context.Context, userID string) ([]models.Project, error)
// UserProjectChannels returns project_channels for the given projects.
UserProjectChannels(ctx context.Context, projectIDs []string) ([]models.ProjectChannel, error)
// UserProjectKBs returns project_knowledge_bases for the given projects.
UserProjectKBs(ctx context.Context, projectIDs []string) ([]models.ProjectKB, error)
// UserProjectNotes returns project_notes for the given projects.
UserProjectNotes(ctx context.Context, projectIDs []string) ([]models.ProjectNote, error)
// UserWorkspaces returns workspaces owned by user (owner_type=user).
UserWorkspaces(ctx context.Context, userID string) ([]models.Workspace, error)
// UserWorkspaceFiles returns file index for the given workspaces.
UserWorkspaceFiles(ctx context.Context, workspaceIDs []string) ([]models.WorkspaceFile, error)
// UserFiles returns file metadata for files uploaded by userID.
UserFiles(ctx context.Context, userID string) ([]models.File, error)
// UserFolders returns all folders for userID.
UserFolders(ctx context.Context, userID string) ([]models.Folder, error)
// UserModelSettings returns user_model_settings for userID.
UserModelSettings(ctx context.Context, userID string) ([]models.UserModelSetting, error)
// UserNotifPrefs returns notification preferences for userID.
UserNotifPrefs(ctx context.Context, userID string) ([]models.NotificationPreference, error)
// UserUsageEntries returns usage entries for userID (last 90 days).
UserUsageEntries(ctx context.Context, userID string) ([]models.UsageEntry, error)
// UserPersonaGroups returns persona groups owned by userID.
UserPersonaGroups(ctx context.Context, userID string) ([]models.PersonaGroup, error)
// UserPersonaGroupMembers returns members for the given groups.
UserPersonaGroupMembers(ctx context.Context, groupIDs []string) ([]models.PersonaGroupMember, error)
// ── Team-scoped export ──
// TeamChannels returns all channels belonging to teamID.
TeamChannels(ctx context.Context, teamID string) ([]models.Channel, error)
// TeamMembers returns team membership records.
TeamMembers(ctx context.Context, teamID string) ([]models.TeamMember, error)
// TeamPersonas returns team-scoped personas.
TeamPersonas(ctx context.Context, teamID string) ([]models.Persona, error)
// TeamPersonaKBs returns persona_knowledge_bases for given persona IDs.
TeamPersonaKBs(ctx context.Context, personaIDs []string) ([]models.PersonaKB, error)
// TeamKnowledgeBases returns team-scoped knowledge bases.
TeamKnowledgeBases(ctx context.Context, teamID string) ([]models.KnowledgeBase, error)
// TeamKBDocuments returns KB document metadata for given KB IDs (no chunks/embeddings).
TeamKBDocuments(ctx context.Context, kbIDs []string) ([]models.KBDocument, error)
// TeamWorkflows returns team-scoped workflows.
TeamWorkflows(ctx context.Context, teamID string) ([]models.Workflow, error)
// TeamWorkflowVersions returns versions for given workflow IDs.
TeamWorkflowVersions(ctx context.Context, workflowIDs []string) ([]models.WorkflowVersion, error)
// TeamWorkflowStages returns stages for given workflow IDs.
TeamWorkflowStages(ctx context.Context, workflowIDs []string) ([]models.WorkflowStage, error)
// TeamGroups returns team-scoped groups.
TeamGroups(ctx context.Context, teamID string) ([]models.Group, error)
// TeamGroupMembers returns members for given group IDs.
TeamGroupMembers(ctx context.Context, groupIDs []string) ([]models.GroupMember, error)
// TeamResourceGrants returns resource grants for team resources.
TeamResourceGrants(ctx context.Context, teamID string) ([]models.ResourceGrant, error)
// TeamProjects returns team-scoped projects.
TeamProjects(ctx context.Context, teamID string) ([]models.Project, error)
// ── Import (CS1) ──
// Each ImportXxx method inserts entities preserving their original IDs.
// Uses INSERT ON CONFLICT DO NOTHING (PG) / INSERT OR IGNORE (SQLite)
// to skip duplicates. Returns (imported, skipped) counts.
ImportFolders(ctx context.Context, folders []models.Folder) (int, int, error)
ImportProjects(ctx context.Context, projects []models.Project) (int, int, error)
ImportWorkspaces(ctx context.Context, workspaces []models.Workspace) (int, int, error)
ImportChannels(ctx context.Context, channels []models.Channel) (int, int, error)
ImportChannelParticipants(ctx context.Context, cps []models.ChannelParticipant) (int, int, error)
ImportChannelModels(ctx context.Context, cms []models.ChannelModel) (int, int, error)
ImportChannelCursors(ctx context.Context, cursors []models.ChannelCursor) (int, int, error)
ImportMessages(ctx context.Context, msgs []models.Message) (int, int, error)
ImportNotes(ctx context.Context, notes []models.Note) (int, int, error)
ImportNoteLinks(ctx context.Context, links []models.ExportNoteLink) (int, int, error)
ImportMemories(ctx context.Context, mems []models.Memory) (int, int, error)
ImportProjectChannels(ctx context.Context, pcs []models.ProjectChannel) (int, int, error)
ImportProjectKBs(ctx context.Context, pks []models.ProjectKB) (int, int, error)
ImportProjectNotes(ctx context.Context, pns []models.ProjectNote) (int, int, error)
ImportWorkspaceFiles(ctx context.Context, wfs []models.WorkspaceFile) (int, int, error)
ImportFiles(ctx context.Context, files []models.File) (int, int, error)
ImportUserModelSettings(ctx context.Context, ums []models.UserModelSetting) (int, int, error)
ImportNotifPrefs(ctx context.Context, nps []models.NotificationPreference) (int, int, error)
ImportPersonaGroups(ctx context.Context, pgs []models.PersonaGroup) (int, int, error)
ImportPersonaGroupMembers(ctx context.Context, pgms []models.PersonaGroupMember) (int, int, error)
// ── GDPR ──
// CountActiveAdmins returns the number of active admin users.
CountActiveAdmins(ctx context.Context) (int, error)
// AnonymizeUser replaces PII with "deleted-user-{hash}" placeholders.
AnonymizeUser(ctx context.Context, userID string, anonHash string) error
// SoftDeleteUserData cascade-deletes/soft-deletes all user-owned data.
// Returns entity counts by type for the audit trail.
SoftDeleteUserData(ctx context.Context, userID string) (map[string]int64, error)
// DeleteUserTokens revokes all refresh tokens and WS tickets.
DeleteUserTokens(ctx context.Context, userID string) error
}
// =========================================
// SHARED TYPES
// =========================================