Session infrastructure: OpenRouter + tree-split reducer + observer→LLM Team + scrum_applier #11

Merged
profit merged 118 commits from scrum/auto-apply-19814 into main 2026-04-27 15:55:24 +00:00
2 changed files with 21 additions and 17 deletions
Showing only changes of commit 6ed48c1a69 - Show all commits

View File

@ -579,22 +579,12 @@ async fn usage(State(state): State<V1State>) -> impl IntoResponse {
/// gates. A monitoring tool should evaluate the booleans + counts
/// against its own thresholds.
async fn health(State(state): State<V1State>) -> impl IntoResponse {
let workers_loaded = {
// Use a lookup with an obviously-fake id to probe — None
// could mean empty roster OR healthy roster without that id.
// We don't have a count() method on the trait; use a sample
// probe + treat presence of workers as a yes/no signal.
let probe = state.validate_workers.find("__healthcheck_probe__");
// probe is always None for the synthetic id, so this isn't
// useful. Better: rely on the fact that an empty-fallback
// InMemoryWorkerLookup ALSO returns None — there's no way
// to distinguish "loaded, just doesn't have this id" from
// "empty fallback". We'd need a count() method on WorkerLookup
// to report honestly. For now report the load attempt was
// performed (boot logs are the source of truth on rows count).
let _ = probe;
true
};
// Honest worker count via WorkerLookup::len. Production switchover
// verification: after swapping workers_500k.parquet → real Chicago
// data and restarting, this number should match the row count of
// the new file. 0 means the file was missing / unreadable / had a
// schema mismatch and the gateway booted with the empty fallback.
let workers_count = state.validate_workers.len();
let providers_configured = serde_json::json!({
"ollama_cloud": state.ollama_cloud_key.is_some(),
"openrouter": state.openrouter_key.is_some(),
@ -607,7 +597,8 @@ async fn health(State(state): State<V1State>) -> impl IntoResponse {
let usage_snapshot = state.usage.read().await.clone();
Json(serde_json::json!({
"status": "ok",
"workers_loaded": workers_loaded,
"workers_count": workers_count,
"workers_loaded": workers_count > 0,
"providers_configured": providers_configured,
"langfuse_configured": langfuse_configured,
"usage_total_requests": usage_snapshot.requests,

View File

@ -130,6 +130,16 @@ pub struct WorkerRecord {
/// hold an in-memory snapshot, not perform per-call I/O.
pub trait WorkerLookup: Send + Sync {
fn find(&self, candidate_id: &str) -> Option<WorkerRecord>;
/// Number of workers in the snapshot. Default 0 for impls that
/// genuinely don't know (e.g. a future SQL-backed lookup that
/// counts on demand). InMemoryWorkerLookup overrides with the
/// HashMap size; ParquetWorkerLookup constructs an
/// InMemoryWorkerLookup so it inherits the override. Used by
/// /v1/health to report data-load status during production
/// switchover (the Chicago dataset replaces synthetic test data;
/// the health endpoint is how operators verify the new file
/// loaded correctly without restart-and-pray).
fn len(&self) -> usize { 0 }
}
/// HashMap-backed lookup. Used by validator unit tests + as a
@ -165,4 +175,7 @@ impl WorkerLookup for InMemoryWorkerLookup {
fn find(&self, candidate_id: &str) -> Option<WorkerRecord> {
self.rows.get(candidate_id).cloned()
}
fn len(&self) -> usize {
self.rows.len()
}
}