Skip to main content

Janus 🏺

Janus CI License: MIT/Apache-2.0 Python 3.11+

The Extensible Multiverse Engine for Python Objects.

Janus provides a Git-like API for branching, switching, and flattening the state of complex Python objects, powered by a lightning-fast Rust backend (Tachyon-RS). No deep-copying, no manual history tracking, and near-zero performance penalties.

📦 Installation

pip install janus-tachyon-rs

🚀 Getting Started

Janus allows you to opt-in to complexity. Start with a simple linear history or dive into multiversal branching.

Linear Mode — Undo / Redo

from janus import TimelineBase

class Document(TimelineBase):
    def __init__(self) -> None:
        super().__init__()
        self.text = ""

doc = Document()
doc.text = "Hello"
doc.text = "Hello World"

doc.undo()
print(doc.text)  # "Hello"

doc.redo()
print(doc.text)  # "Hello World"

Multiversal Mode — Branching

from janus import MultiverseBase

class Simulation(MultiverseBase):
    def __init__(self) -> None:
        super().__init__()
        self.points = [1, 2, 3]

sim = Simulation()
sim.branch("stable")

# Perform mutations
sim.points.append(999)
print(sim.points)  # [1, 2, 3, 999]

# Multiversal rollback via Tachyon-RS
sim.jump_to("stable")
print(sim.points)  # [1, 2, 3]

📊 Visualization

Janus features a built-in visualization suite to inspect the state DAG.

Basic Visualization (Mermaid)

# Returns a Mermaid.js diagram string
print(sim.visualize())

Pluggable Backends (Matplotlib)

Janus supports multiple backends through the plot() API:

# Renders a graphical plot using Matplotlib/NetworkX
fig = sim.plot(backend="matplotlib", title="Multiverse History")

Mermaid Output Example:

graph LR
    node0("Node 0<br/><b>__genesis__</b>")
    style node0 fill:#e1f5fe,stroke:#01579b
    node1["Node 1"]
    node2("Node 2<br/><b>dev</b>")
    style node2 fill:#e1f5fe,stroke:#01579b
    node3["Node 3"]
    node4(("Node 4<br/><b>main</b>"))
    style node4 fill:#ff9ce6,stroke:#333,stroke-width:4px
    node0 --> node1
    node1 --> node2
    node1 --> node3
    node3 --> node4
    node2 --> node4

🔀 Container-Aware Merging

Janus supports intelligent 3-way reconciliation for native Python lists and dictionaries. Unlike blind-append approaches, Janus rebases parallel mutations:

  • List Index Shifting: If two branches insert items at different indices, Janus automatically shifts indices to preserve intent.
  • Conflict Detection: Detects and resolves parallel edits to the same dictionary keys or list positions according to configurable strategies (strict, overshadow, preserve).
  • Custom Callbacks: Provide a custom Python function to resolve conflicts with domain-specific logic (e.g., averaging numeric values).
def average_strategy(name, base, source, target):
    if isinstance(source, (int, float)):
        return (source + target) / 2
    return source  # Default to source for other types

sim.merge("feature", strategy=average_strategy)

🧹 History Management

To maintain peak performance in long-running simulations, Janus supports automated history pruning. You can limit the depth of the state DAG to keep memory and traversal costs constant:

# Keep only the last 1,000 mutations
sim.max_history = 1000

# Or manually trigger a prune
sim.prune()

🏗️ Architectural Pillars

  1. Extensible Plugin Registry: Register a JanusAdapter to track pandas.DataFrames, numpy.ndarrays, torch.Tensors, or any custom object without slowing down the core engine.
  2. Timeline Extraction: Flatten complex multiversal paths into linear audit sequences for visualization and debugging.
  3. Third-Party Integration: Built-in TrackedDataFrame and TrackedNumpyArray support with full indexer and view-tracking.

🚀 Use Cases

  • AI Agent Experiments: Allow agents to test multiple paths in parallel and revert with knowledge of failed states.
  • Data Science Workflows: Instantly reverse complex object states without rerunning expensive computation cells.
  • Non-Linear Document History: Manage "what-if" scenarios for complex file and data structures.

📚 Documentation

The full documentation is available at janustachyon-rs.readthedocs.io.

⚡ Powered by Tachyon-RS

Under the hood, Janus offloads all state delta logic to Tachyon-RS, a modularized Rust engine that operates on a Directed Acyclic Graph (DAG) of state nodes. By storing only bi-directional operations and utilizing specialized modules for graph traversal and reconciliation, Tachyon-RS enables time travel with $O(1)$ logging overhead.

License

Janus is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Metadata

Release files for janus-tachyon-rs 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for janus-tachyon-rs 0.2.1
File Size Uploaded
janus_tachyon_rs-0.2.1.tar.gz 267.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for janus-tachyon-rs 0.2.1
File
janus_tachyon_rs-0.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.11 PyPy 3.11 7.3 Linux glibc 2.17+ x86-64 Details
janus_tachyon_rs-0.2.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
janus_tachyon_rs-0.2.1-cp311-abi3-win32.whl CPython 3.11 abi3 Windows x86-32 Details
janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
janus_tachyon_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
janus_tachyon_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.1 MB

Release files / janus_tachyon_rs-0.2.1.tar.gz

Download URL janus_tachyon_rs-0.2.1.tar.gz
Size 267.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4a5573b5c60709d9bf8fcd35e32f43ec930f675e16b141ebbbbcbf1fdddb07ad
BLAKE2b-256 checksum
How to use checksums
80f9bbe3a402a381927f6879b4bd4040bf047ccfa7ebacde4d4d239612dcc612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL janus_tachyon_rs-0.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 458.8 kB
Tags Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3
SHA-256 checksum
How to use checksums
fe2baeafee3a480a5822135a2cbb73d0734540c97e5550e574a1cf81ee06819d
BLAKE2b-256 checksum
How to use checksums
43fae06af2b764d84f739172fa6ca433f9b32eebae86b88df34149f3409a792c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-win_amd64.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-win_amd64.whl
Size 315.1 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fde38c254fd6b0e4ceebafd744550e0ca70afa64e5b07760d160d94b620df494
BLAKE2b-256 checksum
How to use checksums
54b0d04fe685b77d969dd9accd9edc49da0a9b09cd2843238816685021e0dc8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-win32.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-win32.whl
Size 296.7 kB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
ec517f522c98a88418c77dfc4efb14143cdcf78493ef1a5138630cca099cc112
BLAKE2b-256 checksum
How to use checksums
b30fa44451b043a77bcef527977af5b9fe7615e8246edebfd0406b5682b5011e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 459.7 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b80c9a412a8e23a94b1d7db7379ebdaa0ecd3beef8f8c4c1e1d3432b4229b056
BLAKE2b-256 checksum
How to use checksums
111428e63700308561366fd97eac7ab99f53c3f0de3bfae7d7841fb75461a669
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 444.2 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5495e5866d329ad72d7f2b9d7f6bfbf5f3013a1fa9d6908b7cbdea2340449580
BLAKE2b-256 checksum
How to use checksums
d7707d12f03e51a4005879fc6b5c62f0c686df2c4eaf85ca11df2b6787dafcf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Size 408.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e8123dc46886491427af7df20ad7824c53441e9d2e1b95c678120b4f42d15b1b
BLAKE2b-256 checksum
How to use checksums
5dc2baed7b1d2e0cd501aff6d3ac0ec0996aa78207e1cd53a7f57e82d1fa7abe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / janus_tachyon_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL janus_tachyon_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 427.3 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
baf4b0ca5dc9e7cb7431370de90a339bd26e40abad9d87c2e5e2438fd848437d
BLAKE2b-256 checksum
How to use checksums
02db5ade4719840dce6a6551b0649514d2718f0cfb38b7379a53e760bb2b6226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

8 release files

0.2.0

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page