Skip to main content

domain-suite

Consolidated domain packages for Python services: typed errors, security context, API rate limiting, event monitoring, and cross-cutting aspects.

PyPI CI License Python versions

Overview

domain-suite brings together five complementary domain packages into a single distribution:

  • domain-errors: Typed domain error hierarchy with wrapping and chaining
  • domain-security: Security context management and authorization checks
  • domain-api-limiter: Request rate limiting and quota enforcement
  • domain-monitoring: Event monitoring and telemetry
  • domain-aspects: Composable decorators for logging, auth, throttling, error wrapping, and sensitivity masking

Each package maintains its namespace and API; the consolidation is organizational (single distribution, unified testing).

Installation

# Base install
uv add domain-suite

# With all optional extras (logging + sensitivity)
uv add "domain-suite[all]"

# Or select extras
uv add "domain-suite[logging]"    # for mixin-logging support
uv add "domain-suite[sensitivity]" # for mixin-sensitivity support

or with pip:

pip install domain-suite
pip install "domain-suite[all]"

Requires Python 3.11+.

Packages

domain-errors

Typed domain error hierarchy with wrapping and chaining for Python services.

Public API: DomainError, ErrorChain, WrapErrorsClient, wrap_errors, ChainLink, ChainVia, DomainClassifier, DomainCrossing.

Example:

from domain_errors import DomainError, wrap_errors

class DatabaseError(DomainError):
    domain = "database"
    code = "db_connection_failed"
    http_status = 503
    retryable = True

@wrap_errors(as_=DatabaseError)
def fetch_user(user_id: str):
    raise RuntimeError(f"Database connection failed for {user_id}")

try:
    fetch_user("usr_123")
except DatabaseError as e:
    print(f"Error domain: {e.domain}, code: {e.code}, http_status: {e.http_status}, retryable: {e.retryable}")

Output (Python 3.11+, domain-suite==0.2.0):

Error domain: database, code: db_connection_failed, http_status: 503, retryable: True

See docs/domain_errors/ for full documentation.

domain-security

Security context management and authorization checks.

Public API: SecurityContext, SecurityContextManager, Principal, requires, tenant_scoped, Authorizer, Permission, PolicyDecision, SecretRef, SecretValue, security error classes.

Example:

from domain_security import Principal, SecurityContext, SecurityContextManager, requires

# Create principal with required scope
principal = Principal(id="usr_123", scopes=frozenset(["admin.read"]))
ctx = SecurityContext(principal=principal, tenant_id="org_abc")

# Bind context for a request scope
manager = SecurityContextManager()
with manager.bind(principal=principal, tenant_id="org_abc"):
    # Enforce authorization via decorator
    @requires(permission="admin.read")
    def admin_only_function():
        return "Admin access granted"
    
    result = admin_only_function()
    print(result)

Output (Python 3.11+, domain-suite==0.2.0):

Admin access granted

See docs/domain_security/ for full documentation.

domain-api-limiter

Request rate limiting and quota enforcement.

Public API: throttled, PolicyRegistry, RateLimit, ThrottlePolicy, TierRate, Period, RateLimitExceeded, throttle error classes.

Example:

from domain_api_limiter import throttled

@throttled(scope="api.documents", rate="100/hour")
def create_document(title: str):
    return {"id": "doc_123", "title": title}

result = create_document("My Document")
print(result)

Output (Python 3.11+, domain-suite==0.2.0):

{'id': 'doc_123', 'title': 'My Document'}

See docs/domain_api_limiter/ for full documentation.

domain-monitoring

Event monitoring and telemetry.

Public API: monitored, MonitorRegistry, MetricSink, MetricEvent, Outcome, CollectingSink, NullSink, monitoring error classes.

Example:

from domain_monitoring import monitored

@monitored(event="document.processed")
def process_document(doc_id: str):
    return {"status": "success"}

result = process_document("doc_123")
print(result)

Output (Python 3.11+, domain-suite==0.2.0):

{'status': 'success'}

See docs/domain_monitoring/ for full documentation.

domain-aspects

Composable decorators for logging, auth, throttling, error wrapping, and sensitivity masking.

Public API: aspects, Logged, Requires, Throttled, TenantScoped, WrapErrors, Sensitive, AspectEntry, AspectKind, aspect error classes.

Example:

from domain_aspects import aspects, Logged, Throttled
from domain_security import Principal, SecurityContextManager
from mixin_logging import LoggingMixin

class DocumentService(LoggingMixin):
    @aspects(
        Logged(event="document.create"),
        Throttled(scope="api.documents", rate="100/hour"),
    )
    def create_document(self, title: str, content: str) -> dict:
        return {"id": "doc_123", "title": title}

principal = Principal(id="usr_123")
manager = SecurityContextManager()
with manager.bind(principal=principal, tenant_id="org_abc"):
    service = DocumentService()
    result = service.create_document("My Doc", "Content here")
    print(result)

Output (Python 3.11+, domain-suite==0.2.0):

{'id': 'doc_123', 'title': 'My Doc'}

See docs/domain_aspects/ for full documentation.

Consolidated From

This distribution consolidates five independent domain packages (originally domain-errors, domain-security, domain-api-limiter, domain-monitoring, and domain-aspects) into a single unified distribution to simplify dependency management and testing.

Each package retains its original public API and namespace. Internal dependencies between packages within the suite are resolved locally (no external package re-imports required).

Optional Extras

  • [logging]: Integrates with mixin-logging>=0.6.0 for structured event logging adapters.
  • [sensitivity]: Integrates with mixin-sensitivity>=0.4.0 for automatic PII/PHI field masking.
  • [all]: Includes both mixin-logging and mixin-sensitivity.

Future versions may introduce new extras or migrate integrations (e.g., mixin-suite packages if they consolidate similarly).

Development

Install development dependencies:

uv sync --all-extras

Run tests:

uv run pytest

Run linting and type checking:

ruff check .
ruff format --check .
mypy

License

Apache License 2.0. See LICENSE for details.

Contributing

See CONTRIBUTING.md for guidelines.

Metadata

Release files for domain-suite 0.5.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 domain-suite 0.5.0
File Size Uploaded Provenance Actions
domain_suite-0.5.0.tar.gz 290.2 kB With provenance Details for domain_suite-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for domain-suite 0.5.0
File Interpreter ABI Platform Actions
domain_suite-0.5.0-py3-none-any.whl Python 3 none any Details for domain_suite-0.5.0-py3-none-any.whl

Total release size: 366.5 kB

Release files / domain_suite-0.5.0.tar.gz

Download URL domain_suite-0.5.0.tar.gz
Size 290.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bcc8eee547155ce0d7154f3621e55e09c1be742649bab1d95ae51425677dabea
BLAKE2b-256 checksum
How to use checksums
9485fa66b697cb09174e87ec0da085c9be3c8d600dfcaf19a4b992737c4258f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / domain_suite-0.5.0-py3-none-any.whl

Download URL domain_suite-0.5.0-py3-none-any.whl
Size 76.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
800a2b564f6ede2c9a8e4a671b777d1b0dddf4d0d0cc61b03f5044d902fdb0b0
BLAKE2b-256 checksum
How to use checksums
bfec58794641b73fcf8de82289b344c4fc4ed95fe984a303a0f83d2022b1850f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Security for domain-suite 0.5.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for domain_suite-0.5.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 Jul 27, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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