artifactstore

package
v0.2.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionUpdate

type CollectionUpdate struct {
	ExpectedModifiedAt time.Time
	DisplayName        string
	Description        string
	Enabled            bool
	DataSchemaID       spec.SchemaID
	Data               json.RawMessage
}

CollectionUpdate replaces mutable local collection fields. CollectionID, RootID, Kind, Slug, timestamps, and soft-deletion state remain store-owned.

type DiagnosticValidationError

type DiagnosticValidationError struct {
	Scope       string
	Diagnostics []spec.Diagnostic
}

DiagnosticValidationError reports non-recoverable diagnostics emitted by a registered root, collection, or frontend validator.

func (*DiagnosticValidationError) Error

func (e *DiagnosticValidationError) Error() string

func (*DiagnosticValidationError) Unwrap

func (e *DiagnosticValidationError) Unwrap() error

type RootSourceAttachmentDraft

type RootSourceAttachmentDraft struct {
	RootID       spec.RootID
	SourceID     spec.SourceID
	Role         spec.AttachmentRole
	Priority     int
	Enabled      bool
	DataSchemaID spec.SchemaID
	Data         json.RawMessage
}

RootSourceAttachmentDraft contains local fields for a new root/source link.

type RootSourceAttachmentUpdate

type RootSourceAttachmentUpdate struct {
	ExpectedModifiedAt time.Time
	Role               spec.AttachmentRole
	Priority           int
	Enabled            bool
	DataSchemaID       spec.SchemaID
	Data               json.RawMessage
}

RootSourceAttachmentUpdate replaces mutable fields of an existing link.

type RootUpdate

type RootUpdate struct {
	ExpectedModifiedAt time.Time
	DisplayName        string
	Description        string
	Enabled            bool
	DataSchemaID       spec.SchemaID
	Data               json.RawMessage
}

RootUpdate is a full mutable replacement for an active root's local fields. RootID, Kind, CreatedAt, and soft-deletion state remain store-owned.

type SourceUpdate

type SourceUpdate struct {
	ExpectedModifiedAt time.Time
	DisplayName        string
	Enabled            bool
	ConfigSchemaID     spec.SchemaID
	Config             json.RawMessage
}

SourceUpdate replaces mutable local source-registration fields. SourceID, Kind, CreatedAt, and source observations remain store-owned.

type Store

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

Store owns Artifact Store business logic. It depends only on repository and driver facades; SQLite, MapStore, LLMTools, PostgreSQL, and other concrete data-access mechanisms remain outside service methods.

func NewStore

func NewStore(baseDir string, options ...StoreOption) (*Store, error)

NewStore composes the default SQLite app-metadata repository, MapStore portable-content repository, and required source drivers. Constructor options are applied before defaults so callers can replace any external adapter without changing business logic.

func NewStoreWithMetadataRepository

func NewStoreWithMetadataRepository(
	repository spec.ArtifactMetadataRepository,
	options ...StoreOption,
) (*Store, error)

NewStoreWithMetadataRepository constructs the business layer with injected facades. A PostgreSQL metadata repository and a custom driver registry can use this constructor without changing service logic.

func (*Store) AttachSource

AttachSource creates an app-local root/source attachment after root-hook validation. It does not access the attached source content.

func (*Store) BuildDependencyGraph

func (s *Store) BuildDependencyGraph(ctx context.Context, recordID spec.RecordID) (spec.DependencyGraph, error)

func (*Store) CaptureRecord

func (s *Store) CaptureRecord(
	ctx context.Context,
	request spec.CaptureRecordRequest,
) (spec.ArtifactRecord, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateCollection

func (s *Store) CreateCollection(ctx context.Context, draft spec.CollectionDraft) (spec.ArtifactCollection, error)

CreateCollection creates an app-local grouping of records.

func (*Store) CreateRecord

func (s *Store) CreateRecord(ctx context.Context, draft spec.ArtifactRecordDraft) (spec.ArtifactRecord, error)

func (*Store) CreateRoot

func (s *Store) CreateRoot(ctx context.Context, draft spec.RootDraft) (spec.ArtifactRoot, error)

CreateRoot creates app-local root metadata after generic and typed root validation. It does not create or modify any portable source file.

func (*Store) CreateSource

func (s *Store) CreateSource(ctx context.Context, draft spec.SourceDraft) (spec.ArtifactSource, error)

CreateSource creates only app-local source-registration metadata. A source kind must have a registered driver, but this method never accesses content.

func (*Store) DeleteCollection

func (s *Store) DeleteCollection(
	ctx context.Context,
	collectionID spec.CollectionID,
	expectedModifiedAt time.Time,
) (spec.ArtifactCollection, error)

DeleteCollection disables and soft-deletes an empty collection.

func (*Store) DeleteRecord

func (s *Store) DeleteRecord(
	ctx context.Context,
	recordID spec.RecordID,
	expectedModifiedAt time.Time,
) error

func (*Store) DeleteRoot

func (s *Store) DeleteRoot(
	ctx context.Context,
	rootID spec.RootID,
	expectedModifiedAt time.Time,
) (spec.ArtifactRoot, error)

DeleteRoot marks a root as disabled and soft-deleted. Associated local data remains intact and can be inspected through explicit including-deleted APIs.

func (*Store) DeleteSource

func (s *Store) DeleteSource(
	ctx context.Context,
	sourceID spec.SourceID,
	expectedModifiedAt time.Time,
) error

DeleteSource removes an app-local source registration only when repository relationships permit it. It does not mutate source content.

func (*Store) DetachRecord

func (s *Store) DetachRecord(
	ctx context.Context,
	recordID spec.RecordID,
	expectedModifiedAt time.Time,
) (spec.ArtifactRecord, error)

DetachRecord pins the existing occurrence in place. It is deliberately distinct from CaptureRecord and ForkRecord, which create new occurrences.

func (*Store) DetachSource

func (s *Store) DetachSource(
	ctx context.Context,
	rootID spec.RootID,
	sourceID spec.SourceID,
	expectedModifiedAt time.Time,
) error

DetachSource removes only the local root/source relationship. It does not delete source registration, source content, catalog history, or records.

func (*Store) EnsureBaseCollection

func (s *Store) EnsureBaseCollection(ctx context.Context, draft spec.CollectionDraft) (spec.ArtifactCollection, error)

EnsureBaseCollection returns an active collection with the requested root and slug, creating it when absent. It handles a concurrent creator by reloading the natural key after a uniqueness conflict.

func (*Store) ExplainDependencyResolution

func (s *Store) ExplainDependencyResolution(
	ctx context.Context,
	rootID spec.RootID,
	selector spec.ArtifactSelector,
) (spec.DependencyExplanation, error)

func (*Store) ExportRecord

func (s *Store) ExportRecord(ctx context.Context, recordID spec.RecordID) (spec.ExportedRecord, error)

func (*Store) FindCandidates

func (s *Store) FindCandidates(
	ctx context.Context,
	rootID spec.RootID,
	selector spec.ArtifactSelector,
) ([]spec.DependencyCandidate, error)

func (*Store) ForkRecord

func (s *Store) ForkRecord(
	ctx context.Context,
	request spec.ForkRecordRequest,
) (spec.ArtifactRecord, error)

func (*Store) GetArtifactPackage

func (s *Store) GetArtifactPackage(
	ctx context.Context,
	sourceID spec.SourceID,
	manifestLocator spec.SourceLocator,
) (spec.ArtifactPackage, error)

func (*Store) GetCatalogResource

func (s *Store) GetCatalogResource(
	ctx context.Context,
	key spec.CatalogResourceKey,
) (spec.CatalogResource, error)

GetCatalogResource returns a source-local catalog observation by its natural key. It does not access source content.

func (*Store) GetCollection

func (s *Store) GetCollection(ctx context.Context, collectionID spec.CollectionID) (spec.ArtifactCollection, error)

GetCollection returns one active collection.

func (*Store) GetCollectionIncludingDeleted

func (s *Store) GetCollectionIncludingDeleted(
	ctx context.Context,
	collectionID spec.CollectionID,
) (spec.ArtifactCollection, error)

GetCollectionIncludingDeleted returns a collection regardless of soft deletion.

func (*Store) GetDefinitionByDigest

func (s *Store) GetDefinitionByDigest(
	ctx context.Context,
	digest spec.Digest,
) (spec.CanonicalDefinition, error)

GetDefinitionByDigest resolves portable content through the injected MapStore-backed content repository. It never reads a filesystem directly.

func (*Store) GetDependencies

func (s *Store) GetDependencies(ctx context.Context, recordID spec.RecordID) ([]spec.ArtifactSelector, error)

func (*Store) GetRecord

func (s *Store) GetRecord(ctx context.Context, recordID spec.RecordID) (spec.ArtifactRecord, error)

func (*Store) GetRoot

func (s *Store) GetRoot(ctx context.Context, rootID spec.RootID) (spec.ArtifactRoot, error)

GetRoot returns an active root. Soft-deleted roots are intentionally hidden.

func (*Store) GetRootCatalogGeneration

func (s *Store) GetRootCatalogGeneration(
	ctx context.Context,
	rootID spec.RootID,
) (spec.RootCatalogGeneration, error)

GetRootCatalogGeneration returns the most recently published generation for one root.

func (*Store) GetRootIncludingDeleted

func (s *Store) GetRootIncludingDeleted(ctx context.Context, rootID spec.RootID) (spec.ArtifactRoot, error)

GetRootIncludingDeleted returns a root regardless of its soft-deletion state.

func (*Store) GetRootSourceAttachment

func (s *Store) GetRootSourceAttachment(
	ctx context.Context,
	rootID spec.RootID,
	sourceID spec.SourceID,
) (spec.RootSourceAttachment, error)

GetRootSourceAttachment returns one app-local attachment by its natural key.

func (*Store) GetSource

func (s *Store) GetSource(ctx context.Context, sourceID spec.SourceID) (spec.ArtifactSource, error)

GetSource returns one app-local source registration.

func (*Store) ImportDefinition

func (s *Store) ImportDefinition(
	ctx context.Context,
	request spec.ImportDefinitionRequest,
) (spec.ArtifactRecord, error)

func (*Store) ListArtifactPackagesForSource

func (s *Store) ListArtifactPackagesForSource(
	ctx context.Context,
	sourceID spec.SourceID,
) ([]spec.ArtifactPackage, error)

func (*Store) ListCatalogResourcesForRoot

func (s *Store) ListCatalogResourcesForRoot(
	ctx context.Context,
	rootID spec.RootID,
) ([]spec.CatalogResource, error)

ListCatalogResourcesForRoot lists resources from enabled source attachments belonging to one active root.

func (*Store) ListCatalogResourcesForSource

func (s *Store) ListCatalogResourcesForSource(
	ctx context.Context,
	sourceID spec.SourceID,
) ([]spec.CatalogResource, error)

ListCatalogResourcesForSource lists all current catalog observations for one app-local source registration.

func (*Store) ListCollections

func (s *Store) ListCollections(
	ctx context.Context,
	rootID spec.RootID,
	includeSoftDeleted bool,
) ([]spec.ArtifactCollection, error)

ListCollections lists collections belonging to one root.

func (*Store) ListDefinitionHistory

func (s *Store) ListDefinitionHistory(
	ctx context.Context,
	key spec.CatalogResourceKey,
) ([]spec.CatalogResourceRevision, error)

ListDefinitionHistory returns retained digest revisions for one source-local occurrence. Definition bodies are resolved separately through the portable content repository.

func (*Store) ListDependencySnapshots added in v0.2.9

func (s *Store) ListDependencySnapshots(
	ctx context.Context,
	recordID spec.RecordID,
) ([]spec.ArtifactDependencySnapshot, error)

ListDependencySnapshots returns retained dependency-resolution snapshots for an active record. Callers must inspect CatalogGeneration to determine which snapshot set they need.

func (*Store) ListRecords

func (s *Store) ListRecords(ctx context.Context, rootID spec.RootID) ([]spec.ArtifactRecord, error)

func (*Store) ListRootSources

func (s *Store) ListRootSources(ctx context.Context, rootID spec.RootID) ([]spec.RootSourceAttachment, error)

ListRootSources lists source attachments ordered by priority then source ID.

func (*Store) ListRoots

func (s *Store) ListRoots(ctx context.Context, includeSoftDeleted bool) ([]spec.ArtifactRoot, error)

ListRoots lists roots in descending modification order.

func (*Store) ListSources

func (s *Store) ListSources(ctx context.Context) ([]spec.ArtifactSource, error)

ListSources lists app-local source registrations by modification time.

func (*Store) ListTransferProvenance added in v0.2.9

func (s *Store) ListTransferProvenance(
	ctx context.Context,
	recordID spec.RecordID,
) ([]spec.TransferProvenance, error)

ListTransferProvenance returns app-local transfer audit entries for an active record. Portable definition bodies are not included.

func (*Store) MaterializeSource

func (s *Store) MaterializeSource(
	ctx context.Context,
	request spec.MaterializeSourceRequest,
) (spec.MaterializedSource, error)

MaterializeSource produces a stable real-directory projection for consumers that cannot operate on fs.FS, such as file-oriented runtime libraries.

func (*Store) PinRecord

func (s *Store) PinRecord(
	ctx context.Context,
	recordID spec.RecordID,
	digest spec.Digest,
	expectedModifiedAt time.Time,
) (spec.ArtifactRecord, error)

func (*Store) PublishArtifactPackage

func (s *Store) PublishArtifactPackage(ctx context.Context, artifactPackage spec.ArtifactPackage) error

PublishArtifactPackage persists app-local discovery metadata for a portable package manifest. The caller owns source parsing and never leaks local paths into the portable manifest itself.

func (*Store) RefreshRecord

func (s *Store) RefreshRecord(ctx context.Context, recordID spec.RecordID) (spec.ArtifactRecord, error)

func (*Store) RegisterArtifactFrontend

func (s *Store) RegisterArtifactFrontend(frontend spec.ArtifactFrontend) error

func (*Store) RegisterArtifactVersionMatcher

func (s *Store) RegisterArtifactVersionMatcher(matcher spec.ArtifactVersionMatcher) error

func (*Store) RegisterCollectionKindHook

func (s *Store) RegisterCollectionKindHook(hook spec.CollectionKindHook) error

func (*Store) RegisterDefinitionMaterializer

func (s *Store) RegisterDefinitionMaterializer(materializer spec.DefinitionMaterializer) error

func (*Store) RegisterDependencyResolver added in v0.2.9

func (s *Store) RegisterDependencyResolver(resolver spec.DependencyResolver) error

func (*Store) RegisterRootKindHook

func (s *Store) RegisterRootKindHook(hook spec.RootKindHook) error

func (*Store) RegisterSourceDriver

func (s *Store) RegisterSourceDriver(driver spec.SourceDriver) error

func (*Store) ScanRoot

func (s *Store) ScanRoot(ctx context.Context, rootID spec.RootID, plan spec.ScanPlan) (spec.ScanResult, error)

func (*Store) SyncRecords

func (s *Store) SyncRecords(
	ctx context.Context,
	rootID spec.RootID,
	policy spec.RecordSyncPolicy,
) (spec.RecordSyncResult, error)

SyncRecords synchronizes root-local records with the currently published root catalog. It never automatically deletes a record.

func (*Store) UpdateCollection

func (s *Store) UpdateCollection(
	ctx context.Context,
	collectionID spec.CollectionID,
	update CollectionUpdate,
) (spec.ArtifactCollection, error)

UpdateCollection replaces mutable local collection fields.

func (*Store) UpdateRecord

func (s *Store) UpdateRecord(
	ctx context.Context,
	recordID spec.RecordID,
	update spec.RecordUpdate,
) (spec.ArtifactRecord, error)

func (*Store) UpdateRoot

func (s *Store) UpdateRoot(ctx context.Context, rootID spec.RootID, update RootUpdate) (spec.ArtifactRoot, error)

UpdateRoot replaces mutable app-local root fields.

func (*Store) UpdateRootSourceAttachment

func (s *Store) UpdateRootSourceAttachment(
	ctx context.Context,
	rootID spec.RootID,
	sourceID spec.SourceID,
	update RootSourceAttachmentUpdate,
) (spec.RootSourceAttachment, error)

UpdateRootSourceAttachment replaces mutable attachment fields.

func (*Store) UpdateSource

func (s *Store) UpdateSource(
	ctx context.Context,
	sourceID spec.SourceID,
	update SourceUpdate,
) (spec.ArtifactSource, error)

UpdateSource replaces mutable local registration fields and clears prior observations because changing configuration invalidates them.

type StoreOption

type StoreOption func(*Store) error

func WithArtifactFrontend

func WithArtifactFrontend(frontend spec.ArtifactFrontend) StoreOption

func WithArtifactVersionMatcher

func WithArtifactVersionMatcher(matcher spec.ArtifactVersionMatcher) StoreOption

func WithCollectionKindHook

func WithCollectionKindHook(hook spec.CollectionKindHook) StoreOption

func WithDefinitionMaterializer

func WithDefinitionMaterializer(materializer spec.DefinitionMaterializer) StoreOption

func WithDependencyResolver added in v0.2.9

func WithDependencyResolver(resolver spec.DependencyResolver) StoreOption

func WithEmbeddedFSProvider

func WithEmbeddedFSProvider(providerKey string, provider fs.FS) StoreOption

WithEmbeddedFSProvider registers an application-owned read-only fs.FS under the provider key referenced by embedded-fs-directory source configuration.

func WithPortableContentRepository

func WithPortableContentRepository(repository spec.PortableContentRepository) StoreOption

func WithRootKindHook

func WithRootKindHook(hook spec.RootKindHook) StoreOption

func WithSourceDriver

func WithSourceDriver(driver spec.SourceDriver) StoreOption

func WithSourceMaterializer

func WithSourceMaterializer(materializer spec.SourceMaterializer) StoreOption

Directories

Path Synopsis
Package spec defines Artifact Store's portable and app-local data contracts.
Package spec defines Artifact Store's portable and app-local data contracts.

Jump to

Keyboard shortcuts

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