Skip to main content

Shared interface contracts for wt workflow packages

Project description

wt-contracts

Shared interface contracts for wt workflow packages.

Overview

wt-contracts provides type-safe interface definitions (Pydantic models + Protocols) that enable inter-package compatibility across the wt ecosystem. This package contains no implementation logic - only contracts that other packages depend on.

Purpose

The wt architecture separates serializable metadata (@register) from execution features (@task). To enable cross-environment discovery via CLI serialization boundary, we need shared contracts that all packages agree on:

  1. Registry Contract: JSON schema for wt-registry CLI output
  2. Task Execution Contract: Protocol defining task execution interface
  3. Generated CLI Contract: Standard CLI arguments for generated workflows

Package Contents

wt_contracts.registry

Pydantic models for wt-registry CLI output:

  • RegistryMetadata: Function metadata (title, description, tags, deprecation)
  • RegistryEntry: Complete registry entry (metadata + schemas + import info)
  • RegistryOutput: Top-level CLI output format

wt_contracts.task

Protocol for task execution interface:

  • TaskProtocol[P, R]: Generic protocol with methods like .partial(), .call(), .map()

wt_contracts.cli

Standard CLI contracts for generated workflows:

  • WorkflowCLIArgs: Standard CLI arguments
  • WorkflowCLIEnv: Standard environment variables

Installation

pip install wt-contracts
# or
uv add wt-contracts

Usage

from wt_contracts.registry import RegistryOutput, RegistryEntry
from wt_contracts.task import TaskProtocol
from wt_contracts.cli import WorkflowCLIArgs

# Deserialize registry CLI output
registry_data = RegistryOutput.model_validate_json(cli_output)

# Type-check task implementations
def my_task_wrapper(func: Callable[P, R]) -> TaskProtocol[P, R]:
    ...

Development

# Install dependencies (including dev dependencies)
cd wt/wt-contracts

# IMPORTANT: Use --group dev to install pytest, mypy, ruff, etc.
uv sync --group dev

# Run tests
uv run pytest

# Type check
uv run mypy src/

# Lint
uv run ruff check .

Note: This project uses [dependency-groups] instead of [project.optional-dependencies]. You must use --group dev to install dev dependencies. Running uv sync alone will only install production dependencies (pydantic).

Design Philosophy

  • Minimal dependencies: Only pydantic (for validation)
  • No implementation: Pure interface definitions
  • Type-safe: Full mypy strict mode compliance
  • Version stability: Breaking changes require major version bump
  • Lightweight: Fast to install, minimal impact on dependency trees

Related Packages

  • wt-registry: Function registration with JSON schema generation (uses registry contracts)
  • wt-task: Task decorator with execution features (implements task protocol)
  • wt-compiler: Workflow compilation (uses all contracts for discovery + generation)
  • wt-invokers: Workflow invocation (uses CLI contract)
  • wt-runner: FastAPI workflow execution server (uses CLI contract)

License

BSD-3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wt_contracts-0.1.1.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wt_contracts-0.1.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file wt_contracts-0.1.1.tar.gz.

File metadata

  • Download URL: wt_contracts-0.1.1.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wt_contracts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 896515c3a455a2f50b34b05a379b9b5fa869241900e8e8d39edf3d2ea76201ba
MD5 2dd7a8832360e21876b26c653a95c78e
BLAKE2b-256 4894ca6cfb34cfc07366578c9dd3cb7d6f3d576425cb2f613142429c1a041cd2

See more details on using hashes here.

File details

Details for the file wt_contracts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wt_contracts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wt_contracts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7013867c4a366938b5749c57ce8a907ecc02ede289e4691b88f0dd795ee8677
MD5 e81aa11ad7c2f6d838704b64484cda5a
BLAKE2b-256 e7b848ed6c45b7440069d89ebb66b064237439c178644ba215419cca9769af70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page