Converge versioned payloads to any target schema without coordinated releases.
Quick start · Docs · Examples · API
Every versioned payload you have ever produced is still out there.
Old records in a database. Messages waiting in a queue. A partner integration
that still sends 1.0.0. A nested customer object inside an order from six
deployments ago. You can change the current schema, but you cannot make every
producer and consumer change at the same moment.
That is the problem pyverge removes.
A payload is not one schema. It is a graph of versioned facts.
Order 1.0.0
└── Customer 2.0.0
└── Address 1.0.0
Each fact has an identity. Each identity can move to a newer version. A migration is an edge between two identities.
pyverge lets you describe that graph once, then converge any payload to any target version — including nested entries — without coordinating releases.
The graph separates three things that usually get tangled together:
- identity — what version of what kind, in which namespace;
- schema — the model that describes a node;
- execution — the migration code that moves an edge forward.
That separation is what makes old payloads safe to keep.
A node is a namespace, a kind, and a version. An edge connects two nodes.
from pyverge.versioning import EdgeKey, NodeId, VersionKey
user_v1 = NodeId.parse("com.acme.users", "User", "1.0.0")
user_v2 = NodeId.parse("com.acme.users", "User", "2.0.0")
user_key = VersionKey.parse("com.acme.users", "User", "1.0.0")
migration_edge = EdgeKey.from_pair(user_v1, user_v2)
assert str(user_v1) == "com.acme.users:User@1.0.0"
assert str(user_key) == "com.acme.users:User@1.0.0"
assert migration_edge.source == user_v1A key is enough to describe topology. It can exist before the model is loaded.
Adapters turn provider models into full version nodes. Storing a key first and hydrating it later lets discovery, routing, and model loading happen on their own schedules.
from typing import Literal
from pydantic import BaseModel
from pyverge.registry import Registry
from pyverge.schemas import ModelCodec, PydanticModelAdapter
from pyverge.versioning import VersionKey, default_content_hasher
class UserV1(BaseModel):
kind: Literal["User"] = "User"
version: Literal["1.0.0"] = "1.0.0"
name: str
email: str
adapter = PydanticModelAdapter(
codec=ModelCodec(
namespace="com.acme.users",
version_property="version",
kind_property="kind",
)
)
registry = Registry(
namespace="com.acme.users",
hasher=default_content_hasher(),
)
key = VersionKey.parse("com.acme.users", "User", "1.0.0")
registry.store(key) # topology first
registry.hydrate(adapter.versionable(UserV1))
assert registry.find_model(key) is not Nonestore() accepts a key or a full node. hydrate() upgrades a key-only
placeholder with a model. reconcile() is a separate operation for schema
reconciliation between full nodes. Hydration never invents a model that was
never registered.
Once the identities exist, the graph can decide how to get from one version to another.
from pyverge.graph import GraphBuilder
graph = GraphBuilder().build(registry)
assert graph.get_model(key).model_id.endswith("UserV1")A snapshot may contain key-only and hydrated entries. EdgeKey is edge
identity; VersionEdge adds the diff and executable migration. Snapshots keep
identity and serializable migration metadata, never Python callables.
Before execution, the graph must prove that the complete selected path is ready: every node on the path hydrated, every edge bound. A key-only node or unbound edge forbids execution.
The manager is the everyday interface. It accepts model classes and decorators, normalizes them into graph identity, and gives you a runner.
import semver
from pyverge import Manager
from pyverge.schemas import ModelCodec, PydanticModelAdapter
UserManager = Manager[semver.Version].configure(
PydanticModelAdapter(
codec=ModelCodec(
namespace="com.acme.users",
version_property="version",
kind_property="kind",
)
)
)
@UserManager.model()
class UserV1(BaseModel):
kind: Literal["User"] = "User"
version: Literal["1.0.0"] = "1.0.0"
name: str
email: str
@UserManager.model()
class UserV2(BaseModel):
kind: Literal["User"] = "User"
version: Literal["2.0.0"] = "2.0.0"
name: str
email: str
age: int | None = None
@UserManager.migration("User", "1.0.0", "2.0.0")
def add_age(data: dict, context=None) -> dict:
return {**data, "age": None}
manager = UserManager()
migrated = manager.runner().run(
{"kind": "User", "version": "1.0.0", "name": "Alice", "email": "a@b.com"},
"latest",
)
# {"kind": "User", "version": "2.0.0", "name": "Alice", "email": "a@b.com", "age": None}The old payload did not need to know that 2.0.0 existed. The new code did not
need to care that the payload was still 1.0.0.
Namespace is part of identity, not metadata attached after the fact:
NodeId,VersionKey, andEdgeKeycarry it.- A graph snapshot is single-namespace.
- Cross-namespace edges are rejected.
- JGF and manifest IDs render as
namespace:kind@version. - The adapter codec is the only namespace source.
Manager.configure()derives its registry namespace from the codec.
Use the empty namespace for one application. Use a domain namespace when multiple packages, tenants, or deployment units can register the same kind and version.
orders = Manager[semver.Version].configure(
PydanticModelAdapter(
codec=ModelCodec(
namespace="com.acme.orders",
version_property="version",
kind_property="kind",
)
)
)
billing = Manager[semver.Version].configure(
PydanticModelAdapter(
codec=ModelCodec(
namespace="com.acme.billing",
version_property="version",
kind_property="kind",
)
)
)Both may register User@1.0.0. They remain different identities:
com.acme.orders:User@1.0.0 and com.acme.billing:User@1.0.0.
Namespaces are also what keep references and manifest diffs unambiguous when graphs are compared across services.
A migration is not a script hidden in a release note. It is a named edge between two identities.
| Form | Best for | Runtime context |
|---|---|---|
| JSON Patch | structural changes | no |
| JSONata | declarative transformations | yes |
| Python callable | imperative logic | yes |
Choose the smallest form that expresses the change. The graph treats them the same way: an edge is executable only when its binding is present.
Runner.run() defaults:
container=None
max_depth=-1
context=None
Use context= for read-only bindings shared across every step:
result = manager.runner().run(
payload,
"latest",
context={"tenant_id": "tenant_99"},
)Async execution uses the same planning path:
from pyverge.execution import AsyncBackend
runner = manager.runner(
runtime=AsyncBackend(
backend="asyncio",
backend_options={},
max_workers=4,
)
)
result = await runner.run(payload, "latest")The graph is also a build artifact. The CLI can validate a payload, check compatibility, or emit a namespace-aware JGF manifest whose content hash changes only when the graph changes.
pyverge doctor --manager myapp.models:UserManager
pyverge validate data.json --manager myapp.models:UserManager \
--schema User --version 1.0.0
pyverge migrate data.json --manager myapp.models:UserManager --target latest
pyverge migrate data.json --manager myapp.models:UserManager --check
pyverge compat --manager myapp.models:UserManager --fail-on-breaking
pyverge manifest --manager myapp.models:UserManager > manifest.json
pyverge info --manager myapp.models:UserManagerManagers are module:object_path and may be an instance, a configured subclass,
or a zero-arg factory. Runtime schemas require a factory that builds the manager
from their source.
manifest is a CLI-only contract. Lifespan/startup does not write it. CI
commands (doctor, validate, migrate --check, compat) return non-zero on
failure. Config auto-discovery is not wired yet.
pip install pyverge # core library
pip install "pyverge[cli]" # CLI
pip install "pyverge[fastmcp]" # MCP tool server
pip install "pyverge[faststream]" # messaging adapterDevelopment: uv sync --group dev.
- Getting started
- Managers · Concepts
- Providers
- Migrations · Migration formats
- Runtime and execution · Execution flow
- Target policy · Compatibility
- API reference · Glossary
- Upgrade guide
- CLI reference · Telemetry and hooks
- FastMCP · FastStream · Celery · httpx
- Testing · Benchmarking
- Manager API · Use the manager
- Run payloads · Migrate nested payloads
- Scenarios
- Showcases
This project is licensed under the Apache License 2.0, except for files in the
tests/ directory, which are licensed separately under the GNU General Public
License v3.0 or later (GPL-3.0-or-later). The root LICENSE file applies to
library and runtime code, while tests/LICENSE governs the validation suite.
Upgrading from the previous Manager API? See the upgrade guide for
migrate/amigrate,MigrationSettings, runner, and import-path replacements.
Do not report security vulnerabilities through public issues. Use GitHub private vulnerability reporting. See SECURITY.md for scope, response targets, and disclosure timeline.