customstore

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package customstore demonstrates two application-owned llm.Store adapters: a durable single-file Store opened with Open, and an optional policy middleware opened with Own or Borrow. Neither imports Human internals.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSnapshotTooLarge means the next atomic image exceeds the configured
	// Store limit. The transaction has not reached the filesystem commit point.
	ErrSnapshotTooLarge = errors.New("custom Store: snapshot too large")
	// ErrStorePoisoned means an atomic rename may have committed but directory
	// durability could not be proved. The handle refuses every later operation;
	// release and reopen is the only reconciliation path.
	ErrStorePoisoned = errors.New("custom Store: handle poisoned by ambiguous commit")
)

Functions

func Borrow

func Borrow(
	ctx context.Context,
	next llm.Store,
	config Config,
) (framework.Resource[llm.Store], error)

Borrow decorates a host-owned Store. Releasing the returned Resource is a no-op; the host must keep next alive until every Human runtime using it has reached Done.

func Open

func Open(ctx context.Context, config Config) (framework.Resource[llm.Store], error)

Open creates an application-owned, durable llm.Store. The example uses a checksummed, versioned JSON snapshot and an fsync + atomic-rename commit. It is deliberately a small single-owner adapter rather than a production database driver: every Update rewrites the complete image, which keeps the transaction and crash boundary visible to embedders implementing their own Store. The parent directory must already exist and is a trusted private directory; this compact example does not defend against a process that can replace entries in that directory or ignore advisory locks. Supported Unix platforms hold a non-blocking advisory lock for the Resource lifetime; other platforms fail construction instead of silently running without cross-process fencing.

func Own

Own consumes next even when construction fails. Releasing the returned Resource releases the wrapped resource exactly once; the host must not also release next.

Types

type AuditFunc

type AuditFunc func(operation string)

AuditFunc receives only a fixed operation name: bind, view, or update. It must be concurrency-safe, bounded, and must not panic. Customer payloads and persistence identities are deliberately absent.

type Config

type Config struct {
	Path             string
	Provider         string
	Version          string
	Audit            AuditFunc
	MaxSnapshotBytes int64
}

Config identifies this application adapter. Path and MaxSnapshotBytes apply only to Open; Own and Borrow ignore both physical-storage fields.

Jump to

Keyboard shortcuts

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