1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//! Prometheus-compatible metrics for the hirn engine.
//!
//! Uses the `metrics` crate facade so any `Recorder` backend works — when no
//! recorder is installed, all calls are no-op with zero overhead.
//!
//! Metric naming follows Prometheus conventions:
//! - Counters: `_total` suffix
//! - Histograms: `_seconds` or `_bytes` unit suffix
//! - Gauges: descriptive name, no suffix convention
// ─── Counter names ──────────────────────────────────────────────
/// Total remember operations (labels: realm, status).
pub const REMEMBER_TOTAL: &str = "hirn_remember_total";
/// Total recall operations (labels: realm, status).
pub const RECALL_TOTAL: &str = "hirn_recall_total";
/// Total consolidation operations.
pub const CONSOLIDATION_TOTAL: &str = "hirn_consolidation_total";
/// Total admission rejections (labels: realm).
pub const ADMISSION_REJECTED_TOTAL: &str = "hirn_admission_rejected_total";
/// Total authorization decisions (labels: decision=allow|deny).
pub const AUTHZ_DECISIONS_TOTAL: &str = "hirn_authz_decisions_total";
/// Total RPE routing decisions (labels: realm, namespace, model_id, route, threshold_band).
pub const RPE_PARTITION_ROUTING_TOTAL: &str = "hirn_rpe_partition_routing_total";
/// Total interference-driven consolidation requests (labels: cause).
pub const INTERFERENCE_CONSOLIDATION_TRIGGER_TOTAL: &str =
"hirn_interference_consolidation_trigger_total";
/// Total suppressed interference-driven consolidation requests (labels: reason).
pub const INTERFERENCE_CONSOLIDATION_SUPPRESSED_TOTAL: &str =
"hirn_interference_consolidation_suppressed_total";
/// Total consolidation feedback events applied to the interference backlog (labels: outcome).
pub const INTERFERENCE_CONSOLIDATION_FEEDBACK_TOTAL: &str =
"hirn_interference_consolidation_feedback_total";
/// Total preview-package path decisions (labels: surface=recall|think, path=seeded_reuse|hydrated_refetch).
pub const PREVIEW_PACKAGE_PATH_TOTAL: &str = "hirn_preview_package_path_total";
/// Total offline jobs submitted to the scheduler.
pub const OFFLINE_JOB_SUBMITTED_TOTAL: &str = "hirn_offline_job_submitted_total";
/// Total offline jobs completed successfully.
pub const OFFLINE_JOB_COMPLETED_TOTAL: &str = "hirn_offline_job_completed_total";
/// Total offline jobs that failed.
pub const OFFLINE_JOB_FAILED_TOTAL: &str = "hirn_offline_job_failed_total";
/// Total offline jobs that were skipped.
pub const OFFLINE_JOB_SKIPPED_TOTAL: &str = "hirn_offline_job_skipped_total";
/// Total HirnQL executions by runtime path (labels: statement, path).
pub const QL_EXECUTION_PATH_TOTAL: &str = "hirn_ql_execution_path_total";
// ─── Histogram names ────────────────────────────────────────────
/// Recall duration in seconds (labels: realm).
pub const RECALL_DURATION_SECONDS: &str = "hirn_recall_duration_seconds";
/// Store (remember) duration in seconds (labels: realm).
pub const STORE_DURATION_SECONDS: &str = "hirn_store_duration_seconds";
/// Batch remember stage duration in seconds (labels: realm, stage).
pub const BATCH_REMEMBER_STAGE_DURATION_SECONDS: &str =
"hirn_batch_remember_stage_duration_seconds";
/// Consolidation duration in seconds.
pub const CONSOLIDATION_DURATION_SECONDS: &str = "hirn_consolidation_duration_seconds";
/// Authorization latency in seconds.
pub const AUTHZ_LATENCY_SECONDS: &str = "hirn_authz_latency_seconds";
/// Embedding latency in seconds.
pub const EMBEDDING_LATENCY_SECONDS: &str = "hirn_embedding_latency_seconds";
/// Preview-package resolution latency in seconds (labels: surface=recall|think, path=seeded_reuse|hydrated_refetch).
pub const PREVIEW_PACKAGE_RESOLUTION_SECONDS: &str = "hirn_preview_package_resolution_seconds";
/// Offline job runtime duration in seconds.
pub const OFFLINE_JOB_DURATION_SECONDS: &str = "hirn_offline_job_duration_seconds";
// ─── Gauge names ────────────────────────────────────────────────
/// Total memory count across all layers.
pub const MEMORY_COUNT: &str = "hirn_memory_count";
/// Total graph node count.
pub const GRAPH_NODE_COUNT: &str = "hirn_graph_node_count";
/// Number of recall candidates returned.
pub const RECALL_CANDIDATES: &str = "hirn_recall_candidates";
/// Storage bytes (labels: realm).
pub const STORAGE_BYTES: &str = "hirn_storage_bytes";
/// Total graph edges (labels: realm).
pub const GRAPH_EDGES_TOTAL: &str = "hirn_graph_edges_total";
/// Total provider fallback events (labels: realm, provider_type=embed|llm).
pub const PROVIDER_FALLBACK_TOTAL: &str = "hirn_provider_fallback_total";
/// Event log sequence number (labels: realm).
pub const EVENT_LOG_SEQ: &str = "hirn_event_log_seq";
/// Number of loaded Cedar policies.
pub const POLICY_COUNT: &str = "hirn_policy_count";
/// Current unresolved interference backlog score.
pub const INTERFERENCE_CONSOLIDATION_BACKLOG_SCORE: &str =
"hirn_interference_consolidation_backlog_score";
/// Number of namespaces contributing to the unresolved interference backlog.
pub const INTERFERENCE_CONSOLIDATION_BACKLOG_NAMESPACES: &str =
"hirn_interference_consolidation_backlog_namespaces";
/// Backlog score reduced by the last successful consolidation feedback.
pub const INTERFERENCE_CONSOLIDATION_LAST_SUCCESS_REDUCED_SCORE: &str =
"hirn_interference_consolidation_last_success_reduced_score";
/// Backlog score still outstanding after the last successful consolidation feedback.
pub const INTERFERENCE_CONSOLIDATION_LAST_SUCCESS_REMAINING_SCORE: &str =
"hirn_interference_consolidation_last_success_remaining_score";
/// Number of queued offline jobs.
pub const OFFLINE_JOB_QUEUE_DEPTH: &str = "hirn_offline_job_queue_depth";
/// Number of offline jobs currently running.
pub const OFFLINE_JOB_RUNNING: &str = "hirn_offline_job_running";
/// Number of offline jobs completed since process start.
pub const OFFLINE_JOB_COMPLETED: &str = "hirn_offline_job_completed";
/// Number of offline jobs failed since process start.
pub const OFFLINE_JOB_FAILED: &str = "hirn_offline_job_failed";
/// Number of offline jobs skipped since process start.
pub const OFFLINE_JOB_SKIPPED: &str = "hirn_offline_job_skipped";
// ─── Compaction metrics ─────────────────────────────────────────
/// Compaction duration in seconds.
pub const COMPACTION_DURATION_SECONDS: &str = "hirn_compaction_duration_seconds";
/// Total compaction operations.
pub const COMPACTION_TOTAL: &str = "hirn_compaction_total";
/// Fragments removed during compaction.
pub const COMPACTION_FRAGMENTS_REMOVED: &str = "hirn_compaction_fragments_removed";
/// Fragments added during compaction.
pub const COMPACTION_FRAGMENTS_ADDED: &str = "hirn_compaction_fragments_added";
/// Number of datasets compacted per pass.
pub const COMPACTION_DATASETS: &str = "hirn_compaction_datasets";
/// Memories archived during compaction.
pub const COMPACTION_MEMORIES_ARCHIVED: &str = "hirn_compaction_memories_archived";