Module logging

Module logging 

Source
Expand description

AI prompt/response logging engine (DW-081): the per-generation compiled logging config plus redactor.

Wraps the ai.logging config block and its compiled Redactor into one immutable engine stored on the dataplane behind an ArcSwap and swapped on reload. The capture hook in dataplane::ai_proxy consults this engine to decide whether to capture a request, apply sampling, and redact before storage.

§Sampling

The sample decision is DETERMINISTIC per request: a hash of the request id maps to a 0.0..=1.0 value, and the request is captured when that value is below sample_rate. A re-send with the same request id lands on the same decision (reproducible), and the distribution is uniform across request ids.

§Dependency direction

ai depends on config only (see scripts/check_deps.py); this module reads config::ai::AiConfig and nothing else. The analytics RECORD DTO lives in analytics (a plain struct, not importing ai) — the dataplane converts at the call site.

Structs§

AiLoggingEngine
The per-generation compiled logging engine (DW-081): the enabled flag, sampling rate, retention window, and compiled redactor. Built at dataplane refresh from the published config; immutable once built. Stored on the dataplane behind an ArcSwap and swapped on reload, so a logging change applies to the next request with no restart.