trajectory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package trajectory defines durable, replayable run events independently of transport delivery or user-interface activity.

Index

Constants

This section is empty.

Variables

View Source
var ErrCursorExpired = errors.New("trajectory cursor is older than retained history")

Functions

This section is empty.

Types

type Emitter

type Emitter struct {
	Store  Store
	Redact Redactor
}

func (Emitter) Emit

func (e Emitter) Emit(ctx context.Context, event Event) (Event, error)

type Event

type Event struct {
	ID          string                 `json:"id"`
	SessionID   string                 `json:"session_id"`
	RunID       string                 `json:"run_id"`
	NodeID      string                 `json:"node_id,omitempty"`
	Sequence    uint64                 `json:"sequence"`
	Type        string                 `json:"type"`
	At          time.Time              `json:"at"`
	Reliability Reliability            `json:"reliability"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

Event is one sanitized operational fact. Data must not contain prompts, credentials, or complete raw tool output.

type MemoryStore

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

MemoryStore is a concurrency-safe reference store.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func NewMemoryStoreWithRetention

func NewMemoryStoreWithRetention(maxEvents int) *MemoryStore

func (*MemoryStore) Ack

func (s *MemoryStore) Ack(ctx context.Context, sessionID, runID string, sequence uint64) (StreamState, error)

func (*MemoryStore) Append

func (s *MemoryStore) Append(_ context.Context, event Event) (Event, error)

func (*MemoryStore) Replay

func (s *MemoryStore) Replay(_ context.Context, sessionID, runID string, after uint64, limit int) ([]Event, error)

func (*MemoryStore) SetDegraded

func (s *MemoryStore) SetDegraded(ctx context.Context, sessionID, runID, reason string) error

func (*MemoryStore) State

func (s *MemoryStore) State(ctx context.Context, sessionID, runID string) (StreamState, error)

type Redactor

type Redactor func(Event) Event

Redactor sanitizes structured event data before persistence.

type Reliability

type Reliability string
const (
	ReliabilityDurable  Reliability = "durable"
	ReliabilityDegraded Reliability = "degraded"
)

type ReplayStore

type ReplayStore interface {
	Store
	Ack(context.Context, string, string, uint64) (StreamState, error)
	State(context.Context, string, string) (StreamState, error)
	SetDegraded(context.Context, string, string, string) error
}

ReplayStore adds acknowledgement, retention, and authoritative refresh metadata without coupling the durable event log to a transport.

type Store

type Store interface {
	Append(context.Context, Event) (Event, error)
	Replay(context.Context, string, string, uint64, int) ([]Event, error)
}

Store appends before delivery and replays strictly after a cursor.

type StreamState

type StreamState struct {
	EarliestSequence uint64      `json:"earliest_sequence"`
	HeadSequence     uint64      `json:"head_sequence"`
	AckedSequence    uint64      `json:"acked_sequence"`
	Reliability      Reliability `json:"reliability"`
	LastError        string      `json:"last_error,omitempty"`
}

Jump to

Keyboard shortcuts

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