From 2b7fb98e3ce0f98454ad183fff4b0d18ec917a3a Mon Sep 17 00:00:00 2001 From: Zeying Zhu Date: Sat, 9 May 2026 13:49:53 -0400 Subject: [PATCH] mvp #46: wire ASAP_CONTROLLER_URL env, generalize freshness probe filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `asap-query-engine` ships with `--controller-endpoint` for capability- miss notifications back to the controller (criterion #2 reverse channel). The MVP overlay sets `ASAP_CONTROLLER_URL` in `deploy/docker-compose/base.yml`, but `clap` only read the flag — not the env var — so the backend silently never notified the controller. Added `env = "ASAP_CONTROLLER_URL"` to the arg attribute so the existing compose env var is honored. Also generalized `routing/freshness_probe_cache.rs` so any metric whose name *contains* `freshness_probe_` is captured by the RAM short-circuit (was: literal prefix `http_freshness_probe_`). User-extensible probe families (e.g. `latency_freshness_probe_*`) now hit the cache without a code change. The MVP demo's three canonical probes (`http_freshness_probe_{raw,warm,archive}`) still match — verified by the existing `is_freshness_probe_matches_three_demo_spellings` test. Verification: - `cargo build --manifest-path asap-query-engine/Cargo.toml`: clean - `cargo test --lib freshness_probe_cache`: 8 passed Co-Authored-By: Claude Opus 4.7 (1M context) --- asap-query-engine/src/main.rs | 6 +++++- .../src/routing/freshness_probe_cache.rs | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/asap-query-engine/src/main.rs b/asap-query-engine/src/main.rs index 8e9bed6e..7685ab80 100644 --- a/asap-query-engine/src/main.rs +++ b/asap-query-engine/src/main.rs @@ -91,7 +91,11 @@ struct Args { /// can generate a new sketch plan. When unset (default), /// capability misses fall through to the §5.2 fallback silently. /// Example: `http://controller.svc:8080/api/v1/plan` - #[arg(long)] + /// + /// Falls back to the `ASAP_CONTROLLER_URL` env var when the flag + /// is not passed — `deploy/docker-compose/base.yml` sets the env + /// var so the MVP demo doesn't need a per-arg overlay. + #[arg(long, env = "ASAP_CONTROLLER_URL")] controller_endpoint: Option, /// Wire protocol for `--controller-endpoint`. `generic` (default) diff --git a/asap-query-engine/src/routing/freshness_probe_cache.rs b/asap-query-engine/src/routing/freshness_probe_cache.rs index c75cb63b..6932e330 100644 --- a/asap-query-engine/src/routing/freshness_probe_cache.rs +++ b/asap-query-engine/src/routing/freshness_probe_cache.rs @@ -64,18 +64,20 @@ use std::collections::HashMap; use std::sync::RwLock; use std::time::{SystemTime, UNIX_EPOCH}; -/// Metric-name prefix the cache filters on. Only metrics whose -/// name starts with this string are captured. Matches the three -/// probe metric names emitted by `deploy/fake-exporter/probes.go` -/// (`http_freshness_probe_raw` / `_warm` / `_archive`). -const PROBE_NAME_PREFIX: &str = "http_freshness_probe_"; +/// Substring the cache filters on. Any metric name containing this +/// token (with the trailing underscore to keep the tier suffix +/// disambiguated) is captured. The MVP fake-exporter emits three +/// probes named `http_freshness_probe_{raw,warm,archive}`; user- +/// extensible probes (e.g. `latency_freshness_probe_*`) are matched +/// without a code change. +const PROBE_NAME_TOKEN: &str = "freshness_probe_"; /// Returns `true` iff the metric name belongs to the freshness-probe /// family — used by both the ingest write path (filter before /// storing) and the query read path (intercept before normal /// routing). pub fn is_freshness_probe(metric: &str) -> bool { - metric.starts_with(PROBE_NAME_PREFIX) + metric.contains(PROBE_NAME_TOKEN) } /// One cached entry: the most-recent `(timestamp, value)` for a