Skip to content

feat: add tamper-evident audit trail for workflow execution#277

Open
mvillmow wants to merge 5 commits into
mainfrom
187-auto-impl
Open

feat: add tamper-evident audit trail for workflow execution#277
mvillmow wants to merge 5 commits into
mainfrom
187-auto-impl

Conversation

@mvillmow

@mvillmow mvillmow commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Implement structured JSONL audit logging with optional SHA-256 hash chain for workflow execution events. Records who, when, what, and outcome for all workflow, agent, team, and task state transitions.

Key Features

  • Dependency-injected AuditSink (not module-global singleton) — resolves DIP/Modularity finding from prior review
  • Optional hash chain enabled by default when AUDIT_LOG_PATH is set — tamper-evidence always on in production
  • Hash chain continuity across process restarts — resumes from last record's hash instead of silently zero-restarting (addresses prior review gap)
  • Thread-safe sync emit() (no silent drops if await forgotten) — resolves POLA finding
  • Graceful fallback to NullSink on configuration errors — executor construction never fails due to bad audit path

Implementation

  • New files: src/telemachy/audit.py, tests/test_audit.py, docs/audit-log.md
  • Modified: config.py (added AUDIT_LOG_PATH, AUDIT_HASH_CHAIN), executor.py (inject sink, 11 emit sites), cli.py (build and inject sink), .env.example, CLAUDE.md

Testing & Quality

  • All 56 tests pass (7 new audit tests + 1 integration test)
  • Coverage: 78.89% (exceeds 75% gate)
  • Type-clean (mypy), lint-clean (ruff)
  • End-to-end verification: AUDIT_LOG_PATH=/tmp/wf.jsonl pixi run python -m telemachy.cli run workflows/example.yaml --dry-run produces valid JSONL with verified hash chain

Test Plan

  • Run pixi run pytest tests/test_audit.py -v — verify sink writes structured JSON with chain continuity
  • Run pixi run pytest tests/test_executor.py::TestAuditTrail -v — verify full workflow emits complete event sequence
  • Run pixi run pytest --cov=src/telemachy --cov-fail-under=75 — verify 75% coverage gate
  • Run AUDIT_LOG_PATH=/tmp/wf-audit.jsonl pixi run python -m telemachy.cli run workflows/example.yaml --dry-run — verify end-to-end chain integrity

Closes #187

🤖 Generated with Claude Code

mvillmow and others added 4 commits June 28, 2026 10:11
Implement structured JSONL audit logging with optional SHA-256 hash chain
for workflow execution events. Records who, when, what, and outcome for all
workflow, agent, team, and task state transitions.

Key features:
- Dependency-injected AuditSink (not module-global singleton)
- Optional hash chain enabled by default when AUDIT_LOG_PATH is set
- Hash chain continuity across process restarts (resumes from last record)
- Thread-safe sync emit (no silent drops if await missed)
- Graceful fallback to NullSink on configuration errors

New files:
- src/telemachy/audit.py (AuditSink, NullSink, hash chain logic)
- tests/test_audit.py (7 contract tests for sink behavior)
- docs/audit-log.md (schema, event types, verification guide)

Modified files:
- config.py: added AUDIT_LOG_PATH and AUDIT_HASH_CHAIN settings
- executor.py: inject sink, emit 11 event types at state transitions
- cli.py: build sink from settings and inject into executor
- .env.example, CLAUDE.md: document new env vars

All 56 tests pass. Coverage: 78.89% (exceeds 75% gate).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
No core defects, security gaps, safety hazards, or functional bugs identified.
Implementation is complete with 56 passing tests (78.89% coverage).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
Verdict: CLEAN
- No core defects identified
- No security gaps identified
- No safety hazards identified
- No functional bugs identified

5 feature expansion ideas rejected as out-of-scope.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
@mvillmow mvillmow enabled auto-merge (squash) June 28, 2026 18:45
GHSA-4xgf-cpjx-pc3j)

Signed-off-by: Micah Villmow <4211002+mvillmow@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MINOR] §15: No audit trail for workflow execution events

1 participant