refactor(safety): apply consistent formatting across services and tests
Improved code readability and uniformity by standardizing line breaks, indentation, and inline conditions across safety-related services, models, and tests, including content filters, validation rules, and emergency controls.
This commit is contained in:
@@ -69,7 +69,18 @@ class SafetyMetrics:
|
||||
|
||||
def _init_histogram_buckets(self) -> None:
|
||||
"""Initialize histogram buckets for latency metrics."""
|
||||
latency_buckets = [0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, float("inf")]
|
||||
latency_buckets = [
|
||||
0.01,
|
||||
0.05,
|
||||
0.1,
|
||||
0.25,
|
||||
0.5,
|
||||
1.0,
|
||||
2.5,
|
||||
5.0,
|
||||
10.0,
|
||||
float("inf"),
|
||||
]
|
||||
|
||||
for name in [
|
||||
"validation_latency_seconds",
|
||||
@@ -321,7 +332,8 @@ class SafetyMetrics:
|
||||
async with self._lock:
|
||||
total_validations = sum(self._counters["safety_validations_total"].values())
|
||||
denied_validations = sum(
|
||||
v for k, v in self._counters["safety_validations_total"].items()
|
||||
v
|
||||
for k, v in self._counters["safety_validations_total"].items()
|
||||
if "decision=deny" in k
|
||||
)
|
||||
|
||||
@@ -358,11 +370,13 @@ class SafetyMetrics:
|
||||
"rollbacks_executed": sum(
|
||||
self._counters["safety_rollbacks_total"].values()
|
||||
),
|
||||
"mcp_calls": sum(
|
||||
self._counters["safety_mcp_calls_total"].values()
|
||||
),
|
||||
"pending_approvals": self._gauges.get("safety_pending_approvals", {}).get("", 0),
|
||||
"active_checkpoints": self._gauges.get("safety_active_checkpoints", {}).get("", 0),
|
||||
"mcp_calls": sum(self._counters["safety_mcp_calls_total"].values()),
|
||||
"pending_approvals": self._gauges.get(
|
||||
"safety_pending_approvals", {}
|
||||
).get("", 0),
|
||||
"active_checkpoints": self._gauges.get(
|
||||
"safety_active_checkpoints", {}
|
||||
).get("", 0),
|
||||
}
|
||||
|
||||
async def reset(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user