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.
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.
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.
Index ¶
- func ComputeChecksum(path string) (string, error)
- func ExtractArchive(archivePath, destDir string) ([]string, error)
- func GenerateArtifactID() string
- func GetArtifactsDir() (string, error)
- func IsArchive(contentType string) bool
- type AnalysisResult
- type Analyzer
- type Artifact
- type ArtifactStore
- type ArtifactUpdateCallback
- type Filter
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) Delete(ctx context.Context, id string, hard bool) error
- func (s *SQLiteStore) Get(ctx context.Context, id string) (*Artifact, error)
- func (s *SQLiteStore) GetByName(ctx context.Context, name string) (*Artifact, error)
- func (s *SQLiteStore) GetStats(ctx context.Context) (*Stats, error)
- func (s *SQLiteStore) Index(ctx context.Context, artifact *Artifact) error
- func (s *SQLiteStore) List(ctx context.Context, filter *Filter) ([]*Artifact, error)
- func (s *SQLiteStore) RecordAccess(ctx context.Context, id string) error
- func (s *SQLiteStore) Search(ctx context.Context, query string, limit int) ([]*Artifact, error)
- func (s *SQLiteStore) Update(ctx context.Context, artifact *Artifact) error
- type SourceType
- type Stats
- type Watcher
- type WatcherConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeChecksum ¶
ComputeChecksum calculates the SHA256 checksum of a file.
func ExtractArchive ¶
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 ¶
GetArtifactsDir returns the artifacts directory path.
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 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 ¶
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) 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) RecordAccess ¶
func (s *SQLiteStore) RecordAccess(ctx context.Context, id string) error
RecordAccess updates the last accessed timestamp and access count.
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) 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.