Repository navigation
feat(auditlog): tamper-evident audit events over OTLP logs - #158
Merged
Merged
Conversation
…LP logs - Eight event types sharing Common (tenant, actor, session, source IPs); Validate() enforces required fields, enums and length limits. - Thin OTLP logs client over gRPC or HTTP/protobuf with TLS/mTLS, headers, gzip and transient-only retry. Send returns after the collector acks; partial rejection is an error. - Records carry the ctx trace/span IDs for audit-to-trace correlation.
- ToolMiddleware, AuditConfirm, AuditPermissions and EventHandler audit tool runs, human approvals, policy verdicts and hook rejections; actor via WithActor on ctx. - WithFailClosed refuses to run a tool whose audit record can't be written. - Outcome records are sent on a cancellation-detached ctx.
…y levels
- HMACKey: ArgsHMAC replaces the plain SHA-256 fingerprint (brute-forceable
for low-entropy args); every record is sequenced and HMAC-signed, and
Verify reports modified, forged, renumbered and deleted records.
- Config.Meter: records{kind,result} and export latency, so a broken audit
pipeline is visible.
- ModeBatch: bounded queue, batched export, drops counted and returned as
ErrBufferFull; per-event trace context kept. Fail-closed stays synchronous.
- Multi/MultiAll and JSONLWriter for redundant destinations.
- WithPolicy/WithLevel (None/Metadata/Request/RequestResponse) replace
WithArgs/WithFilter.
- Single-pass event encoding (~10x faster, 3 allocs).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Adds
pkg/auditlog(experimental): durable, tamper-evident "who did what" records for agent actions — tool runs, human approvals, permission verdicts, rejected requests, data and config changes — exported as OTLP log records, so the collector already running for traces and metrics carries the audit trail. Opt-in; nothing in the core imports it.Changes
Common(tenant, actor, session, source IPs). Invalid events fail atSendwithErrInvalidEvent.ModeBlocking:Sendreturns after the collector acks; partial rejection is an error.ModeBatchis opt-in, with a bounded queue and counted drops.ToolMiddleware(per-tool levels, optional fail-closed),AuditConfirm,AuditPermissions,EventHandler. Actor viaWithActor(ctx, ...).HMACKey, argument fingerprints are keyed, and every record is sequenced and HMAC-signed;Verifyreports modified, forged, renumbered, and deleted records.Multi/MultiAllplusJSONLWriterfor redundant destinations; self-health metrics viaConfig.Meter.Testing
otel/opentelemetry-collectorin both modes.Checklist
gofmt -l .prints nothingmake lintis cleanmake buildpassesmake testandmake test-racepassCHANGELOG.mdupdated if this PR is cut as a release tag (at tag time)pkg/llm/,pkg/history/, orpkg/telemetry/