Documentation
¶
Overview ¶
Package provideraudit records every Provider.Complete invocation into a per-project SQLite audit log so the Web UI's "Provider Calls" panel can show recent calls in real time, let users open a modal with the full prompt/response/headers, and replay a call with edited input.
The package wraps a provider.Provider in WithAudit and is composed by pkg/provider.Build above WithRequestIDTracing/WithPanicSafety. It is a best-effort observer: persistence failures (DB locked, disk full) MUST NOT fail the originating provider call. The wrapper therefore swallows every error from pkg/state once it has logged the failure to stderr.
Redaction is applied to the headers blob before insert, never at read time, so on-disk rows are guaranteed safe even if a future caller forgets to redact. The prompt and response themselves are stored verbatim — they originate from user/orchestrator input and never carry the cloop binary's own credentials.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetGlobalNotifier ¶
func SetGlobalNotifier(n CallNotifier)
SetGlobalNotifier registers (or replaces) the global notifier. Pass nil to disable notifications. The pointer-based atomic swap means the audit wrapper can read the current notifier without locking on every call.
func WithAudit ¶
WithAudit returns a Provider that records every Complete invocation to the per-project audit log identified by the WorkDir option. When WorkDir is empty the call is forwarded unmodified — observability is opt-in via the workdir, not mandatory.
Idempotent: applying the wrapper twice has the same effect as applying it once. Composes safely with WithPanicSafety / WithRequestIDTracing in either order, but the canonical assembly in pkg/provider.Build places audit BELOW request-id tagging so the audit row records the same id the caller sees attached to errors.
func WithTaskContext ¶
WithTaskContext returns a copy of ctx that carries the active task's id and title. The orchestrator binds this just before invoking p.Complete so the audit row can record which task issued the call. Empty/zero values are accepted as "no task bound".
Types ¶
type CallNotifier ¶
type CallNotifier func(workDir string, row statedb.ProviderCallRow)
CallNotifier is the optional callback invoked when a new call has been persisted. The Web UI server registers one of these via SetGlobalNotifier so it can push the row over the active WebSocket connections immediately instead of waiting for the client to poll.
Implementations MUST be non-blocking (no I/O in the calling goroutine — fan out to a worker channel) and MUST NOT panic. The audit wrapper does not recover from panics in the notifier path; that is the notifier's responsibility.