Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c70972b
feat: add guardrail settings with auth-aware defaults
kavishkartha05 Nov 2, 2026
a028a61
feat: add SSRF guard for benchmark targets
kavishkartha05 Nov 2, 2026
0b521ef
feat: add pinned-IP httpx transport for benchmark clients
kavishkartha05 Nov 2, 2026
ed9a96b
feat: add exact-match target allowlist
kavishkartha05 Nov 2, 2026
c0986cc
feat: enforce SSRF and allowlist on POST /benchmark and pin connections
kavishkartha05 Nov 2, 2026
8c54c8b
feat: cap requests, concurrency and timeout; limit runs to 60 s
kavishkartha05 Nov 2, 2026
a8ed36c
feat: add active-run limits and daily request budgets
kavishkartha05 Nov 2, 2026
306a74e
feat: add stale-run reaper at startup and on a timer
kavishkartha05 Nov 2, 2026
42bc09b
feat: gate the LLM benchmark route behind LLM_BENCHMARK_ENABLED
kavishkartha05 Nov 2, 2026
de05734
feat: make /health check database connectivity
kavishkartha05 Nov 2, 2026
2de63d1
feat: delete Azure search documents when runs are deleted
kavishkartha05 Nov 2, 2026
a4cc9f5
feat: add standalone demo target service with Dockerfile
kavishkartha05 Nov 2, 2026
eb8cca6
test: use an explicit loop instead of a generator expression
kavishkartha05 Nov 2, 2026
11ad7a0
docs: document guardrail settings and guard the index name config
kavishkartha05 Nov 2, 2026
d4a4c9d
feat: add authenticated GET /config for caps, targets and feature flags
kavishkartha05 Nov 2, 2026
6c179cc
feat: flag runs the caller cannot modify as is_demo
kavishkartha05 Nov 2, 2026
253364d
feat: let callers clear their own baseline and expose Retry-After to …
kavishkartha05 Nov 2, 2026
6049492
build: add Vitest with jsdom and testing-library
kavishkartha05 Nov 2, 2026
49a7d87
feat: add session token storage, auth client, and friendly API errors
kavishkartha05 Nov 2, 2026
279ac92
feat: add landing page, access code login, magic link, and 401 handling
kavishkartha05 Nov 2, 2026
9b1a94a
feat: constrain the benchmark form to server caps and the target allo…
kavishkartha05 Nov 2, 2026
87c2669
feat: label demo runs, per-code baseline controls, and timed-out status
kavishkartha05 Nov 2, 2026
2bbdb40
build: accept VITE_API_URL as a Docker build arg; document DEMO_TARGE…
kavishkartha05 Nov 2, 2026
2970246
chore: remove stray root-level app/core/config.py
kavishkartha05 Nov 2, 2026
160258c
build: multi-stage non-root backend image; migrations opt-in via RUN_…
kavishkartha05 Nov 2, 2026
ab3b89a
build: serve the frontend as static files; add SWA config with CSP an…
kavishkartha05 Nov 2, 2026
0117167
feat: configurable backend URL and access code login for the MCP serv…
kavishkartha05 Nov 2, 2026
1c6e99f
feat: add Bicep templates for the hosted demo (Container Apps, Postgr…
kavishkartha05 Nov 2, 2026
af76f4c
ci: add CI workflow and manual OIDC deploy workflow
kavishkartha05 Nov 2, 2026
f6658f1
docs: add hosted deployment runbook
kavishkartha05 Nov 2, 2026
4ee7757
docs: add Hosted Demo section to the README
kavishkartha05 Nov 2, 2026
c69f7ef
chore: remove em-dashes from code, docs and UI copy
kavishkartha05 Nov 2, 2026
ba293df
fix: make Bicep compile (key vault URI known at start, drop unsupport…
kavishkartha05 Nov 2, 2026
7edcb48
fix: use the GA Postgres Flexible Server API version
kavishkartha05 Nov 2, 2026
bcd38d9
docs: record what is now validated in the runbook
kavishkartha05 Nov 2, 2026
788d277
feat: add createBudget parameter and raise default budget to 40 USD
kavishkartha05 Nov 3, 2026
4f7d558
feat: make Key Vault purge protection a parameter
kavishkartha05 Nov 3, 2026
dbd0a69
fix: correct the Key Vault Secrets User role id; add postgresLocation…
kavishkartha05 Nov 3, 2026
85fa8ad
docs: note the westus and westus2 split and add pre-deployment checks
kavishkartha05 Nov 3, 2026
6ff2661
fix: create a workload-profiles Container Apps environment instead of…
kavishkartha05 Nov 3, 2026
8a48406
docs: add environment mode check to the pre-deployment checklist
kavishkartha05 Nov 3, 2026
6abb738
feat: set the contact email shown on the landing page
kavishkartha05 Nov 3, 2026
41e327d
docs: require --swa-config-location when deploying the frontend
kavishkartha05 Nov 3, 2026
501684d
docs: add stage 5 deployment log (resource names only)
kavishkartha05 Nov 3, 2026
8ee5993
ci: install test dependencies for the demo-target job
kavishkartha05 Nov 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
backend:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"
- name: Install Poetry
# Same version that wrote poetry.lock.
run: pip install "poetry==2.5.1"
- name: Install dependencies
run: poetry install --no-root --no-ansi
- name: Tests (SQLite, no network)
run: poetry run pytest -q

demo-target:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: demo-target
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Tests
run: python -m pytest -q

frontend:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci --ignore-scripts
- name: Type-check
run: npx tsc -b
- name: Lint
run: npm run lint
- name: Tests
run: npm test
- name: Build and render the SWA config
env:
VITE_API_URL: https://api.example.invalid
run: npm run build:swa

node-packages:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: "20"
- name: Build the MCP server
working-directory: mcp-server
run: |
npm ci --ignore-scripts
npx tsc --noEmit
- name: Syntax-check the CLI
working-directory: cli
run: node --check bin/queryscope.js
138 changes: 138 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Deploy (manual)

# Manual only. Needs the repository variables listed in docs/deploy.md and an
# Entra app registration with a federated credential for the "production"
# environment. No cloud passwords are stored in GitHub.
on:
workflow_dispatch:
inputs:
deploy_frontend:
description: Also build and deploy the frontend
type: boolean
default: true

permissions:
id-token: write # OIDC token for azure/login
contents: read

concurrency:
group: deploy
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-24.04
environment: production
timeout-minutes: 40
env:
RG: ${{ vars.AZURE_RESOURCE_GROUP }}
ACR: ${{ vars.ACR_NAME }}
BACKEND_APP: ${{ vars.BACKEND_APP }}
TARGET_APP: ${{ vars.DEMO_TARGET_APP }}
MIGRATE_JOB: ${{ vars.MIGRATE_JOB }}
SWA_NAME: ${{ vars.SWA_NAME }}
API_URL: ${{ vars.API_URL }}
TAG: ${{ github.sha }}
steps:
- uses: actions/checkout@v4.2.2

- name: Log in to Azure (OIDC)
uses: azure/login@v2.2.0
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

- name: Log in to the registry
run: az acr login --name "$ACR"

- name: Build and push images
run: |
set -euo pipefail
SERVER="$ACR.azurecr.io"
docker build -t "$SERVER/queryscope-backend:$TAG" backend
docker build -t "$SERVER/queryscope-demo-target:$TAG" demo-target
docker push "$SERVER/queryscope-backend:$TAG"
docker push "$SERVER/queryscope-demo-target:$TAG"

- name: Run database migrations (one-off job)
run: |
set -euo pipefail
SERVER="$ACR.azurecr.io"
az containerapp job update -g "$RG" -n "$MIGRATE_JOB" \
--image "$SERVER/queryscope-backend:$TAG" --output none
EXEC=$(az containerapp job start -g "$RG" -n "$MIGRATE_JOB" --query name -o tsv)
echo "Started migration execution $EXEC"
for _ in $(seq 1 60); do
STATUS=$(az containerapp job execution show -g "$RG" -n "$MIGRATE_JOB" \
--job-execution-name "$EXEC" --query properties.status -o tsv)
echo "Migration status: $STATUS"
if [ "$STATUS" = "Succeeded" ]; then exit 0; fi
if [ "$STATUS" = "Failed" ] || [ "$STATUS" = "Stopped" ]; then
echo "Migration did not succeed; apps were NOT updated." >&2
exit 1
fi
sleep 10
done
echo "Timed out waiting for the migration job." >&2
exit 1

- name: Update the apps
run: |
set -euo pipefail
SERVER="$ACR.azurecr.io"
az containerapp update -g "$RG" -n "$BACKEND_APP" \
--image "$SERVER/queryscope-backend:$TAG" --output none
az containerapp update -g "$RG" -n "$TARGET_APP" \
--image "$SERVER/queryscope-demo-target:$TAG" --output none

- name: Check the backend is healthy
run: |
set -euo pipefail
for _ in $(seq 1 30); do
if curl -fsS "$API_URL/health" >/dev/null; then
echo "Backend healthy"
exit 0
fi
sleep 10
done
echo "Backend did not become healthy" >&2
exit 1

- uses: actions/setup-node@v4.1.0
if: ${{ inputs.deploy_frontend }}
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json

- name: Build the frontend
if: ${{ inputs.deploy_frontend }}
working-directory: frontend
env:
VITE_API_URL: ${{ vars.API_URL }}
run: |
set -euo pipefail
npm ci --ignore-scripts
npm run build:swa

- name: Fetch the Static Web Apps deployment token
if: ${{ inputs.deploy_frontend }}
id: swa
run: |
set -euo pipefail
TOKEN=$(az staticwebapp secrets list -g "$RG" -n "$SWA_NAME" --query properties.apiKey -o tsv)
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"

- name: Deploy the frontend
if: ${{ inputs.deploy_frontend }}
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ steps.swa.outputs.token }}
action: upload
# The bundle is already built; dist/ contains the rendered
# staticwebapp.config.json.
skip_app_build: true
skip_api_build: true
app_location: frontend/dist
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ CLAUDE.md

# graphify knowledge-graph output (local analysis artifacts)
graphify-out/

infra/main.parameters.json
qs-outputs.json
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Developer observability tool that runs load benchmarks against REST and LLM-backed API endpoints, stores results, tracks regressions against a pinned baseline, enforces SLA thresholds, and lets engineers query degradation patterns in natural language via a RAG pipeline.

**The gap QueryScope fills:** existing load testers (k6, JMeter) produce static reports with no AI layer. LLM observability tools (LangSmith, Langfuse) monitor AI apps but don't run load tests. QueryScope sits in the middle — self-hostable, open-source, and AI-powered.
**The gap QueryScope fills:** existing load testers (k6, JMeter) produce static reports with no AI layer. LLM observability tools (LangSmith, Langfuse) monitor AI apps but don't run load tests. QueryScope sits in the middle, self-hostable, open-source, and AI-powered.

---

Expand Down Expand Up @@ -86,10 +86,10 @@ You can also trigger benchmarks directly from Claude Desktop or Cursor via the M
QueryScope fires configurable concurrent HTTP requests at any REST endpoint using `httpx.AsyncClient` with an `asyncio.Semaphore` for concurrency control. Each request's latency is recorded in milliseconds. After all requests complete, `numpy.percentile` computes p50/p95/p99. Results are stored in PostgreSQL with raw latency arrays for later analysis.

### Baseline pinning and regression detection
Any completed run can be pinned as a baseline. Once pinned, all subsequent runs automatically compute percentage deltas against it for p50, p95, p99, avg latency, and error rate. Deltas are returned from the API and rendered inline as color-coded chips in the dashboard — red for regressions, green for improvements, gray for negligible change (±2%). Only one baseline can be active at a time; pinning a new run atomically clears the previous one.
Any completed run can be pinned as a baseline. Once pinned, all subsequent runs automatically compute percentage deltas against it for p50, p95, p99, avg latency, and error rate. Deltas are returned from the API and rendered inline as color-coded chips in the dashboard, red for regressions, green for improvements, gray for negligible change (±2%). Only one baseline can be active at a time; pinning a new run atomically clears the previous one.

### SLA threshold enforcement
Before running a benchmark, you can optionally define pass/fail SLA thresholds for any combination of p50, p95, p99, avg latency, and error rate. After the run completes, each threshold is evaluated against the actual result and stored on the run record. The dashboard surfaces a prominent SLA Pass or SLA Fail badge per run, with a clickable per-threshold breakdown table showing target, actual, and delta values. SLA config and results are fully persisted — no frontend state involved.
Before running a benchmark, you can optionally define pass/fail SLA thresholds for any combination of p50, p95, p99, avg latency, and error rate. After the run completes, each threshold is evaluated against the actual result and stored on the run record. The dashboard surfaces a prominent SLA Pass or SLA Fail badge per run, with a clickable per-threshold breakdown table showing target, actual, and delta values. SLA config and results are fully persisted, no frontend state involved.

### LLM endpoint benchmarking
A dedicated mode for AI APIs measures time-to-first-token (TTFT) and chunks-per-second by consuming the SSE stream incrementally. Useful for comparing OpenAI vs Gemini vs Claude response characteristics under load.
Expand All @@ -109,13 +109,29 @@ When you ask a question via `/diagnose`:

### MCP server
The Node.js MCP server exposes two tools over stdio:
- `run_benchmark(target_url, method, num_requests, concurrency)` — triggers a benchmark and returns the run_id
- `query_runs(limit)` — returns a formatted summary of recent benchmark runs with latency metrics
- `run_benchmark(target_url, method, num_requests, concurrency)`, triggers a benchmark and returns the run_id
- `query_runs(limit)`, returns a formatted summary of recent benchmark runs with latency metrics

Connect it to Claude Desktop and you can say "benchmark httpbin with 50 requests at concurrency 10" and Claude will call the tool, run the benchmark, and analyze the results autonomously.

---

## Hosted Demo

A live, invite-only demo runs on Azure for recruiters and reviewers.

- **Live URL:** _coming soon (placeholder: add the Static Web App URL here)_
- **Access:** invite-only. Each visitor gets a personal access code (or a one-click
link). To request one, email the address shown on the demo's landing page, or open
an issue on this repository.
- **What it is safe for:** benchmarks can only target a small allowlist (a demo
service plus httpbin.org), and runs are capped at 500 requests, concurrency 20,
10 s per request and 60 s per run. Your runs are private to your code; the seeded
example runs are shared and read-only.
- **How it is deployed:** see [docs/deploy.md](docs/deploy.md). The hosted backend
runs as a single replica by design, so the autoscaler in `k8s/hpa.yaml` does not
apply to it.

## Quick Start

**Prerequisites:** Docker Desktop, Node.js
Expand Down Expand Up @@ -163,7 +179,7 @@ Run `npx queryscope-cli mcp` to print the config snippet, then paste it into `~/
}
```

Restart Claude Desktop and you can say *"Use queryscope to benchmark https://api.example.com/endpoint with 20 requests"* — Claude will call the tool, fire the HTTP requests, and analyze the results autonomously.
Restart Claude Desktop and you can say *"Use queryscope to benchmark https://api.example.com/endpoint with 20 requests"*, Claude will call the tool, fire the HTTP requests, and analyze the results autonomously.

---

Expand Down
3 changes: 0 additions & 3 deletions app/core/config.py

This file was deleted.

11 changes: 11 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.env
.env.*
.venv/
__pycache__/
*.pyc
.pytest_cache/
tests/
*.db
.git/
Dockerfile
.dockerignore
25 changes: 25 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,28 @@ CODE_PEPPER=
ADMIN_API_KEY=
# Hosted only: number of trusted proxy hops in front of the app (see config.py).
TRUSTED_PROXY_HOPS=0

# --- Guardrails (hosted demo). Every value below shows its default. ---------
# Hard caps, enforced in the request schemas for every client.
MAX_NUM_REQUESTS=500
MAX_CONCURRENCY=20
MAX_REQUEST_TIMEOUT_S=10
RUN_WALL_CLOCK_LIMIT_S=60
# Usage limits, computed from the runs table. Enforced only when AUTH_ENABLED=true.
MAX_CONCURRENT_RUNS=2
MAX_ACTIVE_RUNS_PER_CODE=1
DAILY_BUDGET_PER_CODE=2000
DAILY_BUDGET_GLOBAL=10000
# Runs stuck pending/running past the wall-clock limit plus this grace are marked failed.
REAPER_GRACE_SECONDS=120
REAPER_INTERVAL_SECONDS=60
# SSRF protection: refuse loopback, private, link-local, CGNAT, multicast and
# reserved targets. Keep true when hosted; false only for local development
# against localhost services.
BLOCK_PRIVATE_TARGETS=true
# Exact hostnames, comma-separated (no wildcards). Add your demo target's public
# hostname here. Enforced when AUTH_ENABLED=true unless TARGET_ALLOWLIST_ENABLED overrides it.
ALLOWED_TARGET_HOSTS=httpbin.org
# TARGET_ALLOWLIST_ENABLED=
# LLM benchmark route: off when AUTH_ENABLED=true unless set here.
# LLM_BENCHMARK_ENABLED=false
Loading
Loading