Skip to content

Commit 42e1f29

Browse files
aditik0303claude
andcommitted
feat(governance): audit pipeline — manager, console + traces sinks
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 91309f8 commit 42e1f29

8 files changed

Lines changed: 1832 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Audit sink framework for governance events.
2+
3+
This module provides a pluggable audit system that supports multiple
4+
output destinations (sinks) for governance events. Events are emitted
5+
to all registered sinks, allowing flexible audit trail configuration.
6+
7+
Usage::
8+
9+
from uipath.runtime.governance.audit import get_audit_manager, AuditEvent
10+
11+
# Get the global audit manager
12+
manager = get_audit_manager()
13+
14+
# Emit an event (goes to all registered sinks)
15+
manager.emit(AuditEvent(
16+
event_type="rule_evaluation",
17+
trace_id="abc-123",
18+
agent_name="my-agent",
19+
data={"rule_id": "ASI-01", "matched": True},
20+
))
21+
22+
# Register a custom sink
23+
manager.register_sink(MyCustomSink())
24+
25+
Built-in sinks:
26+
27+
- :class:`TracesAuditSink` – OpenTelemetry spans for Orchestrator Traces UI
28+
- :class:`ConsoleAuditSink` – stderr output for debugging
29+
30+
Sink registration:
31+
32+
- The ``traces`` sink (OpenTelemetry spans → Orchestrator audit UI) is
33+
**platform-mandated** and always registered. It cannot be disabled by
34+
a developer-side env var — governance is platform-owned.
35+
- The ``console`` sink is a developer aid for local debugging and is
36+
opt-in via env var.
37+
38+
Environment variables (developer-facing, console only):
39+
40+
- ``UIPATH_AUDIT_VERBOSE`` – verbose console output.
41+
- ``UIPATH_GOVERNANCE_CONSOLE_LOG`` – enable the console sink.
42+
"""
43+
44+
from .base import (
45+
AuditEvent,
46+
AuditManager,
47+
AuditSink,
48+
EventType,
49+
get_audit_manager,
50+
reset_audit_manager,
51+
)
52+
from .console import ConsoleAuditSink
53+
from .factory import create_sink
54+
from .traces import TracesAuditSink
55+
56+
__all__ = [
57+
# Core classes
58+
"AuditEvent",
59+
"AuditManager",
60+
"AuditSink",
61+
"EventType",
62+
# Global manager
63+
"get_audit_manager",
64+
"reset_audit_manager",
65+
# Factory
66+
"create_sink",
67+
# Built-in sinks
68+
"ConsoleAuditSink",
69+
"TracesAuditSink",
70+
]

0 commit comments

Comments
 (0)