[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
301dce301a
357 files changed
+118831
-5113
No files matched your search
@@ -0,0 +1,75 @@
|
||||
//! AT-3.14-04: the accepted discovery budget (≤150 ms p95) measured on the real endpoint.
|
||||
//!
|
||||
//! The measurement is a real one: sequential HTTP `prompts/list` requests against the task-owned
|
||||
//! loopback MCP server, the real PostgreSQL registry and the fixture's three bound Published Prompt
|
||||
//! Versions in a debug build. It is recorded as evidence with workload/revision/environment/sample
|
||||
//! count instead of being replaced by an assertion about speed. A future release benchmark is not
|
||||
//! part of this story.
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use super::fixtures::*;
|
||||
|
||||
const SAMPLES: usize = 30;
|
||||
const WARMUP: usize = 3;
|
||||
const BUDGET: Duration = Duration::from_millis(150);
|
||||
|
||||
fn percentile(sorted: &[Duration], percentile: f64) -> Duration {
|
||||
let rank = ((percentile / 100.0) * sorted.len() as f64).ceil() as usize;
|
||||
sorted[rank.saturating_sub(1).min(sorted.len() - 1)]
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn prompts_list_discovery_p95_stays_within_the_accepted_budget() {
|
||||
let endpoint = prompt_endpoint().await;
|
||||
|
||||
for _ in 0..WARMUP {
|
||||
let body = endpoint.modern("prompts/list", json!({}), None).await;
|
||||
assert!(
|
||||
body["result"].is_object(),
|
||||
"warmup list must succeed: {body}"
|
||||
);
|
||||
}
|
||||
|
||||
let mut samples = Vec::with_capacity(SAMPLES);
|
||||
for _ in 0..SAMPLES {
|
||||
let started = Instant::now();
|
||||
let body = endpoint.modern("prompts/list", json!({}), None).await;
|
||||
samples.push(started.elapsed());
|
||||
assert!(
|
||||
body["result"]["prompts"].is_array(),
|
||||
"every measured list must serve the bound page: {body}"
|
||||
);
|
||||
}
|
||||
samples.sort_unstable();
|
||||
|
||||
let p50 = percentile(&samples, 50.0);
|
||||
let p95 = percentile(&samples, 95.0);
|
||||
let max = *samples.last().unwrap();
|
||||
let report = json!({
|
||||
"case": "AT-3.14-04",
|
||||
"surface": "prompts/list",
|
||||
"revision": MODERN_REVISION,
|
||||
"workload": "one bound Published Prompt snapshot of 3 versions (typed arguments), no pagination",
|
||||
"environment": "debug build, task-owned loopback MCP server, PostgreSQL test container, 4 vCPU",
|
||||
"samples": SAMPLES,
|
||||
"warmup_samples": WARMUP,
|
||||
"p50_ms": p50.as_secs_f64() * 1_000.0,
|
||||
"p95_ms": p95.as_secs_f64() * 1_000.0,
|
||||
"max_ms": max.as_secs_f64() * 1_000.0,
|
||||
"budget_ms": BUDGET.as_millis(),
|
||||
});
|
||||
println!("AT-3.14-04 discovery latency evidence: {report}");
|
||||
|
||||
if let Ok(path) = std::env::var("CRANK_PROMPTS_P95_REPORT") {
|
||||
std::fs::write(&path, serde_json::to_vec_pretty(&report).unwrap())
|
||||
.unwrap_or_else(|error| panic!("latency evidence must be writable at {path}: {error}"));
|
||||
}
|
||||
|
||||
assert!(
|
||||
p95 <= BUDGET,
|
||||
"prompts/list discovery p95 {p95:?} must stay within {BUDGET:?} ({report})"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user