Utilities API

Tools

SemanticSpacetime.remove_chapter!Function
remove_chapter!(sst::SSTConnection, chapter::String)

Delete all nodes and links belonging to a chapter from the database. This is a destructive operation that cannot be undone.

SemanticSpacetime.browse_notesFunction
browse_notes(sst::SSTConnection, chapter::String;
             page::Int=1, width::Int=SCREENWIDTH) -> String

Format notes from a chapter for terminal display. Retrieves the page map for the given chapter and renders each note with its context, chapter heading, and linked content.

Returns a formatted string suitable for terminal output.

SemanticSpacetime.import_json!Function
import_json!(sst::SSTConnection, json_str::String;
             chapter::String="json_import") -> Vector{Node}

Import a JSON structure as SST nodes and links. Each key-value pair in the JSON becomes a node (key) with a CONTAINS link to its value node(s). Nested objects create nested containment structures. Arrays create multiple CONTAINS links from the parent key.

Returns a vector of all created nodes.

Session Tracking

SemanticSpacetime.update_last_saw_nptr!Function
update_last_saw_nptr!(store::AbstractSSTStore, nptr::NodePtr, name::AbstractString)

Record that the given node pointer was accessed at the current time.

SemanticSpacetime.get_last_saw_nptrFunction
get_last_saw_nptr(store::AbstractSSTStore, nptr::NodePtr) -> LastSeen

Return the LastSeen record for a specific node pointer. Returns a default LastSeen if not tracked.

SemanticSpacetime.get_newly_seen_nptrsFunction
get_newly_seen_nptrs(store::AbstractSSTStore, horizon::Int) -> Set{NodePtr}

Return the set of node pointers that were last seen within horizon hours. If horizon <= 0, returns all tracked node pointers.

Display

Built-in Functions

Extended Queries

Convenience Functions

SemanticSpacetime.connect!Function
connect!(store, from, arrow, to; context=String[], weight=1.0f0)

Convenience alias for mem_edge! with keyword arguments.

Example

connect!(store, apple, "contains", fruit)
connect!(store, apple, "note", description; context=["botany"])
SemanticSpacetime.linksFunction
links(node::Node) -> Vector{Link}

Get all links from a node, flattened across all ST types.

links(node::Node, sttype::STType) -> Vector{Link}

Get links from a node for a specific ST type.

Example

fwd_links = links(node, LEADSTO)      # Forward causal links
contains = links(node, CONTAINS)      # Containment links
similar = links(node, NEAR)           # Similarity links
SemanticSpacetime.neighborsFunction
neighbors(store::MemoryStore, node::Node) -> Vector{Node}

Get all nodes directly connected to this node.

neighbors(store::MemoryStore, node::Node, sttype::STType) -> Vector{Node}

Get nodes connected via a specific ST type.

SemanticSpacetime.nodesFunction
nodes(store::MemoryStore) -> Vector{Node}

Get all nodes in the store as a vector.

SemanticSpacetime.eachnodeFunction
eachnode(store::MemoryStore)

Iterate over all nodes in the store.

Example

for node in eachnode(store)
    println(node.s)
end
SemanticSpacetime.eachlinkFunction
eachlink(node::Node)

Iterate over all links from a node (across all ST types).

Example

for link in eachlink(node)
    println("Arrow: $(link.arr), Dst: $(link.dst)")
end
eachlink(node::Node, sttype::STType)

Iterate over links of a specific ST type.

SemanticSpacetime.find_nodesFunction
find_nodes(store::MemoryStore, predicate::Function) -> Vector{Node}

Find all nodes matching a predicate.

Examples

# Find long text nodes
long_nodes = find_nodes(store, n -> n.l > 100)

# Find nodes in a chapter
ch_nodes = find_nodes(store, n -> n.chap == "vocabulary")
find_nodes(store::MemoryStore, pattern::Regex) -> Vector{Node}

Find all nodes whose text matches a regex pattern.

Example

fruit_nodes = find_nodes(store, r"fruit|apple|banana"i)
SemanticSpacetime.map_nodesFunction
map_nodes(f::Function, store::MemoryStore) -> Vector

Apply a function to each node and collect results.

Example

names = map_nodes(n -> n.s, store)
SemanticSpacetime.with_storeFunction
with_store(f::Function) -> MemoryStore
with_store(f::Function, store::MemoryStore) -> MemoryStore

Execute a function with a MemoryStore, using do-block syntax.

Example

store = with_store() do s
    a = mem_vertex!(s, "apple", "fruits")
    b = mem_vertex!(s, "banana", "fruits")
    mem_edge!(s, a, "contains", b)
end
SemanticSpacetime.with_configFunction
with_config(f::Function, config_dir::String)

Execute a function after loading SST arrow configuration.

Example

with_config("/path/to/SSTconfig") do
    result = parse_n4l("-section\n apple (contains) fruit\n")
    @show result
end

SQL Index

SemanticSpacetime.index_sql_database!Function
index_sql_database!(store::MemoryStore, db;
                    config::SQLIndexConfig=SQLIndexConfig()) -> Dict{String,Int}

Index a SQL database into the SST graph.

  • Each table becomes a chapter (prefixed with config.chapter_prefix)
  • Each row becomes a node (labeled by primary key or configured column)
  • Foreign key columns create LEADSTO edges between nodes
  • Other columns become EXPRESS (note) annotations

Returns a Dict mapping table names to number of nodes created.

ETC Validation Integration

SemanticSpacetime.validate_compiled_graph!Function
validate_compiled_graph!(store::MemoryStore; verbose::Bool=false) -> Vector{String}

Run ETC validation on all nodes in the store. First infers ETC types, then validates them. Returns a flat list of warnings about type mismatches (e.g., a Thing with only LEADSTO links, an Event with no temporal arrows).