repository

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package repository provides database access and the SQLite migration runner.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = error(notFound{})

ErrNotFound is returned when an entity is not found.

Functions

func Migrate

func Migrate(ctx context.Context, db *sqlx.DB, migrationsFS fs.FS) error

Migrate runs all unapplied SQL migrations from the provided filesystem. The FS must contain files named NNN_description.sql at its root. Applied migrations are tracked in the schema_migrations table.

Types

type EventRepository

type EventRepository interface {
	Create(ctx context.Context, e domain.SystemEvent) error
	ListByType(ctx context.Context, eventType string, limit int) ([]domain.SystemEvent, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string, limit int) ([]domain.SystemEvent, error)
}

EventRepository provides persistence for system events.

type GithubPRCheckRepository added in v0.0.28

type GithubPRCheckRepository interface {
	Upsert(ctx context.Context, check domain.GithubPRCheck) error
	ListByPRID(ctx context.Context, prID string) ([]domain.GithubPRCheck, error)
	DeleteByPRID(ctx context.Context, prID string) error
}

GithubPRCheckRepository provides persistence for GitHub PR check runs.

type GithubPRReviewRepository added in v0.0.28

type GithubPRReviewRepository interface {
	Upsert(ctx context.Context, review domain.GithubPRReview) error
	ListByPRID(ctx context.Context, prID string) ([]domain.GithubPRReview, error)
	DeleteByPRID(ctx context.Context, prID string) error
}

GithubPRReviewRepository provides persistence for GitHub PR reviews.

type GithubPullRequestRepository

type GithubPullRequestRepository interface {
	Upsert(ctx context.Context, pr domain.GithubPullRequest) error
	Get(ctx context.Context, id string) (domain.GithubPullRequest, error)
	GetByNumber(ctx context.Context, owner, repo string, number int) (domain.GithubPullRequest, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
	ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
}

GithubPullRequestRepository provides persistence for GitHub pull requests.

type GitlabMRCheckRepository added in v0.0.28

type GitlabMRCheckRepository interface {
	Upsert(ctx context.Context, check domain.GitlabMRCheck) error
	ListByMRID(ctx context.Context, mrID string) ([]domain.GitlabMRCheck, error)
	DeleteByMRID(ctx context.Context, mrID string) error
}

GitlabMRCheckRepository provides persistence for GitLab MR pipeline jobs.

type GitlabMRReviewRepository added in v0.0.28

type GitlabMRReviewRepository interface {
	Upsert(ctx context.Context, review domain.GitlabMRReview) error
	ListByMRID(ctx context.Context, mrID string) ([]domain.GitlabMRReview, error)
	DeleteByMRID(ctx context.Context, mrID string) error
}

GitlabMRReviewRepository provides persistence for GitLab MR reviews.

type GitlabMergeRequestRepository

type GitlabMergeRequestRepository interface {
	Upsert(ctx context.Context, mr domain.GitlabMergeRequest) error
	Get(ctx context.Context, id string) (domain.GitlabMergeRequest, error)
	GetByIID(ctx context.Context, projectPath string, iid int) (domain.GitlabMergeRequest, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
	ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
}

GitlabMergeRequestRepository provides persistence for GitLab merge requests.

type InstanceRepository

type InstanceRepository interface {
	Get(ctx context.Context, id string) (domain.SubstrateInstance, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SubstrateInstance, error)
	Create(ctx context.Context, inst domain.SubstrateInstance) error
	Update(ctx context.Context, inst domain.SubstrateInstance) error
	Delete(ctx context.Context, id string) error
}

InstanceRepository provides CRUD for substrate instances.

type NewSessionFilterLockRepository

type NewSessionFilterLockRepository interface {
	Get(ctx context.Context, filterID string) (domain.NewSessionFilterLock, error)
	Acquire(ctx context.Context, lock domain.NewSessionFilterLock) (domain.NewSessionFilterLock, bool, error)
	Renew(ctx context.Context, lock domain.NewSessionFilterLock) (domain.NewSessionFilterLock, bool, error)
	Release(ctx context.Context, filterID, instanceID string) error
}

NewSessionFilterLockRepository coordinates New Session filter lock leases.

type NewSessionFilterRepository

type NewSessionFilterRepository interface {
	Get(ctx context.Context, id string) (domain.NewSessionFilter, error)
	GetByWorkspaceProviderName(ctx context.Context, workspaceID, provider, name string) (domain.NewSessionFilter, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.NewSessionFilter, error)
	ListByWorkspaceProvider(ctx context.Context, workspaceID, provider string) ([]domain.NewSessionFilter, error)
	Create(ctx context.Context, filter domain.NewSessionFilter) error
	Update(ctx context.Context, filter domain.NewSessionFilter) error
	Delete(ctx context.Context, id string) error
}

NewSessionFilterRepository provides CRUD and lookup for saved New Session filters.

type NoopTransacter

type NoopTransacter struct {
	Res Resources
}

NoopTransacter calls fn directly with the stored Resources without transaction semantics. For tests only.

func (NoopTransacter) Transact

func (t NoopTransacter) Transact(ctx context.Context, fn func(context.Context, Resources) error) error

type PlanRepository

type PlanRepository interface {
	Get(ctx context.Context, id string) (domain.Plan, error)
	GetByWorkItemID(ctx context.Context, workItemID string) (domain.Plan, error)
	Create(ctx context.Context, plan domain.Plan) error
	Update(ctx context.Context, plan domain.Plan) error
	Delete(ctx context.Context, id string) error
	AppendFAQ(ctx context.Context, entry domain.FAQEntry) error
}

PlanRepository provides CRUD for plans.

type QuestionRepository

type QuestionRepository interface {
	Get(ctx context.Context, id string) (domain.Question, error)
	ListBySessionID(ctx context.Context, sessionID string) ([]domain.Question, error)
	Create(ctx context.Context, q domain.Question) error
	Update(ctx context.Context, q domain.Question) error
	UpdateProposedAnswer(ctx context.Context, id, proposedAnswer string) error
}

QuestionRepository provides CRUD for questions.

type Resources

type Resources struct {
	Sessions               SessionRepository
	Plans                  PlanRepository
	SubPlans               TaskPlanRepository
	Workspaces             WorkspaceRepository
	NewSessionFilters      NewSessionFilterRepository
	NewSessionFilterLocks  NewSessionFilterLockRepository
	Tasks                  TaskRepository
	Reviews                ReviewRepository
	Questions              QuestionRepository
	Events                 EventRepository
	Instances              InstanceRepository
	GithubPRs              GithubPullRequestRepository
	GitlabMRs              GitlabMergeRequestRepository
	SessionReviewArtifacts SessionReviewArtifactRepository
	GithubPRReviews        GithubPRReviewRepository
	GitlabMRReviews        GitlabMRReviewRepository
	GithubPRChecks         GithubPRCheckRepository
	GitlabMRChecks         GitlabMRCheckRepository
}

Resources groups all transaction-bound repositories. Every field is bound to the same database transaction when created inside a Transact call.

type ReviewRepository

type ReviewRepository interface {
	GetCycle(ctx context.Context, id string) (domain.ReviewCycle, error)
	ListCyclesBySessionID(ctx context.Context, sessionID string) ([]domain.ReviewCycle, error)
	CreateCycle(ctx context.Context, rc domain.ReviewCycle) error
	UpdateCycle(ctx context.Context, rc domain.ReviewCycle) error

	GetCritique(ctx context.Context, id string) (domain.Critique, error)
	ListCritiquesByReviewCycleID(ctx context.Context, cycleID string) ([]domain.Critique, error)
	CreateCritique(ctx context.Context, c domain.Critique) error
	UpdateCritique(ctx context.Context, c domain.Critique) error
}

ReviewRepository provides CRUD for review cycles and critiques.

type SessionFilter

type SessionFilter struct {
	WorkspaceID   *string
	ExternalID    *string
	State         *domain.SessionState
	Source        *string
	Limit, Offset int
}

SessionFilter constrains session repository List results.

type SessionRepository

type SessionRepository interface {
	Get(ctx context.Context, id string) (domain.Session, error)
	List(ctx context.Context, filter SessionFilter) ([]domain.Session, error)
	Create(ctx context.Context, item domain.Session) error
	Update(ctx context.Context, item domain.Session) error
	Delete(ctx context.Context, id string) error
}

SessionRepository provides CRUD for root sessions.

type SessionReviewArtifactRepository

type SessionReviewArtifactRepository interface {
	Upsert(ctx context.Context, link domain.SessionReviewArtifact) error
	ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.SessionReviewArtifact, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SessionReviewArtifact, error)
}

SessionReviewArtifactRepository provides persistence for the link between work items and PR/MR records.

type TaskPlanRepository

type TaskPlanRepository interface {
	Get(ctx context.Context, id string) (domain.TaskPlan, error)
	ListByPlanID(ctx context.Context, planID string) ([]domain.TaskPlan, error)
	Create(ctx context.Context, sp domain.TaskPlan) error
	Update(ctx context.Context, sp domain.TaskPlan) error
	Delete(ctx context.Context, id string) error
}

TaskPlanRepository provides CRUD for task plans.

type TaskRepository

type TaskRepository interface {
	Get(ctx context.Context, id string) (domain.Task, error)
	ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.Task, error)
	ListBySubPlanID(ctx context.Context, subPlanID string) ([]domain.Task, error)
	ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.Task, error)
	ListByOwnerInstanceID(ctx context.Context, instanceID string) ([]domain.Task, error)
	SearchHistory(ctx context.Context, filter domain.SessionHistoryFilter) ([]domain.SessionHistoryEntry, error)
	Create(ctx context.Context, s domain.Task) error
	Update(ctx context.Context, s domain.Task) error
	Delete(ctx context.Context, id string) error
}

TaskRepository provides CRUD for child agent sessions.

type WorkspaceRepository

type WorkspaceRepository interface {
	Get(ctx context.Context, id string) (domain.Workspace, error)
	Create(ctx context.Context, ws domain.Workspace) error
	Update(ctx context.Context, ws domain.Workspace) error
	Delete(ctx context.Context, id string) error
}

WorkspaceRepository provides CRUD for workspaces.

Directories

Path Synopsis
Package sqlite provides SQLite implementations of the repository interfaces.
Package sqlite provides SQLite implementations of the repository interfaces.

Jump to

Keyboard shortcuts

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