Skip to content

feat(audit): add terminal operation lifecycle - #74

Open
P4ST4S wants to merge 1 commit into
mainfrom
feat/audit-operation-lifecycle
Open

feat(audit): add terminal operation lifecycle#74
P4ST4S wants to merge 1 commit into
mainfrom
feat/audit-operation-lifecycle

Conversation

@P4ST4S

@P4ST4S P4ST4S commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary

Introduce the audit operation lifecycle primitives required by v1.2.0: UUIDv7 correlation IDs, explicit terminal outcomes, and a concurrency-safe exactly-once finalizer shared by HTTP and stdio transports.

Persist the additive fields in JSONL and SQLite, including migrations for existing SQLite databases, and document the v1.2 security invariants.

Context

Foundation for #69 and #73.

Approach

  • assign an audit_operation_id when a request enters the proxy
  • centralize terminal recording through audit.Operation.Finalize
  • reject duplicate finalization while allowing a retry after a storage failure
  • record success, denied, rate_limited, and upstream JSON-RPC error outcomes in the existing completed paths
  • preserve all legacy audit fields and legacy signature semantics

Transport failure finalization remains in the dedicated follow-up PRs for #69.

Test plan

  • go test -race ./internal/audit/... ./internal/proxy/...
  • go test -race ./...
  • go build ./...
  • go vet ./...

All commands pass.

Stability impact

Adds the optional audit_operation_id and outcome fields to the stable audit JSON schema. Existing fields and the legacy signature signed field set are unchanged.

Existing SQLite databases are migrated additively with nullable columns, so legacy rows remain readable.

Notes for reviewer

The finalizer deliberately marks an operation complete only after durable store append succeeds. This prevents duplicate successful writes while preserving the ability to retry a transient audit storage failure.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.58824% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/audit/operation.go 70.58% 9 Missing and 6 partials ⚠️
internal/proxy/stdio.go 56.66% 10 Missing and 3 partials ⚠️
internal/proxy/http.go 76.00% 3 Missing and 3 partials ⚠️
internal/audit/storage/sqlite.go 80.00% 2 Missing and 2 partials ⚠️
internal/proxy/policy.go 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants