Skip to main content

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. DataSink is an append-only record stream with the same type system (logs, event streams, attestable audit trails); SharedBuffer is 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 with spec/README.md, then spec/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.

Release files for dagr-cli 2026.9.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 dagr-cli 2026.9.1
File Size Uploaded
dagr_cli-2026.9.1.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dagr-cli 2026.9.1
File Interpreter ABI Platform
dagr_cli-2026.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.0 MB

Release files / dagr_cli-2026.9.1.tar.gz

Download URL dagr_cli-2026.9.1.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
e44053447668fb938ad3f32b0e43da67dace14ae99399308f5e88a0e563c9a4a
BLAKE2b-256 checksum
How to use checksums
05c81283501988971cb0273b3a1378a450ac40df689992aab3ca133cc1cba86a
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.9.1-py3-none-any.whl

Download URL dagr_cli-2026.9.1-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
36981bb0f82aad7d072738e1aaeba4477c45624f846ee409b82292710de53f8c
BLAKE2b-256 checksum
How to use checksums
2f572edd5318965f4aea54f80cb51b8bd213d9d209a7831613b947e8beffdc23
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 history Release notifications | RSS feed

This release

2026.9.1 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