Arrows and Contexts

Arrow Directory

SemanticSpacetime.insert_arrow!Function
insert_arrow!(stname, alias, name, pm) -> ArrowPtr

Register a new arrow type in the directory. Returns the allocated ArrowPtr.

  • stname: ST type name ("NEAR", "LEADSTO", "CONTAINS", "EXPRESS")
  • alias: Short name/alias for the arrow
  • name: Long descriptive name
  • pm: Sign string ("+" or "-")
SemanticSpacetime.get_stindex_by_nameFunction
get_stindex_by_name(stname::AbstractString, pm::AbstractString) -> Int

Convert a Semantic Spacetime type name and sign into a 1-based array index. stname is one of "NEAR", "LEADSTO", "CONTAINS", "EXPRESS" (case-insensitive). pm is "+" or "-" (or "" for NEAR).

SemanticSpacetime.add_mandatory_arrows!Function
add_mandatory_arrows!()

Register the mandatory built-in arrow types required by the SST system. This includes sequence arrows (then/from), extract arrows, fragment arrows, intent/ambient property arrows, and URL/image arrows. Called automatically by parse_n4l.

Arrow Closures

SemanticSpacetime.load_arrow_closuresFunction
load_arrow_closures(config_dir::AbstractString) -> Vector{ClosureRule}

Read closure rules from closures.sst in the config directory. Format: arrow1 + arrow2 => result_arrow (one per line). Lines starting with # are comments.

SemanticSpacetime.apply_arrow_closures!Function
apply_arrow_closures!(store::AbstractSSTStore, rules::Vector{ClosureRule})

For each node, check pairs of consecutive outgoing links where a closure rule applies, and add the composed link.

SemanticSpacetime.complete_inferences!Function
complete_inferences!(store::AbstractSSTStore)

Apply inference completions to all nodes: closeness (NEAR symmetry), sequence completion, and ETC type validation.

SemanticSpacetime.complete_closeness!Function
complete_closeness!(store::AbstractSSTStore, node::Node)

Apply symmetric closure for NEAR links: if A is near B and A is near C by the same arrow type, then B and C should also be near each other.

SemanticSpacetime.complete_sequences!Function
complete_sequences!(store::AbstractSSTStore, node::Node)

Complete sequence chains: if A→B and B→C are in sequence, verify the chain is consistent. (Placeholder for full transitive closure.)

Context Management

SemanticSpacetime.register_context!Function
register_context!(context::Vector{String}) -> ContextPtr

Register a context (given as a vector of labels) in the directory. Returns the pointer to the existing or newly created entry.

SemanticSpacetime.try_contextFunction
try_context(context::Vector{String}) -> ContextPtr

Look up or register a context. Returns 0 for empty contexts.

SemanticSpacetime.get_contextFunction
get_context(ptr::ContextPtr) -> String

Retrieve the context string for a given pointer. Returns "" for pointer 0 or out-of-range pointers.

SemanticSpacetime.compile_context_stringFunction
compile_context_string(context::Vector{String}) -> String

Combine a vector of context labels into a single canonical comma-separated string (sorted, deduplicated, stripped).

SemanticSpacetime.normalize_context_stringFunction
normalize_context_string(ctx::Vector{String}) -> String

Normalize a context vector: sort, deduplicate, join with commas. Alias for compile_context_string matching the Go API.

Node Directory

SemanticSpacetime.append_text_to_directory!Function
append_text_to_directory!(nd::NodeDirectory, event::Node) -> NodePtr

Add a node to the directory. Returns the NodePtr for the (possibly existing) node. Idempotent — returns existing pointer if text already registered.

append_text_to_directory!(event::Node) -> NodePtr

Append to the global node directory.

SemanticSpacetime.check_existing_or_alt_capsFunction
check_existing_or_alt_caps(nd::NodeDirectory, event::Node) -> (ClassedNodePtr, Bool)

Check if a node with the same text (or different capitalization) already exists. Returns (pointer, found). Logs a warning if an alternative capitalization exists.

check_existing_or_alt_caps(event::Node) -> (ClassedNodePtr, Bool)

Check using the global node directory.

Appointed Nodes

SemanticSpacetime.get_appointed_nodes_by_arrowFunction
get_appointed_nodes_by_arrow(store::MemoryStore, arrow::Int;
                             context::Vector{String}=String[],
                             chapter::AbstractString="any",
                             size::Int=100) -> Dict{Int, Vector{Appointment}}

Get appointed nodes grouped by arrow type (memory-backed). Finds nodes that have incoming links with the specified arrow, groups them by arrow pointer, and filters by chapter and context.

get_appointed_nodes_by_arrow(sst::SSTConnection, arrow::Int;
                             context::Vector{String}=String[],
                             chapter::AbstractString="any",
                             size::Int=100) -> Dict{Int, Vector{Appointment}}

Get appointed nodes grouped by arrow type using the PostgreSQL stored procedure.

SemanticSpacetime.get_appointed_nodes_by_sttypeFunction
get_appointed_nodes_by_sttype(store::MemoryStore, sttype::Int;
                              context::Vector{String}=String[],
                              chapter::AbstractString="any",
                              size::Int=100) -> Dict{Int, Vector{Appointment}}

Get appointed nodes grouped by STType (memory-backed). Scans nodes for incoming links in the specified ST channel, groups results by arrow pointer.

get_appointed_nodes_by_sttype(sst::SSTConnection, sttype::Int;
                              context::Vector{String}=String[],
                              chapter::AbstractString="any",
                              size::Int=100) -> Dict{Int, Vector{Appointment}}

Get appointed nodes grouped by STType using the PostgreSQL stored procedure.

SemanticSpacetime.parse_appointed_node_clusterFunction
parse_appointed_node_cluster(whole::AbstractString) -> Appointment

Parse a PostgreSQL appointment cluster tuple string into an Appointment. Expected format: (arr,sttype,chapter,"{ctx1,ctx2}","(class,cptr)","{"(c,p)",...}")