Metadata-Version: 2.5
Name: smooai-audit
Version: 0.3.0
Summary: Polyglot client SDK for tamper-evident, SQL-queryable audit logging — Python port of @smooai/audit.
Project-URL: Homepage, https://github.com/SmooAI/audit
Project-URL: Repository, https://github.com/SmooAI/audit
Project-URL: Issues, https://github.com/SmooAI/audit/issues
Author-email: SmooAI <brent@smooai.com>
License: MIT
Keywords: audit,audit-log,hash-chain,smooai,tamper-evident
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: pydantic>=2.7.0
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20.0; extra == 'otel'
Description-Content-Type: text/markdown

# smooai-audit (Python)

Python port of [`@smooai/audit`](https://github.com/SmooAI/audit) — a polyglot
client SDK for tamper-evident, SQL-queryable audit logging: a canonical
`AuditEvent` schema, canonical JSON serialization, a per-org-per-day SHA-256 hash
chain, and an emit client. Verified byte-for-byte against a shared parity corpus.

> **Status:** complete — `canonical_json`, `compute_event_hash`, `build_hash_chain`,
> and `AuditClient.emit` are implemented and verified byte-for-byte against the
> shared parity corpus (`../spec/parity-corpus.json`), including envelope trace
> correlation (optional OTel via `pip install smooai-audit[otel]`).

## Install

```bash
uv add smooai-audit   # or: pip install smooai-audit
```

## Usage

```python
from smooai_audit import AuditClient, AuditClientOptions, AuditEvent, AuditResource

client = AuditClient(AuditClientOptions(endpoint=endpoint, token=token))
client.emit(
    AuditEvent(
        id="01HXXXXXXXXXXXXXXXXXXXXXXX",
        organization_id="org_123",
        actor_type="user",
        actor_id="user_abc",
        action="crm.contact_deleted",
        resource=AuditResource(type="crm.contact", id="c-42"),
        outcome="success",
        metadata={},
        timestamp="2026-07-14T00:00:00.000Z",
    )
)
```

## License

MIT © SmooAI
