runboundary

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package runboundary tracks the provider-complete and durably branchable prefixes of one active model run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot struct {
	RunID           string
	TurnIndex       int
	Messages        []llm.Message
	DurableAnchorID int64
	Durable         bool
}

Snapshot is an immutable view of one run boundary. Durable is deliberately separate from DurableAnchorID: row ID zero is root branching, not an unavailable active-run boundary.

type Tracker

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

Tracker owns one run's live provider context and completed boundary.

func New

func New(runID string, messages []llm.Message, durableAnchorID int64, durable bool) *Tracker

New initializes a tracker. An initial durable row is published only when durable is true and durableAnchorID is positive.

func (*Tracker) Commit

func (t *Tracker) Commit(runID string, turnIndex int, messages []llm.Message) bool

Commit records one provider-completed turn. Duplicate and out-of-order callbacks are rejected so completed progress is monotonic within the run.

func (*Tracker) CompletedSnapshot

func (t *Tracker) CompletedSnapshot() Snapshot

CompletedSnapshot returns provider-complete context for side questions.

func (*Tracker) InvalidateDurable

func (t *Tracker) InvalidateDurable(runID string) bool

InvalidateDurable fails active branching closed after a persistence operation that may have replaced the published row identity.

func (*Tracker) LiveSnapshot

func (t *Tracker) LiveSnapshot() []llm.Message

LiveSnapshot returns context suitable for estimation, including a pending assistant when one exists.

func (*Tracker) PublishDurable

func (t *Tracker) PublishDurable(runID string, turnIndex int, anchorID int64) bool

PublishDurable associates a successfully persisted row with the matching completed turn. A partial or stale persistence completion cannot advance it.

func (*Tracker) Reset

func (t *Tracker) Reset(runID string, messages []llm.Message, durableAnchorID int64, durable bool)

Reset starts ownership of a new run and invalidates callbacks carrying the previous run identity.

func (*Tracker) RunID

func (t *Tracker) RunID() string

RunID returns the currently owned run identity.

func (*Tracker) SetInitialDurable

func (t *Tracker) SetInitialDurable(runID string, anchorID int64) bool

SetInitialDurable publishes the persisted input boundary before turn zero.

func (*Tracker) UpdateAssistant

func (t *Tracker) UpdateAssistant(runID string, assistant llm.Message) bool

UpdateAssistant replaces the pending assistant in live context. It never advances the completed or durable boundary.

Jump to

Keyboard shortcuts

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