Consolidated domain packages: typed errors, security, API rate limiting, monitoring, retrieval provenance, and cross-cutting aspects
Project description
domain-suite
Consolidated domain packages for Python services: typed errors, security context, API rate limiting, event monitoring, and cross-cutting aspects.
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 withmixin-logging>=0.6.0for structured event logging adapters.[sensitivity]: Integrates withmixin-sensitivity>=0.4.0for automatic PII/PHI field masking.[all]: Includes bothmixin-loggingandmixin-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.
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
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 domain_suite-0.3.0.tar.gz.
File metadata
- Download URL: domain_suite-0.3.0.tar.gz
- Upload date:
- Size: 282.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b80841e26b2375425ad290c74c55175a21ca55d121d3be9d0c8f0099d1102a48
|
|
| MD5 |
529c2beac47105769b907e85da5e4f31
|
|
| BLAKE2b-256 |
43ae15b935e0bc4338762766b8b5b77e1762f6f037bb208c027ba202210ed352
|
Provenance
The following attestation bundles were made for domain_suite-0.3.0.tar.gz:
Publisher:
publish.yml on jekhator/domain-suite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
domain_suite-0.3.0.tar.gz -
Subject digest:
b80841e26b2375425ad290c74c55175a21ca55d121d3be9d0c8f0099d1102a48 - Sigstore transparency entry: 2193336316
- Sigstore integration time:
-
Permalink:
jekhator/domain-suite@1607ab9c425b35792059fae85838833dba6fe73d -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/jekhator
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1607ab9c425b35792059fae85838833dba6fe73d -
Trigger Event:
release
-
Statement type:
File details
Details for the file domain_suite-0.3.0-py3-none-any.whl.
File metadata
- Download URL: domain_suite-0.3.0-py3-none-any.whl
- Upload date:
- Size: 73.6 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 |
5603d3de6204eedbda80d105ffb2a78b3e75d9b7af258ee7f3c2f98f2a3c1964
|
|
| MD5 |
4396dcab549d862eb27a7a7d175e2280
|
|
| BLAKE2b-256 |
9f329ac2c7b0bc549ec425f6c146a160c17a426a6f45da35098dcac1e3ffb6ea
|
Provenance
The following attestation bundles were made for domain_suite-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on jekhator/domain-suite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
domain_suite-0.3.0-py3-none-any.whl -
Subject digest:
5603d3de6204eedbda80d105ffb2a78b3e75d9b7af258ee7f3c2f98f2a3c1964 - Sigstore transparency entry: 2193336336
- Sigstore integration time:
-
Permalink:
jekhator/domain-suite@1607ab9c425b35792059fae85838833dba6fe73d -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/jekhator
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1607ab9c425b35792059fae85838833dba6fe73d -
Trigger Event:
release
-
Statement type: