:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore: move query_performance_ai from products/ to tools/ (#60692)
Julian Bezd0b567724bdf
diff --git a/.agents/skills/optimizing-clickhouse-and-hogql-queries/SKILL.md b/.agents/skills/optimizing-clickhouse-and-hogql-queries/SKILL.mdindex a1e7be316467..48eaa794ad42 100644--- a/.agents/skills/optimizing-clickhouse-and-hogql-queries/SKILL.md+++ b/.agents/skills/optimizing-clickhouse-and-hogql-queries/SKILL.md@@ -172,12 +172,12 @@ The Test Cluster is read-only, so you cannot try schema changes there. For those### Query performance autoresearch (the powertool)-For hard cases, [`products/query_performance_ai/`](../../../products/query_performance_ai/) wraps [pi-autoresearch](https://github.com/davebcn87/pi-autoresearch) in a coordinator that hands the LLM a query and asks it to optimize against the Test Cluster in a loop. Setup is non-trivial (Docker sandbox per query, ANTHROPIC_API_KEY, Metabase database IDs), so ask the user to run the setup themselves:+For hard cases, [`tools/query-performance-ai/query_performance_ai/`](../../../tools/query-performance-ai/query_performance_ai/) wraps [pi-autoresearch](https://github.com/davebcn87/pi-autoresearch) in a coordinator that hands the LLM a query and asks it to optimize against the Test Cluster in a loop. Setup is non-trivial (Docker sandbox per query, ANTHROPIC_API_KEY, Metabase database IDs), so ask the user to run the setup themselves:-- Coordinator and setup: [`products/query_performance_ai/README.md`](../../../products/query_performance_ai/README.md)-- Coordinator entry point: [`products/query_performance_ai/orchestrator/coordinator.py`](../../../products/query_performance_ai/orchestrator/coordinator.py)-- The campaign skill the sandboxed agent runs: [`products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md`](../../../products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md)-- Orchestration contract: [`products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.md`](../../../products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.md)+- Coordinator and setup: [`tools/query-performance-ai/README.md`](../../../tools/query-performance-ai/README.md)+- Coordinator entry point: [`tools/query-performance-ai/query_performance_ai/orchestrator/coordinator.py`](../../../tools/query-performance-ai/query_performance_ai/orchestrator/coordinator.py)+- The campaign skill the sandboxed agent runs: [`tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md`](../../../tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md)+- Orchestration contract: [`tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.md`](../../../tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.md)I am not entirely sure of the exact commands needed beyond the snippets in the README. Ask the user; the setup also takes effort on their side.diff --git a/.github/CODEOWNERS-soft b/.github/CODEOWNERS-softindex e13e83643e44..004651177722 100644--- a/.github/CODEOWNERS-soft+++ b/.github/CODEOWNERS-soft@@ -195,6 +195,7 @@ AGENTS.md @PostHog/team-devex.claude/skills/ingestion-*/ @PostHog/team-ingestiontools/pr-approval-agent/ @PostHog/team-devextools/phrocs/ @PostHog/team-devex+tools/query-performance-ai/ @PostHog/team-analytics-platformgreptile.json @PostHog/team-devexdocs/published/developing-locally.md @PostHog/team-devexdiff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 718cdf00e659..90c8ab0c6c7c 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -649,8 +649,11 @@ jobs:# CHANGED_FILES is space-separated (dorny list-files: escape).# Each entry is products/<name>/product.yaml — strip to <name>.names=$(echo "$CHANGED_FILES" | tr ' ' '\n' | sed -n 's|^products/\([^/]*\)/product.yaml$|\1|p' | xargs)+ # Drop products whose product.yaml was deleted in this PR (e.g. the+ # product moved out of products/) — there are no owners left to validate.+ names=$(for n in $names; do [ -f "products/$n/product.yaml" ] && printf '%s ' "$n"; done | xargs)if [ -z "$names" ]; then- echo "No product.yaml files in diff after filtering"+ echo "No existing product.yaml files in diff after filtering"exit 0fi./bin/hogli product:lint:owners $namesdiff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.ymlindex bbfa22527280..ee18ba3f737b 100644--- a/.github/workflows/ci-python.yml+++ b/.github/workflows/ci-python.yml@@ -69,6 +69,8 @@ jobs:- '.github/scripts/**/*.py'# PR approval agent- 'tools/pr-approval-agent/**'+ # query-performance-ai dev tool+ - 'tools/query-performance-ai/**'code-quality:needs: changes@@ -187,6 +189,11 @@ jobs:run: |pytest tools/hogli-commands/hogli_commands/tests -v --junitxml=junit-hogli-commands.xml+ - name: Run query-performance-ai tests+ shell: bash+ run: |+ pytest tools/query-performance-ai/query_performance_ai -v --junitxml=junit-query-performance-ai.xml+- name: Upload test resultsuses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0if: always()@@ -195,6 +202,7 @@ jobs:path: |junit-hogli.xmljunit-hogli-commands.xml+ junit-query-performance-ai.xml- name: Run dependency detection script testsshell: bashdiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 1a5dd9876a26..8a91697a0e70 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -3213,8 +3213,6 @@ importers:products/product_tours: {}- products/query_performance_ai: {}-products/replay:dependencies:'@posthog/icons':diff --git a/posthog/settings/web.py b/posthog/settings/web.pyindex f11d6b4cf29a..ad0c0b975909 100644--- a/posthog/settings/web.py+++ b/posthog/settings/web.py@@ -72,7 +72,6 @@ PRODUCTS_APPS = ["products.platform_features.backend.apps.PlatformFeaturesConfig","products.streamlit_apps.backend.apps.StreamlitAppsConfig","products.legal_documents.backend.apps.LegalDocumentsConfig",- "products.query_performance_ai.orchestrator.apps.QueryPerformanceAiConfig","products.access_control.backend.apps.AccessControlConfig","products.warehouse_sources_queue.backend.apps.WarehouseSourcesQueueConfig","products.business_knowledge.backend.apps.BusinessKnowledgeConfig",diff --git a/products/query_performance_ai/orchestrator/apps.py b/products/query_performance_ai/orchestrator/apps.pydeleted file mode 100644index 7e333dc8225f..000000000000--- a/products/query_performance_ai/orchestrator/apps.py+++ /dev/null@@ -1,7 +0,0 @@-from django.apps import AppConfig---class QueryPerformanceAiConfig(AppConfig):- default_auto_field = "django.db.models.BigAutoField"- name = "products.query_performance_ai.orchestrator"- label = "query_performance_ai"diff --git a/products/query_performance_ai/package.json b/products/query_performance_ai/package.jsondeleted file mode 100644index 36cec2ae25cd..000000000000--- a/products/query_performance_ai/package.json+++ /dev/null@@ -1,6 +0,0 @@-{- "name": "@posthog/products-query-performance-ai",- "scripts": {- "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. orchestrator sandboxed_autoresearch_agent -v --tb=short"- }-}diff --git a/products/query_performance_ai/product.yaml b/products/query_performance_ai/product.yamldeleted file mode 100644index 77968835ef25..000000000000--- a/products/query_performance_ai/product.yaml+++ /dev/null@@ -1,3 +0,0 @@-name: Query performance AI-owners:- - team-analytics-platformdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.example b/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.exampledeleted file mode 100644index a83704384672..000000000000--- a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.example+++ /dev/null@@ -1,6 +0,0 @@-{- "_comment": "Coordinator transport. The only supported `type` is 'coordinator' (see products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.py). `url` is the coordinator's HTTP server (host.docker.internal from inside a Docker sandbox); `token` is the random per-run token the coordinator prints to its stdout at startup.",- "type": "coordinator",- "url": "http://host.docker.internal:8765",- "token": "<coordinator token>"-}diff --git a/products/ruff.toml b/products/ruff.tomlindex 6f7d8c9806a9..839160d6466f 100644--- a/products/ruff.toml+++ b/products/ruff.toml@@ -86,7 +86,6 @@ extend-select = ["ANN001", "ANN201", "ANN202", "ANN204"]"posthog_ai/**" = ["PLC0415"]"product_analytics/**" = ["PLC0415"]"product_tours/**" = ["PLC0415"]-"query_performance_ai/**" = ["PLC0415"]"replay_vision/**" = ["PLC0415"]"revenue_analytics/**" = ["PLC0415"]"signals/**" = ["PLC0415"]diff --git a/pytest.ini b/pytest.iniindex 9b1442b4ada2..0b768928905d 100644--- a/pytest.ini+++ b/pytest.ini@@ -1,11 +1,11 @@[pytest]-pythonpath = . common tools/hogli-commands+pythonpath = . common tools/hogli-commands tools/query-performance-aienv =DEBUG=1TEST=1DJANGO_SETTINGS_MODULE = posthog.settings# --pytest-durations=0 disables the pytest-durations plugin by default; CI shard steps re-enable it explicitly-addopts = -p no:warnings --reuse-db --pytest-durations=0 --ignore=posthog/user_scripts --ignore=services/llm-gateway --ignore=services/stripe-mock --ignore=common/ingestion/acceptance_tests --ignore=tools/hogli --ignore=tools/hogli-commands --ignore=tools/traffic-sim+addopts = -p no:warnings --reuse-db --pytest-durations=0 --ignore=posthog/user_scripts --ignore=services/llm-gateway --ignore=services/stripe-mock --ignore=common/ingestion/acceptance_tests --ignore=tools/hogli --ignore=tools/hogli-commands --ignore=tools/traffic-sim --ignore=tools/query-performance-aimarkers =eediff --git a/tach.toml b/tach.tomlindex c5ad36fb7a18..1de43b1ba1be 100644--- a/tach.toml+++ b/tach.toml@@ -461,12 +461,6 @@ depends_on = []layer = "modules"-[[modules]]-path = "products.query_performance_ai"-depends_on = ["products.tasks",-]-layer = "modules"-[[modules]]path = "products.replay"depends_on = [diff --git a/products/query_performance_ai/README.md b/tools/query-performance-ai/README.mdsimilarity index 79%rename from products/query_performance_ai/README.mdrename to tools/query-performance-ai/README.mdindex 82755e76212d..21d506991acc 100644--- a/products/query_performance_ai/README.md+++ b/tools/query-performance-ai/README.md@@ -10,6 +10,8 @@ The agent is [pi-coding-agent](https://pi.dev) running the [pi-autoresearch](htt- A docker daemon (Orbstack etc).- `ANTHROPIC_API_KEY` in your `.env`.+The `python -m query_performance_ai.…` commands below need this bundle on `PYTHONPATH` (the inner `query_performance_ai` package imports `products.tasks` from the repo root, so both must be importable). Run from the repo root with `PYTHONPATH=.:tools/query-performance-ai`, or `cd tools/query-performance-ai` with the repo root on the path.+## What happens when you run it1. Fetch slow queries from Metabase's prod `system.query_log` (filtered hard to `ai_data_processing_approved = true` — we only ever feed the agent queries that the customer explicitly approved for AI analysis).@@ -22,14 +24,14 @@ The agent is [pi-coding-agent](https://pi.dev) running the [pi-autoresearch](htt```bash# Replay candidates against a Metabase-fronted test cluster:-python -m products.query_performance_ai.orchestrator.coordinator \+python -m query_performance_ai.orchestrator.coordinator \--target test_cluster --metabase-region us \--query-log-database-id 142 --test-cluster-database-id 146 \--team-id 2 --max-queries 5# Requires `hogli metabase:login --region us` first.# Replay candidates against your local dev ClickHouse:-python -m products.query_performance_ai.orchestrator.coordinator --target local+python -m query_performance_ai.orchestrator.coordinator --target local````--target` decides where candidate SQL runs. Slow queries are always sourced from Metabase regardless; only the execution destination differs.@@ -37,7 +39,7 @@ python -m products.query_performance_ai.orchestrator.coordinator --target local## Smoke test```bash-python -m products.query_performance_ai.orchestrator.coordinator --target local --test-query+python -m query_performance_ai.orchestrator.coordinator --target local --test-query````--test-query` skips Metabase and feeds `SELECT 1, sleep(1)` as the campaign SQL. End-to-end smoke — the agent should drop the `sleep` within a couple of iterations.diff --git a/products/query_performance_ai/__init__.py b/tools/query-performance-ai/query_performance_ai/__init__.pysimilarity index 100%rename from products/query_performance_ai/__init__.pyrename to tools/query-performance-ai/query_performance_ai/__init__.pydiff --git a/products/query_performance_ai/data/.gitignore b/tools/query-performance-ai/query_performance_ai/data/.gitignoresimilarity index 100%rename from products/query_performance_ai/data/.gitignorerename to tools/query-performance-ai/query_performance_ai/data/.gitignorediff --git a/products/query_performance_ai/orchestrator/__init__.py b/tools/query-performance-ai/query_performance_ai/orchestrator/__init__.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/__init__.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/__init__.pydiff --git a/products/query_performance_ai/orchestrator/backends/_query_log.py b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/_query_log.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/backends/_query_log.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/backends/_query_log.pydiff --git a/products/query_performance_ai/orchestrator/backends/base.py b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/base.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/backends/base.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/backends/base.pydiff --git a/products/query_performance_ai/orchestrator/backends/local.py b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/local.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/backends/local.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/backends/local.pydiff --git a/products/query_performance_ai/orchestrator/backends/metabase.py b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/metabase.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/backends/metabase.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/backends/metabase.pydiff --git a/products/query_performance_ai/orchestrator/backends/tests/test_backends.py b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/tests/test_backends.pysimilarity index 97%rename from products/query_performance_ai/orchestrator/backends/tests/test_backends.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/backends/tests/test_backends.pyindex bedf38460dd1..85e57fea134f 100644--- a/products/query_performance_ai/orchestrator/backends/tests/test_backends.py+++ b/tools/query-performance-ai/query_performance_ai/orchestrator/backends/tests/test_backends.py@@ -7,10 +7,10 @@ from typing import Anyimport pytestfrom unittest import mock-from products.query_performance_ai.orchestrator.backends import _query_log-from products.query_performance_ai.orchestrator.backends.base import BackendError-from products.query_performance_ai.orchestrator.backends.local import LocalClickhouseBackend-from products.query_performance_ai.orchestrator.backends.metabase import MetabaseBackend, _tag_with_log_comment+from query_performance_ai.orchestrator.backends import _query_log+from query_performance_ai.orchestrator.backends.base import BackendError+from query_performance_ai.orchestrator.backends.local import LocalClickhouseBackend+from query_performance_ai.orchestrator.backends.metabase import MetabaseBackend, _tag_with_log_commentdef _completed(stdout: str = "", stderr: str = "", returncode: int = 0) -> Any:diff --git a/products/query_performance_ai/orchestrator/coordinator.py b/tools/query-performance-ai/query_performance_ai/orchestrator/coordinator.pysimilarity index 98%rename from products/query_performance_ai/orchestrator/coordinator.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/coordinator.pyindex 6c29f1a52b3b..8c9c643c27c7 100644--- a/products/query_performance_ai/orchestrator/coordinator.py+++ b/tools/query-performance-ai/query_performance_ai/orchestrator/coordinator.py@@ -7,7 +7,7 @@ to ``localhost:$PORT`` (best-effort iptables; see run_campaign.py).Run:# --query-log-database-id 142 is ClickHouse PROD US - OFFLINE- python -m products.query_performance_ai.orchestrator.coordinator \\+ python -m query_performance_ai.orchestrator.coordinator \\--target test_cluster \\--metabase-region us \\--query-log-database-id 142 \\@@ -16,7 +16,7 @@ Run:Or just stand the server up for manual experimentation:- python -m products.query_performance_ai.orchestrator.coordinator --target local --no-spawn+ python -m query_performance_ai.orchestrator.coordinator --target local --no-spawn"""from __future__ import annotations@@ -212,13 +212,14 @@ def _spawn_one_sandbox(# Lazy import: SandboxBase pulls in Django settings, structlog, etc.# Keeping it inside the worker means `--no-spawn` doesn't pay for it._ensure_django_setup()- from products.query_performance_ai.orchestrator.harvest import harvest_artifacts # noqa: PLC0415from products.tasks.backend.services.sandbox import ( # noqa: PLC0415SandboxConfig,SandboxTemplate,get_sandbox_class_for_backend,)+ from query_performance_ai.orchestrator.harvest import harvest_artifacts # noqa: PLC0415+sandbox_name = f"qp-autoresearch-{query.query_id[:12]}-{uuid.uuid4().hex[:6]}"sandbox_env: dict[str, str] = {"COORDINATOR_URL": coordinator_url,@@ -311,15 +312,19 @@ def _spawn_one_sandbox(stderr_tail = (clone_result.stderr or "")[-2000:]raise RuntimeError(f"git clone failed in sandbox (exit {clone_result.exit_code}):\n{stderr_tail}")+ # The package lives in the tools/ bundle, not at the repo root, so the+ # bundle dir has to be on PYTHONPATH for the `-m` lookup to resolve.+ bundle_dir = f"{repo_path}/tools/query-performance-ai"command = (f"cd {shlex.quote(repo_path)} && "f"trap 'rm -f {shlex.quote(env_file)}' EXIT && "f"chmod 600 {shlex.quote(env_file)} && "f"set -a && . {shlex.quote(env_file)} && set +a && "+ f"export PYTHONPATH={shlex.quote(bundle_dir)}${{PYTHONPATH:+:$PYTHONPATH}} && "# `-m` (not direct script invocation) so relative imports inside# the package resolve. `python3 path/to/run_campaign.py` runs the# file with no parent package, which breaks `from .runtime import …`.- f"python3 -m products.query_performance_ai.sandboxed_autoresearch_agent.driver.run_campaign 2>&1"+ f"python3 -m query_performance_ai.sandboxed_autoresearch_agent.driver.run_campaign 2>&1")_log(f"[{query.query_id}] running run_campaign.py inside sandbox {sandbox.id}")diff --git a/products/query_performance_ai/orchestrator/harvest.py b/tools/query-performance-ai/query_performance_ai/orchestrator/harvest.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/harvest.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/harvest.pydiff --git a/products/query_performance_ai/orchestrator/server.py b/tools/query-performance-ai/query_performance_ai/orchestrator/server.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/server.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/server.pydiff --git a/products/query_performance_ai/orchestrator/slow_queries.py b/tools/query-performance-ai/query_performance_ai/orchestrator/slow_queries.pysimilarity index 100%rename from products/query_performance_ai/orchestrator/slow_queries.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/slow_queries.pydiff --git a/products/query_performance_ai/orchestrator/tests/test_server.py b/tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_server.pysimilarity index 95%rename from products/query_performance_ai/orchestrator/tests/test_server.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_server.pyindex 8724f6f79cb1..bd9744b6117b 100644--- a/products/query_performance_ai/orchestrator/tests/test_server.py+++ b/tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_server.py@@ -8,13 +8,8 @@ from typing import Anyimport pytest-from products.query_performance_ai.orchestrator.backends.base import BackendError, ExecutionBackend, ExecutionResult-from products.query_performance_ai.orchestrator.server import (- ServerInfo,- generate_token,- make_server,- serve_forever_in_thread,-)+from query_performance_ai.orchestrator.backends.base import BackendError, ExecutionBackend, ExecutionResult+from query_performance_ai.orchestrator.server import ServerInfo, generate_token, make_server, serve_forever_in_threadclass _StubBackend(ExecutionBackend):diff --git a/products/query_performance_ai/orchestrator/tests/test_slow_queries.py b/tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_slow_queries.pysimilarity index 98%rename from products/query_performance_ai/orchestrator/tests/test_slow_queries.pyrename to tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_slow_queries.pyindex 96b7e94c08b7..fc53979ffd89 100644--- a/products/query_performance_ai/orchestrator/tests/test_slow_queries.py+++ b/tools/query-performance-ai/query_performance_ai/orchestrator/tests/test_slow_queries.py@@ -7,7 +7,7 @@ from typing import Anyimport pytestfrom unittest import mock-from products.query_performance_ai.orchestrator import slow_queries+from query_performance_ai.orchestrator import slow_queriesdef test_build_sql_substitutes_filters() -> None:diff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/driver/run_campaign.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/run_campaign.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/driver/run_campaign.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/run_campaign.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/driver/runtime.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/runtime.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/driver/runtime.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/runtime.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/driver/sandboxing.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/sandboxing.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/driver/sandboxing.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/driver/sandboxing.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/package.json b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/package.jsonsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/package.jsonrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/package.jsondiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/campaign-review.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/campaign-review.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/campaign-review.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/campaign-review.mddiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/lane-review.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/lane-review.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/lane-review.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/lane-review.mddiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/next-experiment.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/next-experiment.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/next-experiment.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/prompts/next-experiment.mddiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/_common.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/_common.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/_common.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/_common.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_campaign_init.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_campaign_init.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_campaign_init.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_campaign_init.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_capture_baseline.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_capture_baseline.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_capture_baseline.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_capture_baseline.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_compare_results.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_compare_results.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_compare_results.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_compare_results.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_run_candidate.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_run_candidate.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_run_candidate.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/ch_run_candidate.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/tests/test_transports.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/tests/test_transports.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/tests/test_transports.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/tests/test_transports.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.mddiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/orchestration.mddiff --git a/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.example b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.examplenew file mode 100644index 000000000000..b108d0772363--- /dev/null+++ b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/adapter.json.example@@ -0,0 +1,6 @@+{+ "_comment": "Coordinator transport. The only supported `type` is 'coordinator' (see tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/transports.py). `url` is the coordinator's HTTP server (host.docker.internal from inside a Docker sandbox); `token` is the random per-run token the coordinator prints to its stdout at startup.",+ "type": "coordinator",+ "url": "http://host.docker.internal:8765",+ "token": "<coordinator token>"+}diff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.md b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.mdsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.mdrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.mddiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch_checks.py b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch_checks.pysimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch_checks.pyrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/autoresearch_checks.pydiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/baseline/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/baseline/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/baseline/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/baseline/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/campaign.json.example b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/campaign.json.examplesimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/campaign.json.examplerename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/campaign.json.examplediff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/hypotheses/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/hypotheses/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/hypotheses/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/hypotheses/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/lanes/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/lanes/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/lanes/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/lanes/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/best.sql b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/best.sqlsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/best.sqlrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/best.sqldiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/current.sql b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/current.sqlsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/current.sqlrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/current.sqldiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/original.sql b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/original.sqlsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/original.sqlrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/query/original.sqldiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/reviews/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/reviews/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/reviews/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/reviews/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runs/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runs/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runs/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runs/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runtime/.gitkeep b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runtime/.gitkeepsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runtime/.gitkeeprename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/runtime/.gitkeepdiff --git a/products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/state.json b/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/state.jsonsimilarity index 100%rename from products/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/state.jsonrename to tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/state.jsondiff --git a/products/query_performance_ai/ruff.toml b/tools/query-performance-ai/ruff.tomlsimilarity index 56%rename from products/query_performance_ai/ruff.tomlrename to tools/query-performance-ai/ruff.tomlindex c8e267b29c78..7e628d898911 100644--- a/products/query_performance_ai/ruff.toml+++ b/tools/query-performance-ai/ruff.toml@@ -1,15 +1,15 @@-extend = "../ruff.toml"+extend = "../../pyproject.toml"[lint.extend-per-file-ignores]# Pi plugin and in-sandbox driver scripts use stdout as their orchestration# protocol (pi-autoresearch's `METRIC name=value` parse format, the campaign# init's human-readable banner, structured log lines for the host-side# coordinator) so the no-print lint doesn't apply.-"sandboxed_autoresearch_agent/pi_plugin/scripts/**" = ["T201"]-"sandboxed_autoresearch_agent/pi_plugin/templates/workspace/**" = ["T201"]-"sandboxed_autoresearch_agent/driver/run_campaign.py" = ["T201"]+"query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/scripts/**" = ["T201"]+"query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/templates/workspace/**" = ["T201"]+"query_performance_ai/sandboxed_autoresearch_agent/driver/run_campaign.py" = ["T201"]# In-sandbox driver: shell-callable scripts where ANN policing isn't worth# the noise (overrides Python stdlib base-class signatures without re-typing# every arg).-"sandboxed_autoresearch_agent/driver/**" = ["ANN"]+"query_performance_ai/sandboxed_autoresearch_agent/driver/**" = ["ANN"]