Skip to main content

Extensible, non-linear state travel powered by the Tachyon-RS engine.

Project description

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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

janus_tachyon_rs-0.2.0.tar.gz (267.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

janus_tachyon_rs-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (458.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

janus_tachyon_rs-0.2.0-cp311-abi3-win_amd64.whl (315.1 kB view details)

Uploaded CPython 3.11+Windows x86-64

janus_tachyon_rs-0.2.0-cp311-abi3-win32.whl (296.9 kB view details)

Uploaded CPython 3.11+Windows x86

janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (459.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (444.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

janus_tachyon_rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl (408.9 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

janus_tachyon_rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl (427.4 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file janus_tachyon_rs-0.2.0.tar.gz.

File metadata

  • Download URL: janus_tachyon_rs-0.2.0.tar.gz
  • Upload date:
  • Size: 267.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for janus_tachyon_rs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 70901d29aa6ac8bc4bd57e052fb9c4184fdf379c8f66208f2ec2079820a57934
MD5 c6a1a36bbe34e17fa3d13bdbc0936324
BLAKE2b-256 e617396051582ef037ef68c9d1de1985d46b2fb8aeb39d74e0f111dcf3de3cd1

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac86ecf6cf33bae083646e33200d82db0d2b088e880591a232b1f7d9f700418e
MD5 a57484193d393f644a30b1d7976eb80d
BLAKE2b-256 0d6db2c79c35fe9751f48808203cffd89224763ca267d2ff38ec386ca75c9bf7

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2c684411f1582b607a622d77f42d5a13c06defcce5119055166f939e7d7c442e
MD5 c528a1e6522ac0f0cfbb774376c80249
BLAKE2b-256 e7f7a04ffeecd882c5dedb512b0e4f1d717735697706aa614b8671d16c99e018

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-win32.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 c40f8fdc099baa638c95eb090e436ac141727907dcc9f2b25fcdd54a9e67177a
MD5 530803e4667ef162607e2bfa9e049129
BLAKE2b-256 c65983d6b40153e5a7ff6660a6b0cc198ca24e366a991128715566250d8928c2

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7ef4632bbc4cee3ba2e05159e46592afd7fe68fd4e0d46166da7cec4c1dbb4b
MD5 a01026db4f129764412bc831b508c541
BLAKE2b-256 a639426c7d782f952a5cc80cf559c37f3438f640ffb351219051c1d5d4fb87ce

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c31c488bcec2079c9344c9602e02e71ba5180cdd55f7427504b74e5ec31e5b67
MD5 2942bc28f4f66d836b8980ab5723523a
BLAKE2b-256 04377ff1876560dfcd4232fd29c7b277f652e4c92f8924931c42963a0567e0c9

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3dcfd86c2f4fcaa644cc3060f88bb365c7545fa02a913a8fa51461c912a8a5bd
MD5 058bbb3d9d1653d89d35a393f1d6cc99
BLAKE2b-256 1b3c11f3909ce1839cd3a672a86bad12b9749475c90a8ef1c312d43ee6839aa2

See more details on using hashes here.

File details

Details for the file janus_tachyon_rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for janus_tachyon_rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6fe90ee9e12f7cc6e3c0c825aa405c4e0a044500cd752c82af9a6efd5a53b59
MD5 3437747213c920f7cf252b25c4742df5
BLAKE2b-256 026dd2a3bb3f28d6e2fe70bc5e4f1dceda1114eaa87b7caa64be447619f8cfb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page