Components, Interfaces, and Applications

GestaltDB combines an embedded graph database, fast bulk ingestion, and a high-performance graph-sampling engine with ontology and reasoning components. Applications can store and explore connected data, prepare training batches, classify entities, or maintain conclusions from changing evidence. Explicit adapters connect these workflows without requiring every graph operation to perform inference.

This is a map of application-facing responsibilities, not a claim that each box is an independently deployed service. GraphDB is the database integration hub; sampling and standalone reasoning expose their own execution interfaces.

Component map linking GraphDB to KV backends, serializers, Cypher, read views, sampling snapshots and engine, and explicit adapters for ontology and temporal reasoning.

Selected API calls and data handoffs. Applications choose when to build snapshots, run reasoning, advance saved state, and publish results.

Follow the database/query branch with Choose How to Load and Query Data, Load Arrow and Polars Data and Query and Mutate with Cypher. The diagram is a component map, not a promise that writes, inference, snapshot construction or publication happen automatically together.

Component responsibilities

Database, ingestion, and queries

gestaltdb.graphdb.GraphDB manages nodes, directed edges, labels, indexes, and mutations. put_node / put_edges_bulk accept graph objects; ingest_arrow / ingest_polars accept columns with explicit payload and index-maintenance policies. The nontransactional PyRex backend offers a native columnar writer for bulk-loading workloads. This is useful for importing customer/product networks, scientific interaction data, and dependency graphs. See Compatibility, Migration, and Recovery, Property-Graph Filtering and Indexes, and Performance and Benchmarks.

gestaltdb.kvstores.KVStore separates persistence from the graph API through LMDB, LevelDB, and PyRex/RocksDB implementations. The independently selected Serializer encodes graph payloads using Pickle, JSON, MessagePack, or Protobuf. Transaction and read-snapshot capabilities vary by backend; see Storage Backends and Serializers when choosing deployment behavior.

GraphDB.query calls the Cypher parser, planner, and runtime and returns a QueryResult. It supports relationship exploration, cohort selection, and graph mutations. Visualization builders consume graph/query/sample results through a bounded graph representation for HTML or SVG output. Follow Cypher Queries and Explore graphs and reasoning offline for application examples.

Sampling engine

SamplerSnapshot is the bridge from graph records to compact integer IDs, NumPy arrays, and compressed sparse row (CSR) adjacency. Build a filtered snapshot once, then reuse SamplerEngine for fast repeated batches without per-batch database reads and graph-object deserialization. The database can be closed after construction. A snapshot is immutable; applications explicitly build another when they want to include source changes.

Inputs are seed IDs and sampling policies; outputs are array-backed neighbor, layer, walk, subgraph, and positive/negative batches. External-ID mappings and framework conversion helpers form the boundary to external ML training code. Neighborhood, heterogeneous, weighted, temporal, and negative sampling support GNN training, link prediction, recommendation, and embeddings. See Graph sampling API and policy reference, Snapshot consistency: staleness, appends and compaction, and Property-Graph Filtering and Indexes. Measure snapshot build/load costs separately from repeated sampling; RAM and memory-mapped loading have different costs (Performance and Benchmarks).

Temporal history and epistemic claims

Temporal storage lives alongside mutable graph records in GraphDB. put_node_version, put_edge_version, and commit_versions record history; assert_claim, correction, and retraction APIs record sourced propositions. The interfaces exchange immutable version records rather than silently converting every ordinary mutation into history.

Valid time describes when an assertion applies. System time describes when it was recorded in the database history. For example, a supplier status valid last month may be corrected today: an application can inspect both the revised account of last month and the account available before the correction. Start with Temporal and bitemporal data for a two-horizon example and Read one historical account consistently for historical traversal and Cypher. Exact version-write, validity and publication contracts remain in Temporal history and service reference.

read_view selects a valid-time point and visible commit prefix; current_read_view pins mutable graph state where the backend supports it. They are different interfaces, suited respectively to historical evidence and coherent current-graph analysis. Their source identities stay distinct.

Claims carry agent/source attribution, a world, polarity, and optional confidence/provenance. Positive and negative evidence may coexist; claim status distinguishes supported, refuted, both, and unknown. The bounded modal API evaluates belief/knowledge formulas over explicit accessibility links. For multi-source scientific knowledge or agent belief models, see Bounded Modal and Epistemic Evaluation. Model-output provenance can be included in historical explanations through Unified inference audit.

Ontology model and compiler

Ontology holds semantic axioms; compile_ontology produces a CompiledOntology containing a binary reasoning Program and exact axiom origins. Supported constructs include class/property hierarchies, domain/range, inverse, symmetric and transitive properties, and selected chains and class expressions. This separation lets an application compile a shared semantic model and evaluate it against explicitly selected facts.

For entity classification and relationship enrichment, start with Ontology reasoning. The offline RDF adapter provides an optional import boundary. Separate validation and snapshot-local equality mechanisms have their own contracts (Explicit negatives and validation reports, Snapshot-local equality and functional identity). Consult Gated profile expansion and conformance matrix for the supported construct matrix rather than assuming a complete OWL profile.

Standalone reasoning, maintenance, and temporal reasoning

The storage-independent reasoning package consumes programs and facts. The binary engine uses Program / Fact and can collect bounded witnesses; the typed engine uses GenericProgram / TypedFact for n-ary relations, strict literals, filters, scoped negation, and selected aggregation. Prepared plans and optional execution paths have explicit compatibility contracts. See Relational execution contracts, Typed Datalog: literals, filters, aggregates, Scoped closed-world negation, and Executor selection and resource limits.

Goal-directed APIs answer selective questions rather than requiring applications to request every consequence (Goal-directed queries and demand specialization, Pinned frontier-demand queries). Support/dependency indexes and DRed-style deletion maintain conclusions when supporting facts change (Bounded maintenance provenance and insertion propagation). Validation reports conflicts without rewriting the fact set; explanation APIs expose bounded derivations with different witness/support contracts (Bounded proofs, export interchange and checkpoints).

Temporal storage and temporal reasoning are separate responsibilities. TemporalFact / IntervalSet and evaluate_range compute the intervals over which conclusions follow. update_range reuses eligible segment computations; verify_closure checks conformance. This enables questions such as “during which periods did this dependency or eligibility rule hold?” Recording versions alone does not execute interval reasoning. See Reason over complete validity ranges, Temporal delta maintenance and interval publication, and Temporal conformance and audit workflows.

Explicit integration adapters

reasoning.adapters connects the database and standalone logic layers:

  • Read and map: select graph records or temporal claims, map them to facts, and retain the selected source context and evidence references.

  • Verify and execute: check database/history, program, policy, and representation compatibility before using a generation.

  • Save and resume: persist reasoning state and apply committed evidence changes through supported incremental operations or an explicit rebuild.

  • Publish and project: write inferred claims under controlled publication rules or turn derived relationships into reusable sampler snapshots.

A reasoning session is the saved state of a particular reasoning computation: its program/catalog, source scope and horizon, evidence ledger, facts, and support index. It is not a user login or a database connection. An authenticated result/artifact is source-verified: checked against the expected database history and application-held identities. This checks source and state correspondence; the relevant execution APIs separately define how closure is recomputed or verified.

Use Current-graph ontology adapters and Current-graph generation admission and execution for current property graphs; Opt-in generation identity and admission for typed-point evidence; Resumable incremental reasoning sessions and Authenticated durable-session resume for saved state; Authenticated temporal-range evaluation and re-admission and Authenticated interval-batch publication for finite intervals; and Authenticated inferred sampler artifacts for derived sampling snapshots.

Choose an application workflow

Graph interoperability and visualization are separate boundaries. The optional gestaltdb.integrations.networkx adapter imports/exports materialized current records and loads supported local static GEXF, not temporal history or live algorithm dispatch (Exchange current graphs with NetworkX and GEXF). The base gestaltdb.viz.api builders consume selected records, query/sample results or reasoning explanations and produce detached offline figures (Explore graphs and reasoning offline). Rendering does not require NetworkX; notebook display does not synchronize browser state back into the database (Notebook Usage). See Installation for independent extras and Performance and Benchmarks for the costs at each handoff.

From application goal to component interfaces

Application

Component handoff

Start here

Explore a dependency or customer network

Ingest -> GraphDB/indexes -> Cypher -> visualization

Quickstart, Compatibility, Migration, and Recovery, Cypher Queries, Explore graphs and reasoning offline

Train a link predictor or recommender

Ingest -> filter graph -> snapshot -> sampler -> external ML framework

Property-Graph Filtering and Indexes, Graph sampling API and policy reference, Performance and Benchmarks

Classify entities with an ontology

Ontology -> compiler -> program; selected graph/claims -> adapter -> evaluator

Ontology reasoning, Current-graph ontology adapters, Explicit negatives and validation reports

Audit historical eligibility or evidence

Versioned claims -> pinned history -> temporal closure -> explanations/publication

Temporal and bitemporal data, Reason over complete validity ranges, Authenticated interval-batch publication

Maintain conclusions as evidence changes

Committed versions -> session ledger -> maintenance -> saved state or publication

Resumable incremental reasoning sessions, Authenticated durable-session resume

Inspect decisions based on model predictions

External model -> tagged claims -> stored rules -> inference audit export

Sourced claims and conflicting evidence, Stored rules and support maintenance, Unified inference audit, Bounded Modal and Epistemic Evaluation

Code navigation and modularity

The main source entry points are graphdb.py (public facade), _graph/ (private implementation collaborators), kvstores.py, serializers.py, readview.py, sampling/, ontology/, reasoning/, reasoning/adapters/, query_engine/cypher/, and viz/ under src/gestaltdb. API Reference exposes documented APIs and source links; Runnable API Workflows collects runnable docstring examples for the main handoffs. Browse the database implementation, sampling components, ontology compiler, and reasoning components and adapters to follow those boundaries in code.

Historical consumers can use graph.temporal.history() (gestaltdb.history.TemporalHistory) instead of accepting the full mutable database. TemporalHistory.from_store also borrows an existing backend and serializer without constructing a GraphDB. This capability exposes only historical reads, does not own the store, and performs no identity initialization or index repair. It is not a snapshot or an authenticated source: use graph.temporal.open_read_view(...) for authenticated fixed-horizon selection. GraphReadView delegates historical queries to this capability; its source verification and sampler integration take the owning handle explicitly as the read source.

Temporal writes, sequencing, index maintenance and recovery live in gestaltdb.temporal_engine.TemporalEngine rather than in the facade. Sourced claims and modal evaluation live in gestaltdb.epistemic_engine.EpistemicEngine (graph.epistemic) and Horn rules in gestaltdb.rules_engine.RulesEngine (graph.rules), both bound to the handle’s temporal scope. Each database handle owns one of each; they are constructed with the store, entity codec, clock and store path, and they borrow the owner’s lifetime and database identity. Transaction and snapshot children rebind the engines to their own store instead of sharing the live handle’s. Reasoning adapters and other services consume the engines (or the temporal reader/history) instead of facade methods; GraphDB keeps no wrapper methods for them, and the engines never call back into the facade. Temporal writes and publication remain behind the guarded engine, not ad-hoc store access.

For example, pass only read authority to an application component:

 1from tempfile import TemporaryDirectory
 2from gestaltdb.graphdb import GraphDB, Node
 3
 4def names_at(history, instant):
 5    return [v.logical_id for v in history.iter_nodes_as_of(valid_time=instant)]
 6
 7with TemporaryDirectory() as root:
 8    graph = GraphDB.create(root + "/db", backend="lmdb")
 9    try:
10        graph.temporal.put_node_version(Node("alice"), valid=(0, 10))
11        assert names_at(graph.temporal.history(), 5) == ["alice"]
12    finally:
13        graph.close()

File coordination lives in gestaltdb.concurrency rather than in GraphDB. The shared default LockManager maintains canonical identity only for live locks (holders and waiters retain strong references); unused paths are reclaimed. Identity initialization, temporal writers and durable-session CAS use the same reentrant file-lock abstraction. Lock files themselves are never unlinked, and independent processes still coordinate through OS file locks.

Current-node consumers can similarly accept graph.nodes rather than GraphDB. gestaltdb.current.NodeRepository uses a StorageSession for codecs, index configuration, cache scope and ordinary backend transactions. It can be constructed over an existing store without GraphDB. Its reader property narrows authority to NodeReader; current read views use that reader on their snapshot store. These services borrow the store lifetime and do not create a snapshot, initialize temporal identity, expose schema DDL or own temporal publication. Unsupported backend transactions remain best-effort; update keeps the legacy non-atomic read/merge boundary unless the session was already transaction-bound. For example:

 1from tempfile import TemporaryDirectory
 2from gestaltdb.current import NodeRepository, StorageSession
 3from gestaltdb.graphdb import GraphDB, Node
 4
 5with TemporaryDirectory() as root:
 6    graph = GraphDB.create(root + "/db", backend="lmdb")
 7    try:
 8        nodes = NodeRepository(StorageSession(graph.store, graph.serializer))
 9        nodes.put(Node("alice", labels=["Person"]))
10        assert nodes.reader.get(b"alice").labels == ("Person",)
11    finally:
12        graph.close()

Current-edge consumers can accept graph.edges or construct EdgeRepository(StorageSession(store, serializer)) from gestaltdb.current. The repository owns object and batched writes, replacement cleanup, typed and legacy adjacency, and configured secondary indexes. It does not construct or redispatch through GraphDB. graph.edges.reader and view.edges expose only current-edge reads; transaction/snapshot children bind their own store. As with nodes, update is not an atomic read-modify-write outside an explicit transaction. Independently constructed sessions own independent adjacency-count caches: use handle-bound repositories when sharing a handle’s cached reads.

Current secondary indexes are owned by gestaltdb.indexes.IndexService (graph.indexes), constructed over the same StorageSession. It owns exact/composite/range ID lookups, stale-family checks, property-index DDL and rebuild transactions without constructing GraphDB children. DDL stages index configuration and publishes it to the session only after rebuild and metadata writes commit successfully. view.indexes exposes an IndexReader bound to the snapshot’s index configuration, without DDL methods. Existing current lookup names on GraphDB remain integration conveniences; the current-graph reasoning frontier consumes the narrow snapshot index reader directly.

Columnar format adapters live in gestaltdb.ingestion_service: graph.ingest.arrow (ArrowIngestor) and graph.ingest.polars (PolarsIngestor). Each accepts a StorageSession for standalone use. nodes/edges load serialized payloads; node_entities/edge_entities encode structured columns. Conversion callbacks stay bound to the same write scope, preserving native columnar writes, optimized JSON conversion, transaction rollback and typed adjacency without GraphDB redispatch. These low-level loaders retain maintain/defer index policy. The existing graph-wide ingest_arrow/ingest_polars entry points still coordinate both entity families and the aggregate deferred-index rebuild. They delegate to IngestionCoordinator, which owns mode dispatch and the optional rebuild over the same session. Callers that need cross-family atomicity wrap the coordinator in a transaction; temporal staleness/rebuild requires an explicitly supplied temporal capability and fails closed otherwise. Snapshot views deliberately do not expose ingest.

Live typed traversal and sampling live in gestaltdb.traversal. graph.traversal is a TraversalService over the current StorageSession: it owns typed adjacency reads/counts, typed-adjacency rebuilds and reservoir sampling of nodes, neighbors, paths and subgraphs. view.traversal narrows to AdjacencyReader, so a snapshot can traverse its pinned adjacency without exposing rebuild or sampling writes. Sampling scans the bound store directly and keeps the label-index freshness check. Snapshot construction (build_sampler_snapshot) and array-native sampling in gestaltdb.sampling remain separate capabilities.

Index-backed decoded reads live in gestaltdb.lookups. graph.lookup is an EntityLookup over the current StorageSession: it composes the index reader with the current node/edge readers to serve nodes_by_*, edges_by_* and count_* queries without touching GraphDB. view.lookup serves the same reads from the snapshot scope. The legacy range_query_nodes is deprecated (use nodes_by_property_range); it keeps its exact raw key format and iteration order.

The decomposition is useful, with four important boundaries:

  • GraphDB is the public integration facade: it owns handle lifecycle, transaction/snapshot scope binding, and thin method delegation. The implementation lives in cohesive collaborators: current-graph services in gestaltdb.current/gestaltdb.concurrency, the temporal subsystem in gestaltdb.temporal_engine, and storage details under src/gestaltdb/_graph/ (entities, typed adjacency, secondary indexes, columnar ingestion, stored rules, sampling, lifecycle, scope binding). Ingestion, stored rules, live traversal, and modal queries remain responsibilities behind that facade; temporal work has its own engine.

  • graph.rules.run / graph.rules.maintain evaluate stored temporal claims. Standalone Datalog evaluators use their own programs, facts, supports, and adapters. These are two rule-execution families with different interfaces.

  • Inside standalone reasoning, temporal closure and maintenance reuse private typed-engine helpers. Binary, typed, prepared, and Polars paths have distinct capabilities. A diagram box does not imply universal executor substitution.

  • Adapters use database internals for source identity, writer coordination, and commit validation. Package initializers also re-export multiple subsystems: logical independence is not an isolated-import or separate-distribution promise.

Scope and caveats

Fast ingestion and sampling are workload-oriented strengths. Snapshot building, index rebuilding, source verification, conversion, and inference incur separate costs (Performance and Benchmarks). Applications choose synchronization points and handle explicit rebuilds when incremental operations do not apply.

Conflict-tolerant evidence and truth maintenance preserve supported conclusions; they do not automatically resolve contradictions. Broader OWL coverage, signed-denial premises, datatype shapes, and reusable TBox closure remain gated or deferred (Gated profile expansion and conformance matrix). External frameworks perform model training. Weighted-rule semantics and an automated neuro-symbolic loop are not provided. Operational guarantees follow the selected backend and documented coordination scope.