profile

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package profile manages global human and agent profiles in the control plane.

Index

Constants

View Source
const (
	KindHuman = "human"
	KindAgent = "agent"

	StatusActive   = "active"
	StatusArchived = "archived"
)

Variables

View Source
var (
	ErrProfileNotFound   = errors.New("profile not found")
	ErrProfileIDConflict = errors.New("profile ID already exists")
	ErrProfileArchived   = errors.New("profile is archived")
	ErrContractNotFound  = errors.New("contract version not found")
	ErrRoleNotFound      = errors.New("role is not declared by the contract version")
	ErrRoleBindingExists = errors.New("profile role binding already exists")
)

Functions

This section is empty.

Types

type BindRoleParams

type BindRoleParams struct {
	ProfileID       string
	ContractID      string
	ContractVersion int
	RoleID          string
	Actor           string
}

BindRoleParams selects one role from an immutable contract version.

type Profile

type Profile struct {
	ID          string
	Name        string
	Kind        string
	Description string
	Status      string
	Revision    int
	CreatedAt   time.Time
	UpdatedAt   time.Time
	ArchivedAt  *time.Time
	Roles       []RoleBinding
}

Profile is the current persisted profile snapshot.

type RegisterParams

type RegisterParams struct {
	ID          string
	Name        string
	Kind        string
	Description string
	Actor       string
}

RegisterParams defines a new global profile.

type RoleBinding

type RoleBinding struct {
	ContractID      string
	ContractVersion int
	RoleID          string
	RoleName        string
	RoleDescription string
	BoundAt         time.Time
}

RoleBinding is one version-scoped role attached to a profile.

type Store

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

Store owns global profile persistence.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens profile persistence and applies technical schema migrations.

func (*Store) Archive

func (s *Store) Archive(ctx context.Context, id string) (Profile, error)

Archive marks a profile archived without deleting it.

func (*Store) ArchiveAs

func (s *Store) ArchiveAs(ctx context.Context, id, actorID string) (Profile, error)

ArchiveAs marks a profile archived and attributes the mutation to actorID.

func (*Store) BindRole

func (s *Store) BindRole(ctx context.Context, params BindRoleParams) (Profile, error)

BindRole attaches a declared contract role and advances the profile revision.

func (*Store) Close

func (s *Store) Close() error

Close releases the database connection.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (Profile, error)

Get returns one profile by ID.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]Profile, error)

List returns all profiles ordered by stable ID.

func (*Store) Register

func (s *Store) Register(ctx context.Context, params RegisterParams) (Profile, error)

Register creates and audits one profile atomically.

func (*Store) Update

func (s *Store) Update(ctx context.Context, params UpdateParams) (Profile, error)

Update changes mutable profile metadata and writes an audit event atomically.

type UpdateParams

type UpdateParams struct {
	ID          string
	Name        *string
	Description *string
	Actor       string
}

UpdateParams defines a partial profile update.

type ValidationError

type ValidationError struct {
	Code    string `json:"code"`
	Path    string `json:"path,omitempty"`
	Message string `json:"message"`
}

ValidationError describes one invalid profile value.

type ValidationFailure

type ValidationFailure struct {
	Errors []ValidationError
}

ValidationFailure reports all detected profile validation errors.

func (*ValidationFailure) Error

func (e *ValidationFailure) Error() string

Jump to

Keyboard shortcuts

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