Metadata-Version: 2.5
Name: edd-kernel-contracts
Version: 0.2.0a2
Summary: Provider-agnostic contracts for EDD Kernel.
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# edd-kernel-contracts

Provider-agnostic contracts for EDD Kernel.

This package is the public contract layer for the EDD Kernel package
family. It defines the shared event types, client protocol, serialization
options, acknowledgement behavior, consumer lifecycle helpers and polling
consumer used by providers.

Providers depend on this package. This package does not depend on providers or
provider SDKs.

## Install

```bash
uv add edd-kernel-contracts
```

An application usually installs `edd-kernel-factory` and one provider instead. The
factory brings this package and re-exports it, so everything below is importable from
the factory as well:

```bash
uv add edd-kernel-factory edd-kernel-provider-in-memory
```

## Usage

```python
from edd_kernel.contracts import EddClientOptions, EddQueueNameAddress
from edd_kernel.provider_in_memory import create_in_memory_client

client = create_in_memory_client(EddClientOptions(create_if_not_exists=True))

await client.send(EddQueueNameAddress(queue_name="events"), {"type": "user.created"})


async def handler(event: object, context: object) -> None:
    await context.ack()


consumer = await client.consume(EddQueueNameAddress(queue_name="events"), handler)
await consumer.stop()
await client.close()
```

## Public Surface

- `EventEnvelope`: optional structured event envelope.
- `EddEventTarget`: provider-neutral send destination.
- `EventQueue`: provider-neutral consume source.
- `EddDeliveryContext`: `ack` and `nack` contract passed to handlers.
- `EddClient`: async client protocol implemented by providers.
- `EddClientClass`: class-constructor protocol accepted by the factory.
- `EddProviderFactory`: equivalent provider creator-function protocol.
- `EddClientOptions`: shared serialization, acknowledgement and lifecycle options.
- `EddSendOptions`: per-send serialization override.
- `EddConsumeOptions`: per-consume queue creation and polling options.
- `EddLogger`: the object the kernel writes its log lines to.
- `EddKernelError` and the typed errors below it.
- the provider registry: `EddProviderName`, `EDD_PROVIDER_ALIASES`,
  `EDD_PROVIDER_TARGET_BY_NAME`, `normalize_provider_name`,
  `find_provider_target`.

`EddPollingConsumer` and `EddClientLifecycle` are the shared implementation and live
in [`edd_kernel.core`](../core/README.md), which this distribution does not depend on.

## Defaults

- `serialization = json`
- `auto_idempotency_key = false`
- `create_if_not_exists = false`
- `auto_ack = false`
- `unhandled_error_action = nack`
- `concurrency = 1`
- `logger = None`
- `debug = false`

`auto_idempotency_key` is only compatible with JSON serialization.

`auto_ack=True` is a kernel-level manual acknowledgement performed before the
handler runs. Providers must still use provider-native manual acknowledgement.

## Package Boundary

Keep provider-specific SDKs, credentials and transport behavior outside this
package. Shared validation, serialization, queue normalization, lifecycle and
portable error handling belong here.
