fix: align replay-query quantile window with warm tier precompute window (④ ε bound) - #347
Merged
Merged
Conversation
…sue #46) Bug 12 fix (DDSketch ε-bound mismatch). The headline-2026-05-06 demo reported DDSketch quantile rel_err mean=0.126, max=0.172 — 12-17x above the controller-emitted ε=0.01 bound — even though the sketch state itself is bounded by ε. Root cause: window mismatch between the warm tier and the replay query. The warm-tier ASAPQuery streaming pre-compute is configured with `windowSize: 30` (`deploy/configs/backend-streaming.yaml`); the warm response confirms this with `precompute_window: [..) ms (width 30000 ms)`. The MVP demo's replay queries asked for `[1m]`, so the warm tier returned a 30s p99 while the archive (Thanos) honored the `[1m]` range. The two sides were computing over different data — the sketch's ε bound is irrelevant when the inputs themselves disagree. Fix: align the two quantile replay ranges (DDSketch `http_requests_ total_latency_ms`, KLL `request_size_bytes`) from `[1m]` to `[30s]`, matching the warm pre-compute window. The change touches both surfaces that need to stay in lock-step: - `deploy/configs/mvp-workload.yaml` — controller workload spec. The analyzer parses the range string to derive `time_window`, which the planner threads through to the agent's `window_duration` and the ASAPQuery aggregation's `windowSize`. - `deploy/scripts/run_mvp_demo.sh` — both the controller plan POST and the inline `replay-queries.json` heredoc the replay client issues against the backend during the soak. This is Option 1 from the bug report (workload-spec change) — the cleanest of the three because it matches the design intent that the planner pre-computes for the workload, and it touches only two config files (no controller-code change needed). New test file `deploy/scripts/tests/test_window_alignment.py` pins both halves of the alignment: 1. Static config check: parses `mvp-workload.yaml`, `run_mvp_demo.sh`'s embedded JSON, and `backend-streaming.yaml`, and asserts every quantile replay range equals the warm `windowSize`. Catches future drift on any single surface. 2. End-to-end rel_err: synthesizes a warm answer at the ε boundary and pipes it through `accuracy_reduce.py`, asserting rel_err ≤ ε. The negative twin synthesizes the pre-fix misaligned-window scenario and confirms rel_err > ε, documenting the failure mode. Expected post-fix rel_err: dominated by the sketch's own ε bound (≤ 0.01 for DDSketch, ≤ 0.005 for KLL rank-error), down from the 0.126 mean observed pre-fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the DDSketch ε-bound mismatch for criterion ④ (Accuracy) in the MVP demo (issue #46). After PR #345 + PR #111, headline-2026-05-06 reported quantile
rel_errmean=0.126, max=0.172 for 343 quantile rows — 12-17x over the controller-emitted ε=0.01. Sketch state itself is bounded by ε, so something else was inflating the error.Root cause
Window mismatch between warm tier and replay query.
windowSize: 30(seedeploy/configs/backend-streaming.yaml). The warm response stamps this in itsinfos:precompute_window: [..) ms (width 30000 ms).[1m](quantile_over_time(0.99, http_requests_total_latency_ms[1m])).[1m], so the two sides computed over different data. The sketch's ε bound says nothing about agreement when the inputs differ.Fix (Option 1 — workload-spec change)
Align the replay-query ranges to match the warm pre-compute window. Two surfaces need to move in lock-step:
deploy/configs/mvp-workload.yaml— controller workload spec. Analyzer parses the range string to derivetime_window, which threads through to the agent'swindow_durationand the ASAPQuery aggregationwindowSize.deploy/scripts/run_mvp_demo.sh— controller plan POST body (line 404) and the inlinereplay-queries.jsonheredoc (lines 564, 567) the replay client issues during the soak.Both DDSketch (
http_requests_total_latency_ms) and KLL (request_size_bytes) quantile entries change from[1m]to[30s].This was the cleanest of the three options listed in the bug — Option 2 (controller-side window calculation) would have re-touched
controller/src/planner/, and Option 3 (backend infers query range) is out of scope for the MVP. Option 1 also matches the design intent that the planner pre-computes for the workload.Expected post-fix rel_err
After alignment, the only error left is the sketch's own approximation. Both are well within their respective bounds.
What's pinned
New test file
deploy/scripts/tests/test_window_alignment.py(6 tests, all passing) pins both halves of the alignment:mvp-workload.yaml, therun_mvp_demo.shheredoc, andbackend-streaming.yaml, asserting every quantile replay range equals the warmwindowSize. Any future edit that desyncs one surface fails this test.accuracy_reduce.py, assertingrel_err ≤ ε. The negative twin reproduces the pre-fix scenario (warm 12.6% off truth) and confirmsrel_err > ε, documenting the failure mode.Test plan
pytest deploy/scripts/tests/test_window_alignment.py— 6 passeddeploy/scripts/tests/(the 13 failures intest_accuracy_reduce.pyandtest_mvp_report.pypre-exist onorigin/main— they referencegorilla_archive/ per-sketch labels other parallel agents are addressing)cargo build --releaseclean (no controller code changed; build is a sanity check only)run_mvp_demo.shend-to-end and confirmaccuracy.csvrel_err mean drops below εCloses #46 (criterion ④ ε-bound mismatch).
🤖 Generated with Claude Code