Skip to main content

panproto

PyPI Python License: MIT

This package exposes panproto's Rust libraries to Python through PyO3. It does not start a subprocess or load the WebAssembly build. Python 3.13 or newer is required.

The package is pre-1.0. A minor release may change the Python API, and the package version follows the Rust workspace version.

Installation

pip install panproto

Release workflows build wheels for Linux on x86-64 and AArch64, macOS on Apple Silicon and x86-64, and Windows on x86-64. A source build requires Rust and maturin.

Quick start

Protocol.schema() returns a mutable SchemaBuilder. Builder methods update the builder and return None; call build() after all changes have been added.

import panproto

atproto = panproto.get_builtin_protocol("atproto")

old_builder = atproto.schema()
old_builder.vertex("post", "record", "app.bsky.feed.post")
old_builder.vertex("post:body", "object")
old_builder.vertex("post:body.text", "string")
old_builder.edge("post", "post:body", "record-schema")
old_builder.edge("post:body", "post:body.text", "prop", "text")
old_schema = old_builder.build()

new_builder = atproto.schema()
new_builder.vertex("post", "record", "app.bsky.feed.post")
new_builder.vertex("post:body", "object")
new_builder.vertex("post:body.content", "string")
new_builder.edge("post", "post:body", "record-schema")
new_builder.edge("post:body", "post:body.content", "prop", "content")
new_schema = new_builder.build()

report = panproto.diff_and_classify(old_schema, new_schema, atproto)
print(report.classification)
print(report.report_text())

CompatReport.classification is one of "fully-compatible", "backward-compatible", or "breaking". The object also exposes compatible, breaking_changes, non_breaking_changes, report_json(), and to_dict().

Migrations and lenses

MigrationBuilder records a source-to-target vertex map. Compile the result against its source and target schemas:

builder = panproto.MigrationBuilder()
builder.map_vertex("post", "post")
builder.map_vertex("post:body", "post:body")
migration = builder.build()

compiled = panproto.compile_migration(migration, old_schema, new_schema)

CompiledMigration.lift(instance, src_protocol, tgt_protocol=None) constructs a target instance from the mapped part of a source instance, validating the instance against the source schema under src_protocol and the result against the target schema under tgt_protocol (which defaults to src_protocol). This operation is the library's source-to-target surviving-fragment transfer. The categorical transports are separate: Delta reindexes a target instance back to the source, while a general left Kan extension computes the source-to-target Sigma transport. The vocabulary in plain terms defines both.

CompiledMigration.get(instance) and Lens.get(instance) project a source instance to a target-shaped view and return an opaque complement. Their corresponding put(view, complement) methods reconstruct a source instance.

lens, quality, proposals = panproto.auto_generate_lens(
    old_schema, new_schema, atproto
)
view, complement = lens.get(source_instance)
restored_source = lens.put(view, complement)

find_morphisms() and find_best_morphism() search for total schema morphisms. find_best_morphism() returns None when none exists. find_span() instead returns a SchemaSpan in every no-overlap case, with an empty apex representing the absence of shared structure.

The ProtolensChain.from_dsl_*() constructors retain both the structural chain and the lens-DSL compiler's value-level field transforms. Instantiating the chain installs those transforms in the compiled migration. to_json() and from_json() preserve them in the optional field_transforms member.

Tree-sitter grammar packages

The default source build enables the 11 group-core grammars: Python, JavaScript, TypeScript, Java, C#, C++, PHP, Bash, C, Go, and Rust. Optional companion wheels register other grammar groups through the panproto.grammars Python entry-point group. panproto-grammars-all contains all 261 grammars currently declared by panproto-grammars.

pip install panproto-grammars-functional

Constructing panproto.AstParserRegistry() loads metadata from installed companions. panproto._native.AstParserRegistry() constructs only the native registry. A companion whose metadata cannot be registered produces a RuntimeWarning for that grammar and does not stop the other grammars from loading.

Object ownership

PyO3 classes own Rust values directly. Several classes share immutable schemas through Rust reference counting, and Python releases those values when their wrappers are collected. There is no numeric handle API and no manual free function.

API reference

API Current behavior
parse_schema_document, parse_schema_source, parse_schema_bundle Parse schema documents or source-language definitions through the registered Rust parsers.
IoRegistry Parse and emit instances. Use len(registry) or list_protocols() to inspect the codecs in the installed build.
Theory, TheoryBuilder, create_theory, colimit_theories Construct and combine generalized algebraic theories.
Repository Open or create a filesystem-backed .panproto repository with commits, branches, tags, merge, rebase, stash, blame, bisect, data tracking, and garbage collection.
VcsRepository A separate in-memory wrapper with only add() and list_refs(). It is not a Repository subclass.
ProjectBuilder, build_project, parse_project Assemble multi-file projects.
AstParserRegistry, parse_source_file, ParseEmitLens Parse source files with the tree-sitter grammars present in the build or supplied by companion packages.
Expr, parse_expr, pretty_print_expr Parse, inspect, and evaluate the expression language through methods on Expr.

Repository reads accept full commit IDs, HEAD, branches, tags, and unique commit-ID prefixes of at least four hexadecimal characters. Prefix lookup is read-only and reports malformed, absent, ambiguous, and non-commit matches.

The type stub at src/panproto/_native.pyi gives the complete public signatures.

Repository.add_data(path, key=None, *, schema_id=None, skip_verify=False) normally validates against the staged schema, or HEAD when no schema is staged. Pass the full object ID of a persisted schema to bind one data set to that exact schema without changing HEAD or the staged schema. The committed data set retains the selected ID, and malformed, missing, or non-schema object IDs are rejected.

A data set records the protocol its records were validated under, so a later definition of the protocol's name changes nothing already staged or committed. add() stages the protocol a schema was built under, add_protocol(protocol) stages one by hand, and every commit keeps the protocols of the commits it is made from. Branches that give a name different protocols do not merge.

Development

Build the extension and run the Python test suite from this directory:

maturin develop
python -m pytest

A development build requires Rust, Python 3.13 or newer, and maturin.

Further reading

License

MIT

Metadata

Release files for panproto 0.78.0

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

Built distributions (wheels)

Table of built distributions (wheels) for panproto 0.78.0
File Actions
panproto-0.78.0-cp313-abi3-win_amd64.whl CPython 3.13 abi3 Windows x86-64 Details for panproto-0.78.0-cp313-abi3-win_amd64.whl
panproto-0.78.0-cp313-abi3-manylinux_2_28_x86_64.whl CPython 3.13 abi3 Linux glibc 2.28+ x86-64 Details for panproto-0.78.0-cp313-abi3-manylinux_2_28_x86_64.whl
panproto-0.78.0-cp313-abi3-manylinux_2_28_aarch64.whl CPython 3.13 abi3 Linux glibc 2.28+ ARM64 Details for panproto-0.78.0-cp313-abi3-manylinux_2_28_aarch64.whl
panproto-0.78.0-cp313-abi3-macosx_11_0_arm64.whl CPython 3.13 abi3 macOS 11.0+ ARM64 Details for panproto-0.78.0-cp313-abi3-macosx_11_0_arm64.whl
panproto-0.78.0-cp313-abi3-macosx_10_12_x86_64.whl CPython 3.13 abi3 macOS 10.12+ x86-64 Details for panproto-0.78.0-cp313-abi3-macosx_10_12_x86_64.whl

Total release size: 76.8 MB

Release files / panproto-0.78.0-cp313-abi3-win_amd64.whl

Download URL panproto-0.78.0-cp313-abi3-win_amd64.whl
Size 17.1 MB
Tags CPython 3.13 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ebc998d4940241c536a291b0ec56a5c33ee55df8a16e1d5536ee4ef7c8aeedd4
BLAKE2b-256 checksum
How to use checksums
2ef085bad2663540479f09f97c311660261edee95968ed06fdcfa42f437a429f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 25, 2026.

Transparency log

Release files / panproto-0.78.0-cp313-abi3-manylinux_2_28_x86_64.whl

Download URL panproto-0.78.0-cp313-abi3-manylinux_2_28_x86_64.whl
Size 15.7 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
ac49e546047bdad22ed9f023fcddf571ce62a0a76a2bf4125ab238dca1d27521
BLAKE2b-256 checksum
How to use checksums
0b2af7533d873662a183d6b9fee18ef0e003414d24936141e0167309259dc232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 25, 2026.

Transparency log

Release files / panproto-0.78.0-cp313-abi3-manylinux_2_28_aarch64.whl

Download URL panproto-0.78.0-cp313-abi3-manylinux_2_28_aarch64.whl
Size 14.4 MB
Tags CPython 3.13 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
65f0cc10d0b1d00e61b24befcc878348c383e8514f7bfaf26d4ae2ea293e15ae
BLAKE2b-256 checksum
How to use checksums
0260eb0ef7536f3fcb2e76879a21b733f57e81e725da08e7d5c9a22d5297cc1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 25, 2026.

Transparency log

Release files / panproto-0.78.0-cp313-abi3-macosx_11_0_arm64.whl

Download URL panproto-0.78.0-cp313-abi3-macosx_11_0_arm64.whl
Size 14.3 MB
Tags CPython 3.13 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
09f6034f374fd03340738e314d91af7e555f07dfdc5a0cad24dfeeca979b4188
BLAKE2b-256 checksum
How to use checksums
29498949ff3237b7863c4e421918fa8a92a207dacbd6e458a5fdb3e1705a84ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 25, 2026.

Transparency log

Release files / panproto-0.78.0-cp313-abi3-macosx_10_12_x86_64.whl

Download URL panproto-0.78.0-cp313-abi3-macosx_10_12_x86_64.whl
Size 15.4 MB
Tags CPython 3.13 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5ef79b30efe1ef3ff2611b8ba2bd500d69ec6741e688d8c92d4769e846ab902c
BLAKE2b-256 checksum
How to use checksums
2c75dc782754f4a0f2f4b7076467df7c49a10c4d0d24af7a346da99c9b4600fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 25, 2026.

Transparency log

Security for panproto 0.78.0

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for panproto-0.78.0-cp313-abi3-win_amd64.whl

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 Nov 25, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.78.0 This release

5 release files Full provenance

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