Repository navigation
feat(gateway): serve pgweb and db-mcp at /svc/ routes - #751
andrewpark-scaleai wants to merge 1 commit into
Conversation
9459d49 to
7985a79
Compare
| problems += [f"website name {w.environment_name!r} is the /svc key of a SQL console the gateway serves" | ||
| for w in website_configs or [] if w.environment_name in _CONSOLE_PATHS] |
There was a problem hiding this comment.
Computer names fail too late. The new check reserves console keys only for websites. A computer named
pgweb, including a website browser computer, still passes MultiEnv's name checks. Deployment then creates its sandboxes and puts pgweb in REST_PROXY_URLS, where the new Gateway clash check stops startup. Check computer names against the console keys before creating sandboxes, and cover this case with a test.
Knowledge Base Used: Environment lifecycle and runtime access
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/env_providers/env_gateway_provider.py
Line: 1763-1764
Comment:
**Computer names fail too late.** The new check reserves console keys only for websites. A computer named `pgweb`, including a website browser computer, still passes `MultiEnv`'s name checks. Deployment then creates its sandboxes and puts `pgweb` in `REST_PROXY_URLS`, where the new `Gateway` clash check stops startup. Check computer names against the console keys before creating sandboxes, and cover this case with a test.
**Knowledge Base Used:** [Environment lifecycle and runtime access](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Fenvironment-lifecycle.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.The gateway serves the env's SQL consoles at /svc/pgweb/ and /svc/db-mcp/ from a new CONSOLE_URLS variable, behind the deployment's control token like its other guarded routes. The deploy records db_web_gateway_url and db_mcp_gateway_url once it has checked the gateway serves both, and keeps db_web_url and db_mcp_url as they are. db-mcp binds every address family on the container path. The CLI prints the gateway URLs, and a website can no longer be named pgweb or db-mcp.
7985a79 to
5d14668
Compare
| return False | ||
| return True | ||
|
|
||
| async with httpx.AsyncClient(timeout=30) as client: |
There was a problem hiding this comment.
Console limits lack names. The new probe hardcodes a 30-second timeout and a two-attempt limit. The repository rule requires magic numbers to be stored as class or instance variables with descriptive names. Give these limits named settings so developers can find and tune them without reading through the probe.
Rule Used: Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. (source)
Learned From
scaleapi/scaleapi#126388
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/env_providers/env_gateway_provider.py
Line: 1232
Comment:
**Console limits lack names.** The new probe hardcodes a 30-second timeout and a two-attempt limit. The repository rule requires magic numbers to be stored as class or instance variables with descriptive names. Give these limits named settings so developers can find and tune them without reading through the probe.
**Rule Used:** Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. ([source](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%3Fmemory%3D002e0051-41ad-46c1-9098-47433c580150))
**Learned From**
[scaleapi/scaleapi#126388](https://github.com/scaleapi/scaleapi/pull/126388)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Why
The gateway already fronts each env's MCP servers and state routes at
/svc/<key>/. This PR adds pgweb and db-mcp to that set, so every harness caller reaches the database consoles the same way: one host, one auth scheme, the deployment's control token.What changed
/svc/pgweb/and/svc/db-mcp/from a newCONSOLE_URLSvariable. Both take the control token, like the gateway's other guarded routes.REST_PROXY_URLS, so they never become backing servers in the env card.pgweb:8081anddb-mcp:8000onenv-network. The container path points it at the console sandboxes.--streamable-http-host=with an empty value).db_web_gateway_url({gateway}/svc/pgweb/) anddb_mcp_gateway_url({gateway}/svc/db-mcp/mcp).db_web_urlanddb_mcp_urlstay as they are, so consumers keep working until they move.env deploy,env get-instance,task run,run --keep) prints the gateway URLs.pgwebordb-mcp, since those are now/svckeys.Blast Radius
pgwebordb-mcpwould now clash. The deploy refuses such a website by name.Verification
tst/unit/env/gateway/console_routes_test.pyis new, with 83 cases.tst/unit/env,tst/unit/providersandtst/unit/clipass.ruff check src tstpasses.Dockerfile.db-mcpand this branch's gateway: both consoles answer through the gateway with the token.Name the console probe's limits before merging to meet the repository rule.
Fix with agent prompt
Summary
The PR adds control-token-protected database consoles under the gateway and records their gateway URLs.
/svc/routes.The new probe limits need names to meet the repository rule.
Reviews (2) · Last reviewed commit: "feat(gateway): serve pgweb and db-mcp at..." · Reviewed by Greptile