Documentation
¶
Overview ¶
Package contextengine provides stable-keyed, revisioned context assembly. Storage and user presentation are host responsibilities.
Index ¶
- func Digest(snapshot Snapshot) string
- type Class
- type Engine
- type Frame
- type Lifecycle
- func (l Lifecycle) BeginTurn(ctx context.Context, owner execution.Identity, id, workspaceID string) (Turn, error)
- func (l Lifecycle) Commit(ctx context.Context, turn Turn) (SnapshotRecord, error)
- func (l Lifecycle) Rebaseline(ctx context.Context, owner execution.Identity, id string, expected uint64) (SnapshotRecord, error)
- type MemorySnapshotStore
- func (s *MemorySnapshotStore) CompareAndSwap(ctx context.Context, owner execution.Identity, id string, expected uint64, ...) (SnapshotRecord, error)
- func (s *MemorySnapshotStore) Create(ctx context.Context, record SnapshotRecord) (SnapshotRecord, error)
- func (s *MemorySnapshotStore) Get(ctx context.Context, owner execution.Identity, id string) (SnapshotRecord, bool, error)
- type OutputManager
- type Registry
- type RetrievalQuery
- type RetrievalResult
- type RetrievalSource
- type Retriever
- type Snapshot
- type SnapshotRecord
- type SnapshotStore
- type Source
- type SourceState
- type SpillStore
- type Trust
- type Turn
- type Update
- type UpdateKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
type Engine struct {
Registry *Registry
MaxFrameBytes int
Spill SpillStore
}
func (Engine) Reconcile ¶
func (e Engine) Reconcile(ctx context.Context, previous Snapshot, workspaceID string) (Snapshot, []Update, error)
Reconcile produces one deterministic chronological update batch. Prior admitted state is retained when an existing source is temporarily unavailable; a missing initial source fails explicitly.
type Frame ¶
type Frame struct {
SourceKey string `json:"source_key"`
Revision string `json:"revision"`
Class Class `json:"class"`
Trust Trust `json:"trust"`
Content string `json:"content"`
SpillRef string `json:"spill_ref,omitempty"`
}
Frame is one model-visible context contribution.
type Lifecycle ¶
type Lifecycle struct {
Engine Engine
Store SnapshotStore
}
type MemorySnapshotStore ¶
type MemorySnapshotStore struct {
// contains filtered or unexported fields
}
func NewMemorySnapshotStore ¶
func NewMemorySnapshotStore() *MemorySnapshotStore
func (*MemorySnapshotStore) CompareAndSwap ¶
func (s *MemorySnapshotStore) CompareAndSwap(ctx context.Context, owner execution.Identity, id string, expected uint64, snapshot Snapshot) (SnapshotRecord, error)
func (*MemorySnapshotStore) Create ¶
func (s *MemorySnapshotStore) Create(ctx context.Context, record SnapshotRecord) (SnapshotRecord, error)
type OutputManager ¶
type OutputManager struct {
MaxBytes int
Spill SpillStore
}
OutputManager applies one bound and spill policy to all provider and tool output before it is admitted into context.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type RetrievalQuery ¶
type RetrievalQuery struct {
Text string `json:"text"`
Limit int `json:"limit"`
AccessScopes []string `json:"access_scopes"`
}
RetrievalQuery is host-authored search input. Access scopes are authority, not model-provided filters, and must be enforced again by the retriever.
type RetrievalResult ¶
type RetrievalResult struct {
DocumentID string `json:"document_id"`
ChunkID string `json:"chunk_id"`
Revision string `json:"revision"`
Provenance string `json:"provenance"`
Content string `json:"content"`
Score float64 `json:"score"`
FreshAt time.Time `json:"fresh_at"`
AccessScope string `json:"access_scope"`
Tombstoned bool `json:"tombstoned,omitempty"`
}
type RetrievalSource ¶
type RetrievalSource struct {
SourceKey string
Query RetrievalQuery
Retriever Retriever
}
RetrievalSource adapts a retriever into the ordinary context lifecycle so search results receive the same revision, spill, and reconciliation rules.
func (RetrievalSource) Key ¶
func (s RetrievalSource) Key() string
type Retriever ¶
type Retriever interface {
Revision(context.Context, RetrievalQuery) (string, error)
Search(context.Context, RetrievalQuery) ([]RetrievalResult, error)
}
Retriever supplies a stable revision and provenance-bearing results. The host owns indexing, deletion propagation, and authorization enforcement.
type Snapshot ¶
type Snapshot struct {
Epoch uint64 `json:"epoch"`
WorkspaceID string `json:"workspace_id,omitempty"`
Sources map[string]SourceState `json:"sources"`
}
Snapshot is the admitted context baseline for one epoch.
func Rebaseline ¶
Rebaseline begins a new epoch after compaction or another destructive projection change while preserving the current admitted sources.
type SnapshotRecord ¶
type SnapshotRecord struct {
ID string `json:"id"`
Identity execution.Identity `json:"identity"`
Snapshot Snapshot `json:"snapshot"`
Digest string `json:"digest"`
Revision uint64 `json:"revision"`
UpdatedAt time.Time `json:"updated_at"`
}
SnapshotRecord is the durable context head for one owner/session.
type SnapshotStore ¶
type Source ¶
type Source interface {
Key() string
Revision(context.Context) (string, error)
Resolve(context.Context) ([]Frame, error)
}
Source is a stable-keyed context contributor.
type SourceState ¶
type SpillStore ¶
SpillStore stores complete oversized frame content and returns an opaque managed reference.
type Turn ¶
type Turn struct {
Record SnapshotRecord
Next Snapshot
Updates []Update
}
Turn pins the exact context head observed before provider inference.
type Update ¶
type Update struct {
Kind UpdateKind `json:"kind"`
SourceKey string `json:"source_key"`
Revision string `json:"revision,omitempty"`
Error string `json:"error,omitempty"`
}
type UpdateKind ¶
type UpdateKind string
const ( UpdateAdded UpdateKind = "added" UpdateChanged UpdateKind = "changed" UpdateRemoved UpdateKind = "removed" )