Audit trail and activity log for Arvel — automatic model change history plus a fluent business-event recorder.
Project description
arvel-audit
Automatic audit trail and a fluent activity log for Arvel.
Two logging layers in one package:
- Audit trail — add
Auditableto a model and every create / update / delete writes anAuditEntry(old values, new values, actor) inside the same transaction. No per-model observer or middleware code. - Activity log — record business events ("user exported report") with the fluent
activity()API, modeled after Spatie's Laravel ActivityLog.
Status: Pre-alpha.
Documentation: https://arvel.dev/packages/audit
Install
uv add "arvel[audit]"
# or: pip install arvel-audit
Register the provider in bootstrap/providers.py:
from arvel_audit import AuditServiceProvider
providers = [
# ...other providers...
AuditServiceProvider,
]
Publish the migrations (audit_entries, activity_entries) and run them:
arvel vendor:publish --tag=arvel-audit # or: arvel audit:install
arvel migrate
The provider binds AuditConfig and wires the Auditable observers on boot.
Audit trail
from arvel.database import Model, id_, string
from arvel_audit import Auditable
class Invoice(Model, Auditable):
__tablename__ = "invoices"
__audit_redact__ = {"card_number", "cvv"} # masked as "***" in the trail
id: int = id_()
status: str = string(20, default="new")
Creating, updating, or deleting an Invoice now records an AuditEntry automatically. The actor is
read from Context.get("user_id") when present, otherwise stored as None.
Query the trail:
from arvel_audit import AuditLog
history = await AuditLog(session).for_model(invoice).get()
mine = await AuditLog(session).by_actor(user.id).action("updated").get()
page = await AuditLog(session).for_model(invoice).paginate(per_page=50)
Activity log
from arvel_audit import activity, ActivityQuery
await (
activity("exports", session=session)
.log("Exported Q1 report")
.by(user)
.on(report)
.with_properties({"format": "pdf", "rows": 1200})
.save()
)
entries = await ActivityQuery(session).for_subject(report).get()
Encryption
Set AUDIT_ENCRYPT_VALUES=true to store old_values / new_values as AES-256-GCM ciphertext (keyed
from APP_KEY). Reads decrypt transparently.
See the full reference for column control and query options.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 arvel_audit-0.6.0.tar.gz.
File metadata
- Download URL: arvel_audit-0.6.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f45e8dc34a34723645c9eecef2a460b54f59db64d3f4ee19a1062241f55ce5d6
|
|
| MD5 |
1620dca5254efb7b5860ed39d1ce42e8
|
|
| BLAKE2b-256 |
43a57055ee6765b917208b22b7199717822bdcf476310d65b4cd22af2fa7c67a
|
Provenance
The following attestation bundles were made for arvel_audit-0.6.0.tar.gz:
Publisher:
publish.yml on mohamed-rekiba/arvel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arvel_audit-0.6.0.tar.gz -
Subject digest:
f45e8dc34a34723645c9eecef2a460b54f59db64d3f4ee19a1062241f55ce5d6 - Sigstore transparency entry: 1695791342
- Sigstore integration time:
-
Permalink:
mohamed-rekiba/arvel@9779b4fcacb917198d2a352c59cb14304a6e45d0 -
Branch / Tag:
refs/tags/arvel-audit-v0.6.0 - Owner: https://github.com/mohamed-rekiba
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9779b4fcacb917198d2a352c59cb14304a6e45d0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file arvel_audit-0.6.0-py3-none-any.whl.
File metadata
- Download URL: arvel_audit-0.6.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0d708c0784f47253a063473a1f313dc3eb3122a9d41469627c80462affc8519
|
|
| MD5 |
1a42b3ffb59c1cbf5053bfaefb59b59c
|
|
| BLAKE2b-256 |
79edb4c7619cfc689122b29e5b4cbebc0fa5abe01a650485cc25a4c2ef95fa17
|
Provenance
The following attestation bundles were made for arvel_audit-0.6.0-py3-none-any.whl:
Publisher:
publish.yml on mohamed-rekiba/arvel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arvel_audit-0.6.0-py3-none-any.whl -
Subject digest:
d0d708c0784f47253a063473a1f313dc3eb3122a9d41469627c80462affc8519 - Sigstore transparency entry: 1695791695
- Sigstore integration time:
-
Permalink:
mohamed-rekiba/arvel@9779b4fcacb917198d2a352c59cb14304a6e45d0 -
Branch / Tag:
refs/tags/arvel-audit-v0.6.0 - Owner: https://github.com/mohamed-rekiba
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9779b4fcacb917198d2a352c59cb14304a6e45d0 -
Trigger Event:
workflow_dispatch
-
Statement type: