Help us shape the future of Go! Take the 2026 Go Developer Survey

reconcile

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package reconcile implements a React-style reconciliation pipeline for incremental graph updates driven by IPC events from Ancora and other sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntityKey

func EntityKey(ev listener.Event) string

EntityKey returns a stable deduplication key for an observation event. For session events it returns the session ID; for unknown types, the raw type.

Types

type ChangeSet

type ChangeSet struct {
	Added   []types.ObservationNode
	Updated []types.ObservationNode
	Deleted []int64 // Ancora IDs of deleted observations
}

ChangeSet describes the minimal set of mutations needed to bring the graph up to date with a batch of incoming events.

func (*ChangeSet) IsEmpty

func (cs *ChangeSet) IsEmpty() bool

IsEmpty reports whether the ChangeSet contains no mutations.

type Differ

type Differ struct{}

Differ computes a ChangeSet from a batch of raw events. It is stateless — state tracking is the responsibility of the Reconciler / Patcher.

func NewDiffer

func NewDiffer() *Differ

NewDiffer creates a Differ.

func (*Differ) Diff

func (d *Differ) Diff(events []listener.Event) (ChangeSet, error)

Diff processes a batch of events and returns the ChangeSet to apply. Events for the same entity within the batch are collapsed: the last event for a given ID wins (which is guaranteed by Queue deduplication).

type Patcher

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

Patcher applies a ChangeSet to the in-memory graph using minimal mutations. It maintains indexes so it can quickly locate existing nodes and edges without scanning the full graph on every event.

func NewPatcher

func NewPatcher(g *igraph.Graph, llmQueueSize int) *Patcher

NewPatcher creates a Patcher that operates on the given graph. llmQueueSize controls the buffer depth of the LLM extraction queue.

func (*Patcher) Apply

func (p *Patcher) Apply(cs ChangeSet) error

Apply mutates the graph according to the ChangeSet. The graph is locked for the duration of the call so callers do not need external synchronization.

func (*Patcher) LLMQueue

func (p *Patcher) LLMQueue() <-chan types.ObservationNode

LLMQueue returns the channel of nodes waiting for LLM reference extraction. The caller should drain this channel with a worker pool.

type Queue

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

Queue buffers incoming events with deduplication and optional debouncing. Multiple events for the same observation ID within the debounce window are collapsed so the reconciler only processes the most-recent state.

func NewQueue

func NewQueue(debounce time.Duration, maxBatch int) *Queue

NewQueue creates a Queue with the given debounce window and max batch size.

func (*Queue) Drain

func (q *Queue) Drain() []listener.Event

Drain removes up to maxBatch events from the queue and returns them in insertion order. The caller is responsible for processing them.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the current number of unique pending events.

func (*Queue) Push

func (q *Queue) Push(ev listener.Event, entityKey string)

Push adds an event to the queue. If an event with the same deduplication key already exists, it is replaced with the newer event (last-write-wins).

func (*Queue) Ready

func (q *Queue) Ready() <-chan struct{}

Ready returns a channel that receives a value when events are available.

Jump to

Keyboard shortcuts

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