feat(judge): watch the judge providers' plan usage; switch to the fallback before the wall
deploy / test (push) Successful in 5m35s
deploy / build (push) Successful in 6m0s

GLM's weekly window ran out while the judge had spent ~0.1% of it: other
consumers of the shared key starve the judge, and ClawMates learned only from
failed phases. A poller now reads z.ai's quota API and Kimi's usages API every
10 minutes, warns once per window per reset at 80%, and the evaluator skips a
judge whose plan is at 95% in any window for the (equally independent)
fallback — only on a real reading, never on a missing one. GET
/api/judge/quota shows the readings.

Parsers pinned to the shapes both APIs returned on 2026-09-23.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Omar Sobh
2026-09-23 07:55:10 -05:00
co-authored by Claude Opus 5.5
parent dd335ccfe6
commit 318a6791b9
5 changed files with 335 additions and 1 deletions
+4
View File
@@ -448,6 +448,10 @@ async fn run() -> Result<(), String> {
cm_api::beszel::spawn_poller(pool.clone(), std::time::Duration::from_secs(15));
// Fleet automation: evaluate metric-threshold rules → drain/undrain/alert.
cm_api::node_rules::spawn_evaluator(pool.clone(), std::time::Duration::from_secs(20));
// Judge providers' plan usage (z.ai, Kimi): warn at 80%, and let the
// evaluator skip a judge at 95% for the fallback. Ten minutes: the windows
// are hours and days long, and each poll is one tiny GET per provider.
cm_api::judge_quota::spawn_poller(std::time::Duration::from_secs(600));
// Nightly: check upstream for newer dev-tool releases (claude/kimi/ollama).
cm_api::tool_versions::spawn_latest_checker(
pool.clone(),