workspace

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultModelPreference = "claude-sonnet-4-6"

DefaultModelPreference is the model used when a workspace has no stored preference. Mirrors the workspace_preferences.model_preference DB column DEFAULT (migrations/000013_workspace_model_preference.up.sql).

Variables

View Source
var (
	ErrNotFound = errors.New("workspace: not found")
	ErrConflict = errors.New("workspace: conflict")
)
View Source
var AllowedModels = map[string]struct{}{
	"claude-haiku-4-5":  {},
	"claude-sonnet-4-6": {},
	"claude-opus-4-8":   {},
}

AllowedModels is the single source of truth for valid AI model identifiers a workspace may select. Add new Claude model versions here as they ship; the frontend selector mirrors this list (web/src/types/api.ts ALLOWED_MODELS).

View Source
var ErrInvalidModel = errors.New("workspace: model not in allowed list")

ErrInvalidModel is returned by UpsertModelPreference when the requested model is not in AllowedModels.

Functions

func IsAllowedModel

func IsAllowedModel(m string) bool

IsAllowedModel reports whether m is a selectable model identifier.

Types

type Store

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

Store handles all database operations for the Workspace bounded context.

func NewStore

func NewStore(dbtx db.DBTX, workspaceID *uuid.UUID) *Store

NewStore returns a Store backed by the given DBTX scoped to the optional workspace. nil workspaceID = legacy unscoped mode.

func (*Store) ActiveRepos

func (s *Store) ActiveRepos(ctx context.Context) ([]db.Repo, error)

ActiveRepos returns all repos with status = 'active', ordered by last_activity.

func (*Store) GetModelPreference

func (s *Store) GetModelPreference(ctx context.Context) (string, error)

GetModelPreference returns the workspace's stored model_preference, or DefaultModelPreference when no row exists (or in legacy unscoped mode).

func (*Store) RepoByID

func (s *Store) RepoByID(ctx context.Context, id uuid.UUID) (*db.Repo, error)

RepoByID returns a single repo by primary key UUID, scoped to the configured workspace. Returns ErrNotFound when no row matches. Hand-written query (not sqlc) so the change is contained to the Go store layer.

func (*Store) RepoByName

func (s *Store) RepoByName(ctx context.Context, name string) (*db.Repo, error)

RepoByName returns a single repo by unique name, or ErrNotFound.

func (*Store) UpsertModelPreference

func (s *Store) UpsertModelPreference(ctx context.Context, model string) error

UpsertModelPreference stores the workspace's model_preference. Returns ErrInvalidModel when model is not allowed.

func (*Store) UpsertRepo

func (s *Store) UpsertRepo(ctx context.Context, p UpsertRepoParams) (*db.Repo, error)

UpsertRepo creates or updates a repo entry. workspaceID must be non-nil: after migration 000028 the unique constraint is (workspace_id, name), so ON CONFLICT does not fire for NULL workspace_id.

func (*Store) WithTx

func (s *Store) WithTx(tx pgx.Tx) *Store

WithTx returns a Store bound to tx, preserving the workspace scope.

type StoreIface

type StoreIface interface {
	ActiveRepos(ctx context.Context) ([]db.Repo, error)
	RepoByName(ctx context.Context, name string) (*db.Repo, error)
	// RepoByID returns a single repo by primary key UUID, scoped to the
	// configured workspace. Returns ErrNotFound when no row matches.
	RepoByID(ctx context.Context, id uuid.UUID) (*db.Repo, error)
	UpsertRepo(ctx context.Context, p UpsertRepoParams) (*db.Repo, error)

	// GetModelPreference returns the workspace's stored AI model, or
	// DefaultModelPreference when no row exists.
	GetModelPreference(ctx context.Context) (string, error)
	// UpsertModelPreference stores the workspace's AI model. Returns
	// ErrInvalidModel when model is not in AllowedModels.
	UpsertModelPreference(ctx context.Context, model string) error
}

StoreIface is the backend-agnostic contract for the Workspace bounded context (tracked Git repos, not the workspace_id scoping concept).

type UpsertRepoParams

type UpsertRepoParams struct {
	Name            string
	Path            *string
	Description     *string
	Language        *string
	CurrentBranch   *string
	KnownIssues     []string // nil → preserve; non-nil (incl. empty slice) → replace
	NextPlannedStep *string
}

UpsertRepoParams holds parameters for creating or updating a repo entry.

Path, Description, Language, CurrentBranch, NextPlannedStep are presence-aware (Ω6, 2026-08-20-mcp-surface-spec.md): nil preserves the stored value; a non-nil pointer — even to "" — explicitly replaces it, matching upsert_project_arch.summary/file_map's established convention. Previously these were plain strings and every field a caller didn't re-supply on a sync_repo call was silently wiped to "" on every backend.

Jump to

Keyboard shortcuts

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