Skip to main content

Append-only governance event stream. Hash-chained for tamper-evidence, SSE for live tailing, REST for queries. The cross-cutting telemetry layer for the Kinetic Gain portfolio.

Project description

audit-stream

CI Python License: MIT

Append-only governance event stream for the Kinetic Gain portfolio. Hash-chained for tamper-evidence, Server-Sent Events for live tailing, REST for queries. The cross-cutting telemetry layer every other portfolio repo can produce into.

                                       ┌─────────────────────┐
                                       │     audit-stream    │
                                       │                     │
   procurement-decision-api ──events──▶│   POST /events      │
   policy-as-code-engine    ──events──▶│   GET  /events?…    │
   data-contract-registry   ──events──▶│   GET  /stream  ◀──── live tail (SSE)
   aeo-validator-service    ──events──▶│   GET  /verify       │
   incident-correlation-rs  ──events──▶│   GET  /stats        │
   hash-attestation-rs      ──events──▶│                     │
   feature-flag-rs          ──events──▶│ chain: prev_hash ──▶ hash  ──▶ next.prev_hash ──▶ …
   request-shadow-rs        ──events──▶│                     │
                                       └─────────────────────┘

Why

Across the portfolio, "something governance-shaped happened" is the recurring event: a Decision Card was drafted, a policy bundle denied a request, a data contract was promoted, a watch detected drift, an attestation failed. Each repo already logs these — but to its own logs, in its own shape, with its own retention.

audit-stream is the shared event spine. One schema, one chain, one SSE socket, one REST query interface. Operators see the whole portfolio's behavior in a single place; auditors get a tamper-evident record by construction.


Endpoints

Method Path What it does
GET / Service info + endpoint list.
GET /healthz Liveness probe.
POST /events Append one governance event. Returns the assigned event_id, prev_hash, and hash.
GET /events?kind=&source=&limit= Query. Filters by kind or source; limit caps the most-recent N events.
GET /events/{id} Fetch one event by id.
GET /stream Live tail via Server-Sent Events. Receives events appended after subscription.
GET /verify Walk the entire chain and report the first integrity break, if any.
GET /stats { count, last_event_id, latest_hash }.

Event envelope

{
  "event_id": 42,
  "timestamp": "2026-05-15T03:14:15+00:00",
  "kind": "watch_drifted",
  "source": "aeo-validator-service",
  "payload": { "watch_id": "abc123", "added_fields": ["claims"] },
  "prev_hash": "9a3f…",
  "hash":      "b7d1…"
}

event_id is monotonic; the store assigns it. prev_hash is the previous event's hash (or 64 zeros for event #1). hash is SHA-256 over the canonical JSON of every other field — sorted keys, no whitespace.


Event kinds (v0.1)

Source repo Kinds
procurement-decision-api decision_card_drafted, decision_card_signed, decision_card_status_changed
policy-as-code-engine policy_bundle_registered, request_allowed, request_denied
data-contract-registry contract_promoted, contract_deprecated, contract_compatibility_failed
aeo-validator-service watch_created, watch_drifted, watch_validity_flipped
incident-correlation-rs incident_filed, remediation_planned
hash-attestation-rs attestation_verified, attestation_tampered
feature-flag-rs / request-shadow-rs flag_swapped, shadow_divergence_recorded
extension other

Adding kinds is a Literal-only change; producers and verifiers stay backwards-compatible if you keep the canonical-hash construction stable.


Tamper-evidence

/verify rewalks the chain top-to-bottom and reports:

{
  "valid": false,
  "checked": 5,
  "first_break_at": 6,
  "reason": "hash mismatch at event #6"
}

Operators can wire a periodic verify into their on-call alerting; a valid: false result is one of the most useful red lights a governance stack can produce.


Live tail

GET /stream is a Server-Sent Events endpoint. Each event the store appends becomes one SSE message:

event: watch_drifted
id: 42
data: {"event_id":42,"timestamp":"2026-05-15T03:14:15+00:00", …}

Tail it with curl -N http://localhost:8093/stream, or wire it into a dashboard (e.g. a EventSource in browser JS, or httpx-sse in Python).


Quick start

pip install audit-stream
audit-stream            # binds 0.0.0.0:8093

# in another shell
curl -X POST http://localhost:8093/events \
  -H 'Content-Type: application/json' \
  -d '{"kind":"decision_card_drafted","source":"procurement-decision-api","payload":{"decision_id":"DEC-001"}}'

Composes with


Tests

pip install -e ".[dev]"
ruff check src tests && ruff format --check src tests
mypy src
pytest -v

CI matrix runs Python 3.11 / 3.12 / 3.13.


License

MIT. See LICENSE.

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

audit_stream-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

audit_stream-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file audit_stream-0.1.0.tar.gz.

File metadata

  • Download URL: audit_stream-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for audit_stream-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4dd3f49e675725f89aec1a33efbeca399b757b080bca5aca95f503815980a3b8
MD5 5f30421c93383558e87d77bedc4267ae
BLAKE2b-256 9500025e83c670867e22cd0dbeab088cdaa628ded0a386843829e0fc175d1fef

See more details on using hashes here.

Provenance

The following attestation bundles were made for audit_stream-0.1.0.tar.gz:

Publisher: publish.yml on mizcausevic-dev/audit-stream-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file audit_stream-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: audit_stream-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for audit_stream-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c559d589d6022035d3fcbdafef84e23aa9d2e9cba395f3b8c7d3e183156a3ffd
MD5 d890222ec51a2d59bfee5d83ba675896
BLAKE2b-256 5df38f3e9c1ecb1c0edf86a24d9ba84443dac6d7522c0edfef15c5e7a42bb68a

See more details on using hashes here.

Provenance

The following attestation bundles were made for audit_stream-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mizcausevic-dev/audit-stream-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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