source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package source defines the public Source model, adapters, catalog, and standard evidence sources.

Index

Constants

View Source
const (
	// MaxIDLength is the maximum Source identifier length in Unicode code points.
	MaxIDLength = 256
	// MaxTypeLength is the maximum registered Source type length in Unicode code points.
	MaxTypeLength = 128
	// MaxBindingNameLength is the maximum persistent Source cursor binding name.
	MaxBindingNameLength = 128
)
View Source
const ContentType = "content"

Variables

This section is empty.

Functions

func Register

func Register[I any, S Value, V any](registry *Registry, adapter Adapter[I, S, V]) error

Register adds an exact typed adapter to a Registry.

func RegisterContent

func RegisterContent(registry *Registry) error

Types

type Adapter

type Adapter[I any, S Value, V any] interface {
	Name() string
	Resolve(context.Context, I) (S, error)
	Read(context.Context, S) (V, error)
}

Adapter resolves one exact input type and reads one exact Source type.

type AdapterNotFoundError

type AdapterNotFoundError struct {
	Route string
	Type  reflect.Type
}

AdapterNotFoundError reports that no adapter owns an exact Go type.

func (*AdapterNotFoundError) Error

func (e *AdapterNotFoundError) Error() string

type Catalog

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

Catalog is an immutable adapter registry over persisted Source reads.

func NewCatalog

func NewCatalog(backend CatalogBackend, registry Registry) (*Catalog, error)

NewCatalog freezes a Registry into a Catalog.

func (*Catalog) Get

func (c *Catalog) Get(ctx context.Context, value Value) (Value, error)

func (*Catalog) List

func (c *Catalog) List(ctx context.Context) ([]Value, error)

func (*Catalog) Read

func (c *Catalog) Read(ctx context.Context, value Value) (any, error)

func (*Catalog) Ref

func (c *Catalog) Ref(value Value) (Ref, error)

func (*Catalog) Resolve

func (c *Catalog) Resolve(ctx context.Context, input any) (Value, error)

type CatalogBackend

type CatalogBackend interface {
	Get(context.Context, Value) (Value, error)
	List(context.Context) ([]Value, error)
}

CatalogBackend provides persisted Source reads.

type ConflictError

type ConflictError struct {
	Field string
	Value any
}

ConflictError reports ambiguous immutable catalog routing.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type ContentAdapter

type ContentAdapter struct{}

func (ContentAdapter) Name

func (ContentAdapter) Name() string

func (ContentAdapter) Read

func (ContentAdapter) Resolve

type ContentCapture

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

ContentCapture is text supplied by an integration with a caller-stable identity. Metadata is copied recursively at construction and access.

func NewContentCapture

func NewContentCapture(sourceID, content string, metadata map[string]any) (ContentCapture, error)

func (ContentCapture) Content

func (c ContentCapture) Content() string

func (ContentCapture) ID

func (c ContentCapture) ID() string

func (ContentCapture) Metadata

func (c ContentCapture) Metadata() map[string]any

type ContentSource

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

ContentSource is captured neutral text usable as Artifact evidence.

func RestoreContentSource

func RestoreContentSource(
	name string,
	materialization Materialization,
	description *string,
	content string,
	metadata map[string]any,
) (ContentSource, error)

RestoreContentSource reconstructs a persisted Content Source. Unlike ContentCapture, persisted content is allowed to be empty because that is a valid ContentSource payload in the Python v0.0.1 storage schema.

func (ContentSource) Content

func (s ContentSource) Content() string

func (ContentSource) Metadata

func (s ContentSource) Metadata() map[string]any

func (ContentSource) SourceDescription

func (s ContentSource) SourceDescription() (string, bool)

func (ContentSource) SourceMaterialization

func (s ContentSource) SourceMaterialization() Materialization

func (ContentSource) SourceName

func (s ContentSource) SourceName() string

type Cursor

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

Cursor is the last Source journal sequence consumed by one binding. It is a value type because trigger transitions are pure.

func NewCursor

func NewCursor(sequence int64) Cursor

func (Cursor) Sequence

func (c Cursor) Sequence() int64

type InvalidAdapterError

type InvalidAdapterError struct {
	Type   reflect.Type
	Field  string
	Detail string
}

InvalidAdapterError reports an invalid adapter declaration.

func (*InvalidAdapterError) Error

func (e *InvalidAdapterError) Error() string

type InvalidEntryError

type InvalidEntryError struct {
	Type reflect.Type
}

InvalidEntryError reports a value that does not satisfy the Source contract.

func (*InvalidEntryError) Error

func (e *InvalidEntryError) Error() string

type InvalidReferenceError

type InvalidReferenceError struct {
	Field  string
	Detail string
}

InvalidReferenceError reports an invalid Source identity.

func (*InvalidReferenceError) Error

func (e *InvalidReferenceError) Error() string

type InvalidResultError

type InvalidResultError struct {
	AdapterName string
	Operation   string
	Expected    reflect.Type
	Actual      reflect.Type
}

InvalidResultError reports an adapter that returned a value outside its declared exact Source type.

func (*InvalidResultError) Error

func (e *InvalidResultError) Error() string

type JournalEntry

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

JournalEntry is one resolved Source in stable per-scope insertion order. The Source value is immutable by contract; concrete built-ins copy mutable fields at their access boundaries.

func NewJournalEntry

func NewJournalEntry(ref Ref, value Value, position int64) (JournalEntry, error)

func (JournalEntry) Position

func (e JournalEntry) Position() int64

func (JournalEntry) Ref

func (e JournalEntry) Ref() Ref

func (JournalEntry) Value

func (e JournalEntry) Value() Value

type Materialization

type Materialization string

Materialization describes where a value read for a Source comes from.

const (
	Captured   Materialization = "captured"
	Referenced Materialization = "referenced"
)

type NotFoundError

type NotFoundError struct {
	Source Value
}

NotFoundError reports that an exact Source value is absent from a catalog.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Ref

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

Ref is a stable reference to one Source in a catalog view.

func NewRef

func NewRef(sourceType, sourceID string) (Ref, error)

NewRef validates and constructs a Source reference.

func (Ref) ID

func (r Ref) ID() string

func (Ref) MarshalText

func (r Ref) MarshalText() ([]byte, error)

func (Ref) String

func (r Ref) String() string

func (Ref) Type

func (r Ref) Type() string

type Registry

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

Registry is a mutable builder for immutable Catalog routing.

type Service

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

Service composes Source acquisition, persistence, and read operations.

func NewService

func NewService(catalog *Catalog, store Store) (*Service, error)

func (*Service) Add

func (s *Service) Add(ctx context.Context, value Value) (Value, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, value Value) (Value, error)

func (*Service) List

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

func (*Service) Read

func (s *Service) Read(ctx context.Context, value Value) (any, error)

func (*Service) Ref

func (s *Service) Ref(value Value) (Ref, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, input any) (Value, error)

type Store

type Store interface {
	Add(context.Context, Value) (Value, error)
}

Store persists resolved Sources for later catalog reads and lineage.

type Value

type Value interface {
	SourceName() string
	SourceMaterialization() Materialization
	SourceDescription() (string, bool)
}

Value is an immutable adapter-owned Source description. Implementations should use value receivers or otherwise prevent callers from changing the identity returned by SourceName.

Jump to

Keyboard shortcuts

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