Documentation
¶
Overview ¶
Package turnbridge adapts the neutral internal turn-event model (internal/turnevent, #606) OUT to the v2 interactive wire payloads (#607): MapEvent shapes one turnevent.Event into a typed payload, and BuildTurnState shapes the turn_state payload the lifecycle machine drives. It is a pure value-to-value adapter — no I/O, no state, no envelope-ID minting, no clock read, no sealing. Every one of those belongs to the consumer (the turn-lifecycle integration slice); keeping them out is what makes this table-testable and isolates it from the lifecycle state machine. See cmd/pyry's interactiveTurnEmitterV2.emit for the consumer shape that wraps a payload into an Envelope.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTurnState ¶
func BuildTurnState(conversationID string, state TurnState) (typ string, payload protocol.TurnStatePayload)
BuildTurnState shapes a turn_state payload for the given conversation and target state. The consumer's lifecycle machine decides WHICH state applies (e.g. observing a ThoughtChunk means "thinking") and calls this; the adapter only shapes the payload. The return type is concrete (not any) because it is monomorphic — the consumer needs no type assertion.
func MapEvent ¶
MapEvent maps one neutral turnevent.Event plus explicit turn context to the matching v2 interactive wire payload and its envelope type discriminant.
ok is false for events with no wire representation: ThoughtChunk (ADR 025 — #607 defines no thought-text envelope; thinking surfaces as a turn_state transition the consumer drives via BuildTurnState, and the thought text is NOT forwarded) and any nil/unknown Event. The consumer drops + debug-logs those. Pure; safe on a zero-value Event.
payload is one of the protocol.*Payload value structs, or nil when ok is false. It is any because the payloads share no marker interface; the consumer json.Marshals it directly (same path as protocol.MessagePayload). The consumer owns the envelope ID, TS, marshal, and seal — none happen here.
Types ¶
type TurnContext ¶
type TurnContext struct {
ConversationID string
TurnID string
// Seq is the per-turn assistant-delta ordering counter. It is consumed
// ONLY by the TextChunk -> assistant_delta mapping and ignored for every
// other event kind; the consumer advances it.
Seq int
}
TurnContext is the per-event turn addressing the consumer supplies to MapEvent. The adapter never derives these — which conversation / turn / seq applies to a given event is a turn-lifecycle decision owned by the consumer.