profile

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package profile owns durable profile identity, selection, resolution, and crash-convergent lifecycle operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = errors.New("profile not found")
	ErrArchived         = errors.New("profile archived")
	ErrNameInvalid      = errors.New("profile name invalid")
	ErrNameTaken        = errors.New("profile name taken")
	ErrNameReserved     = errors.New("profile name reserved")
	ErrPermanent        = errors.New("profile is permanent")
	ErrOwnsWork         = errors.New("profile owns work")
	ErrSessionsRunning  = errors.New("profile sessions are running")
	ErrPlanStale        = errors.New("profile plan is stale")
	ErrUnavailable      = errors.New("profile unavailable")
	ErrSessionConflict  = errors.New("profile session conflict")
	ErrApprovalsPending = errors.New("profile approvals are pending")
	ErrInvalidInput     = errors.New("profile input is invalid")
)

Functions

func NormalizeIdentity

func NormalizeIdentity(color, icon, emoji string) (string, string, string, error)

NormalizeIdentity trims identity fields, lowercases the color, applies the default color and icon, and validates the shared profile identity shape.

func NormalizeName

func NormalizeName(name string) (string, error)

NormalizeName trims and validates a profile name, returning the canonical grammar-safe form (lowercase, 32 characters or fewer) for manifests and other boundaries that bind to profiles by name.

Types

type ArchivePlan

type ArchivePlan struct {
	Revision           string
	RunningSessions    []string
	ApprovalBlockers   []string
	LeasedRuns         int
	QueuedRunsToFreeze int
	AutomationsToPause []string
}

type ArchiveResult

type ArchiveResult struct {
	PausedAutomations []string
	FrozenQueuedRuns  int
}

type AutomationReconciler

type AutomationReconciler interface {
	ReconcileProfileAutomations(ctx context.Context, profileID string) error
}

type CreateInput

type CreateInput struct {
	Name, Color, Icon, Emoji string
	Activate                 *Lens
}

type CredentialAsk

type CredentialAsk struct{ Provider, Slot string }

type CredentialRequirement

type CredentialRequirement struct {
	Provider, Slot, SourceExtension string
	Missing                         bool
}

type DeclaredInput

type DeclaredInput struct {
	Extension string
	Name      string
	Seed      DeclaredSeed
}

type DeclaredSeed

type DeclaredSeed struct {
	Color, Icon, Emoji string
	Defaults           PersonaDefaults
	CredentialAsks     []CredentialAsk
}

type DeletePlan

type DeletePlan struct {
	Revision          string
	Removed           RemovalSummary
	SelectionsToSweep int
	ApprovalBlockers  []string
}

type DeleteResult

type DeleteResult struct {
	Removed         RemovalSummary
	SweptSelections int
}

type DesktopPartitionCatalog

type DesktopPartitionCatalog interface {
	CountDesktopPartitions(ctx context.Context, profileID string) (int, error)
	PurgeDesktopPartitions(ctx context.Context, profileID string) error
}

DesktopPartitionCatalog reports and removes the window arrangements one profile owns across every workspace. Desktops live outside the catalog database, so the count feeds the delete preview and the removal runs as a journaled finalize step.

type Error

type Error struct {
	Code    string
	Message string
	Action  string
	Cause   error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Event

type Event struct {
	Name                string `json:"name"`
	ProfileID           string `json:"profile_id"`
	ProfileName         string `json:"profile_name"`
	ProfileState        State  `json:"-"`
	PreviousProfileName string `json:"previous_profile_name,omitempty"`
	OperationID         string `json:"operation_id,omitempty"`
	Error               string `json:"error,omitempty"`
}

Event is the profile lifecycle payload persisted as an event summary and streamed to clients over the logs stream. The tags are load-bearing: the marshaled form lands in the public `content` field of every log event, so it follows the same snake_case shape as the rest of that wire.

type EventRecorder

type EventRecorder interface{ RecordProfileEvent(Event) }

type IdentityPatch

type IdentityPatch struct{ Color, Icon, Emoji *string }

type Lens

type Lens struct {
	Kind        SelectionLens
	WorkspaceID string
}

func (Lens) Validate

func (l Lens) Validate() error

type LifecycleOp

type LifecycleOp struct{ ID, Kind, Profile, Status, Step, Error string }

type Manager

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

func NewManager

func NewManager(opts ...Option) (*Manager, error)

func (*Manager) Archive

func (m *Manager) Archive(
	ctx context.Context,
	name, planRevision string,
) (ArchiveResult, error)

func (*Manager) AvailableProfileID

func (m *Manager) AvailableProfileID(ctx context.Context, name string) (string, error)

AvailableProfileID resolves an active profile name to its stable owner ID.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, in CreateInput) (Profile, error)

func (*Manager) CreateDeclared

func (m *Manager) CreateDeclared(ctx context.Context, in DeclaredInput) (Profile, error)

func (*Manager) Delete

func (m *Manager) Delete(
	ctx context.Context,
	name, planRevision string,
) (DeleteResult, error)

func (*Manager) EnsureAvailableID

func (m *Manager) EnsureAvailableID(ctx context.Context, profileID string) error

EnsureAvailableID rejects profiles that cannot safely own new runtime work.

func (*Manager) EnsureAvailableName

func (m *Manager) EnsureAvailableName(ctx context.Context, name string) error

EnsureAvailableName rejects profiles that cannot safely own new runtime work.

func (*Manager) GetByName

func (m *Manager) GetByName(ctx context.Context, name string) (Profile, error)

func (*Manager) GetWithCounts

func (m *Manager) GetWithCounts(ctx context.Context, name string) (WithCounts, error)

GetWithCounts returns one profile with its ownership and credential summary.

func (*Manager) HasDeclaredCreation

func (m *Manager) HasDeclaredCreation(ctx context.Context, extension, name, profileID string) (bool, error)

HasDeclaredCreation requires confirmed provenance for the current profile identity.

func (*Manager) HasDeclaredMarker

func (m *Manager) HasDeclaredMarker(ctx context.Context, extension, name string) (bool, error)

HasDeclaredMarker reports a prior binding or creation during this installation lifetime.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]WithCounts, error)

List returns profile identities together with owned-work counts and credential requirements.

func (*Manager) ListIdentities

func (m *Manager) ListIdentities(ctx context.Context) (profiles []Profile, err error)

ListIdentities reads profile metadata without ownership counts or credential requirements.

func (*Manager) ListNames

func (m *Manager) ListNames(ctx context.Context) (names []string, err error)

ListNames returns the profile names needed by lightweight ownership diagnostics.

func (*Manager) ListOps

func (m *Manager) ListOps(ctx context.Context) (ops []LifecycleOp, err error)

func (*Manager) ListSelections

func (m *Manager) ListSelections(ctx context.Context) ([]Selection, error)

func (*Manager) PrepareArchive

func (m *Manager) PrepareArchive(ctx context.Context, name string) (ArchivePlan, error)

func (*Manager) PrepareDelete

func (m *Manager) PrepareDelete(ctx context.Context, name string) (DeletePlan, error)

func (*Manager) PrepareRename

func (m *Manager) PrepareRename(ctx context.Context, name, newName string) (RenamePlan, error)

func (*Manager) ProfileName

func (m *Manager) ProfileName(ctx context.Context, profileID string) (string, error)

ProfileName resolves the current profile name for one stable profile id.

func (*Manager) PutSelection

func (m *Manager) PutSelection(ctx context.Context, selection Selection) error

func (*Manager) Recover

func (m *Manager) Recover(ctx context.Context) error

func (*Manager) Rename

func (m *Manager) Rename(
	ctx context.Context,
	name string,
	opts RenameOptions,
) (RenameResult, error)

func (*Manager) Resolve

func (m *Manager) Resolve(ctx context.Context, in ResolveInput) (Resolution, error)

func (*Manager) RetryOp

func (m *Manager) RetryOp(ctx context.Context, opID string) (LifecycleOp, error)

func (*Manager) SelectionStore

func (m *Manager) SelectionStore() SelectionStore

func (*Manager) Unarchive

func (m *Manager) Unarchive(ctx context.Context, name string) (UnarchiveResult, error)

func (*Manager) UpdateIdentity

func (m *Manager) UpdateIdentity(
	ctx context.Context,
	name string,
	patch IdentityPatch,
) (Profile, error)

type Option

type Option func(*Manager) error

func WithAutomationReconciler

func WithAutomationReconciler(reconciler AutomationReconciler) Option

func WithClock

func WithClock(now func() time.Time) Option

func WithDesktopPartitionCatalog

func WithDesktopPartitionCatalog(catalog DesktopPartitionCatalog) Option

func WithEntropy

func WithEntropy(entropy io.Reader) Option

func WithEventRecorder

func WithEventRecorder(recorder EventRecorder) Option

func WithHomePaths

func WithHomePaths(paths compozyconfig.HomePaths) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

func WithPlacementCatalog

func WithPlacementCatalog(catalog PlacementCatalog) Option

func WithStore

func WithStore(store *globaldb.GlobalDB) Option

func WithUserJournalRemover

func WithUserJournalRemover(remover UserJournalRemover) Option

type PersonaDefaults

type PersonaDefaults struct{ Agent, Provider string }

type PlacementCatalog

type PlacementCatalog interface {
	PlacementsForProfile(context.Context, string) ([]PlacementRef, error)
}

PlacementCatalog reports extension resources that bind to one profile name.

type PlacementRef

type PlacementRef struct{ Extension, Resource, ProfileName string }

type Profile

type Profile struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	Color      string     `json:"color"`
	Icon       string     `json:"icon,omitempty"`
	Emoji      string     `json:"emoji,omitempty"`
	State      State      `json:"state"`
	CreatedAt  time.Time  `json:"created_at"`
	ArchivedAt *time.Time `json:"archived_at,omitempty"`
}

type ReadScope

type ReadScope = store.ReadScope

type RemovalSummary

type RemovalSummary struct {
	AgentInstances, AgentMemoryFiles                                   int
	Agents, Skills, Loops, MCPServers, ConfigKeys, CredentialOverrides int
	DesktopPartitions                                                  int
	PaletteUsage, PaletteQueryHits, PalettePins, TerminalApprovals     int
	EventSummaries                                                     int
}

type RenameOptions

type RenameOptions struct {
	NewName      string
	Repos        RepoChoice
	PlanRevision string
}

type RenamePlan

type RenamePlan struct {
	Revision          string
	MachineFolders    []string
	RepoCandidates    []RepoFolderRef
	DormantPlacements []PlacementRef
	VaultRefRewrites  int
}

type RenameResult

type RenameResult struct {
	RepoResults       []RepoRenameOutcome
	DormantPlacements []PlacementRef
}

type RepoChoice

type RepoChoice struct {
	All, None    bool
	WorkspaceIDs []string
}

func (RepoChoice) Validate

func (r RepoChoice) Validate() error

type RepoFolderRef

type RepoFolderRef struct{ WorkspaceID, WorkspaceName, Path string }

type RepoRenameOutcome

type RepoRenameOutcome struct {
	WorkspaceID string
	Renamed     bool
	Reason      string
}

type Resolution

type Resolution struct {
	Profile Profile
	Source  ResolutionSource
	Note    ResolutionNote
}

type ResolutionNote

type ResolutionNote string
const (
	ResolutionNoteNone                       ResolutionNote = ""
	ResolutionNoteArchivedRememberedFallback ResolutionNote = "archived_remembered_fallback"
	ResolutionNoteNoRememberedChoice         ResolutionNote = "no_remembered_choice"
)

type ResolutionSource

type ResolutionSource string
const (
	ResolutionSourceFlag       ResolutionSource = "flag"
	ResolutionSourceEnv        ResolutionSource = "env"
	ResolutionSourceRemembered ResolutionSource = "remembered"
	ResolutionSourceSession    ResolutionSource = "session"
	ResolutionSourceDefault    ResolutionSource = "default"
)

type ResolveInput

type ResolveInput struct {
	Flag, Env        string
	SessionProfileID string
	Lens             Lens
}

type Selection

type Selection struct {
	Lens        SelectionLens
	WorkspaceID string
	ProfileID   string
}

type SelectionLens

type SelectionLens string
const (
	SelectionLensWorkspace SelectionLens = "workspace"
	SelectionLensGlobal    SelectionLens = "global"
)

type SelectionStore

type SelectionStore interface {
	Get(context.Context, SelectionLens, string) (Selection, bool, error)
	List(context.Context) ([]Selection, error)
	Put(context.Context, Selection) error
	SweepProfile(context.Context, string) error
}

type State

type State string
const (
	StateActive   State = "active"
	StateArchived State = "archived"
)

type UnarchiveResult

type UnarchiveResult struct {
	Profile           Profile
	PausedAutomations []string
}

type UserJournalRemover

type UserJournalRemover interface {
	RemoveUserJournal(context.Context, string) error
}

type WithCounts

type WithCounts struct {
	Profile
	WorkItems              int
	NeedsSetup             bool
	CredentialRequirements []CredentialRequirement
}

Jump to

Keyboard shortcuts

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