npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@unrdf/kgc-4d

v26.5.5

Published

KGC 4D Datum & Universe Freeze Engine - Nanosecond-precision event logging with Git-backed snapshots

Downloads

530

Readme

KGC 4D Engine

Version Production Ready Tests Coverage

A 4-dimensional knowledge graph engine combining Observable State, nanosecond-precision Time, Vector causality, and Git References into a unified, auditable data structure.

What is KGC 4D?

KGC 4D extends RDF knowledge graphs into 4 dimensions:

  • O (Observable): Current state as RDF triples in Universe graph
  • t (Time): Nanosecond-precision BigInt timestamps with monotonic ordering
  • V (Vector): Causality tracking via distributed vector clocks
  • G (Git): Content-addressed immutable snapshots with BLAKE3 verification

Key insight: The entire universe at any point in time is reconstructible from the Event Log + Git snapshots. No external database required.

5-Minute Quick Start

import { KGCStore, GitBackbone, freezeUniverse, reconstructState, EVENT_TYPES } from '@unrdf/kgc-4d';
import { dataFactory } from '@unrdf/oxigraph';

// Initialize
const store = new KGCStore();
const git = new GitBackbone('./my-repo');

// Add data
const alice = dataFactory.namedNode('http://example.org/Alice');
const rdfType = dataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type');
const person = dataFactory.namedNode('http://example.org/Person');

// Append event atomically (L5 hardening: requires policy bounds)
await store.appendEvent(
  { 
    type: EVENT_TYPES.CREATE, 
    policy: { '@type': ['odrl:Policy'], action: 'mcpp:MutateGraph' },
    payload: { description: 'Added Alice' } 
  },
  [{ type: 'add', subject: alice, predicate: rdfType, object: person }]
);

// Freeze universe to Git (creates cryptographic receipt)
const frozen = await freezeUniverse(store, git);
console.log(`✓ Frozen at ${frozen.timestamp_iso}`);
console.log(`✓ Hash: ${frozen.universe_hash}`);

// Add more data
const bob = dataFactory.namedNode('http://example.org/Bob');
await store.appendEvent(
  { 
    type: EVENT_TYPES.CREATE, 
    policy: { '@type': ['odrl:Policy'], action: 'mcpp:MutateGraph' },
    payload: { description: 'Added Bob' } 
  },
  [{ type: 'add', subject: bob, predicate: rdfType, object: person }]
);

// Time-travel back to when only Alice existed
const pastStore = await reconstructState(store, git, BigInt(frozen.t_ns));
console.log(`✓ Time-traveled to ${frozen.timestamp_iso}`);
// pastStore now contains only Alice

Installation

# Workspace
pnpm add @unrdf/kgc-4d

# Or standalone
npm install @unrdf/kgc-4d

Core Features

| Feature | Capability | Use Case | |---------|-----------|----------| | Nanosecond Timestamps | Guaranteed ordering with BigInt precision | Debugging, audit trails | | Universe Snapshots | Freeze & cryptographic verification with BLAKE3 | Checkpoints, rollback | | Time-Travel Queries | Reconstruct state at any historical point | Root cause analysis | | Event Sourcing | Append-only immutable history with SPARQL | Compliance, auditing | | Vector Clocks | Distributed causality tracking | Multi-node coordination | | Git Backing | Content-addressed snapshots, zero external DB | Offline verification | | Dual Runtime | Node.js (true nanoseconds) + Browser (IndexedDB) | Universal deployment |

Documentation Map

Choose your path:

🎓 Learning (Tutorials)

Start here - Hands-on step-by-step introduction to core concepts

See all tutorials →

📖 How-To Guides (Problem → Solution)

Real-world tasks - Solutions to practical problems

See all how-tos →

📚 Reference (API & Concepts)

Precise documentation - Authoritative information

See all references →

🧠 Understanding (Deep Dives)

Design rationale - Why KGC 4D works this way

See all explanations →

Production Status

Version: [VERSION]-beta.1 Tests: ✅ 176/176 passing (100%) OTEL Validation: ✅ 100/100 (production ready) Poka-Yoke Guards: ✅ 24/24 from FMEA analysis

Before Production Deployment

# 1. Run tests
pnpm test
# Expected: 176/176 passing

# 2. OTEL validation (required for production)
node validation/run-all.mjs comprehensive
# Expected: Score ≥ 80/100

Performance (Measured)

| Operation | Latency (100 quads) | Latency (10K quads) | |-----------|-------------------|-------------------| | appendEvent | ~0.8ms | ~3.5ms | | freezeUniverse | ~52ms | ~650ms | | reconstructState (with snapshot) | ~45ms | ~380ms | | reconstructState (cold) | ~150ms | ~6.5s |

See BENCHMARKS.md for detailed performance analysis and optimization patterns.

Examples

Quick demos in examples/:

node examples/basic-usage.mjs              # Simple freeze + time-travel
node examples/mission-critical.mjs         # All 8 use cases
node examples/local-first-collaboration.mjs # Real-time sync patterns

Architecture Principles

  • Zero-Information Invariant: Entire universe at any time reconstructible from Event Log + Git
  • ACID Semantics: Atomic event append with manual rollback on failure
  • Poka-Yoke: 24 guards prevent invalid operations (from FMEA analysis)
  • Receipt-Driven: Every operation returns cryptographic proof
  • Dual Named-Graph: kgc:Universe (hot) + kgc:EventLog (history) separation

For deep technical analysis, see ARCHITECTURE-DEEP-DIVE.md.

Dependencies

Core (Monorepo):

  • @unrdf/core - UnrdfStore foundation
  • @unrdf/oxigraph - RDF semantic store

External (ARD-Compliant):

  • hash-wasm - BLAKE3 hashing (fastest WASM implementation)
  • isomorphic-git - Pure JS Git (Node.js + Browser)

Total: 2 external dependencies, 0 CLI tools required.

Contributing

See CONTRIBUTING.md in the main UNRDF project.

License

MIT - See LICENSE


Quick Decision Tree

Need to...

Support


Status: Production-ready with comprehensive test coverage and OTEL validation. See docs/ for complete documentation organized by learning style (Tutorials → How-To → Reference → Explanation).