Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

trrack

PyPI

Branching, tree-based provenance tracking for Python. A pure model with no UI dependencies: a ProvenanceGraph of full-state snapshots you can navigate, branch, label, and persist.

Part of the trrackpy monorepo; the trrack-widget package is one consumer of this core.

Install

uv add trrack          # or: pip install trrack

Concepts

  • Every state you record is stored as a full snapshot in a Node. Nodes form a tree: committing from an earlier node creates a branch rather than discarding the later history.
  • The model is deterministic and I/O-free. It never reads the clock — timestamps are passed in by the caller via now — so behavior is fully reproducible and easy to test.
  • Persistence is an optional, swappable seam (Store); the model itself holds no opinion about where state is saved.

Quick start

from trrack import ProvenanceGraph

g = ProvenanceGraph({"count": 0}, now="t0")
g.commit({"count": 1}, now="t1")
g.commit({"count": 2}, now="t2")

g.undo()                 # back to {"count": 1}
g.redo()                 # forward to {"count": 2}

# Branch: go back, then commit a different state off the earlier node.
g.go_to(g.root.id)
g.commit({"count": 99}, now="t3")   # new branch from the root

g.current.state          # {"count": 99}
g.is_at_root, g.is_at_latest

Commits are auto-labeled from what changed; pass label= to name them, or relabel later with g.relabel("checkpoint").

Persistence

Round-trip the whole graph to a JSON file:

g.save("graph.json")
restored = ProvenanceGraph.load("graph.json")   # None if the file is absent

save/load use atomic writes (write-to-temp, then os.replace) so a crash mid-write can never leave a half-written file.

For anything other than a local file, use the Store seam — any object with save(dict) -> None and load() -> dict | None qualifies (a database, browser storage, a remote service), with no registry or plugin machinery. JsonFileStore is the built-in implementation:

from trrack import JsonFileStore

store = JsonFileStore("graph.json")
store.save(g.to_dict())
data = store.load()                  # None if nothing saved yet

API

ProvenanceGraph(root_state, *, now, root_id=None) Create a graph with a single root node.
.commit(state, *, now, label=None, node_id=None) Append state as a child of the current node and move there.
.undo() / .redo() Move to the parent / a child of the current node.
.go_to(node_id) Jump to any node by id.
.relabel(text, node_id=None) Rename a node (defaults to current).
.current / .root The current / root Node.
.is_at_root / .is_at_latest Navigation guards (nothing to undo / redo).
.to_dict() / ProvenanceGraph.from_dict(data) Serialize / deserialize.
.save(path) / ProvenanceGraph.load(path) JSON file persistence.

A Node exposes id, parent, children, created_at, label, and state.

License

BSD-3-Clause.

Metadata

Release files for trrack 0.0.1a2

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

Source distribution (sdist)

Source distribution for trrack 0.0.1a2
File Size Uploaded
trrack-0.0.1a2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trrack 0.0.1a2
File Interpreter ABI Platform
trrack-0.0.1a2-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / trrack-0.0.1a2.tar.gz

Download URL trrack-0.0.1a2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8d91bfdfac71a479d2fa41e58d4f2e5dac06fcc6d6aac98ef46d0aba5dd265da
BLAKE2b-256 checksum
How to use checksums
7077a50571a39e002d9518caf14f1e4c429775b0b99da84425e3140102988327
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.

Transparency log

Release files / trrack-0.0.1a2-py3-none-any.whl

Download URL trrack-0.0.1a2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
863f7bdfdc4513ca4043a604af9567a7c7361388b3d59643f6e2df11797f9744
BLAKE2b-256 checksum
How to use checksums
327ffb7dbcfe4cb4d176939a8666f596eec5a62eb4c21fefbde68ea4905999c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1a2 This release

2 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