feat(gateway): phase7 public access layer (entitlements, rate limits, public list)

This commit is contained in:
Apple
2026-03-05 09:19:25 -08:00
parent e6e705a38b
commit 465669fc1d
5 changed files with 2187 additions and 26 deletions

View File

@@ -45,6 +45,79 @@ ROUTER_LATENCY = Histogram(
buckets=[0.5, 1.0, 2.0, 5.0, 10.0, 30.0, 60.0, 120.0]
)
# === Experience Bus Phase-4 Metrics ===
GATEWAY_EXPERIENCE_PUBLISHED_TOTAL = Counter(
"gateway_experience_published_total",
"Gateway experience event publish/store status",
["status"] # ok, err
)
GATEWAY_POLICY_DECISIONS_TOTAL = Counter(
"gateway_policy_decisions_total",
"Gateway policy (SOWA) decisions",
["sowa_decision", "reason"]
)
GATEWAY_USER_SIGNAL_TOTAL = Counter(
"gateway_user_signal_total",
"Detected user signals from webhook stream",
["user_signal"] # none, positive, negative, retry, timeout
)
GATEWAY_WEBHOOK_LATENCY_MS = Histogram(
"gateway_webhook_latency_ms",
"Gateway webhook end-to-end latency in milliseconds",
buckets=[5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000]
)
GATEWAY_EXPERIENCE_EMITTED_TOTAL = Counter(
"gateway_experience_emitted_total",
"Gateway experience events emitted from webhook handler",
["status", "path"] # status: ok|err, path: normal|early_return|exception
)
GATEWAY_EARLY_RETURN_TOTAL = Counter(
"gateway_early_return_total",
"Gateway early return branches observed by reason",
["reason"]
)
GATEWAY_EVENT_FINALIZE_LATENCY_MS = Histogram(
"gateway_event_finalize_latency_ms",
"Gateway event finalize latency in milliseconds",
buckets=[1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000]
)
GATEWAY_ANTI_SILENT_TOTAL = Counter(
"gateway_anti_silent_total",
"Gateway anti-silent actions by reason/chat type",
["action", "reason", "chat_type"] # ACK_EMITTED, ACK_SUPPRESSED_COOLDOWN
)
GATEWAY_ACK_SENT_TOTAL = Counter(
"gateway_ack_sent_total",
"Gateway ACK messages sent by template/chat type",
["template_id", "chat_type"]
)
GATEWAY_ANTI_SILENT_TUNING_APPLIED_TOTAL = Counter(
"gateway_anti_silent_tuning_applied_total",
"Gateway anti-silent tuning applications by reason/chat type/template",
["reason", "chat_type", "template_id"]
)
GATEWAY_ACCESS_DECISIONS_TOTAL = Counter(
"gateway_access_decisions_total",
"Gateway access decisions for public layer",
["decision", "agent_id", "chat_type"] # allow, deny, rate_limited
)
GATEWAY_RATE_LIMITED_TOTAL = Counter(
"gateway_rate_limited_total",
"Gateway rate limit hits by scope",
["scope", "agent_id", "chat_type"] # user_global, user_agent, group_agent
)
# === Memory Service Metrics ===
MEMORY_CALLS_TOTAL = Counter(
"gateway_memory_calls_total",