artifacts

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeChecksum

func ComputeChecksum(path string) (string, error)

ComputeChecksum calculates the SHA256 checksum of a file.

func ExtractArchive

func ExtractArchive(archivePath, destDir string) ([]string, error)

ExtractArchive extracts an archive to a destination directory. Returns a list of extracted file paths.

func GenerateArtifactID

func GenerateArtifactID() string

GenerateArtifactID generates a unique artifact ID.

func GetArtifactsDir

func GetArtifactsDir() (string, error)

GetArtifactsDir returns the artifacts directory path.

func IsArchive

func IsArchive(contentType string) bool

IsArchive checks if the content type represents an archive format.

Types

type AnalysisResult

type AnalysisResult struct {
	ContentType string
	SizeBytes   int64
	Checksum    string
	Tags        []string
	Metadata    map[string]string
}

AnalysisResult contains the results of file analysis.

type Analyzer

type Analyzer struct{}

Analyzer analyzes files and extracts metadata.

func NewAnalyzer

func NewAnalyzer() *Analyzer

NewAnalyzer creates a new file analyzer.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(path string) (*AnalysisResult, error)

Analyze inspects a file and returns analysis results.

type Artifact

type Artifact struct {
	ID             string
	Name           string
	Path           string
	Source         SourceType
	SourceAgentID  string
	Purpose        string
	ContentType    string
	SizeBytes      int64
	Checksum       string
	CreatedAt      time.Time
	UpdatedAt      time.Time
	LastAccessedAt *time.Time
	AccessCount    int
	Tags           []string
	Metadata       map[string]string
	DeletedAt      *time.Time
}

Artifact represents a file artifact with metadata.

type ArtifactStore

type ArtifactStore interface {
	// Index adds or updates an artifact in the catalog.
	Index(ctx context.Context, artifact *Artifact) error

	// Get retrieves artifact metadata by ID.
	Get(ctx context.Context, id string) (*Artifact, error)

	// GetByName retrieves artifact by file name.
	GetByName(ctx context.Context, name string) (*Artifact, error)

	// List returns all artifacts matching filters.
	List(ctx context.Context, filter *Filter) ([]*Artifact, error)

	// Search performs FTS5 full-text search.
	Search(ctx context.Context, query string, limit int) ([]*Artifact, error)

	// Update updates artifact metadata.
	Update(ctx context.Context, artifact *Artifact) error

	// Delete soft-deletes or hard-deletes an artifact.
	Delete(ctx context.Context, id string, hard bool) error

	// RecordAccess updates last_accessed_at and access_count.
	RecordAccess(ctx context.Context, id string) error

	// GetStats returns storage statistics.
	GetStats(ctx context.Context) (*Stats, error)

	// Close closes the store.
	Close() error
}

ArtifactStore defines the interface for artifact storage operations.

type ArtifactUpdateCallback

type ArtifactUpdateCallback func(artifact *Artifact, eventType string)

ArtifactUpdateCallback is called when an artifact is created, modified, or deleted. Parameters: artifact metadata, event type (create/modify/delete).

type Filter

type Filter struct {
	Source         *SourceType
	ContentType    *string
	Tags           []string
	MinSize        *int64
	MaxSize        *int64
	AfterDate      *time.Time
	BeforeDate     *time.Time
	IncludeDeleted bool
	Limit          int
	Offset         int
}

Filter defines filtering options for listing artifacts.

type SQLiteStore

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

SQLiteStore implements ArtifactStore with SQLite backend.

func NewSQLiteStore

func NewSQLiteStore(dbPath string, tracer observability.Tracer) (*SQLiteStore, error)

NewSQLiteStore creates a new SQLite-backed artifact store. It reuses the existing loom.db database and creates the artifacts table if needed.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

Close closes the database connection.

func (*SQLiteStore) Delete

func (s *SQLiteStore) Delete(ctx context.Context, id string, hard bool) error

Delete soft-deletes or hard-deletes an artifact.

func (*SQLiteStore) Get

func (s *SQLiteStore) Get(ctx context.Context, id string) (*Artifact, error)

Get retrieves an artifact by ID.

func (*SQLiteStore) GetByName

func (s *SQLiteStore) GetByName(ctx context.Context, name string) (*Artifact, error)

GetByName retrieves an artifact by name.

func (*SQLiteStore) GetStats

func (s *SQLiteStore) GetStats(ctx context.Context) (*Stats, error)

GetStats returns artifact storage statistics.

func (*SQLiteStore) Index

func (s *SQLiteStore) Index(ctx context.Context, artifact *Artifact) error

Index adds or updates an artifact in the database.

func (*SQLiteStore) List

func (s *SQLiteStore) List(ctx context.Context, filter *Filter) ([]*Artifact, error)

List returns artifacts matching the filter.

func (*SQLiteStore) RecordAccess

func (s *SQLiteStore) RecordAccess(ctx context.Context, id string) error

RecordAccess updates the last accessed timestamp and access count.

func (*SQLiteStore) Search

func (s *SQLiteStore) Search(ctx context.Context, query string, limit int) ([]*Artifact, error)

Search performs FTS5 full-text search on artifacts.

func (*SQLiteStore) Update

func (s *SQLiteStore) Update(ctx context.Context, artifact *Artifact) error

Update updates artifact metadata.

type SourceType

type SourceType string

SourceType defines the source of an artifact.

const (
	SourceUser      SourceType = "user"
	SourceGenerated SourceType = "generated"
	SourceAgent     SourceType = "agent"
)

type Stats

type Stats struct {
	TotalFiles     int
	TotalSizeBytes int64
	UserFiles      int
	GeneratedFiles int
	DeletedFiles   int
}

Stats holds artifact storage statistics.

type Watcher

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

Watcher manages hot-reload for artifacts directory.

func NewWatcher

func NewWatcher(store ArtifactStore, config WatcherConfig) (*Watcher, error)

NewWatcher creates a new hot-reload watcher for the artifacts directory.

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context) error

Start begins watching for artifact file changes.

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops the watcher.

func (*Watcher) WithTracer

func (w *Watcher) WithTracer(tracer observability.Tracer) *Watcher

WithTracer sets the observability tracer for the watcher.

type WatcherConfig

type WatcherConfig struct {
	Enabled    bool                   // Enable hot-reload
	DebounceMs int                    // Debounce delay in milliseconds (default: 500ms)
	Logger     *zap.Logger            // Logger for events
	OnCreate   ArtifactUpdateCallback // Callback for new artifacts (optional)
	OnModify   ArtifactUpdateCallback // Callback for modified artifacts (optional)
	OnDelete   ArtifactUpdateCallback // Callback for deleted artifacts (optional)
}

WatcherConfig configures hot-reload behavior for artifact directory.

Jump to

Keyboard shortcuts

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