Temporal and bitemporal data

Use temporal versions when you need to retain earlier accounts of a node or edge, not just its current value. GestaltDB stores immutable version records alongside the mutable property graph. Historical reads select versions; they do not run rules, infer conclusions or update current records.

Two independent clocks

Valid time says when an assertion applies in your domain. System time says when the database recorded it. Together they are bitemporal: “what applied in April?” differs from “what had we recorded about April by this earlier commit?”

Valid intervals are half-open: [start, end) includes the start, excludes the end, and uses None for an open end. System horizons include the selected visible commit. System timestamps are allocated by the database, not supplied as backdated valid times.

Alice’s department: two recorded accounts

Recorded horizon

January 15

April 15

June 1

S1: original assertion, Research on [January 1, December 31)

Research

Research

Research

S2: correction, Safety on [March 1, June 1)

Research

Safety

Research

S1 and S2 are the actual system timestamps returned by consecutive writes. The March-to-June correction changes only that valid interval, not the entire year; it does not erase the original account or change answers requested at S1.

Run the two-horizon example

This standalone example creates a disposable managed database. It deliberately stores a different mutable current record to make the storage boundary visible. Dates include UTC offsets; captured timestamps avoid sleeps or assumed wall-clock values. Default temporal writes maintain their derived indexes.

Standalone example. Choose the capability-qualified installation tab below.

Immutable temporal writes and as-of selection support these backends/codecs. Logical temporal publication is not a promise of identical backend rollback or current-snapshot capability.

1python -m pip install "gestaltdb[lmdb]"
 1from tempfile import TemporaryDirectory
 2from gestaltdb.graphdb import GraphDB, Node
 3from gestaltdb.temporal import TemporalInterval
 4
 5with TemporaryDirectory() as root:
 6    graph = GraphDB.create(f"{root}/graph", backend='lmdb', serializer='json')
 7    try:
 8        graph.put_node(Node("alice", properties={"department": "current-only"}))
 9        first = graph.temporal.put_node_version(
10            Node("alice", properties={"department": "Research"}),
11            valid=TemporalInterval.parse("2024-01-01T00:00:00Z", "2024-12-31T00:00:00Z"),
12        )
13        corrected = graph.temporal.correct_node_version(
14            Node("alice", properties={"department": "Safety"}),
15            supersedes_version_id=first.version_id,
16            valid=TemporalInterval.parse("2024-03-01T00:00:00Z", "2024-06-01T00:00:00Z"),
17        )
18        instants = ["2024-01-15T00:00:00Z", "2024-04-15T00:00:00Z", "2024-06-01T00:00:00Z"]
19        answers = [
20            [graph.temporal.get_node_as_of("alice", valid_time=at, system_time=known)
21             .node.properties["department"] for at in instants]
22            for known in (first.system_time, corrected.system_time)
23        ]
24        assert answers == [["Research", "Research", "Research"],
25                           ["Research", "Safety", "Research"]]
26        assert graph.get_node("alice").properties["department"] == "current-only"
27        assert graph.temporal.get_node_version(first.version_id).node.properties == {
28            "department": "Research",
29        }
30        print(answers)
31    finally:
32        graph.close()

get_node_as_of returns a version record with its exact version_id, commit_id, system_time and decoded node. It returns None when no assertion applies or a retraction wins. Edge versions follow the same rule and expose edge. Mutating a returned payload does not persist a change.

Choose the right read/write path

Keep current state, history and inference distinct

Task

API / next guide

Replace a current node or edge

Ordinary graph CRUD and unqualified Cypher (The Property Graph)

Append assertions, corrections or retractions

graph.temporal (Append and revise historical records)

Compare known histories or share a fixed horizon

As-of APIs and authenticated views (Read one historical account consistently)

Query historical graph patterns

Qualified read-only Cypher (Read one historical account consistently, Query and Mutate with Cypher)

Sample historical structure

Sample historical graph structure

Retain sourced positive/negative propositions or run stored rules

Separate services (Sourced claims and conflicting evidence, Stored rules and support maintenance, Bounded Modal and Epistemic Evaluation)

Compute validity intervals of inferred conclusions

Reason over complete validity ranges; temporal storage alone does not evaluate Datalog

Property values created by Cypher date() or datetime() are not themselves version history. Likewise, an ordinary put_node does not automatically append a temporal assertion, and a temporal write does not refresh the mutable graph.

For exact winner ordering, publication and integrity contracts, use Temporal history and service reference. For deferred indexes, see Append and revise historical records; for backups, orphan inspection, retention and legacy migration, use Compatibility, Migration, and Recovery. Authentication verifies selected source identity and stored history, not the real-world truth of an assertion.