[skip ci] wip: preserve Hermes crank development checkpoint
Owner-authorized recovery of accumulated source changes.
Includes accepted work and in-progress changes; NOT a release or acceptance.
Parent baseline 1b6db09bd1. Runtime data, build caches and local credentials excluded.
This commit is contained in:
1 parent
1b6db09bd1
commit
75fe5a123c
357 files changed
+118831
-5113
No files matched your search
@@ -3,15 +3,47 @@ use std::{collections::BTreeSet, time::Duration};
|
||||
use crank_metrics::{
|
||||
CacheOutcome, ConfirmationOutcome, DbPoolState, Exporter, HttpMethod, HttpRoute,
|
||||
HttpStatusClass, IdempotencyOutcome, InFlightGuard, InvocationSource, LimitStage, McpMethod,
|
||||
McpOutcome, McpResponseMode, SignalType, ToolErrorKind, ToolInvocationMetrics, ToolOutcome,
|
||||
UpstreamOperationKind, UpstreamOutcome, UpstreamRequestMetrics, initialize_gauges,
|
||||
metric_schema, record_cache_outcome, record_confirmation_outcome, record_export_failure,
|
||||
record_http_request, record_idempotency_outcome, record_invocation_history_lost,
|
||||
record_limit_rejection, record_mcp_request, record_tool_invocation, record_upstream_request,
|
||||
set_catalog, set_db_pool_connections, set_mcp_active_sessions, set_mcp_session_metrics_fresh,
|
||||
McpOutcome, McpResponseMode, MetricService, SignalType, ToolErrorKind, ToolInvocationMetrics,
|
||||
ToolOutcome, UpstreamOperationKind, UpstreamOutcome, UpstreamRequestMetrics,
|
||||
bind_metric_service, initialize_gauges, metric_schema, record_cache_outcome,
|
||||
record_confirmation_outcome, record_export_failure, record_http_request,
|
||||
record_idempotency_outcome, record_invocation_history_lost, record_limit_rejection,
|
||||
record_mcp_request, record_tool_invocation, record_upstream_request, set_catalog,
|
||||
set_db_pool_connections, set_mcp_active_sessions, set_mcp_session_metrics_fresh,
|
||||
};
|
||||
use metrics_util::debugging::DebuggingRecorder;
|
||||
|
||||
/// Service binding is process-global (`OnceLock`), so every case that needs a
|
||||
/// different service runs in a fresh child re-executed from this same test
|
||||
/// binary instead of resetting a global.
|
||||
const BINDING_ROLE_ENV: &str = "CRANK_METRICS_TEST_BINDING_ROLE";
|
||||
|
||||
fn route_to_child(role: &str, test: &str) -> bool {
|
||||
match std::env::var(BINDING_ROLE_ENV).ok().as_deref() {
|
||||
Some(actual) if actual == role => false,
|
||||
Some(actual) => panic!("child for {test} runs with role {actual}, expected {role}"),
|
||||
None => {
|
||||
let output =
|
||||
std::process::Command::new(std::env::current_exe().expect("current test binary"))
|
||||
.args([test, "--exact", "--nocapture"])
|
||||
.env(BINDING_ROLE_ENV, role)
|
||||
.output()
|
||||
.expect("re-executed binding child");
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"binding child {role}/{test} failed:\nstdout:\n{}\nstderr:\n{}",
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn bind(service: MetricService) {
|
||||
bind_metric_service(service).expect("isolated metrics binding for this fixture");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schema_names_are_unique_and_labels_are_closed() {
|
||||
let schema = metric_schema();
|
||||
@@ -82,6 +114,10 @@ fn application_outcomes_are_distinct_from_transport_success() {
|
||||
|
||||
#[test]
|
||||
fn impossible_tool_outcome_pairs_are_normalized() {
|
||||
if route_to_child("mcp_server", "impossible_tool_outcome_pairs_are_normalized") {
|
||||
return;
|
||||
}
|
||||
bind(MetricService::McpServer);
|
||||
let recorder = DebuggingRecorder::new();
|
||||
let snapshotter = recorder.snapshotter();
|
||||
metrics::with_local_recorder(&recorder, || {
|
||||
@@ -102,6 +138,13 @@ fn impossible_tool_outcome_pairs_are_normalized() {
|
||||
|
||||
#[test]
|
||||
fn dropped_product_guards_record_aborted_outcomes() {
|
||||
if route_to_child(
|
||||
"mcp_server",
|
||||
"dropped_product_guards_record_aborted_outcomes",
|
||||
) {
|
||||
return;
|
||||
}
|
||||
bind(MetricService::McpServer);
|
||||
let recorder = DebuggingRecorder::new();
|
||||
let snapshotter = recorder.snapshotter();
|
||||
|
||||
@@ -131,6 +174,10 @@ fn has_label(key: &metrics::Key, name: &str, value: &str) -> bool {
|
||||
|
||||
#[test]
|
||||
fn diverse_calls_cannot_create_unbounded_series() {
|
||||
if route_to_child("mcp_server", "diverse_calls_cannot_create_unbounded_series") {
|
||||
return;
|
||||
}
|
||||
bind(MetricService::McpServer);
|
||||
let recorder = DebuggingRecorder::new();
|
||||
let snapshotter = recorder.snapshotter();
|
||||
|
||||
@@ -178,6 +225,13 @@ fn diverse_calls_cannot_create_unbounded_series() {
|
||||
|
||||
#[test]
|
||||
fn every_recording_api_matches_the_declared_schema() {
|
||||
if route_to_child(
|
||||
"mcp_server",
|
||||
"every_recording_api_matches_the_declared_schema",
|
||||
) {
|
||||
return;
|
||||
}
|
||||
bind(MetricService::McpServer);
|
||||
let recorder = DebuggingRecorder::new();
|
||||
let snapshotter = recorder.snapshotter();
|
||||
|
||||
@@ -259,6 +313,13 @@ fn every_recording_api_matches_the_declared_schema() {
|
||||
|
||||
#[test]
|
||||
fn admin_gauge_initialization_never_emits_mcp_only_series() {
|
||||
if route_to_child(
|
||||
"admin_api",
|
||||
"admin_gauge_initialization_never_emits_mcp_only_series",
|
||||
) {
|
||||
return;
|
||||
}
|
||||
bind(MetricService::AdminApi);
|
||||
let recorder = DebuggingRecorder::new();
|
||||
let snapshotter = recorder.snapshotter();
|
||||
metrics::with_local_recorder(&recorder, || {
|
||||
|
||||
Reference in new issue
Block a user