Interval-tree temporal presence engine for querying who was where, when, and with whom across historical time windows in pure C. Canonical header is <ttypt/joint.h>.
git clone https://github.com/tty-pt/libjointDocumentation
Manual Pages
libjoint
Interval-tree temporal presence engine for querying who was where, when, and with whom across historical time windows in pure C. Canonical header is<ttypt/joint.h>.
1. Quickstart
Record entity presence windows and query concurrent overlaps in under 20 lines:
#include <stdio.h>
#include <time.h>
#include <ttypt/joint.h>
int main(void) {
// Open in-memory temporal database
unsigned jd = joint_init(NULL);
// Entity 1 active from t=1000 to t=2000; Entity 2 active from t=1500 to t=2500
joint_start(jd, 1000, 1);
joint_stop(jd, 2000, 1);
joint_start(jd, 1500, 2);
joint_stop(jd, 2500, 2);
// Query co-presence between t=1200 and t=1800
joint_cur_t cur = joint_iter(jd, 1200, 1800);
time_t min_t, max_t;
unsigned count, who;
while (joint_next(&min_t, &max_t, &count, &who, &cur)) {
printf("Entity %u active in [%ld, %ld) (concurrent: %u)\n",
who, (long)min_t, (long)max_t, count);
}
return 0;
}
Compile and link:
cc presence_query.c $(pkg-config --cflags --libs libjoint) -o presence_query
2. Core API Reference
The essential functions for temporal presence recording and interval overlap queries:
| Function | Signature | Description |
|---|---|---|
joint_init | unsigned joint_init(const char *file) | Open in-memory (NULL) or disk-persisted temporal database |
joint_start | int joint_start(jd, time_t ts, unsigned id) | Mark entity presence started at timestamp |
joint_stop | int joint_stop(jd, time_t ts, unsigned id) | Mark entity presence ended at timestamp |
joint_iter | joint_cur_t joint_iter(jd, time_t a, time_t b) | Create query cursor decomposed into constant-presence slices |
joint_next | int joint_next(&min, &max, &count, &who, &cur) | Advance iterator returning active entities per time slice |
rec_axis_fill_interval | int rec_axis_fill_interval(jd, a, b, set) | Stream all active refs in [a, b) into a sealed recall candidate set |
rec_axis_store_typed | int rec_axis_store_typed(ref, data, len, qtype, ctx) | Ingest typed ISO 8601 dates and epoch intervals from HTOK containers |
๐ For boundary specifications, interval grammar, and worked patterns, see QUICK_REFERENCE.md.
3. Constant-Presence Segment Decomposition
Unlike traditional databases that test individual timestamps sequentially, libjoint segments query intervals into maximal constant-presence slices:
Time โโโบ 1000 1200 1500 1800 2000 2500
Entity 1: [=================================)
Entity 2: [=============================)
Query Window: [โโโโโโโโโโโโโโโโโ]
Decomposed Slices:
Slice A: [1200, 1500) -> Entity 1 only (concurrency: 1)
Slice B: [1500, 1800) -> Entity 1 AND Entity 2 (concurrency: 2 - overlap)
Point presence, co-presence, concurrency counts, and temporal gaps are resolved in a single forward pass without secondary lookups.
4. corm CLI Multi-Axis Integration
libjoint attaches directly to the corm CLI tool as the @joint temporal axis:
# Ingest entity timestamp presence window:
corm -p "2026-10-27T14:30:00Z" audit.db@joint:a:s
# Query presence over temporal range:
corm -X "joint" --joint="range:1730000000..1730003600" audit.db@joint:a:s
libjoint functions as the canonical Time Axis for temporal queries and recall composition:
- Storage Engine: Built on sorted libcorm maps for high-throughput temporal intervals.
- Cross-Axis Recall Kernel: Composes temporal windows directly with sibling axes: libislet (Space), liblemma (Text), and libsepal (Meaning). Matches stream into
cormr_set_tcandidate pools viarec_axis_fill_interval().
5. Installation & Build
Prebuilt Packages
Prebuilt packages are distributed on tty.pt for Linux (APT / Alpine / Arch / Fedora-RHEL), macOS (Homebrew), Windows (winget / MSYS2), and OpenBSD, and mobile static sysroots for Android (https://tty.pt/android/ โ arm64-v8a, armeabi-v7a, x86_64) and iOS (https://tty.pt/ios/ โ libjoint.xcframework). Follow the installation instructions and use libjoint as the package name.
Build from Source
Builds use shared libstele rules (include ttypt/include.mk):
make # builds lib/libjoint.so
make test # run comprehensive test suite
make bench # run microsecond query benchmarks
sudo make install # install headers and library to system
6. JavaScript & WebAssembly Bindings (@tty-pt/joint)
Official Node.js and Browser WebAssembly bindings are colocated in npm/:
- Universal Engine: Native Node-API (
.node) for backend scheduling and pre-compiled WebAssembly (dist/joint.wasm) for client-side calendar UIs. - Reactive Timeline Controller: Provides 60/120 FPS conflict tracking on mouse drag/sliders with zero external framework dependencies.
- C Development Headers: Install via
npm install @tty-pt/joint(from npm orhttps://tty.pt/npm/) and consume headers fromnode_modules/@tty-pt/joint/include.
๐ For complete TypeScript usage, reactive timeline controllers, and API reference, see npm/README.md.
License
BSD 2-Clause License. Copyright (c) 2026, tty-pt. See LICENSE.