Documentation
¶
Overview ¶
Package migrate contains utilities that convert existing markdown-backed memory content into the PostgreSQL wiki/graph schema (memory_nodes + memory_edges). The conversion logic is backend-agnostic: it produces plain NodeSpec/EdgeSpec values so it can be exercised by unit tests without a live database, and persisted by any concrete store implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DerivedEdgeRels = []EdgeRel{EdgeSameProfile, EdgeSameTopic, EdgeSameDay, EdgeRefs}
DerivedEdgeRels is the canonical set of edges rebuilt from node state.
var ImplicitEdgeRels = []EdgeRel{EdgeSameProfile, EdgeSameTopic, EdgeSameDay}
ImplicitEdgeRels is the canonical set of edges derived automatically from node attributes (as opposed to explicit refs/supersedes/... authored later).
Functions ¶
func ParseMemoryLinks ¶
ParseMemoryLinks extracts referenced slugs from a memory body. It supports [[slug]] and markdown links. HTTP(S) links are ignored.
func Plan ¶
func Plan(botID string, items []storefs.MemoryItem) ([]NodeSpec, []EdgeSpec)
Plan converts a bot's markdown memory items into wiki node specs plus the derived edges from shared profile_ref/topic/captured day and explicit wiki cross-references in node bodies. It performs no I/O and is safe to call in dry-run mode.
Layer classification is intentionally conservative: items without any hint fall back to LayerNote. This keeps the backfill deterministic and reversible until the typed-facts formation (P1) starts emitting explicit layers.
Types ¶
type EdgeRel ¶
type EdgeRel string
EdgeRel is the canonical relationship type between two memory nodes.
type EdgeSpec ¶
type EdgeSpec struct {
BotID string
SrcNode string
DstNode string
Rel EdgeRel
Weight float32
Metadata map[string]any
}
EdgeSpec is a backend-agnostic description of a memory_edges row.
func PlanFromNodes ¶
PlanFromNodes derives graph edges from an existing set of nodes (e.g. already persisted in the wiki store) without re-classifying them. It is the edge-derivation half of Plan, used by RebuildDerivedEdges.
type MemoryLayer ¶
type MemoryLayer string
MemoryLayer is the canonical layer a memory node belongs to. Existing flat markdown entries that carry no layer hint are classified as LayerNote.
const ( LayerPreference MemoryLayer = "preference" LayerIdentity MemoryLayer = "identity" LayerContext MemoryLayer = "context" LayerExperience MemoryLayer = "experience" LayerActivity MemoryLayer = "activity" LayerPersona MemoryLayer = "persona" LayerNote MemoryLayer = "note" )
type NodeSpec ¶
type NodeSpec struct {
ID string
BotID string
Body string
Hash string
Layer MemoryLayer
FactType string
Subject string
Confidence float32
Metadata map[string]any
SourceMessageIDs []string
ProfileRef string
Topic string
CapturedAt time.Time
ExpiresAt time.Time // zero value means "no expiry".
}
NodeSpec is a backend-agnostic description of a memory_nodes row, produced from a storefs.MemoryItem. Concrete store (PostgreSQL) translates this into their sqlc UpsertMemoryNodeParams.