engine

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagnosticCodeArtifactInvalid         = "workspace.artifact.invalid"
	DiagnosticCodeContextInvalidContent   = "workspace.context.invalid-content"
	DiagnosticCodeContextInvalidUTF8      = "workspace.context.invalid-utf8"
	DiagnosticCodeDefinitionInvalid       = "workspace.definition.invalid"
	DiagnosticCodeRecordSchemaUnsupported = "workspace.record.schema-unsupported"
	DiagnosticCodeRecordKindMismatch      = "workspace.record.kind-mismatch"
	DiagnosticCodeSkillInvalid            = "workspace.skill.invalid"
)
View Source
const (
	RootKind artifactstore.RootKind = "workspace.root"

	RolePrimary         artifactstore.AttachmentRole = "primary"
	RoleBuiltIn         artifactstore.AttachmentRole = "built-in"
	RoleLibrary         artifactstore.AttachmentRole = "library"
	RoleAttachedPackage artifactstore.AttachmentRole = "attached-package"
	RoleOverlay         artifactstore.AttachmentRole = "overlay"

	DefinitionKind      artifactstore.ArtifactKind = "workspace.definition"
	DefinitionSchemaID  artifactstore.SchemaID     = "workspace.definition.v1"
	DefinitionDecoderID artifactstore.DecoderID    = "workspace.definition-json"

	CapabilityProfileVersion = "1"
	PrimaryPriority          = 1_000_000

	WorkspaceMetadataDirectory = ".flexigpt"

	WorkspaceMetadataLocator artifactstore.Locator = WorkspaceMetadataDirectory
	RepositoryRootLocator    artifactstore.Locator = "."

	WorkspaceDefinitionFileName                       = "workspace.json"
	DefinitionLocator           artifactstore.Locator = WorkspaceMetadataDirectory + "/" + WorkspaceDefinitionFileName
)

Variables

View Source
var (
	ErrInvalidWorkspace           = errors.New("workspace: invalid")
	ErrNotWorkspace               = errors.New("workspace: root is not a Workspace")
	ErrPrimarySourceRequired      = errors.New("workspace: primary source is required")
	ErrPrimarySourceImmutable     = errors.New("workspace: primary source is immutable")
	ErrReferenceUnresolved        = errors.New("workspace: reference unresolved")
	ErrReferenceAmbiguous         = errors.New("workspace: reference ambiguous")
	ErrWorkspaceDefinitionInvalid = errors.New("workspace: definition invalid")
)

Functions

func DecodeDefinitionBody

func DecodeDefinitionBody[T any](
	raw json.RawMessage,
) (T, error)

DecodeDefinitionBody decodes the canonical body held by a definition.

Artifact adapters use this after QueryService has selected an already validated definition.

func WorkspaceArtifactDiagnostics

func WorkspaceArtifactDiagnostics(
	locator artifactstore.Locator,
	code string,
	message string,
) []artifactstore.Diagnostic

func WorkspaceArtifactErrorDiagnostics

func WorkspaceArtifactErrorDiagnostics(
	locator artifactstore.Locator,
	err error,
) []artifactstore.Diagnostic

Types

type ArtifactSupport

type ArtifactSupport struct {
	Kind      artifactstore.ArtifactKind
	SchemaID  artifactstore.SchemaID
	DecoderID artifactstore.DecoderID
}

func (ArtifactSupport) Validate

func (s ArtifactSupport) Validate() error

type AttachRequest

type AttachRequest struct {
	RootID               artifactstore.RootID         `json:"rootID"`
	ExpectedRootRevision uint64                       `json:"expectedRootRevision"`
	SourceID             artifactstore.SourceID       `json:"sourceID"`
	Role                 artifactstore.AttachmentRole `json:"role"`
	Priority             int                          `json:"priority"`
	Enabled              bool                         `json:"enabled"`
	Data                 AttachmentData               `json:"data"`
}

type AttachmentData

type AttachmentData struct {
	Recursive     *bool `json:"recursive,omitempty"`
	Authoritative *bool `json:"authoritative,omitempty"`
}

type CatalogView

type CatalogView struct {
	Workspace         Workspace            `json:"-"`
	Catalog           catalog.Snapshot     `json:"-"`
	Resources         []Resource           `json:"-"`
	Unrecorded        []catalog.Occurrence `json:"-"`
	UnresolvedRecords []record.Record      `json:"-"`
	Groups            []ResourceGroup      `json:"-"`
}

type DefinitionDecoder

type DefinitionDecoder struct{}

func NewDefinitionDecoder

func NewDefinitionDecoder() *DefinitionDecoder

func (*DefinitionDecoder) Decode

func (*DefinitionDecoder) ID

func (*DefinitionDecoder) Recognize

type DefinitionDocument

type DefinitionDocument struct {
	Discovery DiscoveryPreferences `json:"discovery"`
}

type DefinitionLoader

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

DefinitionLoader reads the primary workspace definition before discovery so its discovery preferences can be incorporated into the generated plan.

func NewDefinitionLoader

func NewDefinitionLoader(
	runtime source.Runtime,
) (*DefinitionLoader, error)

func (*DefinitionLoader) Load

type DefinitionObservation

type DefinitionObservation struct {
	Preferences DiscoveryPreferences
	SourceID    artifactstore.SourceID
	Generation  string
}

type DiscoveryPreferences

type DiscoveryPreferences struct {
	AdditionalLocators []artifactstore.Locator `json:"additionalLocators,omitempty"`
	AdditionalRoots    []DiscoveryRoot         `json:"additionalRoots,omitempty"`
	IncludeReadme      bool                    `json:"includeReadme,omitempty"`
}

type DiscoveryProfile

type DiscoveryProfile struct {
	ExplicitLocators []artifactstore.Locator
	ReadmeLocator    artifactstore.Locator
	DirectoryRoots   []discovery.DirectoryRoot
}

DiscoveryProfile defines discovery rules for one attachment class.

Artifact adapters contribute their own conventions through this type.

type DiscoveryProfiles

type DiscoveryProfiles struct {
	Primary  DiscoveryProfile
	Attached DiscoveryProfile
}

func DefaultDiscoveryProfiles

func DefaultDiscoveryProfiles() DiscoveryProfiles

type DiscoveryRoot

type DiscoveryRoot struct {
	Root            artifactstore.Locator `json:"root"`
	Recursive       bool                  `json:"recursive"`
	IncludePatterns []string              `json:"includePatterns,omitempty"`
}

type EmptyWorkspaceRequest

type EmptyWorkspaceRequest struct {
	DisplayName    string               `json:"displayName"`
	Description    string               `json:"description,omitempty"`
	TrustReference string               `json:"trustReference,omitempty"`
	Discovery      DiscoveryPreferences `json:"discovery"`
}

type FilesystemWorkspaceRequest

type FilesystemWorkspaceRequest struct {
	DisplayName     string                 `json:"displayName"`
	Description     string                 `json:"description,omitempty"`
	PrimarySourceID artifactstore.SourceID `json:"primarySourceID"`
	TrustReference  string                 `json:"trustReference,omitempty"`
	Discovery       DiscoveryPreferences   `json:"discovery"`
}

type LoadPlan

type LoadPlan struct {
	RootID          artifactstore.RootID       `json:"-"`
	CatalogRevision uint64                     `json:"-"`
	Items           []LoadPlanItem             `json:"-"`
	Diagnostics     []artifactstore.Diagnostic `json:"-"`
}

type LoadPlanItem

type LoadPlanItem struct {
	Record     record.Record         `json:"-"`
	Definition definition.Definition `json:"-"`
	Source     source.Summary        `json:"-"`
}

LoadPlanItem contains privileged materialized source state. It must be projected into an explicit adapter response before crossing an API boundary.

type Mode

type Mode string
const (
	ModeEmpty      Mode = "empty"
	ModeFilesystem Mode = "filesystem"
)

type Planner

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

func NewPlanner

func NewPlanner(
	profiles DiscoveryProfiles,
	decoderIDs ...artifactstore.DecoderID,
) (*Planner, error)

func (*Planner) Build

func (p *Planner) Build(
	value Workspace,
	definitionPreferences DiscoveryPreferences,
) (discovery.Plan, error)

type QueryService

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

func NewQueryService

func NewQueryService(
	workspaces *Service,
	catalogs catalogSnapshotReader,
	records recordLister,
	definitions definitionLookup,
) (*QueryService, error)

func (*QueryService) Catalog

func (q *QueryService) Catalog(
	ctx context.Context,
	rootID artifactstore.RootID,
) (CatalogView, error)

func (*QueryService) ComposeLoadPlan

func (q *QueryService) ComposeLoadPlan(
	ctx context.Context,
	rootID artifactstore.RootID,
	recordIDs []artifactstore.RecordID,
) (LoadPlan, error)

func (*QueryService) GetWorkspace

func (q *QueryService) GetWorkspace(
	ctx context.Context,
	rootID artifactstore.RootID,
) (Workspace, error)

func (*QueryService) Resolve

func (q *QueryService) Resolve(
	ctx context.Context,
	rootID artifactstore.RootID,
	reference Reference,
) (Resource, error)

type RecordPolicy

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

func NewRecordPolicy

func NewRecordPolicy(
	supports ...ArtifactSupport,
) (*RecordPolicy, error)

func (*RecordPolicy) Derive

type Reference

type Reference struct {
	RecordID *artifactstore.RecordID `json:"-"`
	Selector *definition.Selector    `json:"-"`
}

type Refresher

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

func NewRefresher

func NewRefresher(
	workspaces *Service,
	loader *DefinitionLoader,
	planner *Planner,
	runner refresh.Runner,
	policy *RecordPolicy,
) (*Refresher, error)

func (*Refresher) Refresh

func (r *Refresher) Refresh(
	ctx context.Context,
	rootID artifactstore.RootID,
) (refresh.Result, error)

type Resource

type Resource struct {
	Record         record.Record         `json:"-"`
	Definition     definition.Definition `json:"-"`
	Occurrence     *catalog.Occurrence   `json:"-"`
	Source         source.Summary        `json:"-"`
	CatalogCurrent bool                  `json:"-"`
}

type ResourceGroup

type ResourceGroup struct {
	Kind       artifactstore.ArtifactKind `json:"-"`
	Resources  []Resource                 `json:"-"`
	Unrecorded []catalog.Occurrence       `json:"-"`
}

type RootData

type RootData struct {
	Mode                     Mode                   `json:"mode"`
	PrimarySourceID          artifactstore.SourceID `json:"primarySourceID,omitempty"`
	TrustReference           string                 `json:"trustReference,omitempty"`
	Discovery                DiscoveryPreferences   `json:"discovery"`
	CapabilityProfileVersion string                 `json:"capabilityProfileVersion"`
}

type Service

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

func NewService

func NewService(
	roots workspaceRootStore,
	sources sourceSummaryLookup,
) (*Service, error)

func (*Service) Attach

func (s *Service) Attach(
	ctx context.Context,
	request AttachRequest,
) (Workspace, error)

func (*Service) CreateEmpty

func (s *Service) CreateEmpty(
	ctx context.Context,
	request EmptyWorkspaceRequest,
) (Workspace, error)

func (*Service) CreateFilesystem

func (s *Service) CreateFilesystem(
	ctx context.Context,
	request FilesystemWorkspaceRequest,
) (Workspace, error)

func (*Service) Delete

func (s *Service) Delete(
	ctx context.Context,
	rootID artifactstore.RootID,
	expectedRevision uint64,
) (root.Root, error)

func (*Service) Detach

func (s *Service) Detach(
	ctx context.Context,
	rootID artifactstore.RootID,
	sourceID artifactstore.SourceID,
	expectedRootRevision uint64,
	expectedAttachmentRevision uint64,
) (Workspace, error)

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	rootID artifactstore.RootID,
) (Workspace, error)

func (*Service) List

func (s *Service) List(
	ctx context.Context,
) ([]Workspace, error)

func (*Service) Update

func (s *Service) Update(
	ctx context.Context,
	request UpdateRequest,
) (Workspace, error)

func (*Service) UpdateAttachment

func (s *Service) UpdateAttachment(
	ctx context.Context,
	request UpdateAttachmentRequest,
) (Workspace, error)

type UpdateAttachmentRequest

type UpdateAttachmentRequest struct {
	RootID                     artifactstore.RootID
	SourceID                   artifactstore.SourceID
	ExpectedRootRevision       uint64
	ExpectedAttachmentRevision uint64
	Role                       artifactstore.AttachmentRole
	Priority                   int
	Enabled                    bool
	Data                       AttachmentData
}

type UpdateRequest

type UpdateRequest struct {
	RootID           artifactstore.RootID `json:"rootID"`
	ExpectedRevision uint64               `json:"expectedRevision"`
	DisplayName      string               `json:"displayName"`
	Description      string               `json:"description,omitempty"`
	Enabled          bool                 `json:"enabled"`
	TrustReference   string               `json:"trustReference,omitempty"`
	Discovery        DiscoveryPreferences `json:"discovery"`
}

type Workspace

type Workspace struct {
	Root        root.Root         `json:"-"`
	Data        RootData          `json:"-"`
	Attachments []root.Attachment `json:"-"`
	Sources     []source.Summary  `json:"-"`
}

Workspace is an internal privileged aggregate. API packages must project it into explicit view models instead of serializing source configuration, root data, or attachment data.

Jump to

Keyboard shortcuts

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