Documentation
¶
Index ¶
- Constants
- Variables
- func IsAllowedModel(m string) bool
- type Store
- func (s *Store) ActiveRepos(ctx context.Context) ([]db.Repo, error)
- func (s *Store) GetModelPreference(ctx context.Context) (string, error)
- func (s *Store) RepoByID(ctx context.Context, id uuid.UUID) (*db.Repo, error)
- func (s *Store) RepoByName(ctx context.Context, name string) (*db.Repo, error)
- func (s *Store) UpsertModelPreference(ctx context.Context, model string) error
- func (s *Store) UpsertRepo(ctx context.Context, p UpsertRepoParams) (*db.Repo, error)
- func (s *Store) WithTx(tx pgx.Tx) *Store
- type StoreIface
- type UpsertRepoParams
Constants ¶
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 ¶
var ( ErrNotFound = errors.New("workspace: not found") ErrConflict = errors.New("workspace: conflict") )
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).
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 ¶
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 ¶
NewStore returns a Store backed by the given DBTX scoped to the optional workspace. nil workspaceID = legacy unscoped mode.
func (*Store) ActiveRepos ¶
ActiveRepos returns all repos with status = 'active', ordered by last_activity.
func (*Store) GetModelPreference ¶
GetModelPreference returns the workspace's stored model_preference, or DefaultModelPreference when no row exists (or in legacy unscoped mode).
func (*Store) RepoByID ¶
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 ¶
RepoByName returns a single repo by unique name, or ErrNotFound.
func (*Store) UpsertModelPreference ¶
UpsertModelPreference stores the workspace's model_preference. Returns ErrInvalidModel when model is not allowed.
func (*Store) UpsertRepo ¶
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.
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.