Extensible, non-linear state travel powered by the Tachyon-RS engine.
Project description
Janus 🏺
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
- Extensible Plugin Registry: Register a
JanusAdapterto trackpandas.DataFrames,numpy.ndarrays,torch.Tensors, or any custom object without slowing down the core engine. - Timeline Extraction: Flatten complex multiversal paths into linear audit sequences for visualization and debugging.
- Third-Party Integration: Built-in
TrackedDataFrameandTrackedNumpyArraysupport 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file janus_tachyon_rs-0.2.1.tar.gz.
File metadata
- Download URL: janus_tachyon_rs-0.2.1.tar.gz
- Upload date:
- Size: 267.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a5573b5c60709d9bf8fcd35e32f43ec930f675e16b141ebbbbcbf1fdddb07ad
|
|
| MD5 |
5a7aadd5641e5cc74262d90aa1f263cd
|
|
| BLAKE2b-256 |
80f9bbe3a402a381927f6879b4bd4040bf047ccfa7ebacde4d4d239612dcc612
|
File details
Details for the file janus_tachyon_rs-0.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 458.8 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2baeafee3a480a5822135a2cbb73d0734540c97e5550e574a1cf81ee06819d
|
|
| MD5 |
b2665f26bcbbe250e4f8d33ea85a0ad6
|
|
| BLAKE2b-256 |
43fae06af2b764d84f739172fa6ca433f9b32eebae86b88df34149f3409a792c
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 315.1 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fde38c254fd6b0e4ceebafd744550e0ca70afa64e5b07760d160d94b620df494
|
|
| MD5 |
7ddf9eb5758c0ce2665b650529528683
|
|
| BLAKE2b-256 |
54b0d04fe685b77d969dd9accd9edc49da0a9b09cd2843238816685021e0dc8c
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-win32.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-win32.whl
- Upload date:
- Size: 296.7 kB
- Tags: CPython 3.11+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec517f522c98a88418c77dfc4efb14143cdcf78493ef1a5138630cca099cc112
|
|
| MD5 |
9bbcb56c20f13e53f5f83e1671fda1c0
|
|
| BLAKE2b-256 |
b30fa44451b043a77bcef527977af5b9fe7615e8246edebfd0406b5682b5011e
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 459.7 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b80c9a412a8e23a94b1d7db7379ebdaa0ecd3beef8f8c4c1e1d3432b4229b056
|
|
| MD5 |
3785b1133fc993b23cceca70cf1ea761
|
|
| BLAKE2b-256 |
111428e63700308561366fd97eac7ab99f53c3f0de3bfae7d7841fb75461a669
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 444.2 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5495e5866d329ad72d7f2b9d7f6bfbf5f3013a1fa9d6908b7cbdea2340449580
|
|
| MD5 |
dcee6a35e95eeea7c69b8eb7d1a7e5c9
|
|
| BLAKE2b-256 |
d7707d12f03e51a4005879fc6b5c62f0c686df2c4eaf85ca11df2b6787dafcf4
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 408.7 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8123dc46886491427af7df20ad7824c53441e9d2e1b95c678120b4f42d15b1b
|
|
| MD5 |
e30b827f32ba02a6acf0874d6c87097d
|
|
| BLAKE2b-256 |
5dc2baed7b1d2e0cd501aff6d3ac0ec0996aa78207e1cd53a7f57e82d1fa7abe
|
File details
Details for the file janus_tachyon_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: janus_tachyon_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 427.3 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baf4b0ca5dc9e7cb7431370de90a339bd26e40abad9d87c2e5e2438fd848437d
|
|
| MD5 |
a3ab7a26ff7d3129b84216a8e36b7108
|
|
| BLAKE2b-256 |
02db5ade4719840dce6a6551b0649514d2718f0cfb38b7379a53e760bb2b6226
|