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

cellsync

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cellsync holds the decisions a controller makes when it reconciles a MemoryCell into a memory store: whether the cell is deleted at its deadline, whether it is embedded, seeded or left out of the vector index, when to look at it again. They are functions of the cell, so the host's controller, which has its own config kinds and clients, calls them instead of carrying the logic. The package keeps no state and writes nothing.

Index

Constants

View Source
const KindLabel = "xray.triageagent.dev/kind"

KindLabel is the label every managed cell carries with its kind, so a cell of one kind can be listed without decoding the rest.

Variables

This section is empty.

Functions

func Forget

func Forget(store *memstore.Store, cells *index.CellStore, id, kind string)

Forget takes a cell that was deleted, by this host or by anyone else, out of every in-process index: the store's lexical indexes (the item is marked stale and leaves search) and the vector index. Either may be nil. kind is the cell's kind, for a host that publishes the deletion.

func ListByKind

func ListByKind(ctx context.Context, c client.Reader, namespace, kind, subject string) ([]memstore.Item, error)

ListByKind lists the cells of one kind in namespace as items. With a subject it returns only that instance's cells. It is the read path for kinds a host never seeds into the working set, which have no other way back into the process after a restart.

func MigratePrivateOwner

func MigratePrivateOwner(cell *memoryv1.MemoryCell, subject string) bool

MigratePrivateOwner moves a private cell written under the older rule, where Subject named the owner, to the current one: the owner becomes a user: tag and Subject the identity of this instance. It reports whether it changed the cell; the caller writes it back. A second call changes nothing, a public cell is not touched, and a private cell with no Subject has no owner to record.

func OwnedBy

func OwnedBy(cell *memoryv1.MemoryCell, subject string) bool

OwnedBy reports whether a cell belongs to the instance named subject.

func ShouldSeed

func ShouldSeed(cell *memoryv1.MemoryCell, o Options) bool

ShouldSeed is the per-cell gate of a startup bulk seed of the vector index. It is a separate path from the reconcile, so the same exclusions apply: foreign cells stay out of this instance's search, never-embed cells stay out of the index, and a private cell is never seeded, which closes the window in which a cell that has just flipped to private still carries an embedding the next reconcile has not yet cleared.

Types

type Decision

type Decision struct {
	// Delete: the deadline has passed, or the cell is stale or superseded (unless
	// KeepRetired), and this instance owns it and it is not a config cell. Delete the cell and call
	// Forget; nothing else applies.
	Delete bool
	// Requeue is when to look at the cell again: the time until its deadline, or
	// zero. It is set on every path that does not delete, so a deadline is never
	// missed because the cell took an early return.
	Requeue time.Duration
	// Index: embed the cell, or seed the vector index from the embedding it
	// carries (index.CellStore.SeedOrEmbed).
	Index bool
	// ClearEmbedding: a private cell holds an embedding or an indexed status.
	// Remove it from the vector index, clear Spec.Embedding and Status.Indexed,
	// so a flip back to public re-embeds fresh.
	ClearEmbedding bool
}

Decision is what to do with one cell.

func Decide

func Decide(cell *memoryv1.MemoryCell, now time.Time, o Options) Decision

Decide says what to do with cell at now.

type Options

type Options struct {
	// Subject is the identity of this instance. With one set, only cells whose
	// Spec.Subject matches are owned; cells of another instance sharing the
	// namespace are neither ingested nor deleted. With none set, every cell is
	// owned.
	Subject string
	// ConfigKind reports cells that configure the host rather than hold memory.
	// They are never embedded and never deleted at a deadline: a config cell that
	// only looks expired may be the host's only source of its configuration.
	ConfigKind func(cell *memoryv1.MemoryCell) bool
	// NeverEmbed reports cells that stay durable and listable without entering
	// the vector index (a label, a coordination record).
	NeverEmbed func(cell *memoryv1.MemoryCell) bool
	// KeepRetired keeps a cell whose status is stale or superseded instead of
	// deleting it: a host that treats retirement as an audit trail (a refuted cell
	// with the record of why) leaves the cell and drops it from the indexes
	// only. A cell past its deadline is deleted either way.
	KeepRetired bool
}

Options are the host's seams. Every field may be nil.

Jump to

Keyboard shortcuts

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