sqlite

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string) (*sql.DB, error)

Open opens a SQLite database at the given path with production settings: foreign key enforcement via DSN, single connection (SQLite is single-writer), and WAL mode for concurrent reads.

func OpenForTest added in v0.5.0

func OpenForTest(migrationsFS fs.FS) (*sql.DB, error)

OpenForTest opens an in-memory database, runs migrations, and forces foreign key enforcement off. Migrations may toggle the FK pragma for table-swap operations and leave it on; tests assert invariants through explicit app-level checks instead, so we reset the connection to the test contract afterwards.

func OpenRaw

func OpenRaw(path string) (*sql.DB, error)

OpenRaw opens a SQLite database without foreign key enforcement or connection limits. Intended for tests only.

func RunMigrations

func RunMigrations(db *sql.DB, migrationsFS fs.FS) error

RunMigrations applies all pending migrations from migrationsFS to db. It is idempotent — running it twice is a no-op.

Types

type Store

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

Store implements the contract.Store interface backed by SQLite via sqlc.

func New

func New(db *sql.DB) *Store

New creates a Store wrapping an already-opened *sql.DB.

func (*Store) AttachSkillToBrain added in v0.6.0

func (s *Store) AttachSkillToBrain(ctx context.Context, workspaceID models.WorkspaceID, brainSlug, skillSlug models.Slug, position int) error

AttachSkillToBrain links a skill to a brain at the given position. Position controls display ordering under the brain — runtime load order is decided by the agent runtime, not by brainjar.

func (*Store) BeginTx

func (s *Store) BeginTx(ctx context.Context) (*sql.Tx, error)

BeginTx starts a new database transaction.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, key *models.APIKey) error

func (*Store) CreateWorkspace

func (s *Store) CreateWorkspace(ctx context.Context, ws *models.Workspace) error

func (*Store) DeleteAPIKey

func (s *Store) DeleteAPIKey(ctx context.Context, id models.APIKeyID) error

func (*Store) DeleteBrain

func (s *Store) DeleteBrain(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteLayerOverride

func (s *Store) DeleteLayerOverride(ctx context.Context, workspaceID models.WorkspaceID, scopeType models.ScopeType, referenceID string) error

func (*Store) DeletePersona

func (s *Store) DeletePersona(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteProcedure added in v0.5.0

func (s *Store) DeleteProcedure(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteProceduresByWorkspace added in v0.5.0

func (s *Store) DeleteProceduresByWorkspace(ctx context.Context, workspaceID models.WorkspaceID) error

DeleteProceduresByWorkspace removes every procedure in a workspace without checking brain references. Used by PurgeWorkspaceContent and by tests that need to simulate a procedure disappearing out from under a brain.

func (*Store) DeleteRule

func (s *Store) DeleteRule(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteSkill added in v0.6.0

func (s *Store) DeleteSkill(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteSkillsByWorkspace added in v0.6.0

func (s *Store) DeleteSkillsByWorkspace(ctx context.Context, workspaceID models.WorkspaceID) error

DeleteSkillsByWorkspace removes every skill in a workspace without checking brain references. Used by PurgeWorkspaceContent.

func (*Store) DeleteSoul

func (s *Store) DeleteSoul(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*Store) DeleteWorkspace

func (s *Store) DeleteWorkspace(ctx context.Context, id models.WorkspaceID) error

func (*Store) DetachSkillFromBrain added in v0.6.0

func (s *Store) DetachSkillFromBrain(ctx context.Context, workspaceID models.WorkspaceID, brainSlug, skillSlug models.Slug) error

func (*Store) FindBrain

func (s *Store) FindBrain(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Brain, error)

func (*Store) FindLayerOverride

func (s *Store) FindLayerOverride(ctx context.Context, workspaceID models.WorkspaceID, scopeType models.ScopeType, referenceID string) (*models.LayerOverride, error)

func (*Store) FindPersona

func (s *Store) FindPersona(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Persona, error)

func (*Store) FindProcedure added in v0.5.0

func (s *Store) FindProcedure(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Procedure, error)

func (*Store) FindRule

func (s *Store) FindRule(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Rule, error)

func (*Store) FindSkill added in v0.6.0

func (s *Store) FindSkill(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Skill, error)

func (*Store) FindSoul

func (s *Store) FindSoul(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Soul, error)

func (*Store) FindWorkspaceByName

func (s *Store) FindWorkspaceByName(ctx context.Context, name string) (*models.Workspace, error)

func (*Store) GetAPIKey

func (s *Store) GetAPIKey(ctx context.Context, id models.APIKeyID) (*models.APIKey, error)

func (*Store) GetAPIKeyByHash

func (s *Store) GetAPIKeyByHash(ctx context.Context, keyHash string) (*models.APIKey, error)

func (*Store) GetBrain

func (s *Store) GetBrain(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Brain, error)

func (*Store) GetContentVersion

func (s *Store) GetContentVersion(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug, version int) (*models.ContentVersion, error)

func (*Store) GetPersona

func (s *Store) GetPersona(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Persona, error)

func (*Store) GetProcedure added in v0.5.0

func (s *Store) GetProcedure(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Procedure, error)

func (*Store) GetRule

func (s *Store) GetRule(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Rule, error)

func (*Store) GetSkill added in v0.6.0

func (s *Store) GetSkill(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Skill, error)

func (*Store) GetSoul

func (s *Store) GetSoul(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Soul, error)

func (*Store) GetWorkspace

func (s *Store) GetWorkspace(ctx context.Context, id models.WorkspaceID) (*models.Workspace, error)

func (*Store) ListAPIKeysByWorkspace added in v0.3.1

func (s *Store) ListAPIKeysByWorkspace(ctx context.Context, workspaceID models.WorkspaceID) ([]models.APIKeySummary, error)

func (*Store) ListBrains

func (s *Store) ListBrains(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Brain, error)

func (*Store) ListContentVersions

func (s *Store) ListContentVersions(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug) ([]models.VersionSummary, error)

func (*Store) ListLayerOverrides added in v0.7.0

func (s *Store) ListLayerOverrides(ctx context.Context, workspaceID models.WorkspaceID) ([]models.LayerOverride, error)

func (*Store) ListPersonas

func (s *Store) ListPersonas(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Persona, error)

func (*Store) ListProcedures added in v0.5.0

func (s *Store) ListProcedures(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Procedure, error)

func (*Store) ListRules

func (s *Store) ListRules(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Rule, error)

func (*Store) ListSkills added in v0.6.0

func (s *Store) ListSkills(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Skill, error)

func (*Store) ListSouls

func (s *Store) ListSouls(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Soul, error)

func (*Store) ListWorkspaces

func (s *Store) ListWorkspaces(ctx context.Context) ([]models.Workspace, error)

func (*Store) PurgeWorkspaceContent added in v0.3.1

func (s *Store) PurgeWorkspaceContent(ctx context.Context, workspaceID models.WorkspaceID) error

PurgeWorkspaceContent deletes everything attached to a workspace except the workspace row itself, inside one transaction. Used by the CLI's `workspace delete --purge` flag. Order of deletes matters: content_versions reference content tables, layer_overrides reference the workspace, and api_keys reference the workspace — removing them first lets the workspace row be dropped afterwards without tripping any FK.

func (*Store) Query

func (s *Store) Query(tx *sql.Tx) *sqlgen.Queries

Query returns sqlc queries scoped to tx if non-nil, otherwise the default connection.

func (*Store) ReplaceBrainSkills added in v0.6.0

func (s *Store) ReplaceBrainSkills(ctx context.Context, workspaceID models.WorkspaceID, brainSlug models.Slug, skillSlugs []models.Slug) error

ReplaceBrainSkills clears every skill link for a brain. Callers follow with AttachSkillToBrain per slug, preserving the input order via the position field. This is the path UpsertBrain takes when SkillSlugs changes.

func (*Store) RevokeAPIKey

func (s *Store) RevokeAPIKey(ctx context.Context, key *models.APIKey) error

func (*Store) SkillSlugsForBrain added in v0.6.0

func (s *Store) SkillSlugsForBrain(ctx context.Context, workspaceID models.WorkspaceID, brainSlug models.Slug) ([]models.Slug, error)

SkillSlugsForBrain returns the slugs of every skill attached to the given brain, ordered by position. Used by Brain hydration.

func (*Store) UpdateWorkspace

func (s *Store) UpdateWorkspace(ctx context.Context, ws *models.Workspace) error

func (*Store) UpsertBrain

func (s *Store) UpsertBrain(ctx context.Context, brain *models.Brain) error

func (*Store) UpsertLayerOverride

func (s *Store) UpsertLayerOverride(ctx context.Context, override *models.LayerOverride) error

func (*Store) UpsertPersona

func (s *Store) UpsertPersona(ctx context.Context, persona *models.Persona) error

func (*Store) UpsertProcedure added in v0.5.0

func (s *Store) UpsertProcedure(ctx context.Context, proc *models.Procedure) error

func (*Store) UpsertRule

func (s *Store) UpsertRule(ctx context.Context, rule *models.Rule) error

func (*Store) UpsertSkill added in v0.6.0

func (s *Store) UpsertSkill(ctx context.Context, skill *models.Skill) error

UpsertSkill inserts or replaces a skill. On replace, the prior row is archived to content_versions with the description + triggers + version captured in metadata so reverts can rebuild the original surface. The stored Body is the markdown body emitted to disk.

func (*Store) UpsertSoul

func (s *Store) UpsertSoul(ctx context.Context, soul *models.Soul) error

Jump to

Keyboard shortcuts

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