Skip to main content

quadkit-contracts

Core types and protocols for the Quadkit Framework.

Unstable (0.x). These protocols are not covered by a compatibility guarantee yet. Minor releases may add, rename, or remove members while the framework is pre-1.0.

This package is published whole, so it also carries protocols for Quadkit packages that are not released yet. Those are the most likely to change: they have not been exercised by a public implementation. Protocols used by quadkit, quadkit-web, quadkit-testing and quadkit-cli are the settled ones.

Pin an exact version (quadkit-contracts==0.1.1) if you depend on these types directly. Stability guarantees begin at 1.0.


Overview

quadkit-contracts defines all Protocols, base types, Result types, domain models, and exception hierarchies used across the Quadkit ecosystem. It has zero runtime dependencies so it can be imported into any package — including thin integrations — without pulling in the full framework.

This package is the single source of truth for every interface in Quadkit. All other packages depend on contracts; no implementation package defines its own protocol that another package depends on.

Full documentation: docs.quadkit.dev

Install

uv add quadkit-contracts

Quick Start

Result type

from quadkit.result import Result, Ok, Err


async def find_user(user_id: str) -> Result[User, UserNotFound]:
    user = await db.get(user_id)
    if not user:
        return Err(UserNotFound(user_id))
    return Ok(user)


# Safe consumption
result = await find_user("u-123")
name = result.match(ok=lambda u: u.name, err=lambda e: "unknown")

Domain models

from quadkit.domain.models import Entity, ValueObject
from quadkit.domain import AggregateRoot
from quadkit.contracts.domain.events import DomainEvent


class UserCreated(DomainEvent):
    user_id: str
    email: str


class User(AggregateRoot):
    email: str

Protocols

from quadkit.contracts.infra.cache import CacheBackendProtocol
from quadkit.contracts.data import DatabaseProviderProtocol
from quadkit.contracts.security.secrets import SecretStoreProtocol

Key Modules

Module What it contains
quadkit.result Result[T, E], Ok, Err, as_result(), as_result_sync(), try_catch(), ResultPipeline
quadkit.domain.models DomainModel, Entity, ValueObject (concrete domain models, in core quadkit)
quadkit.domain AggregateRoot (re-exported from quadkit.domain.models.aggregate)
quadkit.contracts.domain.base DomainModelProtocol, ID
quadkit.contracts.domain.events DomainEvent
quadkit.contracts.infra.cache CacheBackendProtocol
quadkit.contracts.data DatabaseProviderProtocol
quadkit.contracts.security.secrets SecretStoreProtocol
quadkit.contracts.core.di ContainerRegistrarProtocol, ContainerResolverProtocol
quadkit.contracts.core.provider ProviderProtocol, ProviderPriority
quadkit.contracts.core.registry RegistryProtocol, StrategyRegistryProtocol, BackendRegistryProtocol
quadkit.contracts.exceptions QuadkitError, full error hierarchy

Key Source Files

File What it contains
src/quadkit/contracts/__init__.py Lazy-loading re-exports of all public types
src/quadkit/result/ Result type and Ok/Err helpers
src/quadkit/contracts/domain/ DomainModelProtocol, DomainEvent
src/quadkit/contracts/core/ Container, Provider, Registry protocols
src/quadkit/contracts/exceptions/ QuadkitError and domain error hierarchies

Design Principles

  • Minimal dependencies — typing-extensions only; no framework imports
  • Protocol-only — defines interfaces, never implementations
  • Central contract — every other Quadkit package depends on this one, so changes here are the most disruptive kind the project can make

Release files for quadkit-contracts 0.0.2

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

Source distribution (sdist)

Source distribution for quadkit-contracts 0.0.2
File Size Uploaded
quadkit_contracts-0.0.2.tar.gz 395.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quadkit-contracts 0.0.2
File Interpreter ABI Platform
quadkit_contracts-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 829.6 kB

Release files / quadkit_contracts-0.0.2.tar.gz

Download URL quadkit_contracts-0.0.2.tar.gz
Size 395.2 kB
Tags Source
SHA-256 checksum
How to use checksums
87af5ac7df3ebd09a92e2e9a322a3693c09a89618be737287ca50b7a0c5d4a55
BLAKE2b-256 checksum
How to use checksums
5f9c3abd44a58393fe166dee645c53d0dd5174a392d0bf15cf74afe730ceeeb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release files / quadkit_contracts-0.0.2-py3-none-any.whl

Download URL quadkit_contracts-0.0.2-py3-none-any.whl
Size 434.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
153ced71bdefaae6629cee4256579646cf1ca1c863f980c0eb1582d5ee77a9de
BLAKE2b-256 checksum
How to use checksums
a36e51cc2ef1c09d229e80e9d29cf5e52a6404c63b7f401da85c7154d9454ee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release history Release notifications | RSS feed

0.0.42

2 release files

0.0.41

2 release files

0.0.4

2 release files

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

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