Skip to main content

weaver_contracts Python Package

Minimal Python contracts for the Weaver Stack.

This package provides dataclasses and type definitions for all Core Weaver contracts. It has no runtime dependencies beyond the Python standard library (Python 3.9+).


Installation

pip install weaver_contracts

For development (includes pytest and jsonschema):

pip install "weaver_contracts[dev]"

Verifying SLSA build provenance

Starting with version 0.3.0, releases ship with a PEP 740 Sigstore-signed SLSA build provenance attestation. Earlier releases (0.2.0 and below) do not carry an attestation. Verify a downloaded wheel before installing in production:

pip install sigstore
pip download "weaver_contracts==<VERSION>" --no-deps -d ./dist
sigstore verify identity \
  --cert-identity-regexp '^https://github.com/dgenio/weaver-spec/' \
  --cert-oidc-issuer 'https://token.actions.githubusercontent.com' \
  ./dist/weaver_contracts-*.whl

See SECURITY.md for the full adopter security guidance.


Usage

from weaver_contracts import (
    SelectableItem,
    ChoiceCard,
    RoutingDecision,
    Capability,
    CapabilityToken,
    PolicyDecision,
    Frame,
    Handle,
    TraceEvent,
)
from weaver_contracts.version import CONTRACT_VERSION, is_compatible
from datetime import datetime, timezone

# Routing
item = SelectableItem(id="search-1", label="Search docs", description="Search documentation")
card = ChoiceCard(id="card-1", items=[item], context_hint="Select a retrieval action")
rd = RoutingDecision(
    id="rd-abc",
    choice_cards=[card],
    timestamp=datetime.now(timezone.utc),
    selected_item_id="search-1",
)

# Authorization
token = CapabilityToken(
    token_id="tok-xyz",
    principal="my-agent",
    scope=["org.myapp.search_docs"],
    issued_at=datetime.now(timezone.utc),
    expires_at=datetime(2099, 1, 1, tzinfo=timezone.utc),
)

# Frame (safe output)
frame = Frame(
    frame_id="frame-001",
    capability_id="org.myapp.search_docs",
    summary="Found 3 documents matching 'query'.",
    created_at=datetime.now(timezone.utc),
    handle_refs=["handle-abc"],  # reference to raw artifact
)

Contract Tiers

Module Contents Stability
weaver_contracts.core Core contracts (all 9 types) Stable within major version
weaver_contracts.extended Optional metadata types May evolve in minor versions
weaver_contracts.version Version constants + is_compatible() Stable

Running Tests

cd contracts/python
pip install -e ".[dev]"
pytest

Schema Alignment

The JSON Schemas in contracts/json/ are the language-agnostic source of truth. The Python types mirror the schemas exactly. If a schema changes, the corresponding Python type and tests should be updated in the same PR.

Metadata

Release files for weaver-contracts 0.7.0

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

Source distribution (sdist)

Source distribution for weaver-contracts 0.7.0
File Size Uploaded Provenance
weaver_contracts-0.7.0.tar.gz 37.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for weaver-contracts 0.7.0
File Interpreter ABI Platform
weaver_contracts-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.6 kB

Release files / weaver_contracts-0.7.0.tar.gz

Download URL weaver_contracts-0.7.0.tar.gz
Size 37.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f51cf76a9dc69fbf4f694ff0f943cc33deca0d2a1832dc015af8a84cd6f6b606
BLAKE2b-256 checksum
How to use checksums
29ff399f26978455aad84ff48896ae01782c6c6025b3bdb1808adc6e79601ab7
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 6, 2026.

Transparency log

Release files / weaver_contracts-0.7.0-py3-none-any.whl

Download URL weaver_contracts-0.7.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
068e829bc7c8d515809e83e4244649be845599ccaf14574f4db7e14fbc7e5465
BLAKE2b-256 checksum
How to use checksums
20e27d6e789cdb48cb2d8345bdcc05d1d2cec2b493552b818c085269221ffa4d
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 6, 2026.

Transparency log

Security for weaver-contracts 0.7.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 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for weaver_contracts-0.7.0.tar.gz

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 6, 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.

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