Skip to main content

bfagent-core

Shared core components for the BFAgent Hub ecosystem.

Features

  • Tenancy: Multi-tenant support with subdomain resolution and Postgres RLS
  • Request Context: Thread-safe context propagation (tenant_id, user_id, request_id)
  • Audit: Audit event logging for compliance
  • Outbox: Transactional outbox pattern for reliable event publishing

Installation

pip install bfagent-core
# or from git
pip install "bfagent-core @ git+https://github.com/achimdehnert/platform.git#subdirectory=packages/bfagent-core"

Usage

Request Context

from bfagent_core.context import get_context, set_tenant, set_user_id

# Set context (typically in middleware)
set_tenant(tenant_id=uuid, tenant_slug="demo")
set_user_id(user_id)

# Get context anywhere
ctx = get_context()
print(ctx.tenant_id, ctx.user_id, ctx.request_id)

Audit Events

from bfagent_core.audit import emit_audit_event

emit_audit_event(
    tenant_id=tenant_id,
    category="risk.assessment",
    action="created",
    entity_type="risk.Assessment",
    entity_id=assessment.id,
    payload={"title": assessment.title},
)

Outbox Pattern

from bfagent_core.outbox import emit_outbox_event

emit_outbox_event(
    tenant_id=tenant_id,
    topic="risk.assessment.created",
    payload={"assessment_id": str(assessment.id)},
)

Postgres RLS

from bfagent_core.db import set_db_tenant

# Set tenant for RLS (in middleware)
set_db_tenant(tenant_id)

Django Integration

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "bfagent_core",
]

Add middleware:

MIDDLEWARE = [
    ...
    "bfagent_core.middleware.RequestContextMiddleware",
    "bfagent_core.middleware.SubdomainTenantMiddleware",
]

License

MIT

Metadata

Release files for iil-bfagent-core 0.2.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 iil-bfagent-core 0.2.0
File Size Uploaded Provenance
iil_bfagent_core-0.2.0.tar.gz 33.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iil-bfagent-core 0.2.0
File Interpreter ABI Platform
iil_bfagent_core-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 81.0 kB

Release files / iil_bfagent_core-0.2.0.tar.gz

Download URL iil_bfagent_core-0.2.0.tar.gz
Size 33.4 kB
Tags Source
SHA-256 checksum
How to use checksums
79185fc9cc08dcb8f8313d8de0c414a31784b10badb8fc166c4659818187fb91
BLAKE2b-256 checksum
How to use checksums
86e389c3e16b9d2de715d5c9a19942615107a54a21d1927745596d77180df1e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / iil_bfagent_core-0.2.0-py3-none-any.whl

Download URL iil_bfagent_core-0.2.0-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d375126f6134b1a6d55597cb26b308b817f6406c45d77f215595b7a62dbad4e2
BLAKE2b-256 checksum
How to use checksums
62b3bc9b76f293e3800ef7c3cc283a2cacbb57be6bf48832d3d988dbae0c9bf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for iil-bfagent-core 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.2.0 This release

2 release files No 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