Skip to main content

unified audit envelope + fire-and-forget publish helper for the 3tears platform

Project description

3tears-agent-audit

Unified audit envelope + fire-and-forget publish helper for the 3tears platform.

Purpose

Single AuditEvent envelope + single publish_audit helper used by every domain (workspace, rbac, memory, custom tools) so the audit pipeline is one subject tree, one consumer, one table, one admin query API. Replaces domain-specific envelopes (WorkspaceAuditEnvelope, RbacAuditEnvelope) that produced slightly-different wire shapes per domain and made cross-domain audit queries require a UNION.

The package is pure Python with no NATS consumer code and no Postgres code. Publish is the only direction: a consumer-side audit consumer owns persistence to the audit events table.

Public API

from threetears.agent.audit import AuditEvent, publish_audit
  • AuditEvent -- pydantic BaseModel with extra='forbid', timezone-aware timestamp validator, closed event_type string family (dotted verb, e.g. workspace.fs_write, rbac.assignment.create). All common identity fields are typed columns on the envelope; event-type-specific extras live in details: dict[str, Any].
  • publish_audit(event, nats_client, namespace) -- fire-and-forget async helper. Serializes the envelope via model_dump_json() and awaits one nats_client.publish on {namespace}.audit.{event_type}. On any publish failure logs at WARN and returns; never raises.

Design commitments

  • Fire-and-forget. Audit publish failures must never break the producing call. The helper catches every exception, logs at WARN, and returns.
  • Typed wire contract. extra='forbid' + timezone-aware validator catch publisher-side drift at construction time, not at the consumer's decode.
  • No domain-specific envelope types. Every domain publishes the same model; event_type conveys the domain.
  • No dual-emit. There is no legacy envelope the consumer still accepts in parallel. Emission sites migrate in the same PR that deletes the legacy envelope module.

Subject naming

{namespace}.audit.{event_type} where event_type is the dotted event name (e.g. {namespace}.audit.workspace.fs_write). The consumer subscribes to {namespace}.audit.> so new event types route automatically without consumer-side changes.

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

3tears_agent_audit-0.14.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

3tears_agent_audit-0.14.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file 3tears_agent_audit-0.14.1.tar.gz.

File metadata

  • Download URL: 3tears_agent_audit-0.14.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for 3tears_agent_audit-0.14.1.tar.gz
Algorithm Hash digest
SHA256 fbc7c256fe8eb661eddb6e77ec0e0900b6eea60986cb3b4773ecc3f8fc2907d9
MD5 f27d9b89af5b9b6f797f588d702410db
BLAKE2b-256 86b9bccaddab6fa185653b41176fc906d4ab4b35dd08814e8eae435aa58b4ba0

See more details on using hashes here.

File details

Details for the file 3tears_agent_audit-0.14.1-py3-none-any.whl.

File metadata

  • Download URL: 3tears_agent_audit-0.14.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for 3tears_agent_audit-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a504805e124b5017c6711370081373a8226c667f383d198c456a06562a39be88
MD5 b5ba0cd4cd5bbe3e0c7147c40cb3664e
BLAKE2b-256 99a955f8b4fc5f2fbdae89cd103eace02a4c8d219a76d9efdeaec59b3b01ef14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page