Skip to main content

keel-core (Python)

Tier-1 shared library for keel Python services (see ADR-0009). It implements the platform contract (platform.yaml) so services stay thin and consistent by construction.

Layout (hexagonal - ADR-0002)

keel_core/
  ports/        # Protocols: Logger, Clock, Authenticator (+ Principal)
  domain/       # errors: taxonomy mapped to RFC 9457 (ADR + platform.yaml)
  adapters/
    inbound/http/      # FastAPI app factory, problem+json, health, deny-by-default auth
    inbound/rpc/       # gRPC server factory (OTel-instrumented)
    outbound/          # StructuredLogger, SystemClock
    outbound/rpc/      # gRPC ServiceClient channel factory (trace-propagating)
    outbound/messaging/ # MessageBus port + InMemory, NATS JetStream, Kafka, RabbitMQ adapters
    outbound/auth/     # OIDCAuthenticator + ApiKeyAuthenticator
    outbound/secrets/  # SecretProvider: Env (dev); OpenBao, AWS, GCP (prod)
    outbound/telemetry/ # OpenTelemetry tracing + metrics + saturation
    outbound/persistence/  # async SQLAlchemy: Database, UnitOfWork (repos are service-defined)
  config.py     # BaseServiceConfig (typed, 12-factor, fail-fast)
  context.py    # request/trace/span contextvars injected into logs
  testkit/      # fakes: FrozenClock, StubAuthenticator, capturing_logger

What's here now

  • Structured logging (on structlog, ADR-0014) - contract-schema JSON, real exception tracebacks, recursive secret redaction + value-pattern/message scrubbing, reserved-field protection, field-size caps, optional rate limiting, non-blocking background writer, correlation ids from context, and configure_logging() to route stdlib/library logs through the same schema.
  • Error taxonomy - DomainError hierarchy with category -> HTTP status mapping.
  • Typed config - BaseServiceConfig (Pydantic Settings), KEEL_-prefixed, immutable, fails fast.
  • Clock - injectable time for testability.
  • Auth - Authenticator / Principal port with OIDCAuthenticator (Bearer JWTs verified against the issuer JWKS; issuer/audience/expiry enforced; claims mapped to a Principal) and ApiKeyAuthenticator (SHA-256-hashed keys, accepted via X-API-Key).
  • Secrets - SecretProvider port + EnvSecretProvider (dev); production backends OpenBao/Vault (ADR-0023), AWS Secrets Manager, and GCP Secret Manager (ADR-0024) over one caching core, selected fail-closed at most one (KEEL_VAULT_ADDR / KEEL_AWS_SECRET_ID / KEEL_GCP_SECRET); opt-in [openbao]/[aws]/[gcp] extras. Secrets are reached only through the port.
  • Distributed tracing - configure_tracing() installs an OpenTelemetry provider; FastAPI/Starlette then emit spans and continue inbound W3C trace context natively. The structured logger reads the active span, so every log line carries the correct trace_id/span_id with no wiring. OTLP export is configured at deployment.
  • gRPC - create_channel (ServiceClient) and create_server (GrpcApi) factories carry the OpenTelemetry interceptors; the server enforces deny-by-default auth + scope authorization and publishes the Principal on a contextvar. mTLS credential builders (mtls_channel_credentials/mtls_server_credentials) via OpenBao PKI.
  • Messaging - MessageBus port with InMemoryMessageBus (dev/test) and durable NatsMessageBus (JetStream), KafkaMessageBus (aiokafka), and RabbitMqMessageBus (aio-pika) adapters - all at-least-once with ack/nak/dead-letter and W3C trace propagation, selected fail-closed at most one via message_bus_from_env (KEEL_NATS_URL / KEEL_KAFKA_BROKERS / KEEL_RABBITMQ_URL; ADR-0025); opt-in [nats]/[kafka]/[rabbitmq] extras. A reusable assert_pubsub_roundtrip contract they all satisfy.
  • FastAPI app factory (ADR-0013) - create_app wires request-id, problem+json (RFC 9457, incl. invalid-params), health, metrics, optional rate limiting, default-deny CORS, environment-gated docs, and a deny-by-default auth dependency. Requires an Authenticator.
  • Persistence - async SQLAlchemy 2.0 plumbing: Database, UnitOfWork, the Entity base, and a bounded readiness ping(). Repositories are service-defined per aggregate (mapping ORM<->domain); keel-core ships no generic repository.
  • Test kit - fakes + reusable contracts (messaging, health/problem conformance) so services test against the ports.

Usage

from keel_core.adapters.outbound.logging import StructuredLogger

log = StructuredLogger(service="orders", version="1.0.0")
log.info("order placed", order_id=42)  # -> one JSON line, secrets redacted

Metadata

Release files for keel-core 0.1.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 keel-core 0.1.0
File Size Uploaded Provenance Actions
keel_core-0.1.0.tar.gz 103.9 kB With provenance Details for keel_core-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keel-core 0.1.0
File Interpreter ABI Platform Actions
keel_core-0.1.0-py3-none-any.whl Python 3 none any Details for keel_core-0.1.0-py3-none-any.whl

Total release size: 194.8 kB

Release files / keel_core-0.1.0.tar.gz

Download URL keel_core-0.1.0.tar.gz
Size 103.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1c4b8c7f6ef8ace08f3103f2f4761f19802fb98a877e93a183ce331b85570048
BLAKE2b-256 checksum
How to use checksums
00317a397eb1c4375b7b168cd487a707924f10164b206cd78366dd9c0e87f0cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 23, 2026.

Transparency log

Release files / keel_core-0.1.0-py3-none-any.whl

Download URL keel_core-0.1.0-py3-none-any.whl
Size 90.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16f6ebac9998b61f4b9d997794aca5cc41f8d5bfb9f5ff354030c0095097a9d3
BLAKE2b-256 checksum
How to use checksums
034e6ff18438425fa6351129729e984f93b57c8ea7e697127fb247142c12f66f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 23, 2026.

Transparency log

Security for keel-core 0.1.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 keel_core-0.1.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 Nov 23, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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