Minimal Python contracts for the Weaver Stack (contextweaver, agent-kernel, ChainWeaver)
Project description
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]"
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weaver_contracts-0.2.0.tar.gz.
File metadata
- Download URL: weaver_contracts-0.2.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4fc6773526ef1b433eecb0cf10d6c46da4fb133a6eee390b33321b7678a5fa3
|
|
| MD5 |
dee08a3397d5ec11d75738d9499f5a4b
|
|
| BLAKE2b-256 |
addf7653f501d321bd6acff1e9675bfbc3c70fac4915e1e4f37e23ad4c25212f
|
Provenance
The following attestation bundles were made for weaver_contracts-0.2.0.tar.gz:
Publisher:
publish.yml on dgenio/weaver-spec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weaver_contracts-0.2.0.tar.gz -
Subject digest:
a4fc6773526ef1b433eecb0cf10d6c46da4fb133a6eee390b33321b7678a5fa3 - Sigstore transparency entry: 1278760451
- Sigstore integration time:
-
Permalink:
dgenio/weaver-spec@72efb2a057f752e306319e3af0bfd807af996271 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dgenio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@72efb2a057f752e306319e3af0bfd807af996271 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file weaver_contracts-0.2.0-py3-none-any.whl.
File metadata
- Download URL: weaver_contracts-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e3ce7417e621d1604d1394e7b0502587f605ff4a14c7ceba96b8db2582529a2
|
|
| MD5 |
31be61dbe777c00fdf28596477390786
|
|
| BLAKE2b-256 |
9a235c5801668738688c5690f851ddbe3ec037b3ee254709d61fc5fba09b86f3
|
Provenance
The following attestation bundles were made for weaver_contracts-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on dgenio/weaver-spec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weaver_contracts-0.2.0-py3-none-any.whl -
Subject digest:
7e3ce7417e621d1604d1394e7b0502587f605ff4a14c7ceba96b8db2582529a2 - Sigstore transparency entry: 1278760646
- Sigstore integration time:
-
Permalink:
dgenio/weaver-spec@72efb2a057f752e306319e3af0bfd807af996271 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dgenio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@72efb2a057f752e306319e3af0bfd807af996271 -
Trigger Event:
workflow_dispatch
-
Statement type: