Storage API
Abstract Interface
SemanticSpacetime.AbstractSSTStore — Type
AbstractSSTStoreAbstract supertype for all SST storage backends.
In-Memory Store
SemanticSpacetime.MemoryStore — Type
MemoryStore <: AbstractSSTStoreA fully in-memory graph store. Holds nodes, links, page map entries, and per-size-class counters for NodePtr allocation. Arrow and context directories use the existing module-level state.
Example
store = MemoryStore()
n1 = mem_vertex!(store, "hello", "ch1")
n2 = mem_vertex!(store, "world", "ch1")
mem_edge!(store, n1, "then", n2)SemanticSpacetime.mem_vertex! — Function
mem_vertex!(store::MemoryStore, name::AbstractString, chap::AbstractString) -> NodeCreate or retrieve a node in the in-memory store. Idempotent — if a node with the same text already exists, returns the existing node.
SemanticSpacetime.mem_edge! — Function
mem_edge!(store::MemoryStore, from::Node, arrow::AbstractString,
to::Node, context::Vector{String}=String[],
weight::Float32=1.0f0) -> (ArrowPtr, Int)Create a directed link between two nodes using a named arrow type. The arrow must already be registered in the arrow directory. Also creates the inverse link if one is registered.
Returns (arrow_ptr, sttype).
SemanticSpacetime.mem_get_node — Function
mem_get_node(store::MemoryStore, nptr::NodePtr) -> Union{Node, Nothing}Retrieve a node by its pointer. Returns nothing if not found.
SemanticSpacetime.mem_get_nodes_by_name — Function
mem_get_nodes_by_name(store::MemoryStore, name::AbstractString) -> Vector{Node}Retrieve all nodes with exactly the given text.
SemanticSpacetime.mem_get_chapters — Function
mem_get_chapters(store::MemoryStore) -> Vector{String}Return a sorted list of all chapter names in the store.
SemanticSpacetime.mem_search_text — Function
mem_search_text(store::MemoryStore, query::AbstractString) -> Vector{Node}Simple case-insensitive substring search across all node texts. Returns nodes whose text contains query.
SemanticSpacetime.node_count — Function
node_count(store::MemoryStore) -> IntReturn the total number of nodes in the store.
SemanticSpacetime.link_count — Function
link_count(store::MemoryStore) -> IntReturn the total number of links that have been added to the store.
DBStore (SQLite / DuckDB)
SemanticSpacetime.DBStore — Type
DBStore <: AbstractSSTStoreDatabase-backed graph store using DBInterface.jl for portable SQL access. Works with SQLite, DuckDB, or any DBInterface-compatible connection.
Example
using SQLite
db = SQLite.DB(":memory:")
store = DBStore(db)
db_vertex!(store, "hello", "ch1")SemanticSpacetime.open_sqlite — Function
open_sqlite(path::AbstractString=":memory:") -> DBStoreOpen a SQLite-backed SST store. Requires using SQLite.
SemanticSpacetime.open_duckdb — Function
open_duckdb(path::AbstractString=":memory:") -> DBStoreOpen a DuckDB-backed SST store. Requires using DuckDB.
SemanticSpacetime.close_db — Function
close_db(store::DBStore)Close the database connection.
SemanticSpacetime.db_vertex! — Function
db_vertex!(store::DBStore, name::AbstractString, chap::AbstractString) -> NodeCreate or retrieve a node. Idempotent.
SemanticSpacetime.db_edge! — Function
db_edge!(store::DBStore, from::Node, arrow::AbstractString, to::Node;
context::Vector{String}=String[], weight::Float32=1.0f0)Create a directed link between two nodes. Also creates the inverse link.
SemanticSpacetime.db_get_node — Function
Get a node by NodePtr.
SemanticSpacetime.db_get_links — Function
Get all links from a node.
SemanticSpacetime.db_get_nodes_by_name — Function
Find nodes by name.
SemanticSpacetime.db_search_nodes — Function
Search nodes by text pattern (LIKE-based for portability).
SemanticSpacetime.db_get_chapters — Function
Get all distinct chapters.
SemanticSpacetime.db_get_chapter_nodes — Function
Get nodes in a chapter.
SemanticSpacetime.db_stats — Function
Count nodes and links.
SemanticSpacetime.db_upload_arrows! — Function
Upload all in-memory arrows to the database.
SemanticSpacetime.db_load_arrows! — Function
Load arrows from DB into module-level directory.
SemanticSpacetime.db_upload_contexts! — Function
Upload all contexts to DB.
SemanticSpacetime.db_load_contexts! — Function
Load contexts from DB.
PostgreSQL Connection
SemanticSpacetime.SSTConnection — Type
SSTConnectionWraps a PostgreSQL database connection with cached SST state. Create with open_sst(), close with close_sst(sst).
SemanticSpacetime.open_sst — Function
open_sst(; load_arrows::Bool=false, host::String="localhost", port::Int=5432) -> SSTConnectionOpen a connection to the SSTorytime PostgreSQL database. If load_arrows is true, arrow and context directories are loaded from the database on connection.
SemanticSpacetime.close_sst — Function
close_sst(sst::SSTConnection)Close the database connection.
SemanticSpacetime.configure! — Function
configure!(sst::SSTConnection)Configure the database connection: create types, tables, stored functions, and optionally load arrows and contexts from existing data.
High-Level Graph API
SemanticSpacetime.vertex! — Function
vertex!(sst::SSTConnection, name::AbstractString, chap::AbstractString) -> NodeCreate or retrieve a node in the SST graph. Idempotent — if a node with the same text already exists, returns the existing node.
Arguments
sst: Open database connectionname: Text content of the nodechap: Chapter/section this node belongs to
Example
sst = open_sst()
n1 = vertex!(sst, "Mary had a little lamb", "nursery rhymes")
n2 = vertex!(sst, "Whose fleece was white as snow", "nursery rhymes")
close_sst(sst)SemanticSpacetime.edge! — Function
edge!(sst::SSTConnection, from::Node, arrow::AbstractString, to::Node,
context::Vector{String}=String[], weight::Float32=1.0f0) -> (ArrowPtr, Int)Create a directed link between two nodes using a named arrow type. The arrow must already be registered in the arrow directory.
Returns (arrow_ptr, sttype) for the created link.
Arguments
sst: Open database connectionfrom: Source node (returned byvertex!)arrow: Short or long name of a registered arrowto: Destination node (returned byvertex!)context: Optional context labels for the linkweight: Optional link weight (default 1.0)
Example
sst = open_sst(load_arrows=true)
n1 = vertex!(sst, "Event A", "chapter1")
n2 = vertex!(sst, "Event B", "chapter1")
edge!(sst, n1, "then", n2, String[], 1.0f0)
close_sst(sst)SemanticSpacetime.hub_join! — Function
hub_join!(sst::SSTConnection, name::AbstractString, chap::AbstractString,
from_ptrs::Vector{NodePtr}, arrow::AbstractString,
context::Vector{String}, weights::Vector{Float32}) -> NodeCreate a hub node and link multiple source nodes to it with the same arrow type. Used for many-to-one relationships.
Returns the hub node.
SemanticSpacetime.graph_to_db! — Function
graph_to_db!(sst::SSTConnection; show_progress::Bool=false)Upload the entire in-memory graph (from the global node directory) to the database. This is typically called after building a graph with the N4L compiler.
DB Sync
SemanticSpacetime.download_arrows_from_db! — Function
download_arrows_from_db!(sst::SSTConnection)Load the arrow directory from the database into module-level state, replacing any existing in-memory arrows.
SemanticSpacetime.download_contexts_from_db! — Function
download_contexts_from_db!(sst::SSTConnection)Load the context directory from the database into module-level state, replacing any existing in-memory contexts.
SemanticSpacetime.synchronize_nptrs! — Function
synchronize_nptrs!(sst::SSTConnection, store::MemoryStore)Sync in-memory node pointer counters with the database by reading the maximum CPtr for each size class channel.
SemanticSpacetime.cache_node! — Function
cache_node!(n::Node)Cache a node in the module-level node directory. Idempotent — does not overwrite an existing entry.
SemanticSpacetime.get_cached_node — Function
get_cached_node(nptr::NodePtr) -> Union{Node, Nothing}Retrieve a node from the module-level cache.
SemanticSpacetime.reset_node_cache! — Function
reset_node_cache!()Clear the module-level node cache. Primarily for testing.