personastore

package
v1.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package personastore persists database-managed persona definitions, independent of the platform assembly. It holds the persona_definitions storage model (Definition), its Store interface, and the PostgreSQL and no-op implementations. Extracted from pkg/platform so the persona storage layer can be reasoned about (and size-budgeted) on its own.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("persona not found")

ErrNotFound is returned when a persona definition does not exist in the database.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name        string                   `json:"name"`
	DisplayName string                   `json:"display_name"`
	Description string                   `json:"description,omitempty"`
	Roles       []string                 `json:"roles"`
	ToolsAllow  []string                 `json:"tools_allow"`
	ToolsDeny   []string                 `json:"tools_deny"`
	ConnsAllow  []string                 `json:"connections_allow,omitempty"`
	ConnsDeny   []string                 `json:"connections_deny,omitempty"`
	Context     persona.ContextOverrides `json:"context"`
	Priority    int                      `json:"priority"`
	CreatedBy   string                   `json:"created_by"`
	UpdatedAt   time.Time                `json:"updated_at"`
}

Definition represents a database-managed persona.

func DefinitionFromPersona

func DefinitionFromPersona(p *persona.Persona, author string) Definition

DefinitionFromPersona converts a persona.Persona to a Definition.

func (*Definition) ToPersona

func (d *Definition) ToPersona() *persona.Persona

ToPersona converts a Definition to a persona.Persona.

type NoopStore

type NoopStore struct{}

NoopStore is a no-op implementation for when no database is available.

func (*NoopStore) Delete

func (*NoopStore) Delete(_ context.Context, _ string) error

Delete always returns ErrNotFound (no database available).

func (*NoopStore) Get

Get always returns ErrNotFound (no database available).

func (*NoopStore) List

func (*NoopStore) List(_ context.Context) ([]Definition, error)

List returns an empty list (no database available).

func (*NoopStore) Set

Set is a no-op (no database available).

type PostgresStore

type PostgresStore struct {
	// contains filtered or unexported fields
}

PostgresStore implements Store backed by PostgreSQL.

func NewPostgresStore

func NewPostgresStore(db *sql.DB) *PostgresStore

NewPostgresStore creates a new PostgreSQL-backed persona store.

func (*PostgresStore) Delete

func (s *PostgresStore) Delete(ctx context.Context, name string) error

Delete removes a persona definition by name.

func (*PostgresStore) Get

func (s *PostgresStore) Get(ctx context.Context, name string) (*Definition, error)

Get returns a single persona definition by name.

func (*PostgresStore) List

func (s *PostgresStore) List(ctx context.Context) ([]Definition, error)

List returns all persona definitions.

func (*PostgresStore) Set

func (s *PostgresStore) Set(ctx context.Context, def Definition) error

Set creates or updates a persona definition.

type Store

type Store interface {
	List(ctx context.Context) ([]Definition, error)
	Get(ctx context.Context, name string) (*Definition, error)
	Set(ctx context.Context, def Definition) error
	Delete(ctx context.Context, name string) error
}

Store manages persona definition persistence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL