From fc748939d66cf36964004e9e3e0de670f19c0953 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 19 Nov 2026 18:36:58 +0000 Subject: [PATCH] refactor(env): reach pgweb and db-mcp only through the gateway's /svc routes The VM path exposes only the gateway's port, the compose file publishes no port for pgweb or db-mcp, and the container path creates their sandboxes with expose_externally=False. DeployedGateway drops db_web_url and db_mcp_url, so new records name the consoles only at db_web_gateway_url and db_mcp_gateway_url. DeployedGatewayEnv still reads both from older records for one release. --- src/agent_env/env/env.py | 2 + .../env_providers/env_gateway_provider.py | 28 ++------------ .../providers/env_state/local_postgres.py | 12 +----- tst/integration/env/custom_env_config_test.py | 2 +- .../task_step/test_record_step_concurrency.py | 2 +- tst/unit/cli/deploy_vm_sizing_test.py | 2 +- tst/unit/cli/deployed_env_output_test.py | 4 +- tst/unit/cli/env_state_type_parity_test.py | 2 +- tst/unit/env/envs/test_env_card_loads.py | 7 ++-- .../envs/test_mcp_server_container_mode.py | 2 +- tst/unit/env/envs/test_multi_env_name.py | 5 +-- .../envs/test_multi_env_plugin_provider.py | 4 +- .../env/envs/test_multi_env_snapshot_guard.py | 3 +- tst/unit/env/store_test.py | 4 +- tst/unit/env/task_step/test_context_ops.py | 2 +- .../env/task_step/verify_env_card_test.py | 4 +- .../verify_env_core_protocol_test.py | 4 +- tst/unit/env/test_env.py | 20 ++++++++-- tst/unit/env/test_legacy_protocol.py | 3 +- .../compose_host_port_publish_test.py | 38 +++++++------------ .../env_gateway_provider_test.py | 38 ++++++++++--------- tst/unit/store/derived_ids_test.py | 2 +- tst/unit/store/fakes.py | 2 +- tst/unit/store/local_id_acceptance_test.py | 2 +- tst/unit/task/local_run_write_fence_test.py | 3 +- .../attribution_serialization_test.py | 4 +- tst/unit/task_step/capture_stubs.py | 1 - tst/unit/task_step/deploy_env_test.py | 1 - tst/unit/task_step/retry_test.py | 5 +-- tst/unit/task_step/sync_env_clock_test.py | 6 +-- .../task_step/test_apply_server_config.py | 2 +- tst/unit/task_step/test_collect_artifacts.py | 7 ++-- .../test_combine_universe_verdicts.py | 2 +- .../test_configure_scheduled_checks.py | 3 +- .../task_step/test_deploy_agent_mcp_alias.py | 3 +- .../test_deploy_agent_role_delivery.py | 3 +- .../task_step/test_deploy_ttl_from_budget.py | 2 +- .../test_load_artifact_env_binding.py | 2 +- tst/unit/task_step/test_load_artifact_file.py | 2 +- .../test_load_artifact_service_universe.py | 2 +- tst/unit/task_step/test_mcp_cli_builder.py | 4 +- .../task_step/test_modify_env_tool_access.py | 2 +- .../test_parallel_deploy_env_binding.py | 1 - .../task_step/test_prompt_agent_triggers.py | 2 +- .../task_step/test_register_agent_triggers.py | 2 +- .../task_step/test_register_env_triggers.py | 2 +- tst/unit/task_step/test_run_code.py | 2 +- .../task_step/test_snapshot_agent_state.py | 1 - tst/unit/task_step/test_snapshot_env.py | 6 +-- .../test_snapshot_env_env_binding.py | 2 +- tst/unit/task_step/test_teardown_sandboxes.py | 3 +- .../task_step/test_verify_spec_conformance.py | 2 +- .../test_verify_universe_roundtrip.py | 2 +- 53 files changed, 113 insertions(+), 160 deletions(-) diff --git a/src/agent_env/env/env.py b/src/agent_env/env/env.py index 4cd8ba555..eddde7ee8 100644 --- a/src/agent_env/env/env.py +++ b/src/agent_env/env/env.py @@ -228,6 +228,8 @@ class DeployedGatewayEnv(DeployedSandboxEnv): env_provider_type: Optional[str] = "gateway" gateway_url: str gateway_mode: str = GatewayMode.PERFORMANCE.value + # pgweb's and db-mcp's direct URLs, which only a record an older deploy wrote carries; nothing writes them now. + # Kept for one release so a consumer can still read an env deployed before then. Remove in the release after. db_web_url: Optional[str] = None db_mcp_url: Optional[str] = None # pgweb and db-mcp behind the gateway, which take the control token (``control_headers_for``); None when its image diff --git a/src/agent_env/providers/env_providers/env_gateway_provider.py b/src/agent_env/providers/env_providers/env_gateway_provider.py index 6446555aa..ff315a551 100644 --- a/src/agent_env/providers/env_providers/env_gateway_provider.py +++ b/src/agent_env/providers/env_providers/env_gateway_provider.py @@ -50,10 +50,7 @@ ) from agent_env.env.envs.service_db import ( DATABASE_SERVICE_NAME, - DB_MCP_CONTAINER_PORT, - DB_MCP_PORT, DB_MCP_SERVICE_NAME, - DB_WEB_PORT, PGWEB_SERVICE_NAME, ) from agent_env.env.envs.computer.utils.boot import control_environment @@ -143,8 +140,6 @@ class DeployedGateway: gateway_url: str mcp_url: str - db_web_url: str - db_mcp_url: str | None = None db_web_gateway_url: str | None = None db_mcp_gateway_url: str | None = None website_frontend_urls: dict[str, str] | None = None @@ -721,10 +716,8 @@ async def deploy( env_version=env.version, env_provider_type=self.type, gateway_url=deployed.gateway_url, - db_web_url=deployed.db_web_url, sandbox_id=self._sandbox.sandbox_id, sandbox_type=self._sandbox.type, sandbox_ids=self._sandbox_ids(always_name_gateway=topology.names_gateway_on_vm), - db_mcp_url=deployed.db_mcp_url, db_web_gateway_url=deployed.db_web_gateway_url, db_mcp_gateway_url=deployed.db_mcp_gateway_url, environment_card_url=f"{deployed.gateway_url}{WELL_KNOWN_PATH}", @@ -883,7 +876,7 @@ async def _deploy_via_vm( if memory_mb is not None: vm_kwargs["memory"] = memory_mb self._sandbox = await sandbox_provider.create_vm( - exposed_ports=[gateway_port, DB_WEB_PORT, DB_MCP_PORT] + [sc.host_port for sc in sidecars], + exposed_ports=[gateway_port] + [sc.host_port for sc in sidecars], timeout=ttl_seconds, disk_size_gb=disk_size_gb, attribution=attribution, @@ -1003,13 +996,6 @@ async def _stand_up(_spec): logger.warning(f"{name} container not found") gateway_url = sandbox.tunnel_urls.get(gateway_port) - db_web_base_url = sandbox.tunnel_urls.get(DB_WEB_PORT) if PGWEB_SERVICE_NAME in sidecar_names else None - db_web_url = f"{db_web_base_url}/" if db_web_base_url else None - db_mcp_base_url = sandbox.tunnel_urls.get(DB_MCP_PORT) if DB_MCP_SERVICE_NAME in sidecar_names else None - db_mcp_url = f"{db_mcp_base_url}/mcp" if db_mcp_base_url else None - logger.info(f"pgweb URL: {db_web_url}") - if db_mcp_url: - logger.info(f"DB MCP endpoint: {db_mcp_url}") # Wait for the tunnel to serve the env card, which the deploy records card = await self._wait_for_tunnel(gateway_url, timeout=120) @@ -1030,8 +1016,7 @@ async def _stand_up(_spec): logger.info(f"Gateway URL: {gateway_url}") return DeployedGateway( - gateway_url=gateway_url, mcp_url=mcp_url, db_web_url=db_web_url, db_mcp_url=db_mcp_url, - db_web_gateway_url=consoles.get(PGWEB_SERVICE_NAME), db_mcp_gateway_url=consoles.get(DB_MCP_SERVICE_NAME), + gateway_url=gateway_url, mcp_url=mcp_url, db_web_gateway_url=consoles.get(PGWEB_SERVICE_NAME), db_mcp_gateway_url=consoles.get(DB_MCP_SERVICE_NAME), website_frontend_urls=website_frontend_urls, mcp_server_name=mcp_server_name, env_state_instance_ids=[state_instance.instance_id], environment_card=card, environment_card_read_at_utc=card_read_at_utc, control_token=control_token, @@ -1113,8 +1098,6 @@ async def _deploy_via_containers( external: list[ExternalChild] = [] mcp_results: list[tuple[str, "Sandbox"]] = [] - pgweb_sb = None - db_mcp_sb = None consoles: dict[str, str] = {} errors: list[BaseException] = [] for i, r in enumerate(all_results): @@ -1133,10 +1116,8 @@ async def _deploy_via_containers( if r.private_host: consoles[spec.name] = f"http://{r.private_host}:{spec.port}" if spec.name == PGWEB_SERVICE_NAME: - pgweb_sb = r self._pgweb_sandbox = r elif spec.name == DB_MCP_SERVICE_NAME: - db_mcp_sb = r self._db_mcp_sandbox = r if errors: @@ -1186,14 +1167,10 @@ async def _deploy_via_containers( card_read_at_utc = datetime.now(timezone.utc).isoformat() await self._refuse_tool_name_clashes(gateway_url) - db_web_url = pgweb_sb.tunnel_urls[DB_WEB_PORT] + "/" if pgweb_sb else None - db_mcp_url = db_mcp_sb.tunnel_urls[DB_MCP_CONTAINER_PORT] + "/mcp" if db_mcp_sb else None served = await self._served_consoles(gateway_url, consoles, control_token) return DeployedGateway( gateway_url=gateway_url, mcp_url=_mcp_url(gateway_url, card), - db_web_url=db_web_url, - db_mcp_url=db_mcp_url, db_web_gateway_url=served.get(PGWEB_SERVICE_NAME), db_mcp_gateway_url=served.get(DB_MCP_SERVICE_NAME), website_frontend_urls=None, @@ -1401,6 +1378,7 @@ async def _provision_sidecar(self, deploy: _ContainerDeploy, spec) -> Sandbox: command=spec.command, **_size_kwargs(deploy.cpu, None), disk_size_gb=deploy.disk_size_gb, timeout=deploy.ttl_seconds, + expose_externally=False, attribution=deploy.attribution, private_network=True, ) diff --git a/src/agent_env/providers/env_state/local_postgres.py b/src/agent_env/providers/env_state/local_postgres.py index 21fa4e238..3f6d2e005 100644 --- a/src/agent_env/providers/env_state/local_postgres.py +++ b/src/agent_env/providers/env_state/local_postgres.py @@ -21,7 +21,6 @@ from agent_env.env.envs.service_db import ( DATABASE_SERVICE_NAME, DB_MCP_CONTAINER_PORT, - DB_MCP_PORT, DB_MCP_SERVICE_NAME, DB_NAME, DB_PASSWORD, @@ -30,7 +29,6 @@ PGWEB_SERVICE_NAME, SERVICE_DB_PORT, ) -from agent_env.providers.sandbox_providers.sandbox import port_bindings from agent_env.providers.env_state.env_state_provider import ( DatabaseStateProvider, DEFAULT_STATE_TTL_SECONDS, @@ -258,10 +256,8 @@ def render_sidecar_containers( host_ips: tuple[str, ...] = (), ) -> list[str]: """The pgweb + db-mcp direct-SQL browse UIs (VM/compose path), each gated on the - servicedb's health. Beyond the mandatory readiness service.""" - # Opened from the host only, so kept off the bridge address containers reach the host through. - host_ips = host_ips[:1] - publish = host_port or (lambda port: port) + servicedb's health. Beyond the mandatory readiness service. Neither publishes a port: only the gateway reaches + them, on the env's network, behind its control token.""" cfg = self.service_db_config lines: list[str] = [] if cfg.db_web_image: @@ -278,8 +274,6 @@ def render_sidecar_containers( # sidecar_specs for why: Disconnect tore down pgweb's shared # session and 500'd the changelog export on Save & Next). " - PGWEB_LOCK_SESSION=true", - " ports:", - *(f' - "{spec}"' for spec in port_bindings(host_ips, publish(DB_WEB_PORT), DB_WEB_PORT)), " networks:", " - env-network", "", @@ -295,8 +289,6 @@ def render_sidecar_containers( " environment:", f" - DATABASE_URI={self._pg_url(DATABASE_SERVICE_NAME, scheme='postgresql')}", " command: --transport=streamable-http --streamable-http-host=0.0.0.0 --access-mode=unrestricted", - " ports:", - *(f' - "{spec}"' for spec in port_bindings(host_ips, publish(DB_MCP_PORT), DB_MCP_CONTAINER_PORT)), " networks:", " - env-network", "", diff --git a/tst/integration/env/custom_env_config_test.py b/tst/integration/env/custom_env_config_test.py index 8e9f31adc..c24afa0a5 100644 --- a/tst/integration/env/custom_env_config_test.py +++ b/tst/integration/env/custom_env_config_test.py @@ -51,7 +51,7 @@ async def deploy(self, **kwargs) -> DeployedEnv: env_id=self.id, env_version=self.version or 1, gateway_url=f"https://gw.example/{self.id}", mcp_url=f"https://mcp.example/{self.id}", - db_web_url=None, sandbox_id=f"sbx-{self.id}", + sandbox_id=f"sbx-{self.id}", metadata={"deployed_by": type(self).__name__, "flavor": self.flavor}, ) diff --git a/tst/integration/env/task_step/test_record_step_concurrency.py b/tst/integration/env/task_step/test_record_step_concurrency.py index 85204e6c3..5c2a94aab 100644 --- a/tst/integration/env/task_step/test_record_step_concurrency.py +++ b/tst/integration/env/task_step/test_record_step_concurrency.py @@ -44,7 +44,7 @@ def _assert_journal_matches(instance_id: str, n: int) -> None: def _env(instance_id: str) -> DeployedEnv: return DeployedGatewayEnv( env_id="e", env_version=1, gateway_url="g", mcp_url="m", - db_web_url=None, sandbox_id="s", instance_id=instance_id, + sandbox_id="s", instance_id=instance_id, ) diff --git a/tst/unit/cli/deploy_vm_sizing_test.py b/tst/unit/cli/deploy_vm_sizing_test.py index 33d86d805..163c91866 100644 --- a/tst/unit/cli/deploy_vm_sizing_test.py +++ b/tst/unit/cli/deploy_vm_sizing_test.py @@ -26,7 +26,7 @@ async def fake_deploy(**kwargs): captured.update(kwargs) return DeployedGatewayEnv( env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", + sandbox_id="s1", ) fake_env = MagicMock(id="e1", version=1, type="multi") diff --git a/tst/unit/cli/deployed_env_output_test.py b/tst/unit/cli/deployed_env_output_test.py index 05b7694ee..7f72da27b 100644 --- a/tst/unit/cli/deployed_env_output_test.py +++ b/tst/unit/cli/deployed_env_output_test.py @@ -49,12 +49,11 @@ def test_task_run_prints_a_gateway_record_as_before_and_omits_a_missing_gateway( _CONSOLES = DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url="https://gw.example", mcp_url="https://gw.example/mcp", sandbox_id="gw", instance_id="i1", - db_web_url="https://tunnel-8081.example/", db_mcp_url="https://tunnel-18767.example/mcp", db_web_gateway_url="https://gw.example/svc/pgweb/", db_mcp_gateway_url="https://gw.example/svc/db-mcp/mcp") -def test_the_cli_prints_the_sql_consoles_at_the_gateway_and_never_their_tunnels(): +def test_the_cli_prints_the_sql_consoles_at_the_gateway(): async def fake_deploy(**kwargs): return _CONSOLES @@ -66,7 +65,6 @@ async def fake_deploy(**kwargs): got = CliRunner().invoke(env_cli, ["get-instance", "--id", "i1"]).output for output in (deployed, got, _format_env(_CONSOLES)): assert "https://gw.example/svc/pgweb/" in output and "https://gw.example/svc/db-mcp/mcp" in output - assert "tunnel-" not in output def test_a_record_outside_our_sandboxes_prints_no_sandbox(): diff --git a/tst/unit/cli/env_state_type_parity_test.py b/tst/unit/cli/env_state_type_parity_test.py index a7587be3e..1bfebefa4 100644 --- a/tst/unit/cli/env_state_type_parity_test.py +++ b/tst/unit/cli/env_state_type_parity_test.py @@ -24,7 +24,7 @@ def _fake_deployed() -> DeployedEnv: return DeployedGatewayEnv( env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", + sandbox_id="s1", ) diff --git a/tst/unit/env/envs/test_env_card_loads.py b/tst/unit/env/envs/test_env_card_loads.py index 37c385d18..6ca760083 100644 --- a/tst/unit/env/envs/test_env_card_loads.py +++ b/tst/unit/env/envs/test_env_card_loads.py @@ -156,7 +156,7 @@ async def test_a_standalone_env_keeps_the_record_it_deploys(make, module): env = make() provider = MagicMock( spec=EnvironmentGatewayProvider, sandbox=SimpleNamespace(sandbox_id="sb-1", type="vm"), - deploy=AsyncMock(return_value=DeployedGatewayEnv(env_id="e", env_version=1, gateway_url=_GW, mcp_url=f"{_GW}/mcp", db_web_url=None, sandbox_id="sb-1")), + deploy=AsyncMock(return_value=DeployedGatewayEnv(env_id="e", env_version=1, gateway_url=_GW, mcp_url=f"{_GW}/mcp", sandbox_id="sb-1")), _environment_sandboxes={}, ) provider.environment_sandbox.return_value = None @@ -204,7 +204,7 @@ async def test_multi_env_deploy_hands_its_record_to_every_child_env(): container = MagicMock() provider.environment_sandbox.side_effect = lambda name: container if name == "email" else None # container mode: the server's own provider.deploy = AsyncMock(return_value=DeployedGatewayEnv(env_id="multi", env_version=1, gateway_url=_GW, mcp_url=f"{_GW}/mcp", - db_web_url=None, sandbox_id="sb-1")) + sandbox_id="sb-1")) with patch("agent_env.providers.build_env_provider", return_value=provider), \ patch("agent_env.providers.get_env_sandbox_provider", MagicMock()), \ @@ -297,8 +297,7 @@ async def fetch(client, key, base_url): def _record(card: dict | None) -> DeployedEnv: return DeployedGatewayEnv( - env_id="multi", env_version=1, gateway_url=_GW, mcp_url=f"{_GW}/mcp", db_web_url=None, - sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card, + env_id="multi", env_version=1, gateway_url=_GW, mcp_url=f"{_GW}/mcp", sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card, ) diff --git a/tst/unit/env/envs/test_mcp_server_container_mode.py b/tst/unit/env/envs/test_mcp_server_container_mode.py index b89ff3b37..db8d77e95 100644 --- a/tst/unit/env/envs/test_mcp_server_container_mode.py +++ b/tst/unit/env/envs/test_mcp_server_container_mode.py @@ -392,7 +392,7 @@ async def deploy_path(sandbox_provider, mcp_servers, mcp_server_images, **kwargs gp._environment_sandboxes = {"email": sandboxes["srv"]} gp._db_sandbox, gp._pgweb_sandbox, gp._db_mcp_sandbox = sandboxes.get("db"), sandboxes.get("pg"), sandboxes.get("dm") gp._container_sandboxes = [sandboxes[i] for i in ("db", "srv", "pg", "dm", "gw") if i in sandboxes] - return DeployedGateway(gateway_url=_GW, mcp_url=f"{_GW}/mcp", db_web_url=None, db_mcp_url=None, mcp_server_name=kwargs["mcp_server_name"], + return DeployedGateway(gateway_url=_GW, mcp_url=f"{_GW}/mcp", mcp_server_name=kwargs["mcp_server_name"], env_state_instance_ids=["st-1"], environment_card=_CARD, environment_card_read_at_utc="2026-09-26T00:00:00+00:00") async def server_path(env, sandbox_provider, **kwargs): diff --git a/tst/unit/env/envs/test_multi_env_name.py b/tst/unit/env/envs/test_multi_env_name.py index 125dc3eee..2a1eefba2 100644 --- a/tst/unit/env/envs/test_multi_env_name.py +++ b/tst/unit/env/envs/test_multi_env_name.py @@ -57,7 +57,7 @@ def test_random_default_is_env_plus_four_digits(): def test_deployed_env_records_the_gateway_name(): - base = dict(env_id="e", env_version=1, gateway_url="g", mcp_url="m", db_web_url=None, sandbox_id="s") + base = dict(env_id="e", env_version=1, gateway_url="g", mcp_url="m", sandbox_id="s") assert DeployedEnv.from_dict({**base, "mcp_server_name": "env4821"}).mcp_server_name == "env4821" assert DeployedEnv.from_dict(base).mcp_server_name is None @@ -65,8 +65,7 @@ def test_deployed_env_records_the_gateway_name(): @pytest.mark.asyncio async def test_a_deploy_records_the_mcp_url_and_name_its_gateway_card_gives(): card = {"name": "crm", "additionalInterfaces": [{"url": "/mcp", "transport": "mcp"}]} - result = SimpleNamespace(gateway_url="https://gw.example", mcp_url="https://gw.example/mcp", db_web_url=None, db_mcp_url=None, - db_web_gateway_url="https://gw.example/svc/pgweb/", + result = SimpleNamespace(gateway_url="https://gw.example", mcp_url="https://gw.example/mcp", db_web_gateway_url="https://gw.example/svc/pgweb/", db_mcp_gateway_url="https://gw.example/svc/db-mcp/mcp", website_frontend_urls=None, environment_card=card, environment_card_read_at_utc="t", env_state_instance_ids=[], mcp_server_name="crm", control_token="t0k") diff --git a/tst/unit/env/envs/test_multi_env_plugin_provider.py b/tst/unit/env/envs/test_multi_env_plugin_provider.py index f14b1369a..cf677b5e1 100644 --- a/tst/unit/env/envs/test_multi_env_plugin_provider.py +++ b/tst/unit/env/envs/test_multi_env_plugin_provider.py @@ -374,7 +374,7 @@ async def deploy_gateway(self, sandbox_provider, **kwargs): if len(calls) > 1: raise RuntimeError("second boom") self._sandbox = vm - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None) + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp") env = _multi("gateway", websites=()) with patch.object(EnvironmentGatewayProvider, "_deploy_gateway", deploy_gateway), \ @@ -434,7 +434,7 @@ async def test_close_after_two_successful_gateway_deploys_terminates_both_vms(): async def deploy_gateway(self, sandbox_provider, **kwargs): self._sandbox = next(created) - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None) + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp") env = _multi("gateway", websites=()) with patch.object(EnvironmentGatewayProvider, "_deploy_gateway", deploy_gateway), \ diff --git a/tst/unit/env/envs/test_multi_env_snapshot_guard.py b/tst/unit/env/envs/test_multi_env_snapshot_guard.py index fb4f479c2..a9fce8945 100644 --- a/tst/unit/env/envs/test_multi_env_snapshot_guard.py +++ b/tst/unit/env/envs/test_multi_env_snapshot_guard.py @@ -85,8 +85,7 @@ async def test_snapshot_capture_gated_off_for_remote_backend(): early with a clear error — not a cryptic 'servicedb container not found' deep in the capture.""" from agent_env.env.snapshot_store import EnvSnapshot - deployed = DeployedGatewayEnv(env_id="env-1", env_version=1, sandbox_id="sb-1", gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None) + deployed = DeployedGatewayEnv(env_id="env-1", env_version=1, sandbox_id="sb-1", gateway_url="https://gw", mcp_url="https://gw/mcp") inst_store = MagicMock() inst_store.get.return_value = deployed inst_store.get_environment_universe.return_value = {"id": "universe-1", "version": 1} diff --git a/tst/unit/env/store_test.py b/tst/unit/env/store_test.py index 1a401aa6d..ba1842947 100644 --- a/tst/unit/env/store_test.py +++ b/tst/unit/env/store_test.py @@ -25,9 +25,9 @@ def test_deployed_env_roundtrip_preserves_all_fields(): env_version=3, gateway_url="https://gw.example/", mcp_url="https://gw.example/mcp", - db_web_url="https://gw.example/dbweb/", + db_web_gateway_url="https://gw.example/svc/pgweb/", sandbox_id="sb-abc", - db_mcp_url="https://gw.example/dbmcp/mcp", + db_mcp_gateway_url="https://gw.example/svc/db-mcp/mcp", website_frontend_urls={"a": "https://gw.example/site/a/"}, sandbox_type="modal", vnc_url="vnc://example:5900", diff --git a/tst/unit/env/task_step/test_context_ops.py b/tst/unit/env/task_step/test_context_ops.py index 9e8e75b99..36713528b 100644 --- a/tst/unit/env/task_step/test_context_ops.py +++ b/tst/unit/env/task_step/test_context_ops.py @@ -16,7 +16,7 @@ def _env(instance_id: str = "i1") -> DeployedEnv: return DeployedGatewayEnv( env_id="e", env_version=1, gateway_url="g", mcp_url="m", - db_web_url=None, sandbox_id="s", instance_id=instance_id, + sandbox_id="s", instance_id=instance_id, ) diff --git a/tst/unit/env/task_step/verify_env_card_test.py b/tst/unit/env/task_step/verify_env_card_test.py index 359275014..226a69368 100644 --- a/tst/unit/env/task_step/verify_env_card_test.py +++ b/tst/unit/env/task_step/verify_env_card_test.py @@ -37,7 +37,7 @@ def _make_context(): ctx = TaskStepContext() ctx.deployed_envs = [DeployedGatewayEnv( env_id="e1", env_version=3, gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None, sandbox_id="sb", environment_card_url=f"https://gw{WELL_KNOWN_PATH}", + sandbox_id="sb", environment_card_url=f"https://gw{WELL_KNOWN_PATH}", )] return ctx @@ -154,7 +154,7 @@ class TestWire: def test_reads_the_card_at_its_address(self, gateway_url): base = gateway_url.rstrip("/") ctx = TaskStepContext(deployed_envs=[DeployedGatewayEnv( - env_id="e1", env_version=3, gateway_url=gateway_url, mcp_url=f"{base}/mcp", db_web_url=None, sandbox_id="sb", + env_id="e1", env_version=3, gateway_url=gateway_url, mcp_url=f"{base}/mcp", sandbox_id="sb", environment_card_url=f"{gateway_url}{WELL_KNOWN_PATH}", )]) sent = [] diff --git a/tst/unit/env/task_step/verify_env_core_protocol_test.py b/tst/unit/env/task_step/verify_env_core_protocol_test.py index 857c516c6..5d7588752 100644 --- a/tst/unit/env/task_step/verify_env_core_protocol_test.py +++ b/tst/unit/env/task_step/verify_env_core_protocol_test.py @@ -28,7 +28,7 @@ def _make_context(): ctx = TaskStepContext() ctx.deployed_envs = [DeployedGatewayEnv( env_id="e1", env_version=3, gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None, sandbox_id="sb", environment_card_url=f"https://gw{WELL_KNOWN_PATH}", + sandbox_id="sb", environment_card_url=f"https://gw{WELL_KNOWN_PATH}", )] return ctx @@ -154,7 +154,7 @@ class TestWire: def test_reads_the_card_and_probes_the_data_plane_at_the_cards_address(self, gateway_url): base = gateway_url.rstrip("/") ctx = TaskStepContext(deployed_envs=[DeployedGatewayEnv( - env_id="e1", env_version=3, gateway_url=gateway_url, mcp_url=f"{base}/mcp", db_web_url=None, sandbox_id="sb", + env_id="e1", env_version=3, gateway_url=gateway_url, mcp_url=f"{base}/mcp", sandbox_id="sb", environment_card_url=f"{gateway_url}{WELL_KNOWN_PATH}", control_token="s3cret", )]) sent = [] diff --git a/tst/unit/env/test_env.py b/tst/unit/env/test_env.py index d94ba0eb1..59123ed34 100644 --- a/tst/unit/env/test_env.py +++ b/tst/unit/env/test_env.py @@ -73,8 +73,7 @@ async def fetch(client, key, base_url): def _record(card: dict | None, base: str = _BASES[0]) -> DeployedEnv: return DeployedGatewayEnv( - env_id="multi", env_version=1, gateway_url=base, mcp_url=f"{base.rstrip('/')}/mcp", db_web_url=None, - sandbox_id="sb-1", instance_id="inst-1", environment_card_url=f"{base}{WELL_KNOWN_PATH}", environment_card=card, + env_id="multi", env_version=1, gateway_url=base, mcp_url=f"{base.rstrip('/')}/mcp", sandbox_id="sb-1", instance_id="inst-1", environment_card_url=f"{base}{WELL_KNOWN_PATH}", environment_card=card, ) @@ -290,7 +289,7 @@ def test_a_stored_record_loads_as_its_type_or_else_its_shape_keeping_every_field def test_a_gateway_record_is_filled_the_way_it_always_was(): record = DeployedEnv.from_dict({"env_id": "e", "env_version": 1, "mcp_url": "https://m/mcp", "gateway_url": "https://gw", "sandbox_id": "sb", "sandbox_ids": None, "env_state_instance_ids": None}) - assert (record.gateway_mode, record.sandbox_ids, record.env_state_instance_ids, record.db_web_url) == ("performance", {}, [], None) + assert (record.gateway_mode, record.sandbox_ids, record.env_state_instance_ids, record.db_web_gateway_url) == ("performance", {}, [], None) @pytest.mark.parametrize("record", [ @@ -298,7 +297,7 @@ def test_a_gateway_record_is_filled_the_way_it_always_was(): DeployedSandboxEnv(env_id="e", env_version=1, env_provider_type="server", sandbox_id="srv", sandbox_type="modal", sandbox_ids={"mcp_server": {"slack": "srv"}}, environment_card_url=_CARD_URL, environment_card=_CARD), DeployedGatewayEnv(env_id="e", env_version=1, gateway_url="https://gw.example/sb/x", gateway_mode="consistent", sandbox_id="gw", - sandbox_type="modal_vm", sandbox_ids={"gateway_server": "gw"}, db_web_url="https://pg/", db_mcp_url="https://dm/mcp", + sandbox_type="modal_vm", sandbox_ids={"gateway_server": "gw"}, db_web_gateway_url="https://gw.example/sb/x/svc/pgweb/", db_mcp_gateway_url="https://gw.example/sb/x/svc/db-mcp/mcp", website_frontend_urls={"shop": "https://gw/shop/"}, vnc_url="https://vnc", env_state_instance_ids=["st-1"], @@ -319,6 +318,19 @@ def test_the_gateway_only_fields_are_the_gateway_classs_own(): assert set(_GATEWAY_ONLY_FIELDS) == own - {"gateway_mode", "env_provider_type"} +def test_a_record_an_older_deploy_wrote_keeps_its_console_tunnels(): + """A gateway deployed before the consoles moved behind it is still alive, or is reused by id, and its record names + the consoles only at their tunnels, which a consumer reads until that gateway is gone.""" + old = {"env_id": "e", "env_version": 1, "env_provider_type": "gateway", "sandbox_id": "sb-1", + "gateway_url": "https://gw.example", "db_web_url": "https://pg.example/", + "db_mcp_url": "https://db-mcp.example/mcp"} + record = DeployedEnv.from_dict(old) + assert isinstance(record, DeployedGatewayEnv) + assert (record.db_web_url, record.db_mcp_url) == ("https://pg.example/", "https://db-mcp.example/mcp") + stored = dataclasses.asdict(record) + assert (stored["db_web_url"], stored["db_mcp_url"]) == ("https://pg.example/", "https://db-mcp.example/mcp") + + def test_only_a_gateway_record_has_a_gateway_url(): gateway = DeployedGatewayEnv(env_id="e", env_version=1, gateway_url="https://gw", sandbox_id="gw") bare = DeployedSandboxEnv(env_id="e", env_version=1, sandbox_id="srv") diff --git a/tst/unit/env/test_legacy_protocol.py b/tst/unit/env/test_legacy_protocol.py index d426e3259..682d04df8 100644 --- a/tst/unit/env/test_legacy_protocol.py +++ b/tst/unit/env/test_legacy_protocol.py @@ -229,8 +229,7 @@ def test_card_servers_of_a_leaf_card_is_the_env_itself_and_a_composed_card_servi def _record(card: dict | None, card_url: str | None = "https://env.example/.well-known/agent-env.json"): from agent_env.env.env import DeployedGatewayEnv - return DeployedGatewayEnv(env_id="e", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", db_web_url=None, - sandbox_id="sb", environment_card_url=card_url, environment_card=card) + return DeployedGatewayEnv(env_id="e", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", sandbox_id="sb", environment_card_url=card_url, environment_card=card) @pytest.mark.asyncio diff --git a/tst/unit/providers/compose_host_port_publish_test.py b/tst/unit/providers/compose_host_port_publish_test.py index c463bac02..d54e1078d 100644 --- a/tst/unit/providers/compose_host_port_publish_test.py +++ b/tst/unit/providers/compose_host_port_publish_test.py @@ -17,7 +17,6 @@ from agent_env.env.gateway import AGENT_ENV_GATEWAY_MCP_PORT from agent_env.providers.env_providers import EnvironmentGatewayProvider, MCPServerConfig, SidecarConfig -from agent_env.env.envs.service_db import DB_MCP_CONTAINER_PORT, DB_MCP_PORT, DB_WEB_PORT from agent_env.providers.env_state.local_postgres import LocalPostgresStateProvider SRC = Path(__file__).resolve().parents[3] / "src" @@ -201,9 +200,9 @@ def test_gateway_compose_resolves_every_host_port(stub_postgres, environments, s ) pairs = assert_all_resolved(compose) - # The gateway, pgweb and the DB MCP sidecar are always present; each extra sidecar adds - # one more publication. - assert len(pairs) == 3 + len(sidecars) + # The gateway is always published, and each extra sidecar adds one more publication; pgweb and the DB MCP + # sidecar publish none, since only the gateway reaches them. + assert len(pairs) == 1 + len(sidecars) def test_gateway_compose_defaults_to_identity(stub_postgres): @@ -218,35 +217,26 @@ def test_gateway_compose_defaults_to_identity(stub_postgres): state_instance=_StateInstance(), ) - assert f'"{DB_WEB_PORT}:{DB_WEB_PORT}"' in compose - assert f'"{DB_MCP_PORT}:{DB_MCP_CONTAINER_PORT}"' in compose + assert f'"{AGENT_ENV_GATEWAY_MCP_PORT}:{AGENT_ENV_GATEWAY_MCP_PORT}"' in compose assert '"18768:8000"' in compose -def test_postgres_sidecar_fragment_resolves_host_ports(stub_postgres): - """The state provider renders its own fragment, so it is checked directly as well as - through the full compose above.""" +@pytest.mark.parametrize("host_ips", [(), ("127.0.0.1",)], ids=["every-interface", "loopback"]) +def test_postgres_sidecars_publish_no_port(stub_postgres, host_ips): + """pgweb and db-mcp are reached only through the gateway, on the env's network, so the compose file publishes no + port for either.""" lines = "\n".join( - stub_postgres.render_sidecar_containers(["slack"], host_port=lambda p: p + OFFSET), + stub_postgres.render_sidecar_containers(["slack"], host_port=lambda p: p + OFFSET, host_ips=host_ips), ) - assert f'"{DB_WEB_PORT + OFFSET}:{DB_WEB_PORT}"' in lines - assert f'"{DB_MCP_PORT + OFFSET}:{DB_MCP_CONTAINER_PORT}"' in lines - # Container side untouched: it is the env's internal contract. - assert f'"{DB_WEB_PORT}:{DB_WEB_PORT}"' not in lines - - -def test_postgres_sidecar_fragment_defaults_to_identity(stub_postgres): - lines = "\n".join(stub_postgres.render_sidecar_containers(["slack"])) - - assert f'"{DB_WEB_PORT}:{DB_WEB_PORT}"' in lines - assert f'"{DB_MCP_PORT}:{DB_MCP_CONTAINER_PORT}"' in lines + assert " pgweb:" in lines and " db-mcp:" in lines + assert "ports:" not in lines + assert _PORT_PAIR.findall(lines) == [] @pytest.mark.parametrize("host_ips", [("127.0.0.1",), ("127.0.0.1", "172.17.0.1")], ids=["loopback", "loopback-and-bridge"]) def test_gateway_compose_publishes_only_on_the_host_ips(stub_postgres, host_ips): - """Each port once per host IP, and none on every interface. pgweb and db-mcp, opened only from the - host, stay off the bridge address.""" + """Each port once per host IP, and none on every interface.""" compose = EnvironmentGatewayProvider.create_docker_compose( EnvironmentGatewayProvider.__new__(EnvironmentGatewayProvider), mcp_servers=[MCPServerConfig(image="slack:test", environment_name="slack")], @@ -259,8 +249,6 @@ def test_gateway_compose_publishes_only_on_the_host_ips(stub_postgres, host_ips) ) everywhere = [(AGENT_ENV_GATEWAY_MCP_PORT, AGENT_ENV_GATEWAY_MCP_PORT), (18768, 8000)] - host_only = [(DB_WEB_PORT, DB_WEB_PORT), (DB_MCP_PORT, DB_MCP_CONTAINER_PORT)] assert sorted(_PORT_PAIR.findall(compose)) == sorted( [(ip, str(host + OFFSET), str(container)) for ip in host_ips for host, container in everywhere] - + [(host_ips[0], str(host + OFFSET), str(container)) for host, container in host_only] ) diff --git a/tst/unit/providers/env_providers/env_gateway_provider_test.py b/tst/unit/providers/env_providers/env_gateway_provider_test.py index cc8be6e51..f8be68fc5 100644 --- a/tst/unit/providers/env_providers/env_gateway_provider_test.py +++ b/tst/unit/providers/env_providers/env_gateway_provider_test.py @@ -434,8 +434,8 @@ async def _spy_acquire(self, ctx): gp._wait_for_tunnel.assert_awaited_once_with("https://agent-gateway.modal.host", timeout=120) assert result.environment_card == _CARD assert datetime.fromisoformat(result.environment_card_read_at_utc).utcoffset().total_seconds() == 0 - assert result.db_web_url is None - assert result.db_mcp_url is None + assert result.db_web_gateway_url is None + assert result.db_mcp_gateway_url is None @pytest.mark.asyncio @@ -1490,6 +1490,8 @@ def _fake_env_get(env_id, *a, **k): sandbox.load_docker_images.assert_awaited_once() loaded = sandbox.load_docker_images.call_args.args[0] assert sidecar_art in loaded, "sidecar image_artifact was not side-loaded onto the VM" + # The VM exposes the gateway and the sidecars, and no port of pgweb's or db-mcp's: the gateway serves both. + assert sandbox_provider.create_vm.call_args.kwargs["exposed_ports"] == [18765, 18768] # --- name injection: SERVICE_NAME + ENVIRONMENT_NAME -------------------------- @@ -1875,7 +1877,7 @@ class _Stop(Exception): def _probed(mcp_url: str = "https://gw.example/mcp") -> DeployedGateway: - return DeployedGateway(gateway_url="https://gw.example", mcp_url=mcp_url, db_web_url=None, environment_card=_PROBE_CARD) + return DeployedGateway(gateway_url="https://gw.example", mcp_url=mcp_url, environment_card=_PROBE_CARD) def _probe_records(caplog) -> list[logging.LogRecord]: @@ -2103,9 +2105,7 @@ async def test_deploy_returns_the_gateway_record_for_the_env(caplog): assert re.fullmatch(r"env\d{4}", compose.call_args.kwargs["mcp_server_name"]) assert compose.call_args.kwargs["host_ips"] == () assert dataclasses.asdict(record) == dataclasses.asdict(DeployedGatewayEnv( - env_id="crm-env", env_version=3, gateway_url="https://vm.example", mcp_url="https://vm.example/mcp", db_web_url=None, - sandbox_id="vm-1", sandbox_type="modal_vm", sandbox_ids={}, db_mcp_url=None, - environment_card_url="https://vm.example/.well-known/agent-env.json", environment_card=card, + env_id="crm-env", env_version=3, gateway_url="https://vm.example", mcp_url="https://vm.example/mcp", sandbox_id="vm-1", sandbox_type="modal_vm", sandbox_ids={}, environment_card_url="https://vm.example/.well-known/agent-env.json", environment_card=card, environment_card_read_at_utc=record.environment_card_read_at_utc, gateway_mode="consistent", env_state_instance_ids=["st-ext"], control_token=record.control_token)) assert len(record.control_token) >= 43 and compose.call_args.kwargs["control_token"] == record.control_token @@ -2160,8 +2160,8 @@ async def test_deploy_records_the_gateways_sidecar_urls_and_its_containers(): async def deploy_gateway(sandbox_provider, **kwargs): gp._sandbox, gp._environment_sandboxes = sandboxes["gw"], {"slack": sandboxes["srv"]} gp._db_sandbox, gp._pgweb_sandbox, gp._db_mcp_sandbox = sandboxes["db"], sandboxes["pg"], sandboxes["dm"] - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url="https://pg/", db_mcp_url="https://dm/mcp", - environment_card={"name": "env1234"}, env_state_instance_ids=["st-1"]) + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_gateway_url="https://gw/svc/pgweb/", + db_mcp_gateway_url="https://gw/svc/db-mcp/mcp", environment_card={"name": "env1234"}, env_state_instance_ids=["st-1"]) with patch.object(gp, "_deploy_gateway", side_effect=deploy_gateway), \ patch("agent_env.env.env.Env.get", MagicMock()), \ @@ -2169,7 +2169,8 @@ async def deploy_gateway(sandbox_provider, **kwargs): patch.object(env_gateway_provider, "_tool_names", AsyncMock(return_value={"slack_send"})): record = await gp.deploy(env, ModalSandboxProvider()) - assert (record.gateway_url, record.db_web_url, record.db_mcp_url, record.env_state_instance_ids) == ("https://gw", "https://pg/", "https://dm/mcp", ["st-1"]) + assert (record.gateway_url, record.db_web_gateway_url, record.db_mcp_gateway_url, record.env_state_instance_ids) == ( + "https://gw", "https://gw/svc/pgweb/", "https://gw/svc/db-mcp/mcp", ["st-1"]) assert (record.sandbox_id, record.sandbox_type, record.website_frontend_urls, record.mcp_server_name) == ("gw", "modal", None, "env1234") assert record.sandbox_ids == { "gateway_server": "gw", "mcp_server": {"slack": "srv"}, "service_db": {"servicedb": "db", "pgweb": "pg", "db-mcp": "dm"}} @@ -2200,7 +2201,7 @@ async def test_a_deploy_on_an_external_state_store_needs_no_servicedb_env(make): async def deploy_gateway(sandbox_provider, **kwargs): gp._sandbox = MagicMock(sandbox_id="vm-1", type="modal_vm") - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None, env_state_instance_ids=["st-ext"]) + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", env_state_instance_ids=["st-ext"]) external = MagicMock(state_type="remote", instance_id="st-ext") with _deploying(gp, deploy_gateway) as deploying, \ @@ -2238,7 +2239,8 @@ async def test_deploy_fronts_a_multi_envs_servers_and_websites_under_its_name(): async def deploy_gateway(sandbox_provider, **kwargs): seen.update(kwargs) gp._sandbox = MagicMock(sandbox_id="vm-1", type="modal_vm") - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url="https://pg/", website_frontend_urls={"shop": "https://shop"}, + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_gateway_url="https://gw/svc/pgweb/", + website_frontend_urls={"shop": "https://shop"}, environment_card={"name": "crm"}, env_state_instance_ids=["st-1"]) with _deploying(gp, deploy_gateway) as deploying: @@ -2251,9 +2253,8 @@ async def deploy_gateway(sandbox_provider, **kwargs): assert [i.image_name for i in seen["website_images"]] == ["shop-be", "shop-fe", "blog-be", "blog-fe"] and seen["mcp_server_name"] == "crm" deploying.acquire.assert_awaited_once_with(env_state_type=None, ttl_seconds=60, name_hint="crm-suite", env_state_instance_id="st-1") assert dataclasses.asdict(record) == dataclasses.asdict(DeployedGatewayEnv( - env_id="crm-suite", env_version=2, env_provider_type="gateway", gateway_url="https://gw", db_web_url="https://pg/", - sandbox_id="vm-1", sandbox_type="modal_vm", sandbox_ids={"gateway_server": "vm-1"}, db_mcp_url=None, - environment_card_url="https://gw/.well-known/agent-env.json", environment_card={"name": "crm"}, environment_card_read_at_utc=None, + env_id="crm-suite", env_version=2, env_provider_type="gateway", gateway_url="https://gw", db_web_gateway_url="https://gw/svc/pgweb/", + sandbox_id="vm-1", sandbox_type="modal_vm", sandbox_ids={"gateway_server": "vm-1"}, environment_card_url="https://gw/.well-known/agent-env.json", environment_card={"name": "crm"}, environment_card_read_at_utc=None, website_frontend_urls={"shop": "https://shop"}, gateway_mode="performance", env_state_instance_ids=["st-1"])) assert (record.mcp_url, record.mcp_server_name, deploying.tool_names.await_count) == ("https://gw/mcp", "crm", 1) @@ -2270,7 +2271,7 @@ async def deploy_gateway(sandbox_provider, **kwargs): gp._sandbox = _FakeSandbox("gw", 18765, "https://gw") gp._environment_sandboxes = {name: _FakeSandbox(f"srv-{name}", 18765, "https://srv") for name in servers} gp._db_sandbox = _FakeSandbox("db", SERVICE_DB_PORT, "https://db") - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None) + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp") with _deploying(gp, deploy_gateway): record = await gp.deploy(MultiEnv(id="crm-suite", version=2, mcp_server_envs=[_mcp(n) for n in servers]), ModalSandboxProvider()) @@ -2284,7 +2285,7 @@ async def test_deploy_fronts_a_website_env(): async def deploy_gateway(sandbox_provider, **kwargs): seen.update(kwargs) gp._sandbox = MagicMock(sandbox_id="vm-1", type="modal_vm") - return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None, website_frontend_urls={"shop": "https://shop"}, + return DeployedGateway(gateway_url="https://gw", mcp_url="https://gw/mcp", website_frontend_urls={"shop": "https://shop"}, env_state_instance_ids=["st-1"]) with _deploying(gp, deploy_gateway): @@ -2296,8 +2297,7 @@ async def deploy_gateway(sandbox_provider, **kwargs): def _multi_record(env_state_instance_ids: list[str]) -> DeployedGatewayEnv: - return DeployedGatewayEnv(env_id="crm-suite", env_version=2, gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None, - sandbox_id="gw", sandbox_type="modal", env_state_instance_ids=env_state_instance_ids, + return DeployedGatewayEnv(env_id="crm-suite", env_version=2, gateway_url="https://gw", mcp_url="https://gw/mcp", sandbox_id="gw", sandbox_type="modal", env_state_instance_ids=env_state_instance_ids, sandbox_ids={"gateway_server": "gw", "mcp_server": {"slack": "srv"}, "service_db": {"servicedb": "db", "pgweb": "pg"}}) @@ -3205,6 +3205,8 @@ async def create_container(**kwargs): del gp._served_consoles # the real check, asking the gateway deployed = await gp._deploy_via_containers(sandbox_provider=provider, control_token="t0k", **args) pgweb, db_mcp = made["pgweb"][0], made["db-mcp"][0] + assert {name: kwargs.get("expose_externally", True) for name, (_, kwargs) in made.items() + if name in ("pgweb", "db-mcp")} == {"pgweb": False, "db-mcp": False} assert made["agent-gateway"][1]["env"]["CONSOLE_URLS"] == ( f"pgweb=http://{pgweb.private_host}:8081,db-mcp=http://{db_mcp.private_host}:8000") assert (deployed.db_web_gateway_url, deployed.db_mcp_gateway_url) == ( diff --git a/tst/unit/store/derived_ids_test.py b/tst/unit/store/derived_ids_test.py index 94f4f99a0..92a7eb170 100644 --- a/tst/unit/store/derived_ids_test.py +++ b/tst/unit/store/derived_ids_test.py @@ -216,7 +216,7 @@ async def snapshot_env_state(**kwargs): monkeypatch.setattr("agent_env.env.env.Env.get", lambda *args: SimpleNamespace(id="crm-suite")) monkeypatch.setattr(SnapshotEnvTaskStep, "snapshot_env_state", staticmethod(snapshot_env_state)) deployed = DeployedGatewayEnv(env_id="crm-suite", env_version=1, gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None, sandbox_id="sb-1") + sandbox_id="sb-1") assert asyncio.run(series._capture_env_state(TaskStepContext(deployed_envs=[deployed]), {}, 30)) is None (snapshot_id,) = snapshot_ids return snapshot_id diff --git a/tst/unit/store/fakes.py b/tst/unit/store/fakes.py index d36a66011..c50530054 100644 --- a/tst/unit/store/fakes.py +++ b/tst/unit/store/fakes.py @@ -292,7 +292,7 @@ def reattach_for_snapshot(monkeypatch, env_id: str, env_version: int, universe_i """Make ``EnvSnapshot.create`` find ``env_id`` deployed with ``universe_id`` loaded, and reconnect to a ``SnapshotSandbox``, which it returns.""" deployed = DeployedGatewayEnv(env_id=env_id, env_version=env_version, sandbox_id="sb-1", gateway_url="https://gw", - mcp_url="https://gw/mcp", db_web_url=None) + mcp_url="https://gw/mcp") instances = SimpleNamespace(get=lambda instance_id: deployed, get_environment_universe=lambda instance_id: {"id": universe_id, "version": universe_version}) provider = EnvironmentGatewayProvider() diff --git a/tst/unit/store/local_id_acceptance_test.py b/tst/unit/store/local_id_acceptance_test.py index 8f3498a05..97a9190d6 100644 --- a/tst/unit/store/local_id_acceptance_test.py +++ b/tst/unit/store/local_id_acceptance_test.py @@ -350,7 +350,7 @@ async def deploy(self, **kwargs): store.insert("env_state_instances", {"instance_id": f"esi-{self.id}", "state_type": "none"}) store.insert("env_instances", {"instance_id": f"gateway-for-{self.id}", "env_id": "gateway"}) return SimpleNamespace( - instance_id="i", mcp_url="m", gateway_url="g", db_web_url=None, db_mcp_url=None, vnc_url=None, + instance_id="i", mcp_url="m", gateway_url="g", vnc_url=None, website_frontend_urls=None, expires_at_utc=None, a2a_url="a", sandbox_id="s", agent_card={}, ) diff --git a/tst/unit/task/local_run_write_fence_test.py b/tst/unit/task/local_run_write_fence_test.py index 6c62f3ade..b9f022574 100644 --- a/tst/unit/task/local_run_write_fence_test.py +++ b/tst/unit/task/local_run_write_fence_test.py @@ -281,8 +281,7 @@ def exports(monkeypatch): def _deployed(env_id): - return DeployedGatewayEnv(env_id=env_id, env_version=1, gateway_url="https://gw", mcp_url="https://gw/mcp", db_web_url=None, - sandbox_id="sb-1") + return DeployedGatewayEnv(env_id=env_id, env_version=1, gateway_url="https://gw", mcp_url="https://gw/mcp", sandbox_id="sb-1") def _assert_snapshot(universe_id): diff --git a/tst/unit/task_step/attribution_serialization_test.py b/tst/unit/task_step/attribution_serialization_test.py index 57db30565..a5d78c735 100644 --- a/tst/unit/task_step/attribution_serialization_test.py +++ b/tst/unit/task_step/attribution_serialization_test.py @@ -87,7 +87,7 @@ async def deploy(*, attribution=None, **kwargs): passed.update(kwargs, attribution=attribution) return DeployedGatewayEnv( env_id="art-1", env_version=2, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", metadata=None, + sandbox_id="s1", metadata=None, ) env = MagicMock() @@ -109,7 +109,7 @@ async def deploy(*, attribution=None, **kwargs): passed["attribution"] = attribution return DeployedGatewayEnv( env_id="art-1", env_version=2, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", metadata=None, + sandbox_id="s1", metadata=None, ) env = MagicMock() diff --git a/tst/unit/task_step/capture_stubs.py b/tst/unit/task_step/capture_stubs.py index c1bc73954..b6135924a 100644 --- a/tst/unit/task_step/capture_stubs.py +++ b/tst/unit/task_step/capture_stubs.py @@ -210,7 +210,6 @@ def context(*, agent: Optional[_StubAgent] = None, env_id: Optional[str] = None) env_version=1, gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None, sandbox_id="sb-env", ) ] diff --git a/tst/unit/task_step/deploy_env_test.py b/tst/unit/task_step/deploy_env_test.py index d0f47a62a..f878a9000 100644 --- a/tst/unit/task_step/deploy_env_test.py +++ b/tst/unit/task_step/deploy_env_test.py @@ -17,7 +17,6 @@ def _deployed_env(metadata): env_version=2, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", metadata=metadata, ) diff --git a/tst/unit/task_step/retry_test.py b/tst/unit/task_step/retry_test.py index 62e33bcbd..14d93ec64 100644 --- a/tst/unit/task_step/retry_test.py +++ b/tst/unit/task_step/retry_test.py @@ -73,8 +73,7 @@ async def execute(self, context: TaskStepContext) -> TaskStepContext: self.deploy_calls.append(self.id) context.deployed_envs.append( DeployedGatewayEnv( - env_id=self.id, env_version=1, gateway_url="g", mcp_url="m", db_web_url=None, - sandbox_id=f"sb-{self.id}-{len(self.deploy_calls)}", sandbox_type="fake", + env_id=self.id, env_version=1, gateway_url="g", mcp_url="m", sandbox_id=f"sb-{self.id}-{len(self.deploy_calls)}", sandbox_type="fake", ) ) return context @@ -551,7 +550,7 @@ async def execute(self, context): self.runs += 1 context.deployed_envs.append( DeployedGatewayEnv(env_id=self.id, env_version=1, gateway_url="g", mcp_url="m", - db_web_url=None, sandbox_id="") + sandbox_id="") ) await release.wait() return context diff --git a/tst/unit/task_step/sync_env_clock_test.py b/tst/unit/task_step/sync_env_clock_test.py index a615101bc..191247b98 100644 --- a/tst/unit/task_step/sync_env_clock_test.py +++ b/tst/unit/task_step/sync_env_clock_test.py @@ -275,15 +275,13 @@ async def fetch(client, key, base_url): def _cardless() -> DeployedEnv: """A record that kept no card, which a sync reads live from the gateway.""" - return DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", db_web_url=None, - sandbox_id="sb-1") + return DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", sandbox_id="sb-1") def _carded(card: dict) -> DeployedEnv: from agent_env.env.gateway.constants import WELL_KNOWN_PATH - return DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", db_web_url=None, - sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card) + return DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card) def _mock_http(monkeypatch, state: dict | None = None, set_time_status: int = 200): diff --git a/tst/unit/task_step/test_apply_server_config.py b/tst/unit/task_step/test_apply_server_config.py index 9df2a67ec..bfb2d6c6d 100644 --- a/tst/unit/task_step/test_apply_server_config.py +++ b/tst/unit/task_step/test_apply_server_config.py @@ -56,7 +56,7 @@ def _ext(uri: str, endpoint: str, method: str = "POST") -> dict: def _make_context(*, env_id="env-x", gateway_url=_GATEWAY, metadata=None): env = DeployedGatewayEnv( env_id=env_id, env_version=1, gateway_url=gateway_url, mcp_url="", - db_web_url=None, sandbox_id="sb-env", + sandbox_id="sb-env", ) return TaskStepContext(deployed_envs=[env], metadata={} if metadata is None else metadata) diff --git a/tst/unit/task_step/test_collect_artifacts.py b/tst/unit/task_step/test_collect_artifacts.py index c439304b1..2b869e6c1 100644 --- a/tst/unit/task_step/test_collect_artifacts.py +++ b/tst/unit/task_step/test_collect_artifacts.py @@ -59,7 +59,7 @@ def _non_cua_context(): instance_id="inst-1", deployed_envs=[DeployedGatewayEnv( env_id="ubuntu-cua", env_version=1, gateway_url="http://gw", - mcp_url="http://gw", db_web_url=None, sandbox_id="vm-1", + mcp_url="http://gw", sandbox_id="vm-1", metadata={"some_other_env": True}, environment_card_url=f"http://gw{WELL_KNOWN_PATH}", environment_card=_gateway_card(), )], @@ -1092,15 +1092,14 @@ def _gateway_card(extensions: list = GATEWAY_EXTENSIONS) -> dict: def _cua_record(extensions: list = GATEWAY_EXTENSIONS) -> DeployedEnv: """An Ubuntu CUA env (the marker CuaEnv.deploy sets) whose stored card is the gateway's.""" - return DeployedGatewayEnv(env_id="ubuntu-cua", env_version=1, gateway_url="http://gw", mcp_url="http://gw", db_web_url=None, - sandbox_id="vm-1", metadata={"cua_vm_sandbox_id": "cua-vm-1"}, + return DeployedGatewayEnv(env_id="ubuntu-cua", env_version=1, gateway_url="http://gw", mcp_url="http://gw", sandbox_id="vm-1", metadata={"cua_vm_sandbox_id": "cua-vm-1"}, environment_card_url=f"http://gw{WELL_KNOWN_PATH}", environment_card=_gateway_card(extensions)) def _macos_record() -> DeployedEnv: """A macOS CUA env: the gateway (CUA MCP server, 18765) plus a distinct osworld sidecar (18768).""" return DeployedGatewayEnv(env_id="macos-cua", env_version=1, gateway_url="http://gw-18765", mcp_url="http://gw-18765/mcp", - db_web_url=None, sandbox_id="vm-1", + sandbox_id="vm-1", metadata={"cua_vm_sandbox_id": "cua-vm-1", "cua_controller_url": "http://ctrl-18768"}, environment_card_url=f"http://gw-18765{WELL_KNOWN_PATH}", environment_card=_gateway_card()) diff --git a/tst/unit/task_step/test_combine_universe_verdicts.py b/tst/unit/task_step/test_combine_universe_verdicts.py index 174de8606..f3db62ac8 100644 --- a/tst/unit/task_step/test_combine_universe_verdicts.py +++ b/tst/unit/task_step/test_combine_universe_verdicts.py @@ -31,7 +31,7 @@ def put(self, **kwargs): def _deployed_env(env_id="multi-x", env_version=3): return DeployedGatewayEnv( env_id=env_id, env_version=env_version, gateway_url="g", mcp_url="m", - db_web_url=None, sandbox_id="sb-1", + sandbox_id="sb-1", ) diff --git a/tst/unit/task_step/test_configure_scheduled_checks.py b/tst/unit/task_step/test_configure_scheduled_checks.py index 8702651e2..045ed37d5 100644 --- a/tst/unit/task_step/test_configure_scheduled_checks.py +++ b/tst/unit/task_step/test_configure_scheduled_checks.py @@ -74,8 +74,7 @@ def _step(**kwargs) -> ConfigureScheduledChecksTaskStep: def _record(extensions: list = GATEWAY_EXTENSIONS) -> DeployedEnv: - return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", db_web_url=None, - sandbox_id="sb", environment_card_url=f"{_GATEWAY}{WELL_KNOWN_PATH}", + return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", sandbox_id="sb", environment_card_url=f"{_GATEWAY}{WELL_KNOWN_PATH}", environment_card={"name": "gw", "capabilities": {"extensions": extensions}}) diff --git a/tst/unit/task_step/test_deploy_agent_mcp_alias.py b/tst/unit/task_step/test_deploy_agent_mcp_alias.py index 89fa22ba6..597d23adb 100644 --- a/tst/unit/task_step/test_deploy_agent_mcp_alias.py +++ b/tst/unit/task_step/test_deploy_agent_mcp_alias.py @@ -64,8 +64,7 @@ async def test_a_record_without_a_stored_card_relays_no_name_and_warns(monkeypat def _deployed_env(card: dict | None) -> DeployedEnv: return DeployedGatewayEnv( - env_id="crm", env_version=1, gateway_url="https://gw.example", mcp_url=_MCP_URL, db_web_url=None, - sandbox_id="sb-1", environment_card_url="https://gw.example/.well-known/agent-env.json", environment_card=card, + env_id="crm", env_version=1, gateway_url="https://gw.example", mcp_url=_MCP_URL, sandbox_id="sb-1", environment_card_url="https://gw.example/.well-known/agent-env.json", environment_card=card, ) diff --git a/tst/unit/task_step/test_deploy_agent_role_delivery.py b/tst/unit/task_step/test_deploy_agent_role_delivery.py index 3e605df0f..ff4ed9e88 100644 --- a/tst/unit/task_step/test_deploy_agent_role_delivery.py +++ b/tst/unit/task_step/test_deploy_agent_role_delivery.py @@ -285,7 +285,6 @@ def wiring(monkeypatch) -> _Wiring: def _gateway_env() -> DeployedGatewayEnv: return DeployedGatewayEnv( - env_id="crm", env_version=1, gateway_url="https://gw.example", mcp_url=_GATEWAY_MCP_URL, db_web_url=None, - sandbox_id="sb-1", environment_card_url="https://gw.example/.well-known/agent-env.json", + env_id="crm", env_version=1, gateway_url="https://gw.example", mcp_url=_GATEWAY_MCP_URL, sandbox_id="sb-1", environment_card_url="https://gw.example/.well-known/agent-env.json", environment_card={"name": "crm"}, ) diff --git a/tst/unit/task_step/test_deploy_ttl_from_budget.py b/tst/unit/task_step/test_deploy_ttl_from_budget.py index bd1e60eb2..fd5a0cf6b 100644 --- a/tst/unit/task_step/test_deploy_ttl_from_budget.py +++ b/tst/unit/task_step/test_deploy_ttl_from_budget.py @@ -17,7 +17,7 @@ async def _env_deploy_ttl(step_ttl, overrides) -> int: env = MagicMock() env.deploy = AsyncMock(return_value=DeployedGatewayEnv( env_id="art-1", env_version=2, gateway_url="http://gw", mcp_url="http://mcp", - db_web_url=None, sandbox_id="s1", metadata=None, + sandbox_id="s1", metadata=None, )) step = DeployEnvTaskStep(id="d", version=None, env_id="art-1", env_version=2, ttl_seconds=step_ttl) ctx = TaskStepContext(metadata={"user_overrides": overrides}) diff --git a/tst/unit/task_step/test_load_artifact_env_binding.py b/tst/unit/task_step/test_load_artifact_env_binding.py index a4f377c43..b9a64d1b6 100644 --- a/tst/unit/task_step/test_load_artifact_env_binding.py +++ b/tst/unit/task_step/test_load_artifact_env_binding.py @@ -25,7 +25,7 @@ async def _deploy(**_kwargs): await asyncio.sleep(0) return DeployedGatewayEnv( env_id=ENV_ID, env_version=1, gateway_url=f"https://gw-{sandbox_id}", - mcp_url=f"https://{sandbox_id}/mcp", db_web_url=None, sandbox_id=sandbox_id, + mcp_url=f"https://{sandbox_id}/mcp", sandbox_id=sandbox_id, ) env = MagicMock() diff --git a/tst/unit/task_step/test_load_artifact_file.py b/tst/unit/task_step/test_load_artifact_file.py index b4fb13a80..d1d2ed653 100644 --- a/tst/unit/task_step/test_load_artifact_file.py +++ b/tst/unit/task_step/test_load_artifact_file.py @@ -134,7 +134,7 @@ async def from_deployed_env(cls, deployed): context = TaskStepContext() context.deployed_envs = [DeployedGatewayEnv( env_id="tickets", env_version=1, gateway_url="https://gw", mcp_url="https://gw/mcp", - db_web_url=None, sandbox_id="sb-env", + sandbox_id="sb-env", )] step = LoadArtifactTaskStep(id="stage", version=None, env_id="tickets", artifact_id="check", destination_path="/data") context = await step.execute(context) diff --git a/tst/unit/task_step/test_load_artifact_service_universe.py b/tst/unit/task_step/test_load_artifact_service_universe.py index f102e4d75..edc154d86 100644 --- a/tst/unit/task_step/test_load_artifact_service_universe.py +++ b/tst/unit/task_step/test_load_artifact_service_universe.py @@ -75,7 +75,7 @@ async def _fake_load(deployed, universe, destination): def _deployed_env(env_id: str = "multi-slack-email") -> DeployedEnv: return DeployedGatewayEnv( env_id=env_id, env_version=7, gateway_url="http://gw", mcp_url="http://gw/mcp", - db_web_url=None, sandbox_id="sb-env", instance_id="env-inst-1", + sandbox_id="sb-env", instance_id="env-inst-1", ) diff --git a/tst/unit/task_step/test_mcp_cli_builder.py b/tst/unit/task_step/test_mcp_cli_builder.py index af7d6eb74..763351fce 100644 --- a/tst/unit/task_step/test_mcp_cli_builder.py +++ b/tst/unit/task_step/test_mcp_cli_builder.py @@ -207,7 +207,7 @@ def put(**kw): monkeypatch.setattr(build_mcp_cli.Env, "get", staticmethod(lambda id, version=None: SimpleNamespace(environment_name="slack"))) monkeypatch.setattr(build_mcp_cli, "fetch_interface_manifest", no_manifest) monkeypatch.setattr(build_mcp_cli.CliArtifact, "put", staticmethod(put)) - record = DeployedGatewayEnv(env_id="slack-mcp", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", db_web_url=None, sandbox_id="sb") + record = DeployedGatewayEnv(env_id="slack-mcp", env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", sandbox_id="sb") await BuildMcpCliTaskStep(id="s1", version=None, env_id="slack-mcp", command_name="slack").execute( TaskStepContext(deployed_envs=[record]) @@ -217,7 +217,7 @@ def put(**kw): def _gateway_record(env_id: str = "slack-mcp") -> DeployedGatewayEnv: - return DeployedGatewayEnv(env_id=env_id, env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", db_web_url=None, sandbox_id="sb") + return DeployedGatewayEnv(env_id=env_id, env_version=1, gateway_url="http://gw", mcp_url="http://gw/mcp", sandbox_id="sb") def _no_gateway(monkeypatch) -> None: diff --git a/tst/unit/task_step/test_modify_env_tool_access.py b/tst/unit/task_step/test_modify_env_tool_access.py index 450ef5a66..8a3ea58b3 100644 --- a/tst/unit/task_step/test_modify_env_tool_access.py +++ b/tst/unit/task_step/test_modify_env_tool_access.py @@ -58,7 +58,7 @@ def _step(action: str) -> ModifyEnvToolAccessStep: def _record(extensions: list = GATEWAY_EXTENSIONS) -> DeployedEnv: """A gateway deployment whose stored card advertises `extensions` (the gateway's own, by default).""" - return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", db_web_url=None, sandbox_id="sb", + return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", sandbox_id="sb", environment_card_url=f"{_GATEWAY}{WELL_KNOWN_PATH}", environment_card={"name": "gw", "capabilities": {"extensions": extensions}}) diff --git a/tst/unit/task_step/test_parallel_deploy_env_binding.py b/tst/unit/task_step/test_parallel_deploy_env_binding.py index 5b95f7430..36dd69f15 100644 --- a/tst/unit/task_step/test_parallel_deploy_env_binding.py +++ b/tst/unit/task_step/test_parallel_deploy_env_binding.py @@ -30,7 +30,6 @@ async def _deploy(**_kwargs): env_version=1, gateway_url=f"https://gw-{sandbox_id}", mcp_url=mcp_url, - db_web_url=None, sandbox_id=sandbox_id, ) diff --git a/tst/unit/task_step/test_prompt_agent_triggers.py b/tst/unit/task_step/test_prompt_agent_triggers.py index 0d33d5b9a..b770980b5 100644 --- a/tst/unit/task_step/test_prompt_agent_triggers.py +++ b/tst/unit/task_step/test_prompt_agent_triggers.py @@ -29,7 +29,7 @@ def _env(env_id: str, gateway_url: str, *uris: str): """A record whose stored card is the gateway's, offering only `uris` when given.""" extensions = [e for e in GATEWAY_EXTENSIONS if not uris or e["uri"] in uris] return DeployedGatewayEnv(env_id=env_id, env_version=1, gateway_url=gateway_url, mcp_url="", - db_web_url=None, sandbox_id="sb", environment_card_url=f"{gateway_url}{WELL_KNOWN_PATH}", + sandbox_id="sb", environment_card_url=f"{gateway_url}{WELL_KNOWN_PATH}", environment_card={"capabilities": {"extensions": extensions}}) diff --git a/tst/unit/task_step/test_register_agent_triggers.py b/tst/unit/task_step/test_register_agent_triggers.py index 612ecf933..836ca22ac 100644 --- a/tst/unit/task_step/test_register_agent_triggers.py +++ b/tst/unit/task_step/test_register_agent_triggers.py @@ -34,7 +34,7 @@ def _context(*, card: dict | None = None, env_ids: tuple[str, ...] = ("env-x",), if registered_env_triggers is None: registered_env_triggers = {"env-x": ["v6-rate"]} envs = [DeployedGatewayEnv(env_id=e, env_version=1, gateway_url="http://gw", mcp_url="", - db_web_url=None, sandbox_id="sb") for e in env_ids] + sandbox_id="sb") for e in env_ids] agents = [] if with_agent: agents.append(DeployedAgent(agent_name="stake-1", api_url="http://stakeholder:8000/api", diff --git a/tst/unit/task_step/test_register_env_triggers.py b/tst/unit/task_step/test_register_env_triggers.py index 78f370aee..9659893a4 100644 --- a/tst/unit/task_step/test_register_env_triggers.py +++ b/tst/unit/task_step/test_register_env_triggers.py @@ -353,7 +353,7 @@ def _with_features(*features: str) -> list: def _record(extensions: list = GATEWAY_EXTENSIONS) -> DeployedEnv: """A gateway deployment whose stored card advertises `extensions` (the gateway's own, by default).""" - return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", db_web_url=None, sandbox_id="sb", + return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url="", sandbox_id="sb", environment_card_url=f"{_GATEWAY}{WELL_KNOWN_PATH}", environment_card={"name": "gw", "capabilities": {"extensions": extensions}}) diff --git a/tst/unit/task_step/test_run_code.py b/tst/unit/task_step/test_run_code.py index 5527367e1..cb1ba3128 100644 --- a/tst/unit/task_step/test_run_code.py +++ b/tst/unit/task_step/test_run_code.py @@ -46,7 +46,7 @@ def _make_context(*, with_agent=True, metadata=None): ) env = DeployedGatewayEnv( env_id="env-x", env_version=1, gateway_url="", mcp_url="", - db_web_url=None, sandbox_id="sb-env", + sandbox_id="sb-env", ) return TaskStepContext( deployed_agents=[agent] if with_agent else [], diff --git a/tst/unit/task_step/test_snapshot_agent_state.py b/tst/unit/task_step/test_snapshot_agent_state.py index 551f1cd26..c0a372b1e 100644 --- a/tst/unit/task_step/test_snapshot_agent_state.py +++ b/tst/unit/task_step/test_snapshot_agent_state.py @@ -74,7 +74,6 @@ def _ctx(): env_version=1, gateway_url="https://gw", mcp_url="m", - db_web_url=None, sandbox_id="sb-1", ) ] diff --git a/tst/unit/task_step/test_snapshot_env.py b/tst/unit/task_step/test_snapshot_env.py index cf75fb7ca..3720f0d32 100644 --- a/tst/unit/task_step/test_snapshot_env.py +++ b/tst/unit/task_step/test_snapshot_env.py @@ -30,7 +30,6 @@ def _deployed(env_id="env-1", instance_id="env-1-abc123", gateway="https://gw-1" env_version=3, gateway_url=gateway, mcp_url=f"{gateway}/mcp", - db_web_url=None, sandbox_id="sb-1", instance_id=instance_id, environment_card_url=f"{gateway}{WELL_KNOWN_PATH}", @@ -1104,7 +1103,7 @@ def test_snapshot_servers_refuses_an_env_with_none(): def _deployed_without_a_card() -> DeployedEnv: """An older record: no card URL, so its servers are the ones its definition names.""" return DeployedGatewayEnv(env_id="env-1", env_version=3, gateway_url="https://gw-1", mcp_url="https://gw-1/mcp", - db_web_url=None, sandbox_id="sb-1") + sandbox_id="sb-1") def test_resolve_loaded_universe_ref_reads_store(monkeypatch): @@ -1343,8 +1342,7 @@ def _carded(card: dict) -> DeployedEnv: from agent_env.env.gateway.constants import WELL_KNOWN_PATH return DeployedGatewayEnv( - env_id="env-1", env_version=3, gateway_url="https://gw-1", mcp_url="https://gw-1/mcp", db_web_url=None, - sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card, + env_id="env-1", env_version=3, gateway_url="https://gw-1", mcp_url="https://gw-1/mcp", sandbox_id="sb-1", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card, ) diff --git a/tst/unit/task_step/test_snapshot_env_env_binding.py b/tst/unit/task_step/test_snapshot_env_env_binding.py index 990ca7807..4c120cea0 100644 --- a/tst/unit/task_step/test_snapshot_env_env_binding.py +++ b/tst/unit/task_step/test_snapshot_env_env_binding.py @@ -30,7 +30,7 @@ async def _deploy(**_kwargs): await asyncio.sleep(0) return DeployedGatewayEnv( env_id=ENV_ID, env_version=1, gateway_url=f"https://gw-{sandbox_id}", - mcp_url=f"https://{sandbox_id}/mcp", db_web_url=None, sandbox_id=sandbox_id, + mcp_url=f"https://{sandbox_id}/mcp", sandbox_id=sandbox_id, ) env = MagicMock() diff --git a/tst/unit/task_step/test_teardown_sandboxes.py b/tst/unit/task_step/test_teardown_sandboxes.py index a7120fcf9..8638ee882 100644 --- a/tst/unit/task_step/test_teardown_sandboxes.py +++ b/tst/unit/task_step/test_teardown_sandboxes.py @@ -85,8 +85,7 @@ def _context() -> TaskStepContext: ], deployed_envs=[ DeployedGatewayEnv( - env_id="shop", env_version=1, gateway_url=None, mcp_url="http://m", db_web_url=None, - sandbox_id="sb-gw", sandbox_type="modal", + env_id="shop", env_version=1, gateway_url=None, mcp_url="http://m", sandbox_id="sb-gw", sandbox_type="modal", sandbox_ids={"gateway": "sb-gw", "service_db": {"orders": "sb-db"}, "modal_vm": "sb-vm"}, ), ], diff --git a/tst/unit/task_step/test_verify_spec_conformance.py b/tst/unit/task_step/test_verify_spec_conformance.py index 40a2ebedf..6c77aae54 100644 --- a/tst/unit/task_step/test_verify_spec_conformance.py +++ b/tst/unit/task_step/test_verify_spec_conformance.py @@ -622,7 +622,7 @@ def handle(request): sent.append((request.method, str(request.url))) return httpx.Response(200, json={"name": "items"}) if request.url.path.endswith(WELL_KNOWN_PATH) else httpx.Response(404) - record = DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url=gateway_url, mcp_url="", db_web_url=None, sandbox_id="sb", + record = DeployedGatewayEnv(env_id="e1", env_version=1, gateway_url=gateway_url, mcp_url="", sandbox_id="sb", environment_card_url=f"{gateway_url}{WELL_KNOWN_PATH}", environment_card=card) env = MagicMock(environment_name="items") with patch.object(httpx, "AsyncClient", lambda *a, **k: real(transport=httpx.MockTransport(handle))), \ diff --git a/tst/unit/task_step/test_verify_universe_roundtrip.py b/tst/unit/task_step/test_verify_universe_roundtrip.py index 67a8badde..d21675c06 100644 --- a/tst/unit/task_step/test_verify_universe_roundtrip.py +++ b/tst/unit/task_step/test_verify_universe_roundtrip.py @@ -154,7 +154,7 @@ async def fetch(client, key, base_url): def _record(card: dict | None) -> DeployedEnv: - return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url=f"{_GATEWAY}/mcp", db_web_url=None, sandbox_id="sb", + return DeployedGatewayEnv(env_id="env-x", env_version=1, gateway_url=_GATEWAY, mcp_url=f"{_GATEWAY}/mcp", sandbox_id="sb", environment_card_url=f"{_CARD}{WELL_KNOWN_PATH}", environment_card=card)