Dagr
Dagr ("Data Graph") is a binary serialization format for data graphs — object graphs with cycles and shared nodes — and a set of code generators that emit a complete, self-contained implementation of your schema for Swift, Rust, TypeScript, Go, Mojo, Odin and Python.
You describe a graph once, in a small Python DSL:
from dagr.dsl import DataGraph, Node, Enum, t, required
from dagr.config import Library, Swift, Rust
address_book = DataGraph("AddressBook", root_type=t.ref("Book"), node_types=[
Node("Book", fields=["people" >> t.ref("Person").array]),
Node("Person", fields=[
"name" >> t.utf8 >> required,
"age" >> t.u8,
"friends" >> t.ref("Person").array, # cycles and shared nodes are fine
"status" >> t.ref("Status"),
]),
Enum("Status", ["single", "married", "widowed"]),
])
library = Library("AddressBook", schemas=[address_book], targets=[
Swift(out="gen/swift", features=["lazy", "path_query", "explain"]),
Rust(out="gen/rust", features=["lazy", "path_query"]),
], wire_format_version=1)
dagr build then generates, per language, an arena-backed typed API (no reference
cycles to leak, value-type handles), byte-exact serialization and restore, and optionally
zero-allocation lazy accessors, path queries that read one field straight out of a
buffer, and an explain tool that annotates every byte. The generated code has no runtime
dependency — the runtime is emitted alongside it.
Why Dagr
- Graphs, not trees. Cycles, back-references and shared nodes serialize naturally; the arena model is what makes that safe in every target language.
- One schema, seven languages, identical bytes. Swift, Rust, TypeScript, Go, Mojo, Odin and Python read and write the same buffers; a cross-language test corpus of ~1000 fixture permutations gates every change byte-for-byte.
- Four node layouts to choose from. Regular (vtable, evolvable), packed (compact),
frozen (fixed-offset, O(1) reads) and frozen+packed — per node type, per schema
(
spec/16-choosing-a-node-layout.md). - More than graphs.
DataSinkis an append-only record stream with the same type system (logs, event streams, attestable audit trails);SharedBufferis a fixed-layout overlay for IPC, GPU and no-allocation embedded use, with seqlock, ring and double-buffer strategies. - Tooling around the format. Schema import from
.proto, FlatBuffers, JSON Schema and ASN.1; generation receipts and compatibility checks (dagr check); a browser schema editor (dagr ui); self-contained HTML explorers for any buffer; git diff and three-way merge drivers; an ImHex pattern exporter; a fuzzer; Arrow producers.
Install
The tool is pure Python 3.9+ with no dependencies.
pip install dagr-cli # or: uv tool install dagr-cli; from a checkout: pip install -e .
dagr init --name my_schema # scaffolds schema.py + pyproject.toml
dagr build # generates every target in Library.targets, writes dagr.lock.json
dagr check # diffs the schema against the committed receipt
Compiling and running the generated code needs the respective toolchain (Swift 6.2, Rust 1.85+, Node 20+, Go 1.22+, Mojo 1.0 via pixi, Odin). Generating never does.
Targets
| Target | Arena + serde | Lazy | Path query | Explain | DataSink | SharedBuffer | Notes |
|---|---|---|---|---|---|---|---|
| Swift | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | primary target |
| Rust | ✓ | ✓ | ✓ | ✓ (tooling) | ✓ | ✓ | primary target; no_std tiers, Arrow, fuzz, git tools |
| TypeScript | ✓ | ✓ | – | – | ✓ | ✓ | HTML explorers are generated TS |
| Go | ✓ | ✓ | – | – | ✓ | ✓ | direct builder; io.Writer sinks; sync/atomic SharedBuffer strategies |
| Mojo | ✓ | ✓ | ✓ | – | ✓ | ✓ (+GPU) | |
| Odin | ✓ | ✓ | – | – | ✓ | ✓ | |
| Python | ✓ (reflective) | – | – | – | ✓ | ✓ (numpy zero-copy) | plus a native Arrow target |
Documentation
spec/— the numbered wire-format specification and design plans; start withspec/README.md, thenspec/01-motivation-for-arenas.md.docs/technical-feature-overview.md— every feature with an engineering assessment.examples/— worked examples: an attested audit log, JWT-shaped tokens, a structured log sink, a package registry, stress graphs, a Swift↔Rust FFI demo.CONTRIBUTING.md— repository layout, toolchains, and the generate → test loop.
Repository layout
dagr/ the Python package: DSL, config, CLI, code generators, importers, runtime, web UI
spec/ numbered specification documents
targets/ per-language runtimes, example packages and generated test crates
tests/ test generators, runners, unit tests, fixture schemas and (generated) fixture corpora
examples/ worked examples built with `dagr build`
benchmarks/ micro-benchmarks
site/ showcase site and spec-document generators
docs/ prose documentation, blog posts, images
Generated code is not committed. After cloning, run ./regen_all.sh once to emit every
generated source, fixture and test suite (see CONTRIBUTING.md).
Status
Dagr is used in production-style projects by its author and is versioned by CalVer
(2026.9.0); the wire format is versioned separately per schema (wire_format_version) and
checked by dagr check. Swift and Rust are the most complete targets; see CHANGELOG.md for
what changed and spec/30-deferred-codegen-gaps.md for known gaps per target.
License
Apache License 2.0 — see LICENSE.
Metadata
Release files for dagr-cli 2026.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dagr_cli-2026.10.2.tar.gz | 2.0 MB | Without provenance | Details for dagr_cli-2026.10.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dagr_cli-2026.10.2-py3-none-any.whl | Python 3 | none | any | Details for dagr_cli-2026.10.2-py3-none-any.whl |
Total release size: 4.2 MB
Release files / dagr_cli-2026.10.2.tar.gz
| Download URL | dagr_cli-2026.10.2.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96e9d9de633a7d25f1f4d89bc75265d590f3dc83460dc3a3557fe8a6d8f19281
|
|
BLAKE2b-256 checksum How to use checksums |
bf162a9af92258834115a29acb47fcbf66168d664511b0390da03cb7ee809f6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / dagr_cli-2026.10.2-py3-none-any.whl
| Download URL | dagr_cli-2026.10.2-py3-none-any.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfd0d5ce6f56b617d905d4a5d60b1f8de9fb4afd94951b60a7c5547de2b41400
|
|
BLAKE2b-256 checksum How to use checksums |
6086879e2993f117b85defe3fe85368d17526cc075b974b64f66659f8b55add4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for dagr-cli 2026.10.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.