Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

test(cua-sandbox): tolerate Fleet 403 for not-yet-created pool namespaces (#3235)

r33drichards74ea02490c52
diff --git a/.github/scripts/tests/test_cua_fleet_release_wiring.py b/.github/scripts/tests/test_cua_fleet_release_wiring.py
index 72e4bfdc10..1add9bf2ab 100644
--- a/.github/scripts/tests/test_cua_fleet_release_wiring.py
+++ b/.github/scripts/tests/test_cua_fleet_release_wiring.py
@@ -3,21 +3,20 @@
from pathlib import Path
import unittest
-
REPO_ROOT = Path(__file__).resolve().parents[3]
class TestCuaFleetReleaseWiring(unittest.TestCase):
"""Keep Fleet's promotion workflow aligned with canonical SDK wheels."""
- def test_publisher_promotes_cua_fleet_0_1_11(self) -> None:
+ def test_publisher_promotes_cua_fleet_0_1_12(self) -> None:
workflow = (REPO_ROOT / ".github/workflows/cd-py-fleet.yml").read_text()
expected_sources = {
- "cua_fleet-0.1.11-py3-none-manylinux_2_34_x86_64.whl": "0539a40aac915368362dd2f3e90d4b6d233e7bece77d13a5733d8cecb7298731",
- "cua_fleet-0.1.11-py3-none-manylinux_2_34_aarch64.whl": "c76052d9cb1710936a59709fd5a2894fe9fb43fe89e2a0313ad0b88faf4c2b1e",
- "cua_fleet-0.1.11-py3-none-macosx_10_12_x86_64.whl": "5884a26388b44e9cf59314d20b9aae34f278c48b108d927ebaf802b8d5b7d7f6",
- "cua_fleet-0.1.11-py3-none-macosx_11_0_arm64.whl": "1f6d1532f76166fe30001c68765c4f3fcb94e9b713751f7a009d3780f523aa9c",
- "cua_fleet-0.1.11-py3-none-win_amd64.whl": "da8e1c40abcd3fee5cdab48801d4bd43a277ecddb7afebcba3d9885d9ec5d431",
+ "cua_fleet-0.1.12-py3-none-manylinux_2_34_x86_64.whl": "d8ef6a0c8ac6e6f8dda937e3aebeef7f5b4fa9e3f29edc55a602a1c874f3f96a",
+ "cua_fleet-0.1.12-py3-none-manylinux_2_34_aarch64.whl": "0a39e52cbec94a2bc71f45282dd34c896fd154bc7f7a137fc6ceff82edfc0973",
+ "cua_fleet-0.1.12-py3-none-macosx_10_12_x86_64.whl": "d5114ba97ef208e257bef261f6d3585b265f1f2c32cb627bcc9f44d753e60b75",
+ "cua_fleet-0.1.12-py3-none-macosx_11_0_arm64.whl": "82762fae4943b20aae05b39362f5bd0c179f84c16dac1e948debb3d58db5adc2",
+ "cua_fleet-0.1.12-py3-none-win_amd64.whl": "c280d7ceadedc1d5c4c59869940c3390aac321f12ac9c9ee52250f212b6aac75",
}
self.assertIn("https://wheels.cua.ai/simple/cua-fleet/$WHEEL", workflow)
diff --git a/.github/scripts/tests/test_periodic_cua_sandbox_live.py b/.github/scripts/tests/test_periodic_cua_sandbox_live.py
index 316ab91512..c2dbd6947e 100644
--- a/.github/scripts/tests/test_periodic_cua_sandbox_live.py
+++ b/.github/scripts/tests/test_periodic_cua_sandbox_live.py
@@ -370,6 +370,7 @@ class TestPeriodicCuaSandboxLive(unittest.TestCase):
self.assertIn("unexpected_inventory", pool_test)
self.assertIn("module_origins", pool_test)
self.assertIn("pool_pre_existed", pool_test)
+ self.assertIn("is_pool_missing_error", pool_test)
self.assertNotIn("pool.delete(", pool_test)
self.assertNotIn("delete_pool", pool_test)
self.assertNotIn("delete_namespace", pool_test)
diff --git a/docs/superpowers/plans/2026-08-09-periodic-cua-sandbox-live-e2e.md b/docs/superpowers/plans/2026-08-09-periodic-cua-sandbox-live-e2e.md
index 84d286adda..b8b3d58e51 100644
--- a/docs/superpowers/plans/2026-08-09-periodic-cua-sandbox-live-e2e.md
+++ b/docs/superpowers/plans/2026-08-09-periodic-cua-sandbox-live-e2e.md
@@ -930,8 +930,11 @@ The warm pool keeps `replicas=1` so claims bind to pre-provisioned capacity;
the cold pool expresses scale-to-zero with
`WarmPoolAutoscaling(min_pool_size=0, initial_pool_size=0, max_pool_size=1)`
because pool reconciliation rejects `replicas` below one. Each run records
-`pool_pre_existed` and replica counts from `Pool.get`, reconciles the pinned
-configuration idempotently with `Pool.apply`, claims through
+`pool_pre_existed` and replica counts from `Pool.get`, treating both 403 and
+404 as not-pre-existed (`is_pool_missing_error`) because Fleet evaluates
+authorization before existence for namespaces that have not been created
+yet, reconciles the pinned configuration idempotently with `Pool.apply`,
+claims through
`Sandbox.ephemeral(pool=..., name=...)` with the claim name fixed to the
namespace, and exits with a claim-only release. After release the monitor
polls until claims are absent and requires the reconciled inventory to contain
diff --git a/docs/superpowers/specs/2026-08-09-periodic-cua-sandbox-live-e2e-design.md b/docs/superpowers/specs/2026-08-09-periodic-cua-sandbox-live-e2e-design.md
index 35d6240620..6062fbe043 100644
--- a/docs/superpowers/specs/2026-08-09-periodic-cua-sandbox-live-e2e-design.md
+++ b/docs/superpowers/specs/2026-08-09-periodic-cua-sandbox-live-e2e-design.md
@@ -203,7 +203,12 @@ cold-starts capacity through autoscaler demand.
Each run observes the pool first with `Pool.get`, recording
`pool_pre_existed` and the replica counts, then reconciles the pinned
configuration with `Pool.apply` using the same certified image digest,
-`cpu=4`, and `memory_mb=4096`. Reconciliation is idempotent: it bootstraps a
+`cpu=4`, and `memory_mb=4096`. Fleet evaluates authorization before
+existence, so reading a pool in a namespace that has not been created yet
+returns 403 rather than 404; the observe step treats both statuses as
+not-pre-existed (`is_pool_missing_error`), mirroring the SDK's reconcile
+semantics, and a genuine access denial still fails the run at `Pool.apply`
+with the canonical `PoolAccessDenied` guidance. Reconciliation is idempotent: it bootstraps a
missing pool, heals drift, and never deletes. The claim uses
`Sandbox.ephemeral(pool=..., name=...)` with the claim name fixed to the
namespace, so an interrupted run's claim is adopted and released by the next
diff --git a/libs/python/cua-sandbox/.bumpversion.cfg b/libs/python/cua-sandbox/.bumpversion.cfg
index 238bca270f..b9f99a3bd1 100644
--- a/libs/python/cua-sandbox/.bumpversion.cfg
+++ b/libs/python/cua-sandbox/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.3.6
+current_version = 0.4.1
commit = True
tag = True
tag_name = sandbox-v{new_version}
diff --git a/libs/python/cua-sandbox/tests/live/fleet_e2e_support.py b/libs/python/cua-sandbox/tests/live/fleet_e2e_support.py
index b60320fa91..b2b730eae9 100644
--- a/libs/python/cua-sandbox/tests/live/fleet_e2e_support.py
+++ b/libs/python/cua-sandbox/tests/live/fleet_e2e_support.py
@@ -98,6 +98,13 @@ def is_not_found_error(error: BaseException) -> bool:
return isinstance(error, SdkError.Status) and error.status == 404
+def is_pool_missing_error(error: BaseException) -> bool:
+ # Fleet evaluates RBAC before existence, so reading a pool in a namespace
+ # that has not been created yet returns 403 rather than 404. Mirror the
+ # SDK's reconcile semantics, which create the pool on either status.
+ return isinstance(error, SdkError.Status) and error.status in (403, 404)
+
+
async def wait_claims_absent(
client: CyclopsClient,
name: str,
diff --git a/libs/python/cua-sandbox/tests/live/test_fleet_pool_persistent.py b/libs/python/cua-sandbox/tests/live/test_fleet_pool_persistent.py
index 8c4ed1966f..6c63803ac9 100644
--- a/libs/python/cua-sandbox/tests/live/test_fleet_pool_persistent.py
+++ b/libs/python/cua-sandbox/tests/live/test_fleet_pool_persistent.py
@@ -16,7 +16,7 @@ from tests.live.fleet_e2e_support import (
build_pool_namespace_name,
collect_resource_inventory,
has_oauth_credentials,
- is_not_found_error,
+ is_pool_missing_error,
wait_claims_absent,
write_summary,
)
@@ -103,7 +103,7 @@ async def run_fleet_pool_live(mode: str) -> None:
try:
existing = await Pool.get(namespace)
except BaseException as error:
- if not is_not_found_error(error):
+ if not is_pool_missing_error(error):
raise
summary["pool_pre_existed"] = False
else:
diff --git a/libs/python/cua-sandbox/tests/test_live_fleet_e2e_support.py b/libs/python/cua-sandbox/tests/test_live_fleet_e2e_support.py
index 6cc5f26f40..80157d0a5f 100644
--- a/libs/python/cua-sandbox/tests/test_live_fleet_e2e_support.py
+++ b/libs/python/cua-sandbox/tests/test_live_fleet_e2e_support.py
@@ -14,6 +14,7 @@ from tests.live.fleet_e2e_support import (
build_pool_namespace_name,
collect_resource_inventory,
has_oauth_credentials,
+ is_pool_missing_error,
wait_claims_absent,
write_summary,
)
@@ -74,6 +75,21 @@ def test_build_pool_namespace_name_normalizes_invalid_overlong_input() -> None:
assert name.startswith("cua-live-pool-warm-published-package-")
+ ("error", "missing"),
+ [
+ (SdkError.Status("get pool", 404, b"not found"), True),
+ (SdkError.Status("get pool", 403, b"forbidden"), True),
+ (SdkError.Status("get pool", 500, b"failure"), False),
+ (RuntimeError("transport down"), False),
+ ],
+)
+def test_is_pool_missing_error_mirrors_reconcile_semantics(
+ error: BaseException, missing: bool
+) -> None:
+ assert is_pool_missing_error(error) is missing
+
+
def test_support_has_oauth_credentials_requires_both_values(monkeypatch) -> None:
monkeypatch.delenv("CUA_CLIENT_ID", raising=False)
monkeypatch.delenv("CUA_CLIENT_SECRET", raising=False)
diff --git a/libs/python/cua-sandbox/tests/test_live_fleet_pool_support.py b/libs/python/cua-sandbox/tests/test_live_fleet_pool_support.py
index 654471b5e1..eeddae0fd4 100644
--- a/libs/python/cua-sandbox/tests/test_live_fleet_pool_support.py
+++ b/libs/python/cua-sandbox/tests/test_live_fleet_pool_support.py
@@ -22,6 +22,12 @@ def not_found(operation: str = "get pool") -> SdkError.Status:
return SdkError.Status(operation, 404, b"not found")
+def forbidden(operation: str = "get pool") -> SdkError.Status:
+ # Fleet returns 403 for pool reads in namespaces that have not been
+ # created yet, because RBAC is evaluated before existence.
+ return SdkError.Status(operation, 403, b"forbidden")
+
+
class FakePoolHandle:
def __init__(self, resource) -> None:
self._resource = resource
@@ -229,6 +235,36 @@ async def test_pool_pre_existed_false_is_recorded_for_public_sdk_404(monkeypatch
assert summary["warm_bind_sla_applied"] is False
+async def test_pool_pre_existed_false_is_recorded_for_uncreated_namespace_403(
+ monkeypatch, tmp_path
+) -> None:
+ namespace = "cua-live-pool-warm-test-schedule"
+ harness = install_pool_runner(monkeypatch, tmp_path, mode="warm", namespace=namespace)
+ harness.get_results = [forbidden(), make_pool_resource(namespace)]
+
+ await pool_live.run_fleet_pool_live("warm")
+
+ summary = harness.summaries["summary-pool-warm.json"]
+ assert summary["pool_pre_existed"] is False
+ assert "ready_replicas_before" not in summary
+ assert summary["warm_bind_sla_applied"] is False
+
+
+async def test_observe_propagates_non_missing_pool_errors(monkeypatch, tmp_path) -> None:
+ namespace = "cua-live-pool-warm-test-schedule"
+ harness = install_pool_runner(monkeypatch, tmp_path, mode="warm", namespace=namespace)
+ harness.get_results = [SdkError.Status("get pool", 500, b"failure")]
+
+ with pytest.raises(SdkError.Status):
+ await pool_live.run_fleet_pool_live("warm")
+
+ assert harness.apply_calls == []
+ summary = harness.summaries["summary-pool-warm.json"]
+ assert summary["error"] == {"type": "Status"}
+
+
@pytest.mark.asyncio
async def test_empty_inventory_fails_as_unexpected(monkeypatch, tmp_path) -> None:
namespace = "cua-live-pool-warm-test-schedule"