* feat: add domain virtual responses with a compact editor and bounded edge matching
* fix: keep traffic working during rolling edge script updates
* refactor: centralize edge management transport
The edge stores server_analytics.response_time as the TOTAL response time of
each minute's requests: site_logger.lua adds every request's time to the
minute's `:t` counter and mgmt_api.lua returns that sum in seconds.
summariseBuckets and buildHourlyPeriods treated the value as a per-minute
average and multiplied it by `requests` again, so the dashboard's Avg Response
grew with traffic: a busy site averaging ~80 ms reported ~7 s. The CLI edge
traffic panel averaged the per-minute totals, which overstated it too.
Divide the summed time by total requests, matching the Cloud path
(response_time_sum / requests), and correct the schema comment that described
the column as an average.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`server_analytics.response_time` is a per-minute AVERAGE (documented in the
schema). `summariseBuckets` and `buildHourlyPeriods` averaged those per-minute
averages unweighted (÷ number of minute-buckets), so a period's
`avgResponseTimeMs` is skewed whenever minutes carry unequal traffic. The
OpenShip Cloud path already computes the correct request-weighted average
(`response_time_sum / requests`); the self-hosted path did not.
Example — two minutes in one period: 1 request at 1000ms, then 99 at 100ms.
Correct request-weighted average is (1·1000 + 99·100) / 100 = 109ms; the
unweighted mean reported 550ms.
Both self-hosted reducers now weight each minute by its request count and
divide by total requests (guarding zero-request periods against NaN, matching
the cloud path). Exported both pure functions and added
response-time-weighting.test.ts (verified failing before the fix, passing
after). Full `bun run test` green (6/6 turbo tasks); `bun run --cwd apps/api
lint` clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>