Documentation
¶
Overview ¶
Package interleavedstate holds pure, serializable value types shared by routing, continuity, and runtime for interleaved thinking.
The package must stay free of runtime or memo-processing dependencies so it can be imported by any core package without introducing cycles. Only the standard library is used.
Package interleavedstate Interleaved-thinking state tracking for multi-turn reasoning.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalStateText ¶
MarshalStateText serializes state for compact durable storage. Empty state is encoded as an empty string so old rows and non-thinker routes stay cheap.
Types ¶
type CycleEntry ¶
CycleEntry is one position in a thinker-aware weighted cycle. Key identifies the branch within its selector; Role records whether it is the thinker branch.
type CycleState ¶
type CycleState struct {
SelectorKey string `json:"selector_key,omitempty"`
Sequence []CycleEntry `json:"sequence,omitempty"`
NextIndex int `json:"next_index"`
}
CycleState is the selector-scoped cursor for thinker-aware weighted cycles. An empty (zero-value) state means no cycle has been established yet.
func (CycleState) Equal ¶
func (c CycleState) Equal(other CycleState) bool
Equal reports whether two cycle states have identical selector, sequence, and cursor. It is invariant under nil-vs-empty sequence normalization.
func (CycleState) IsEmpty ¶
func (c CycleState) IsEmpty() bool
IsEmpty reports whether the cycle state has no established sequence.
func (CycleState) MarshalJSON ¶
func (c CycleState) MarshalJSON() ([]byte, error)
MarshalJSON serializes CycleState with nil sequence normalized to empty so round-trip equality holds for zero-value inputs.
func (CycleState) MatchesSelector ¶
func (c CycleState) MatchesSelector(selectorKey string) bool
MatchesSelector reports whether the stored cycle is fresh for the given selector key. An empty state is considered fresh for any selector (callers treat missing state as a new session for cycle purposes).
func (CycleState) Validate ¶
func (c CycleState) Validate() error
Validate checks that a non-empty cycle state has an in-bounds cursor. An empty state is valid.
type Role ¶
type Role string
Role labels a cycle entry or routing candidate as thinker, executor, or none.
const ( // RoleNone is the zero value for unannotated entries and candidates. RoleNone Role = "" // RoleThinker marks a weighted branch that produces a planning memo. RoleThinker Role = "thinker" // RoleExecutor marks a branch that consumes a memo and produces client output. RoleExecutor Role = "executor" )
type State ¶
type State struct {
Cycle CycleState `json:"cycle"`
}
State bundles the cycle cursor for one A-leg required by routing and continuity. Memo payload and reference semantics are owned by the interleavedthinking feature, not by core interleavedstate.
func UnmarshalStateText ¶
UnmarshalStateText decodes state produced by MarshalStateText. An empty string is the zero state for backward-compatible durable rows.