Documentation
¶
Index ¶
- Constants
- func Backup(srcPath, destPath string) error
- func Embed(text string) ([]float32, error)
- func EmbedTextForNode(label, description, whyMatters string) string
- func EmbeddingModel() string
- type AuditEntry
- type ConflictCandidate
- type ConnectionResult
- type DomainAlias
- type DriftCandidate
- type Edge
- type EdgeInput
- type EdgeSuggestion
- type KindCoverageResult
- type LifecycleState
- type MergeDomainsResult
- type MisdomainCandidate
- type Node
- type NodeInput
- type NodeResult
- type NodeUpdateInput
- type NodeWithEdges
- type PathResult
- type PurgeResult
- type RenameDomainResult
- type ScoredNode
- type SearchResult
- type SignificanceResult
- type Store
- func (s *Store) AddAlias(alias, domain string) error
- func (s *Store) AddEdge(fromID, toID, relationship, narrative string, verdict ...string) (*Edge, error)
- func (s *Store) AddEdgesBatch(inputs []EdgeInput) ([]*Edge, error)
- func (s *Store) AddNode(label, description, whyMatters, domain string, occurredAt *time.Time, ...) (*Node, error)
- func (s *Store) AddNodesBatch(inputs []NodeInput) ([]*Node, error)
- func (s *Store) ArchiveNode(id, reason string) error
- func (s *Store) ArchiveNodesBatch(items []struct{ ... }) error
- func (s *Store) AssessTrustForNodeIDs(nodeIDs []string, recencyWindowDays int, excludeInboundFrom ...string) (map[string]TrustAssessment, error)
- func (s *Store) BackfillEmbeddings(progress func(done, total int)) (int, error)
- func (s *Store) Close()
- func (s *Store) CountArchived(domain string) (int, error)
- func (s *Store) CountNodes(domain string) (int, error)
- func (s *Store) CountStaleDrift(domain string) (int, error)
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteEdge(id string) error
- func (s *Store) DomainExists(domain string) (bool, error)
- func (s *Store) EdgeCount() (int, error)
- func (s *Store) EmbeddingCoverage() (live, covered int, err error)
- func (s *Store) FindConflictCandidates(domain string, limit int, tags, nodeKinds []string) ([]ConflictCandidate, error)
- func (s *Store) FindConnections(fromTerm, toTerm, domain string) (*ConnectionResult, error)
- func (s *Store) FindConnectionsResolved(fromID, fromLabel, toID, toLabel, domain string) (*ConnectionResult, error)
- func (s *Store) FindDisconnected(domain string, tags, nodeKinds []string, limit int) ([]Node, error)
- func (s *Store) FindDrift(domain string, limit int, tags, nodeKinds []string, memoryID string, depth int) ([]DriftCandidate, error)
- func (s *Store) FindKindCoverage(domain string, limit int, tags, nodeKinds []string) (KindCoverageResult, error)
- func (s *Store) FindMisdomainCandidate(nodeID, requestedDomain string) (*MisdomainCandidate, error)
- func (s *Store) FindPath(fromID, toID string, maxDepth int) (*PathResult, error)
- func (s *Store) FindPossibleDuplicates(label, domain, excludeID string) ([]Node, error)
- func (s *Store) GetDomainGraph(domain string, limit int) (nodes []Node, edges []Edge, truncated bool, nodesTotal int, edgesTotal int, ...)
- func (s *Store) GetHistoryForMemoryID(nodeID string, depth int, importantOnly bool, tags, nodeKinds []string, ...) ([]Node, error)
- func (s *Store) GetNode(id string) (*NodeWithEdges, error)
- func (s *Store) GetNodeLabels(ids []string) map[string]string
- func (s *Store) GetNodeNeighbourhood(nodeID string) (nodes []Node, edges []Edge, err error)
- func (s *Store) GetSignificance(domain string, limit int, recencyWindowDays int, tags, nodeKinds []string, ...) (SignificanceResult, error)
- func (s *Store) GetSignificanceForMemoryID(nodeID string, depth int, recencyWindowDays int, nodeKinds []string) (SignificanceResult, error)
- func (s *Store) GetStandingNodes(domain string, limit int) ([]Node, bool, error)
- func (s *Store) GetTrust(domain string, limit, recencyWindowDays int, tags, nodeKinds []string) (TrustResult, error)
- func (s *Store) GetTrustForMemoryID(nodeID string, depth int, recencyWindowDays int, nodeKinds []string) (TrustResult, error)
- func (s *Store) LastAuditEntry() (entry AuditEntry, ok bool, err error)
- func (s *Store) LifecycleStates(nodeIDs []string) (map[string]LifecycleState, error)
- func (s *Store) ListAliases() ([]DomainAlias, error)
- func (s *Store) ListArchived(domain string, tags, nodeKinds []string, limit int) ([]Node, error)
- func (s *Store) ListDomains() ([]string, error)
- func (s *Store) LogDomainCreationFlagged(nodeID, nodeLabel, reason string) error
- func (s *Store) MergeDomains(sourceDomain, targetDomain string, dryRun bool) (*MergeDomainsResult, error)
- func (s *Store) NodeCounts() (live, archived int, err error)
- func (s *Store) Purge(domain string, before *time.Time, dryRun bool, includeLive bool) (PurgeResult, error)
- func (s *Store) RecentChanges(domain string, limit int, nodeKinds []string) ([]Node, error)
- func (s *Store) RecentChangesScoped(memoryID string, depth int, domain string, tags, nodeKinds []string, limit int) ([]Node, error)
- func (s *Store) RemoveAlias(alias string) error
- func (s *Store) RenameDomain(oldDomain, newDomain string) (*RenameDomainResult, error)
- func (s *Store) ResolveAlias(name string) string
- func (s *Store) RestoreNode(id string) error
- func (s *Store) SchemaVersion() (applied, expected int, err error)
- func (s *Store) SearchNodes(query, domain string, limit int, memoryID string, nodeKinds []string) (*SearchResult, error)
- func (s *Store) SearchNodesExact(query, domain string, limit int, memoryID string, nodeKinds []string) (*SearchResult, error)
- func (s *Store) SuggestEdges(id string, limit int) ([]EdgeSuggestion, error)
- func (s *Store) Timeline(domain string, importantOnly bool, tags, nodeKinds []string, ...) ([]Node, error)
- func (s *Store) UpdateNode(id string, label, description, whyMatters, tags *string, occurredAt *time.Time, ...) (*Node, error)
- func (s *Store) UpdateNodesBatch(inputs []NodeUpdateInput) ([]*Node, error)
- func (s *Store) VecAvailable() bool
- func (s *Store) VecVersion() string
- type TrustAssessment
- type TrustNode
- type TrustResult
Constants ¶
const CandidateSimilarityFloor = 0.5
CandidateSimilarityFloor is the maximum cosine distance for a node to be considered a meaningful filing-time candidate connection. vec_distance_cosine returns values in [0, 2]; 0 = identical, 2 = opposite. Candidates whose embedding distance exceeds this floor are suppressed — the server returns fewer than limit (even zero) rather than handing back noise. Chosen to be less strict than semanticDistanceThreshold (0.3) used in search, because suggest_connections tolerates a looser signal. Exported so that audit.go (conflicts mode) can reuse the same threshold.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶ added in v1.33.0
Backup writes a transactionally-consistent standalone snapshot of the database at srcPath to destPath using VACUUM INTO. The result is a single self-contained file with no -wal/-shm sidecars, safe to copy or sync even while the source DB is in use. It refuses to overwrite an existing destination.
func Embed ¶ added in v1.3.0
Embed is the exported form of embed, used by external tools such as the embeddings backfill command.
func EmbedTextForNode ¶ added in v1.45.0
EmbedTextForNode is the exported form of embedTextForNode, for use in tests.
func EmbeddingModel ¶ added in v1.45.0
func EmbeddingModel() string
EmbeddingModel is the exported form of embeddingModel, used by main.go subcommands.
Types ¶
type AuditEntry ¶ added in v1.4.1
AuditEntry is a single row from the audit_log table.
type ConflictCandidate ¶ added in v1.36.0
type ConflictCandidate struct {
AID string `json:"a_id"`
ALabel string `json:"a_label"`
BID string `json:"b_id"`
BLabel string `json:"b_label"`
SemanticDistance float64 `json:"semantic_distance"`
Reason string `json:"reason"`
}
ConflictCandidate is a pair of nodes that are semantically adjacent and may warrant agent review for potential contradiction. The server never asserts these conflict — only that their embedding distance is low enough to warrant attention.
type ConnectionResult ¶
type DomainAlias ¶
type DriftCandidate ¶
type DriftCandidate struct {
Node Node `json:"node"`
ConflictsWith *Node `json:"conflicts_with,omitempty"`
Reason string `json:"reason"`
EdgeCount int `json:"edge_count"` // total edges (from + to) incident to this node
}
DriftCandidate is a node flagged as potentially stale or conflicting.
type EdgeInput ¶
type EdgeInput struct {
FromNode string
ToNode string
Relationship string
Narrative string
Verdict string
}
EdgeInput is the input type for AddEdgesBatch.
type EdgeSuggestion ¶ added in v1.2.0
type EdgeSuggestion struct {
ID string `json:"id"`
Label string `json:"label"`
Reason string `json:"reason"`
Domain string `json:"domain"`
}
EdgeSuggestion is a candidate connection returned by SuggestEdges.
type KindCoverageResult ¶ added in v1.41.0
type KindCoverageResult struct {
TotalNodes int `json:"total_nodes"`
ByKind map[string]int `json:"by_kind"`
LegacyDominantPct float64 `json:"legacy_dominant_pct"`
MigrationCandidates []Node `json:"migration_candidates"`
ResultsTruncated bool `json:"results_truncated"`
}
KindCoverageResult is the store-layer result for audit(mode=kind_coverage). The audit tool maps MigrationCandidates to lean entries before responding.
type LifecycleState ¶ added in v1.42.0
type LifecycleState string
LifecycleState is a derived graph signal for lean/digest rendering — not stored.
const ( LifecycleContested LifecycleState = "contested" LifecycleResolved LifecycleState = "resolved" LifecycleSuperseded LifecycleState = "superseded" )
type MergeDomainsResult ¶ added in v1.7.0
type MergeDomainsResult struct {
NodesMoved int
SourceDomain string
TargetDomain string
LabelCollisions []string
}
MergeDomainsResult holds the output of MergeDomains.
type MisdomainCandidate ¶ added in v1.41.0
MisdomainCandidate is the top workspace KNN match suggesting a different domain for a newly-created domain's first memory.
type Node ¶
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
WhyMatters string `json:"why_matters"`
Tags string `json:"tags,omitempty"`
Domain string `json:"domain"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
OccurredAt *time.Time `json:"occurred_at,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"` // nil = live
NodeKind string `json:"node_kind,omitempty"`
}
type NodeInput ¶
type NodeInput struct {
Label string
Description string
WhyMatters string
Tags string
Domain string
OccurredAt *time.Time
NodeKind string
}
NodeInput is the input type for AddNodesBatch.
type NodeResult ¶ added in v1.3.0
NodeResult is a single search result. SemanticDistance is set when the result was matched by vector-distance search; it is nil for LIKE results.
type NodeUpdateInput ¶ added in v1.4.0
type NodeUpdateInput struct {
ID string
Label *string
Description *string
WhyMatters *string
Tags *string
OccurredAt *time.Time
NodeKind *string
Domain *string
Reason *string
}
NodeUpdateInput is a single entry in an UpdateNodesBatch call.
type NodeWithEdges ¶
type PathResult ¶ added in v1.4.1
PathResult holds the shortest path between two nodes and all edges incident to any node on that path (spine edges + context branches).
type PurgeResult ¶ added in v1.9.0
type PurgeResult struct {
Nodes []Node // nodes that were (or would be) purged
TotalEdges int // total edges deleted (0 in dry-run)
LiveRemaining int // live (non-archived) nodes still matching the domain filter, untouched
}
PurgeResult holds the outcome of a Purge call.
type RenameDomainResult ¶ added in v1.7.0
ListDomains returns all distinct domains that have at least one live node, sorted alphabetically. RenameDomainResult holds the output of RenameDomain.
type ScoredNode ¶ added in v1.14.0
ScoredNode is a Node decorated with a structural importance score.
type SearchResult ¶
type SearchResult struct {
Nodes []NodeResult `json:"nodes"`
Edges []Edge `json:"edges"`
Truncated bool `json:"truncated,omitempty"`
}
type SignificanceResult ¶ added in v1.14.0
type SignificanceResult struct {
Declared []Node `json:"declared"`
Structural []ScoredNode `json:"structural"`
Uncurated []ScoredNode `json:"uncurated"`
PotentiallyStale []Node `json:"potentially_stale"`
CallID string `json:"call_id"`
DeclaredResultsTruncated bool `json:"declared_results_truncated"`
StructuralResultsTruncated bool `json:"structural_results_truncated"`
UncuratedResultsTruncated bool `json:"uncurated_results_truncated"`
PotentiallyStaleResultsTruncated bool `json:"potentially_stale_results_truncated"`
}
SignificanceResult holds the four sections returned by GetSignificance.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddEdgesBatch ¶
AddEdgesBatch inserts all edges in a single transaction. If any edge references a non-existent or archived node the transaction is rolled back.
func (*Store) AddNodesBatch ¶
AddNodesBatch inserts all nodes in a single transaction. If any node fails validation or insertion the transaction is rolled back.
func (*Store) ArchiveNode ¶
ArchiveNode soft-deletes a node by setting archived_at and records an audit_log entry.
func (*Store) ArchiveNodesBatch ¶ added in v1.12.0
ArchiveNodesBatch archives multiple nodes in a single transaction. If any node ID does not exist, the whole transaction is rolled back and an error is returned — no nodes are archived on partial failure.
func (*Store) AssessTrustForNodeIDs ¶ added in v1.41.0
func (s *Store) AssessTrustForNodeIDs(nodeIDs []string, recencyWindowDays int, excludeInboundFrom ...string) (map[string]TrustAssessment, error)
AssessTrustForNodeIDs computes trust basis and the low-trust predicate for each node ID without normalising scores or writing significance_log rows. excludeInboundFrom omits inbound edges from those node IDs (typically the node being filed or revised, so its depends_on link does not mask low-trust deps).
func (*Store) BackfillEmbeddings ¶ added in v1.3.0
BackfillEmbeddings generates and stores embeddings for all live nodes that do not yet have one. Returns the count of embeddings successfully written. Requires Ollama to be running with the model named by embeddingModel() (default: snowflake-arctic-embed; override: MEMORYWEB_EMBED_MODEL env var). The model must output exactly 1024-dimensional vectors. progress is called after each successful embedding with (done, total); pass nil to disable progress reporting.
func (*Store) CountArchived ¶ added in v1.25.0
CountArchived returns the number of archived nodes in a domain.
func (*Store) CountNodes ¶ added in v1.18.0
CountNodes returns the number of live (non-archived) nodes in a domain.
func (*Store) CountStaleDrift ¶ added in v1.29.0
CountStaleDrift returns the number of live nodes that would be surfaced by audit(mode=stale) — i.e. the union of all FindDrift rules. Used to populate the stale_count field in the orient response.
func (*Store) DB ¶ added in v1.45.0
DB returns the underlying *sql.DB. Used only in tests that need raw SQL access to internal tables (config, node_embeddings) to set up or assert state.
func (*Store) DeleteEdge ¶ added in v1.4.0
func (*Store) DomainExists ¶ added in v1.41.0
func (*Store) EmbeddingCoverage ¶ added in v1.4.1
EmbeddingCoverage returns the count of live nodes and the count that have an embedding in node_embeddings. covered is always 0 if sqlite-vec is unavailable.
func (*Store) FindConflictCandidates ¶ added in v1.36.0
func (s *Store) FindConflictCandidates(domain string, limit int, tags, nodeKinds []string) ([]ConflictCandidate, error)
FindConflictCandidates returns pairs of live nodes whose embedding distance is below CandidateSimilarityFloor, excluding pairs that already have a contradicts edge between them. Same-domain pairs are preferred; cross-domain pairs are included only when their distance is below conflictsDomainThreshold. The result contains up to limit pairs. Empty slice (not nil) is returned when no embeddings exist.
func (*Store) FindConnections ¶
func (s *Store) FindConnections(fromTerm, toTerm, domain string) (*ConnectionResult, error)
func (*Store) FindConnectionsResolved ¶ added in v1.40.0
func (s *Store) FindConnectionsResolved(fromID, fromLabel, toID, toLabel, domain string) (*ConnectionResult, error)
FindConnectionsResolved returns direct edges between two nodes. Each side is resolved by id (exact live node) or label (bestMatch fuzzy search).
func (*Store) FindDisconnected ¶ added in v1.4.1
func (s *Store) FindDisconnected(domain string, tags, nodeKinds []string, limit int) ([]Node, error)
FindDisconnected returns live, non-transient nodes that have no edges (neither as from_node nor as to_node), optionally scoped to a domain. limit caps results (default 50 when limit <= 0); query fetches limit+1 rows.
func (*Store) FindDrift ¶
func (s *Store) FindDrift(domain string, limit int, tags, nodeKinds []string, memoryID string, depth int) ([]DriftCandidate, error)
FindDrift returns nodes that may be stale, contradicted, or superseded. Rules are applied in order; the first match per node wins:
- Contradiction: connected by a "contradicts" edge.
- Shadow domain: live node filed under a registered alias name (unreachable by domain-scoped reads) — runs early so limit truncation does not hide data-loss rows.
- Superseded label: contains "old", "deprecated", "replaced", "legacy", "previous".
- Stale open question: contains open-question keywords and is older than 30 days.
- Duplicate label: identical lowercased label in the same domain.
- Transient node older than 7 days.
- Standing node with fewer than 2 inbound edges and older than 30 days.
- Connected placeholder whose target appears resolved.
func (*Store) FindKindCoverage ¶ added in v1.41.0
func (s *Store) FindKindCoverage(domain string, limit int, tags, nodeKinds []string) (KindCoverageResult, error)
FindKindCoverage returns per-kind counts, legacy-dominance measure, and migration candidates for nodes whose node_kind looks stale relative to text.
func (*Store) FindMisdomainCandidate ¶ added in v1.41.0
func (s *Store) FindMisdomainCandidate(nodeID, requestedDomain string) (*MisdomainCandidate, error)
FindMisdomainCandidate runs workspace-wide KNN from nodeID's embedding with only the similarity floor applied (no domain-affinity reranking). Returns nil when no embedding exists, vec is unavailable, or no cross-domain match clears the floor.
func (*Store) FindPath ¶ added in v1.4.1
func (s *Store) FindPath(fromID, toID string, maxDepth int) (*PathResult, error)
FindPath returns the shortest path between fromID and toID using a BFS traversal of edges. Only live (non-archived) nodes are traversed; archived nodes act as walls. maxDepth caps the search at that many hops (hard limit: 6). Returns an empty PathResult (no error) when no path exists.
func (*Store) FindPossibleDuplicates ¶ added in v1.4.0
FindPossibleDuplicates returns live nodes in the same domain whose normalised label closely matches the given label (lowercased, punctuation stripped). The node with the given excludeID is excluded (used to avoid self-match).
func (*Store) GetDomainGraph ¶ added in v1.4.2
func (s *Store) GetDomainGraph(domain string, limit int) (nodes []Node, edges []Edge, truncated bool, nodesTotal int, edgesTotal int, err error)
GetDomainGraph returns the live nodes and the edges between them for a domain. Nodes are sorted by edge count descending so the most-connected appear first; the result is capped at limit (default 40, max 100). truncated is true when the full node set was larger than limit. nodesTotal is the full domain node count before any truncation; edgesTotal is the count of intra-domain edges across all nodes (not just the shown subset).
func (*Store) GetHistoryForMemoryID ¶ added in v1.22.0
func (s *Store) GetHistoryForMemoryID(nodeID string, depth int, importantOnly bool, tags, nodeKinds []string, from, to *time.Time, limit int) ([]Node, error)
GetHistoryForMemoryID returns the chronological timeline of a memory's neighbourhood (depth hops from nodeID, domain-clipped). Applies the same filters as Timeline: importantOnly, tags, from/to date range.
func (*Store) GetNodeLabels ¶ added in v1.45.0
GetNodeLabels returns a map of id → label for the given node IDs. Missing or archived nodes are omitted from the result.
func (*Store) GetNodeNeighbourhood ¶ added in v1.4.4
GetNodeNeighbourhood returns the target node, all live nodes directly connected to it (depth 1), and all edges between those nodes. Returns an error if the node does not exist or is archived.
func (*Store) GetSignificance ¶ added in v1.14.0
func (s *Store) GetSignificance(domain string, limit int, recencyWindowDays int, tags, nodeKinds []string, declaredLimit int) (SignificanceResult, error)
GetSignificance returns a dual-signal importance analysis for a domain.
- declared: live nodes with occurred_at set, ordered by occurred_at ASC.
- structural: live nodes ranked by weighted inbound degree (decay by linker age), capped at limit, ordered by importance_score DESC.
- uncurated: structural top-N nodes that have no occurred_at.
- potentially_stale: declared nodes whose ID does not appear in structural top-N.
When tags is non-empty, only nodes matching at least one tag (whole-word match) are included in each section. Callers that pass nil or []string{} get full domain behaviour.
Every call writes rows to significance_log (one per returned node in structural, uncurated, potentially_stale) so the decay function can be validated over time.
func (*Store) GetSignificanceForMemoryID ¶ added in v1.21.0
func (s *Store) GetSignificanceForMemoryID(nodeID string, depth int, recencyWindowDays int, nodeKinds []string) (SignificanceResult, error)
GetSignificanceForMemoryID returns dual-signal importance analysis scoped to the depth-hop neighbourhood of the given memory ID, clipped to the anchor's domain. Depth 2 is recommended; depth 1 produces near-uniform low scores.
func (*Store) GetStandingNodes ¶ added in v1.27.0
GetStandingNodes returns live nodes with node_kind = 'standing' for the given domain, ordered by inbound edge count descending. limit caps results (default 20 when limit <= 0). truncated is true when more standing nodes exist.
func (*Store) GetTrust ¶ added in v1.32.0
func (s *Store) GetTrust(domain string, limit, recencyWindowDays int, tags, nodeKinds []string) (TrustResult, error)
GetTrust returns nodes in domain ranked by computed epistemic trust — derived from each node's own node_kind plus the kinds of nodes that connect to it (parallel to how GetSignificance derives structural importance from inbound edge count). reference and transient nodes are excluded from the ranked output (they are not epistemic claims) but still count as neighbours, at zero weight. contradicts edges subtract; every other relationship adds, all discounted by the same recency decay GetSignificance uses. Scores are normalised to [0, 1] within the result set, ordered by trust_score DESC, capped at limit.
func (*Store) GetTrustForMemoryID ¶ added in v1.32.0
func (s *Store) GetTrustForMemoryID(nodeID string, depth int, recencyWindowDays int, nodeKinds []string) (TrustResult, error)
GetTrustForMemoryID returns trust analysis scoped to the depth-hop neighbourhood of the given memory ID, clipped to the anchor's domain.
func (*Store) LastAuditEntry ¶ added in v1.4.1
func (s *Store) LastAuditEntry() (entry AuditEntry, ok bool, err error)
LastAuditEntry returns the most recent audit log entry. ok is false if the audit log is empty.
func (*Store) LifecycleStates ¶ added in v1.42.0
func (s *Store) LifecycleStates(nodeIDs []string) (map[string]LifecycleState, error)
LifecycleStates returns derived lifecycle markers for live nodes. Missing keys mean no marker. Priority: contested > superseded > resolved.
func (*Store) ListAliases ¶
func (s *Store) ListAliases() ([]DomainAlias, error)
ListAliases returns all registered domain aliases.
func (*Store) ListArchived ¶
ListArchived returns archived nodes, optionally filtered by domain. limit caps results (default 25 when limit <= 0); query fetches limit+1 to detect truncation.
func (*Store) ListDomains ¶ added in v1.4.0
func (*Store) LogDomainCreationFlagged ¶ added in v1.41.0
LogDomainCreationFlagged records a domain_creation_flagged audit event when remember() creates a new domain that KNN suggests may be mis-assigned.
func (*Store) MergeDomains ¶ added in v1.7.0
func (s *Store) MergeDomains(sourceDomain, targetDomain string, dryRun bool) (*MergeDomainsResult, error)
MergeDomains moves all live nodes from sourceDomain into targetDomain, then inserts a domain alias from sourceDomain → targetDomain. Both the UPDATE and alias INSERT are performed in a single transaction.
When dryRun is true, no writes are performed; the result describes what would happen.
Returns an error if:
- sourceDomain has no live nodes (not found)
- targetDomain has no live nodes (caller should use RenameDomain instead)
func (*Store) NodeCounts ¶ added in v1.4.1
NodeCounts returns the count of live and archived nodes.
func (*Store) Purge ¶ added in v1.9.0
func (s *Store) Purge(domain string, before *time.Time, dryRun bool, includeLive bool) (PurgeResult, error)
Purge hard-deletes nodes from the database. By default only archived nodes are eligible — this is the only sanctioned hard-delete path and it never touches live data unless includeLive is explicitly set.
domain and before are optional filters. When dryRun is true the database is not modified and only the candidate list is returned. When includeLive is true, live (non-archived) nodes matching domain are hard-deleted too — this is a genuine, irreversible removal of live data and callers must gate it behind an explicit opt-in (the CLI requires --domain alongside --include-live to prevent an accidental whole-graph wipe).
When domain is set, LiveRemaining on the result reports how many live nodes match that domain and were left untouched (0 when includeLive is true, or when there is no domain filter). This exists so an operator who only archives-then-purges doesn't mistake "0 archived candidates" for "domain is empty" — the domain can still have live nodes.
func (*Store) RecentChanges ¶
RecentChanges orders by updated_at DESC, breaking ties on rowid DESC so two nodes written within the same clock tick (observed on Windows) still come back in insertion order instead of in SQLite's unspecified tie order.
func (*Store) RecentChangesScoped ¶ added in v1.28.0
func (s *Store) RecentChangesScoped(memoryID string, depth int, domain string, tags, nodeKinds []string, limit int) ([]Node, error)
RecentChangesScoped is a composable variant of RecentChanges that supports tag filtering and neighbourhood scoping via a memory_id.
When memoryID is non-empty the query is restricted to the depth-hop neighbourhood of that memory; domain is ignored in that case. When tags is non-nil and non-empty, only nodes whose tags column contains at least one of the supplied tags (whole-word OR match) are returned.
func (*Store) RemoveAlias ¶ added in v1.1.0
RemoveAlias deletes an alias. Returns an error if the alias does not exist.
func (*Store) RenameDomain ¶ added in v1.7.0
func (s *Store) RenameDomain(oldDomain, newDomain string) (*RenameDomainResult, error)
RenameDomain renames all live nodes in oldDomain to newDomain, then inserts a domain alias from oldDomain → newDomain so cached references continue to resolve. Both the UPDATE and alias INSERT are performed in a single transaction.
Returns an error if:
- oldDomain has no live nodes (not found)
- newDomain already has live nodes (caller should use MergeDomains instead)
func (*Store) ResolveAlias ¶
ResolveAlias returns the canonical domain for name, or name itself if no alias is registered.
func (*Store) RestoreNode ¶
RestoreNode clears archived_at on a node and records an audit_log entry.
func (*Store) SchemaVersion ¶ added in v1.4.1
SchemaVersion returns the highest applied migration version and the highest version defined in the binary. applied is 0 if no migrations have been recorded.
func (*Store) SearchNodes ¶
func (*Store) SearchNodesExact ¶ added in v1.19.0
func (s *Store) SearchNodesExact(query, domain string, limit int, memoryID string, nodeKinds []string) (*SearchResult, error)
SearchNodesExact performs a pure substring (LIKE) search, bypassing semantic ranking entirely. Use this when the query contains a unique identifier, ticket number, or short code that is known to appear verbatim in the stored content. Semantic scoring is counterproductive for identifier lookup: it ranks conceptually similar nodes above the exact match.
func (*Store) SuggestEdges ¶ added in v1.2.0
func (s *Store) SuggestEdges(id string, limit int) ([]EdgeSuggestion, error)
SuggestEdges returns up to limit candidate connections for the given node. When sqlite-vec embeddings are available for the node, it uses semantic nearest-neighbour search with a similarity floor (candidateSimilarityFloor) and domain affinity (same-domain preferred; cross-domain candidates only when their distance is at least crossDomainAffinityBoost better than the best same-domain match). Falls back to keyword matching (tag overlap + label words) when embeddings are unavailable. It never creates edges — the caller must use AddEdge to act on suggestions.
func (*Store) Timeline ¶
func (s *Store) Timeline(domain string, importantOnly bool, tags, nodeKinds []string, from, to *time.Time, limit int) ([]Node, error)
Timeline returns nodes ordered by COALESCE(occurred_at, created_at) ASC. When importantOnly is true, only nodes with occurred_at explicitly set are returned. tags filters to nodes matching at least one tag (whole-word match). from/to filter by effective date (COALESCE(occurred_at, created_at)).
func (*Store) UpdateNode ¶ added in v1.2.0
func (s *Store) UpdateNode(id string, label, description, whyMatters, tags *string, occurredAt *time.Time, nodeKind *string, domain *string, moveReason *string) (*Node, error)
UpdateNode merges the provided (non-nil) fields into an existing live node. Writes an audit_log entry recording which fields changed and their old values. Returns the full updated node. Returns an error if the node does not exist or has been archived.
func (*Store) UpdateNodesBatch ¶ added in v1.4.0
func (s *Store) UpdateNodesBatch(inputs []NodeUpdateInput) ([]*Node, error)
UpdateNodesBatch updates multiple nodes in a single transaction. All updates succeed or all are rolled back.
func (*Store) VecAvailable ¶ added in v1.3.0
VecAvailable reports whether sqlite-vec is loaded and the node_embeddings table is available for semantic search.
func (*Store) VecVersion ¶ added in v1.4.1
VecVersion returns the sqlite-vec version string, or "" if unavailable.
type TrustAssessment ¶ added in v1.41.0
type TrustAssessment struct {
TrustBasis string `json:"trust_basis"`
IsLowTrust bool `json:"is_low_trust"`
}
TrustAssessment holds a per-node trust basis and low-trust predicate result. Used by orient inline annotation and filing-time nudges — no normalised score.
type TrustNode ¶ added in v1.32.0
type TrustNode struct {
Node
TrustScore float64 `json:"trust_score"`
TrustBasis string `json:"trust_basis"`
}
TrustNode is a Node decorated with a computed epistemic trust score.
type TrustResult ¶ added in v1.32.0
TrustResult holds the ranked trust output.