feat: real two-persona workload to DBRE triage flow#104
Merged
Conversation
Users run guided, read-only MongoDB workloads from a console; each query's real explain evidence is captured and attributed. The DBRE triages the actual slowest captured queries (ranked by evidence, not wall-clock), diagnoses one through the existing ESR analyzer, and approves a hash-bound index fix the controller applies and verifies - replacing the hardcoded demo query as the primary path. Seeded role-based login (scrypt + HS256 httpOnly session); user vs DBRE planes. Guided query builder + evidence capture to query_log; evidence-ranked queue. POST /run accepts a captured query (natural-plan diagnosis); approver derives from the verified session. Workload-baseline seed keeps trap shapes slow so the ESR fix verifies. EvidencePack v1 unchanged; agents read-only; mutation backend-only after approval.
…age range deploy/deploy_cloudrun.sh: write RUN_API_TOKEN + SESSION_SECRET into Secret Manager and reference via --set-secrets (no plaintext in the Cloud Run env-var config); grant the SA on all three secrets. deploy/cloudrun.md: smoke tests obtain a DBRE bearer and diagnose a captured query; note the approver comes from the verified session. controller/workload.py: assert_safe_query validates customer.age range bounds are ints within 16..75. Format tests/unit/test_auth.py.
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
Replaces the single hardcoded demo query with a real two-persona loop:
explainevidence is captured and attributed to whoever ran it.The queries the DBRE fixes are the ones users really ran. EvidencePack v1 is unchanged, agents/tools stay read-only, and index mutation happens only after a matching hash-bound approval — with the approver identity derived from the verified session, never the browser.
Key changes
query_logcollection (kept separate from the diagnose-run ledger).GET /workload/slow-queries, attributed per user, bounded + sorted Mongo-side.POST /runaccepts acaptured_query_idand diagnoses that query's natural plan (no forced index hint); the captured filter is re-validated before it reaches the backend. Approver is taken from the verified DBRE session.seed/seed_workload.pyresets a baseline index set so trap shapes stay genuinely slow and the ESR fix verifies as a real improvement (re-runresetbetween demos).seed/seed_users.pyseeds the three accounts.Deploy notes (read before deploying)
SESSION_SECRETmust be byte-identical on BOTH services (read API + dashboard). Without it on the dashboard, middleware bounces every request to/logineven after a successful sign-in — login silently fails. Both deploy paths now require it (deploy/deploy_cloudrun.sh+dashboard/DEPLOY.md).SESSION_SECRETis unset in production.seed_users.py) and the workload baseline (seed_workload.py verify) against the cluster before the demo.Post-deploy smoke test
The local E2E ran the deterministic controller. Add one check at the deploy gate: diagnose a captured query through the Agent Engine path (production runs the three split Vertex roles with the new
current_index=None) and confirm the DIAGNOSED → approve → VERIFIED loop.Test plan / verification
controller/auth.py+api/auth.py(auth is security-critical).mappingproxydefect in apply+verify (only reachable through the live engine, bypassed by the orchestrator unit tests) was caught by the browser E2E and fixed with a regression test.