skills

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package skills implements Lesser's canonical skill authority service layer.

Index

Constants

View Source
const (
	// SkillBundleSchemaVersion is the stable publication contract version emitted by Lesser.
	SkillBundleSchemaVersion = "lesser.skill.bundle.v1"
)

Variables

View Source
var (
	// ErrRepositoryUnavailable indicates the skill repository was not wired.
	ErrRepositoryUnavailable = errors.New("skill repository unavailable")
	// ErrSkillNotFound indicates the requested skill was not found or not visible.
	ErrSkillNotFound = errors.New("skill not found")
	// ErrSkillRevisionNotFound indicates the requested skill revision was not found.
	ErrSkillRevisionNotFound = errors.New("skill revision not found")
	// ErrSkillAssignmentNotFound indicates the requested skill assignment was not found.
	ErrSkillAssignmentNotFound = errors.New("skill assignment not found")
	// ErrSkillProposalNotFound indicates the requested skill proposal was not found.
	ErrSkillProposalNotFound = errors.New("skill proposal not found")
	// ErrForbidden indicates the caller cannot inspect or mutate the requested skill state.
	ErrForbidden = errors.New("skill access forbidden")
	// ErrInvalidInput indicates malformed request input.
	ErrInvalidInput = errors.New("invalid skill request")
	// ErrInvalidState indicates a requested transition is not valid for current state.
	ErrInvalidState = errors.New("invalid skill state")
	// ErrApprovalDigestMismatch indicates a caller-provided approval digest did not match Lesser's digest.
	ErrApprovalDigestMismatch = errors.New("approval digest mismatch")
	// ErrExposureViolation indicates the requested exposure exceeds the canonical revision exposure.
	ErrExposureViolation = errors.New("skill exposure violation")
	// ErrPromotionDigestMismatch indicates promotion source/output digest validation failed.
	ErrPromotionDigestMismatch = errors.New("skill promotion digest mismatch")
	// ErrPromotionConflict indicates a proposal was already promoted into a conflicting canonical revision.
	ErrPromotionConflict = errors.New("skill promotion conflict")
)

Functions

func CanInspectRevision

func CanInspectRevision(viewer Viewer, revision *models.SkillRevision) bool

CanInspectRevision reports whether a viewer can inspect a skill revision record.

func CanInspectSkill

func CanInspectSkill(viewer Viewer, skill *models.Skill) bool

CanInspectSkill reports whether a viewer can inspect a skill record.

func CanResolveSubject

func CanResolveSubject(viewer Viewer, subjectType, subjectID string) bool

CanResolveSubject reports whether the viewer can resolve a subject's effective skills.

func ExposureWithin

func ExposureWithin(requested, allowed string) bool

ExposureWithin reports whether requested exposure is no broader than allowed exposure.

Types

type ApprovalCommand

type ApprovalCommand struct {
	ActorUsername         string
	ApprovalID            string
	PrincipalID           string
	PrincipalApprovalID   string
	ApprovalAuthorityType string
	ApprovalAuthorityID   string
	ApprovalDigest        string
	ApprovalSignature     string
	ApprovalRef           string
	ApprovalReason        string
	ApprovedAt            time.Time
}

ApprovalCommand approves a canonical skill revision.

type AssignmentCommand

type AssignmentCommand struct {
	ActorUsername       string
	AssignmentID        string
	SkillID             string
	RevisionNumber      int
	SubjectType         string
	SubjectID           string
	Exposure            string
	ApprovalID          string
	PrincipalID         string
	PrincipalApprovalID string
	AssignedAt          time.Time
}

AssignmentCommand creates an effective-resolution assignment.

type AssignmentRevocationCommand

type AssignmentRevocationCommand struct {
	SkillID      string
	AssignmentID string
	SubjectType  string
	SubjectID    string
	RevocationCommand
}

AssignmentRevocationCommand revokes an assignment at its subject boundary.

type CatalogEntry

type CatalogEntry struct {
	Skill    *models.Skill
	Revision *models.SkillRevision
	Bundle   SkillBundle
}

CatalogEntry binds an approved canonical revision to its publication bundle.

type CatalogFilter

type CatalogFilter struct {
	Exposure string
	Limit    int
	Cursor   string
}

CatalogFilter constrains approved skill catalog listing.

type EffectiveSkill

type EffectiveSkill struct {
	Skill      *models.Skill
	Revision   *models.SkillRevision
	Assignment *models.SkillAssignment
}

EffectiveSkill is one resolved canonical skill revision and assignment.

type ListFilter

type ListFilter struct {
	Status   string
	Exposure string
	Limit    int
	Cursor   string
}

ListFilter constrains skill listing.

type PromotionCommand

type PromotionCommand struct {
	ActorUsername          string
	ProposalID             string
	ExpectedManifestDigest string
	ExpectedSourceDigest   string
	ApprovalID             string
	PrincipalID            string
	PrincipalApprovalID    string
	ApprovalAuthorityType  string
	ApprovalAuthorityID    string
	ApprovalDigest         string
	ApprovalSignature      string
	ApprovalRef            string
	ApprovalReason         string
	ApprovedAt             time.Time
}

PromotionCommand promotes accepted proposal/conversation output into a canonical revision.

type PromotionResult

type PromotionResult struct {
	Revision *models.SkillRevision
	Proposal *models.SkillProposal
	Created  bool
}

PromotionResult describes the canonical revision produced by a proposal promotion.

type ResolveCommand

type ResolveCommand struct {
	SubjectType string
	SubjectID   string
	Limit       int
	Cursor      string
}

ResolveCommand resolves active assignments for a subject.

type ResolveResult

type ResolveResult struct {
	SubjectType string
	SubjectID   string
	Items       []EffectiveSkill
	NextCursor  string
}

ResolveResult contains effective skills for a subject boundary.

type RevocationCommand

type RevocationCommand struct {
	ActorUsername string
	Reason        string
	RevokedAt     time.Time
}

RevocationCommand revokes a canonical skill revision or assignment.

type Service

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

Service owns canonical skill approval, assignment, and resolution semantics.

func NewService

func NewService(repo interfaces.SkillRepository) *Service

NewService constructs a canonical skill service.

func (*Service) ApproveRevision

func (s *Service) ApproveRevision(ctx context.Context, skillID string, revisionNumber int, cmd ApprovalCommand) (*models.SkillRevision, error)

ApproveRevision approves a canonical revision and updates the skill current pointer.

func (*Service) AssignSkill

func (s *Service) AssignSkill(ctx context.Context, cmd AssignmentCommand) (*models.SkillAssignment, error)

AssignSkill assigns an approved revision to a subject for effective resolution.

func (*Service) GetBundle

func (s *Service) GetBundle(ctx context.Context, viewer Viewer, skillID string, revisionNumber int, includeContent bool) (*CatalogEntry, error)

GetBundle returns the publication bundle for one approved canonical skill revision.

func (*Service) GetProposal

func (s *Service) GetProposal(ctx context.Context, proposalID string) (*models.SkillProposal, error)

GetProposal returns one proposal for admin inspection.

func (*Service) GetRevision

func (s *Service) GetRevision(ctx context.Context, viewer Viewer, skillID string, revisionNumber int) (*models.SkillRevision, error)

GetRevision returns one revision when both the skill and revision are visible to the viewer.

func (*Service) GetSkill

func (s *Service) GetSkill(ctx context.Context, viewer Viewer, skillID string) (*models.Skill, error)

GetSkill returns a skill when the viewer may inspect it.

func (*Service) ListAssignmentsForSkill

func (s *Service) ListAssignmentsForSkill(ctx context.Context, skillID string, limit int, cursor string) ([]*models.SkillAssignment, string, error)

ListAssignmentsForSkill returns assignment records for admin inspection.

func (*Service) ListCatalog

func (s *Service) ListCatalog(ctx context.Context, viewer Viewer, filter CatalogFilter) ([]CatalogEntry, string, error)

ListCatalog returns approved canonical skill revisions as publishable catalog entries.

func (*Service) ListProposals

func (s *Service) ListProposals(ctx context.Context, skillID string, status string, limit int, cursor string) ([]*models.SkillProposal, string, error)

ListProposals returns proposal records for admin inspection.

func (*Service) ListRevisions

func (s *Service) ListRevisions(ctx context.Context, viewer Viewer, skillID string, limit int, cursor string) ([]*models.SkillRevision, string, error)

ListRevisions returns revision records visible to the viewer.

func (*Service) ListSkills

func (s *Service) ListSkills(ctx context.Context, viewer Viewer, filter ListFilter) ([]*models.Skill, string, error)

ListSkills returns inspectable skills for the viewer.

func (*Service) PromoteProposal

func (s *Service) PromoteProposal(ctx context.Context, skillID string, cmd PromotionCommand) (*PromotionResult, error)

PromoteProposal promotes accepted proposal output into an approved canonical revision.

func (*Service) ResolveEffectiveSkills

func (s *Service) ResolveEffectiveSkills(ctx context.Context, viewer Viewer, cmd ResolveCommand) (*ResolveResult, error)

ResolveEffectiveSkills returns active approved skill revisions for a subject.

func (*Service) RevokeAssignment

RevokeAssignment revokes an existing subject assignment.

func (*Service) RevokeRevision

func (s *Service) RevokeRevision(ctx context.Context, skillID string, revisionNumber int, cmd RevocationCommand) (*models.SkillRevision, error)

RevokeRevision revokes a canonical revision and clears the skill pointer when needed.

func (*Service) WithNow

func (s *Service) WithNow(now func() time.Time) *Service

WithNow overrides the clock for tests.

type SkillBundle

type SkillBundle struct {
	SchemaVersion     string
	BundleID          string
	BundleDigest      string
	PublicationDigest string
	ManifestDigest    string
	ContentDigest     string
	ApprovalDigest    string
	Files             []SkillBundleFile
	InstallHints      SkillInstallHints
	Provenance        []models.SkillProvenanceRef
}

SkillBundle is the approved revision publication contract consumed by downstream clients.

type SkillBundleFile

type SkillBundleFile struct {
	Path            string
	Digest          string
	ContentType     string
	Role            string
	SizeBytes       int64
	InstallPath     string
	Content         string
	Encoding        string
	ContentIncluded bool
}

SkillBundleFile is one file record in a published skill bundle.

type SkillInstallHints

type SkillInstallHints struct {
	Layout         string
	RuntimeTargets []string
	DirectoryName  string
	EntryPoint     string
	RequiredFiles  []string
}

SkillInstallHints are advisory, client-consumed placement hints. Lesser never writes a client workspace.

type Viewer

type Viewer struct {
	Username      string
	Authenticated bool
	Admin         bool
}

Viewer identifies the caller for exposure and self-resolution checks.

Jump to

Keyboard shortcuts

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