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.

refactor(analytics): derive Fleet activation binding in backend (#7294)

Francesco Bonacci94240c896682
diff --git a/libs/fleet/backend/handlers/attribution.go b/libs/fleet/backend/handlers/attribution.go
index 0d4c21dd24..dc0bd6d345 100644
--- a/libs/fleet/backend/handlers/attribution.go
+++ b/libs/fleet/backend/handlers/attribution.go
@@ -13,10 +13,8 @@ import (
"cyclops-cs-backend/productanalytics"
)
-const FleetClaimHeader = "X-Cua-Fleet-Claim"
-
type AttributionFactsReader interface {
- ReadBoundClaim(context.Context, string, string) (BoundClaim, error)
+ ReadBoundClaimForSandbox(context.Context, string, string) (BoundClaim, error)
PoolExists(context.Context, string, string) (bool, error)
}
@@ -45,13 +43,50 @@ func (reader fleetAttributionFactsReader) userSubject(ctx context.Context) (stri
return user.ID, nil
}
-func (reader fleetAttributionFactsReader) ReadBoundClaim(ctx context.Context, namespace, claim string) (BoundClaim, error) {
+func (reader fleetAttributionFactsReader) ReadBoundClaimForSandbox(ctx context.Context, namespace, sandbox string) (BoundClaim, error) {
subject, err := reader.userSubject(ctx)
if err != nil {
return BoundClaim{}, err
}
- path := fmt.Sprintf("/apis/osgym.cua.ai/v1alpha1/namespaces/%s/osgymsandboxclaims/%s", url.PathEscape(namespace), url.PathEscape(claim))
- response, err := reader.handlers.k8sImpersonate(ctx, http.MethodGet, path, nil, subject)
+ sandboxPath := fmt.Sprintf("/apis/osgym.cua.ai/v1alpha1/namespaces/%s/osgymsandboxes/%s", url.PathEscape(namespace), url.PathEscape(sandbox))
+ response, err := reader.handlers.k8sImpersonate(ctx, http.MethodGet, sandboxPath, nil, subject)
+ if err != nil {
+ return BoundClaim{}, err
+ }
+ defer response.Body.Close()
+ if response.StatusCode != http.StatusOK {
+ return BoundClaim{}, fmt.Errorf("sandbox lookup returned HTTP %d", response.StatusCode)
+ }
+ var sandboxPayload struct {
+ Metadata struct {
+ OwnerReferences []struct {
+ APIVersion string `json:"apiVersion"`
+ Kind string `json:"kind"`
+ Name string `json:"name"`
+ UID string `json:"uid"`
+ Controller *bool `json:"controller"`
+ } `json:"ownerReferences"`
+ } `json:"metadata"`
+ }
+ if err := json.NewDecoder(io.LimitReader(response.Body, 1<<20)).Decode(&sandboxPayload); err != nil {
+ return BoundClaim{}, err
+ }
+ var ownerName, ownerUID string
+ for _, owner := range sandboxPayload.Metadata.OwnerReferences {
+ if owner.APIVersion != "osgym.cua.ai/v1alpha1" || owner.Kind != "OSGymSandboxClaim" || owner.Controller == nil || !*owner.Controller {
+ continue
+ }
+ if ownerName != "" {
+ return BoundClaim{}, fmt.Errorf("sandbox has multiple claim controller owners")
+ }
+ ownerName, ownerUID = owner.Name, owner.UID
+ }
+ if ownerName == "" || ownerUID == "" {
+ return BoundClaim{Sandbox: sandbox}, nil
+ }
+
+ claimPath := fmt.Sprintf("/apis/osgym.cua.ai/v1alpha1/namespaces/%s/osgymsandboxclaims/%s", url.PathEscape(namespace), url.PathEscape(ownerName))
+ response, err = reader.handlers.k8sImpersonate(ctx, http.MethodGet, claimPath, nil, subject)
if err != nil {
return BoundClaim{}, err
}
@@ -62,6 +97,7 @@ func (reader fleetAttributionFactsReader) ReadBoundClaim(ctx context.Context, na
var payload struct {
Metadata struct {
Name string `json:"name"`
+ UID string `json:"uid"`
} `json:"metadata"`
Status struct {
Phase string `json:"phase"`
@@ -73,7 +109,12 @@ func (reader fleetAttributionFactsReader) ReadBoundClaim(ctx context.Context, na
if err := json.NewDecoder(io.LimitReader(response.Body, 1<<20)).Decode(&payload); err != nil {
return BoundClaim{}, err
}
- return BoundClaim{Claim: payload.Metadata.Name, Sandbox: payload.Status.Sandbox.Name, Bound: payload.Status.Phase == "Bound"}, nil
+ return BoundClaim{
+ Claim: payload.Metadata.Name,
+ Sandbox: payload.Status.Sandbox.Name,
+ Bound: payload.Status.Phase == "Bound",
+ OwnerMatched: payload.Metadata.Name == ownerName && payload.Metadata.UID == ownerUID,
+ }, nil
}
func (reader fleetAttributionFactsReader) PoolExists(ctx context.Context, namespace, pool string) (bool, error) {
@@ -122,22 +163,25 @@ func QualifySvcRequestResult(ctx context.Context, r *http.Request, status int, r
if upgrade {
return QualificationResult{Reason: "upgrade_request"}
}
- claim := r.Header.Get(FleetClaimHeader)
- if len(r.Header.Values(FleetClaimHeader)) > 1 {
- return QualificationResult{Reason: "multiple_claims"}
- }
- if claim == "" {
- return QualificationResult{Reason: "missing_claim"}
+ if status < http.StatusOK || status >= http.StatusMultipleChoices {
+ return QualificationResult{Reason: "non_2xx"}
}
- if len(claim) > 128 || !validAttributionClaim(claim) {
- return QualificationResult{Reason: "invalid_claim"}
+ if isProbePath(r.PathValue("path")) {
+ return QualificationResult{Reason: "probe_request"}
}
ns, service := r.PathValue("namespace"), r.PathValue("service")
- bound, err := reader.ReadBoundClaim(ctx, ns, claim)
+ sandbox, ok := strings.CutSuffix(service, "-server")
+ if !ok || sandbox == "" {
+ return QualificationResult{Reason: "service_mismatch"}
+ }
+ bound, err := reader.ReadBoundClaimForSandbox(ctx, ns, sandbox)
if err != nil {
- return QualificationResult{Reason: "claim_lookup_failed"}
+ return QualificationResult{Reason: "binding_lookup_failed"}
+ }
+ if bound.Claim == "" {
+ return QualificationResult{Reason: "claim_missing"}
}
- if bound.Claim != claim {
+ if !bound.OwnerMatched {
return QualificationResult{Reason: "claim_mismatch"}
}
if !bound.Bound {
@@ -146,7 +190,7 @@ func QualifySvcRequestResult(ctx context.Context, r *http.Request, status int, r
if bound.Sandbox == "" {
return QualificationResult{Reason: "sandbox_missing"}
}
- if service != bound.Sandbox+"-server" {
+ if bound.Sandbox != sandbox || service != bound.Sandbox+"-server" {
return QualificationResult{Reason: "service_mismatch"}
}
pool, err := reader.PoolExists(ctx, ns, ns)
@@ -156,10 +200,7 @@ func QualifySvcRequestResult(ctx context.Context, r *http.Request, status int, r
if !pool {
return QualificationResult{Reason: "pool_missing"}
}
- if status < 200 || status >= 300 {
- return QualificationResult{Reason: "non_2xx"}
- }
- if !QualifiesFleetAttribution(AttributionFacts{AuthenticatedNamespace: true, SDKClaim: claim, Claim: bound, Service: service, Namespace: ns, Route: r.Pattern, Path: r.PathValue("path"), Method: r.Method, NamespacePoolExists: pool, UpstreamStatus: status, Upgrade: upgrade}) {
+ if !QualifiesFleetAttribution(AttributionFacts{AuthenticatedNamespace: true, Claim: bound, Service: service, Namespace: ns, Route: r.Pattern, Path: r.PathValue("path"), Method: r.Method, NamespacePoolExists: pool, UpstreamStatus: status, Upgrade: upgrade}) {
return QualificationResult{Reason: "probe_request"}
}
return QualificationResult{Qualifies: true}
@@ -179,25 +220,16 @@ func isUpgradeRequest(r *http.Request) bool {
return false
}
-func validAttributionClaim(value string) bool {
- for _, b := range []byte(value) {
- if !(b >= 'a' && b <= 'z' || b >= 'A' && b <= 'Z' || b >= '0' && b <= '9' || strings.ContainsRune("._~-", rune(b))) {
- return false
- }
- }
- return true
-}
-
-// BoundClaim is the exact claim correlation supplied by the SDK.
+// BoundClaim is the persisted sandbox-to-claim relationship derived by the backend.
type BoundClaim struct {
Claim, Sandbox string
Bound bool
+ OwnerMatched bool
}
// AttributionFacts contains already-proven facts; qualification performs no I/O.
type AttributionFacts struct {
AuthenticatedNamespace bool
- SDKClaim string
Claim BoundClaim
Service, Namespace, Route, Path, Method string
NamespacePoolExists bool
@@ -207,17 +239,24 @@ type AttributionFacts struct {
// QualifiesFleetAttribution is a pure Phase 1 predicate, not an activation claim.
func QualifiesFleetAttribution(f AttributionFacts) bool {
- if !f.AuthenticatedNamespace || f.SDKClaim == "" || !f.Claim.Bound || f.Claim.Claim == "" || f.Claim.Claim != f.SDKClaim || f.Claim.Sandbox == "" || f.Service != f.Claim.Sandbox+"-server" || !f.NamespacePoolExists || f.UpstreamStatus < 200 || f.UpstreamStatus >= 300 || f.Upgrade || f.Method == "HEAD" || f.Method == "OPTIONS" {
+ if !f.AuthenticatedNamespace || !f.Claim.Bound || !f.Claim.OwnerMatched || f.Claim.Claim == "" || f.Claim.Sandbox == "" || f.Service != f.Claim.Sandbox+"-server" || !f.NamespacePoolExists || f.UpstreamStatus < 200 || f.UpstreamStatus >= 300 || f.Upgrade || f.Method == "HEAD" || f.Method == "OPTIONS" {
return false
}
if f.Route == "/api/k8s" || f.Route == "/api/orch" || !strings.HasPrefix(f.Route, "/api/svc/") {
return false
}
+ if isProbePath(f.Path) {
+ return false
+ }
+ return true
+}
+
+func isProbePath(path string) bool {
probes := map[string]struct{}{"health": {}, "healthz": {}, "ready": {}, "readiness": {}, "readyz": {}, "live": {}, "liveness": {}, "livez": {}, "metrics": {}}
- for _, segment := range strings.Split(strings.ToLower(strings.Trim(f.Path, "/")), "/") {
+ for _, segment := range strings.Split(strings.ToLower(strings.Trim(path, "/")), "/") {
if _, excluded := probes[segment]; excluded {
- return false
+ return true
}
}
- return true
+ return false
}
diff --git a/libs/fleet/backend/handlers/attribution_test.go b/libs/fleet/backend/handlers/attribution_test.go
index ad28e25be8..651ae9e40f 100644
--- a/libs/fleet/backend/handlers/attribution_test.go
+++ b/libs/fleet/backend/handlers/attribution_test.go
@@ -16,7 +16,7 @@ type fakeAttributionFactsReader struct {
calls int
}
-func (f *fakeAttributionFactsReader) ReadBoundClaim(context.Context, string, string) (BoundClaim, error) {
+func (f *fakeAttributionFactsReader) ReadBoundClaimForSandbox(context.Context, string, string) (BoundClaim, error) {
f.calls++
return f.claim, nil
}
@@ -25,13 +25,15 @@ func (f *fakeAttributionFactsReader) PoolExists(context.Context, string, string)
return f.pool, nil
}
-func TestFleetAttributionFactsReaderUsesBoundClaimAndExactPool(t *testing.T) {
+func TestFleetAttributionFactsReaderDerivesClaimFromSandboxOwnerAndExactPool(t *testing.T) {
var paths []string
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
paths = append(paths, r.URL.Path)
switch r.URL.Path {
+ case "/apis/osgym.cua.ai/v1alpha1/namespaces/pool-1/osgymsandboxes/sandbox-1":
+ _, _ = w.Write([]byte(`{"metadata":{"ownerReferences":[{"apiVersion":"osgym.cua.ai/v1alpha1","kind":"OSGymSandboxClaim","name":"claim-1","uid":"claim-uid-1","controller":true}]}}`))
case "/apis/osgym.cua.ai/v1alpha1/namespaces/pool-1/osgymsandboxclaims/claim-1":
- _, _ = w.Write([]byte(`{"metadata":{"name":"claim-1"},"status":{"phase":"Bound","sandbox":{"name":"sandbox-1"}}}`))
+ _, _ = w.Write([]byte(`{"metadata":{"name":"claim-1","uid":"claim-uid-1"},"status":{"phase":"Bound","sandbox":{"name":"sandbox-1"}}}`))
case "/apis/cua.ai/v1/namespaces/pool-1/osgymworkspacepools/pool-1":
_, _ = w.Write([]byte(`{"metadata":{"name":"pool-1"}}`))
default:
@@ -50,21 +52,21 @@ func TestFleetAttributionFactsReaderUsesBoundClaimAndExactPool(t *testing.T) {
ctx := context.WithValue(context.Background(), auth.UserKey, &auth.User{ID: "user-1"})
reader := fleetAttributionFactsReader{handlers: Handlers{}}
- claim, err := reader.ReadBoundClaim(ctx, "pool-1", "claim-1")
- if err != nil || claim != (BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}) {
+ claim, err := reader.ReadBoundClaimForSandbox(ctx, "pool-1", "sandbox-1")
+ if err != nil || claim != (BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true, OwnerMatched: true}) {
t.Fatalf("claim = %#v, err = %v", claim, err)
}
exists, err := reader.PoolExists(ctx, "pool-1", "pool-1")
if err != nil || !exists {
t.Fatalf("pool exists = %v, err = %v", exists, err)
}
- if len(paths) != 2 || paths[1] != "/apis/cua.ai/v1/namespaces/pool-1/osgymworkspacepools/pool-1" {
+ if len(paths) != 3 || paths[0] != "/apis/osgym.cua.ai/v1alpha1/namespaces/pool-1/osgymsandboxes/sandbox-1" || paths[1] != "/apis/osgym.cua.ai/v1alpha1/namespaces/pool-1/osgymsandboxclaims/claim-1" || paths[2] != "/apis/cua.ai/v1/namespaces/pool-1/osgymworkspacepools/pool-1" {
t.Fatalf("lookup paths = %#v", paths)
}
}
func TestQualifiesFleetAttribution(t *testing.T) {
- base := AttributionFacts{AuthenticatedNamespace: true, SDKClaim: "claim-1", Claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}, Service: "sandbox-1-server", NamespacePoolExists: true, UpstreamStatus: 200, Method: "GET", Route: "/api/svc/ns/svc", Path: "/v1/tools"}
+ base := AttributionFacts{AuthenticatedNamespace: true, Claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true, OwnerMatched: true}, Service: "sandbox-1-server", NamespacePoolExists: true, UpstreamStatus: 200, Method: "GET", Route: "/api/svc/ns/svc", Path: "/v1/tools"}
cases := []struct {
name string
mutate func(*AttributionFacts)
@@ -72,8 +74,8 @@ func TestQualifiesFleetAttribution(t *testing.T) {
}{
{"all conjuncts", func(*AttributionFacts) {}, true},
{"auth missing", func(f *AttributionFacts) { f.AuthenticatedNamespace = false }, false},
- {"sdk claim missing", func(f *AttributionFacts) { f.SDKClaim = "" }, false},
- {"claim mismatch", func(f *AttributionFacts) { f.Claim.Claim = "other" }, false},
+ {"claim missing", func(f *AttributionFacts) { f.Claim.Claim = "" }, false},
+ {"owner mismatch", func(f *AttributionFacts) { f.Claim.OwnerMatched = false }, false},
{"not bound", func(f *AttributionFacts) { f.Claim.Bound = false }, false},
{"sandbox missing", func(f *AttributionFacts) { f.Claim.Sandbox = "" }, false},
{"service mismatch", func(f *AttributionFacts) { f.Service = "sandbox-1-mcp" }, false},
@@ -106,21 +108,19 @@ func TestQualifiesFleetAttribution(t *testing.T) {
}
}
-func TestQualifySvcRequestUsesOnlyValidatedExactClaimAndSvcRoutes(t *testing.T) {
- reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}, pool: true}
+func TestQualifySvcRequestDerivesExactBindingWithoutClientHeader(t *testing.T) {
+ reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true, OwnerMatched: true}, pool: true}
r := httptest.NewRequest("GET", "/api/svc/pool-1/sandbox-1-server/tools", nil)
r.Pattern = "/api/svc/{namespace}/{service}/{path...}"
r.SetPathValue("namespace", "pool-1")
r.SetPathValue("service", "sandbox-1-server")
r.SetPathValue("path", "tools")
- r.Header.Set(FleetClaimHeader, "claim-1")
if !QualifySvcRequest(r.Context(), r, 204, reader) {
- t.Fatal("expected exact claim to qualify")
+ t.Fatal("expected backend-derived binding to qualify")
}
for _, mutate := range []func(*http.Request){
- func(r *http.Request) { r.Header.Set(FleetClaimHeader, "bad claim") },
- func(r *http.Request) { r.Header.Add(FleetClaimHeader, "claim-2") },
+ func(r *http.Request) { r.SetPathValue("service", "sandbox-1-mcp") },
func(r *http.Request) { r.Pattern = "/api/k8s/{path...}" },
} {
before := reader.calls
@@ -140,33 +140,44 @@ func TestQualifySvcRequestUsesOnlyValidatedExactClaimAndSvcRoutes(t *testing.T)
}
func TestQualifySvcRequestResultReportsBoundedReasons(t *testing.T) {
- reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}, pool: true}
+ reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true, OwnerMatched: true}, pool: true}
r := httptest.NewRequest("GET", "/api/svc/pool-1/sandbox-1-server/health", nil)
r.Pattern = "/api/svc/{namespace}/{service}/{path...}"
r.SetPathValue("namespace", "pool-1")
r.SetPathValue("service", "sandbox-1-server")
r.SetPathValue("path", "health")
- r.Header.Set(FleetClaimHeader, "claim-1")
result := QualifySvcRequestResult(r.Context(), r, http.StatusOK, reader)
if result.Qualifies || result.Reason != "probe_request" {
t.Fatalf("result = %#v", result)
}
}
+func TestQualifySvcRequestRejectsBindingThatDoesNotMatchSandboxOwner(t *testing.T) {
+ reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}, pool: true}
+ r := httptest.NewRequest(http.MethodPost, "/api/svc/pool-1/sandbox-1-server/tools", nil)
+ r.Pattern = "/api/svc/{namespace}/{service}/{path...}"
+ r.SetPathValue("namespace", "pool-1")
+ r.SetPathValue("service", "sandbox-1-server")
+ r.SetPathValue("path", "tools")
+ result := QualifySvcRequestResult(r.Context(), r, http.StatusOK, reader)
+ if result.Qualifies || result.Reason != "claim_mismatch" {
+ t.Fatalf("result = %#v", result)
+ }
+}
+
func TestQualifySvcRequestRejectsUpgradeSignalsBeforeReadingFacts(t *testing.T) {
for _, headers := range []http.Header{
{"Upgrade": {"websocket"}},
{"Connection": {"keep-alive, Upgrade"}},
{"Connection": {"UPGRADE"}},
} {
- reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true}, pool: true}
+ reader := &fakeAttributionFactsReader{claim: BoundClaim{Claim: "claim-1", Sandbox: "sandbox-1", Bound: true, OwnerMatched: true}, pool: true}
r := httptest.NewRequest("GET", "/api/svc/pool-1/sandbox-1-server/tools", nil)
r.Pattern = "/api/svc/{namespace}/{service}/{path...}"
r.SetPathValue("namespace", "pool-1")
r.SetPathValue("service", "sandbox-1-server")
r.SetPathValue("path", "tools")
r.Header = headers
- r.Header.Set(FleetClaimHeader, "claim-1")
if QualifySvcRequest(r.Context(), r, 200, reader) {
t.Fatal("upgrade request qualified")
}
diff --git a/libs/fleet/backend/productanalytics/events.go b/libs/fleet/backend/productanalytics/events.go
index 3a0d96a90d..375dc6e065 100644
--- a/libs/fleet/backend/productanalytics/events.go
+++ b/libs/fleet/backend/productanalytics/events.go
@@ -82,8 +82,8 @@ var allowedProperties = map[string]struct{}{
var allowedResourceTypes = map[string]struct{}{"pool": {}, "template": {}, "claim": {}}
var allowedReasons = map[string]struct{}{
"payment_required": {}, "authorization": {}, "validation": {}, "quota": {}, "timeout": {}, "internal": {},
- "not_svc_route": {}, "invalid_method": {}, "upgrade_request": {}, "missing_claim": {}, "multiple_claims": {},
- "invalid_claim": {}, "claim_lookup_failed": {}, "claim_mismatch": {}, "claim_not_bound": {}, "sandbox_missing": {},
+ "not_svc_route": {}, "invalid_method": {}, "upgrade_request": {}, "binding_lookup_failed": {}, "claim_missing": {},
+ "claim_mismatch": {}, "claim_not_bound": {}, "sandbox_missing": {},
"service_mismatch": {}, "pool_lookup_failed": {}, "pool_missing": {}, "non_2xx": {}, "probe_request": {}, "facts_unavailable": {},
}
diff --git a/libs/fleet/docs/fleet-attribution-phase1.md b/libs/fleet/docs/fleet-attribution-phase1.md
index 6656012632..3ec11ffdb3 100644
--- a/libs/fleet/docs/fleet-attribution-phase1.md
+++ b/libs/fleet/docs/fleet-attribution-phase1.md
@@ -12,6 +12,6 @@ The five stable fields are acquisition-channel neutral. They can represent email
After Keycloak authentication, the SPA submits the validated record to the authenticated `/api/analytics/attribution` endpoint. The backend repeats the version, size, age, key, and value checks and accepts only the Fleet SPA principal. Stable authenticated identities emit `fleet_attribution_bound` unless verified `@trycua.com` evidence classifies them as internal. Missing or unverified email evidence is treated as external for growth measurement; unauthenticated identities or identities without a stable user ID remain unknown. PostHog receives the five fields only as set-once first-touch person properties under the keyed-HMAC pseudonym. The endpoint never accepts a URL, referrer, email, raw identity, arbitrary property, or provider payload, and attribution delivery cannot affect authentication or application readiness.
-`QualifiesFleetAttribution` is a deterministic, side-effect-free predicate over explicit facts. Qualification requires authenticated namespace authorization, an exact SDK-provided claim matching a Bound claim with a sandbox identity, service exactly `<sandbox>-server`, an exact namespace pool, and a 2xx upstream response. Probe paths, redirects, upgrades, HEAD/OPTIONS, non-service routes, and Kubernetes/orchestration routes are excluded.
+`QualifiesFleetAttribution` is a deterministic, side-effect-free predicate over explicit facts. Qualification requires authenticated namespace authorization, a persisted Bound claim whose sandbox identity matches the requested service, service exactly `<sandbox>-server`, an exact namespace pool, and a 2xx upstream response. Probe paths, redirects, upgrades, HEAD/OPTIONS, non-service routes, and Kubernetes/orchestration routes are excluded.
-The SDK supplies correlation using the exact claim already present on `Sandbox` in the `X-Cua-Fleet-Claim` request header. No claim lookup, user identity, cohort, recipient, or timestamp inference is performed. `qualifies` is a qualification verdict only; it is not an activation claim or emission.
+The backend derives the claim from Kubernetes state: the requested service identifies the sandbox, the sandbox's controller owner reference identifies the claim, and the persisted claim must point back to that sandbox. No SDK header or client-side claim inference is required. `qualifies` is a qualification verdict only; it is not an activation claim or emission.
diff --git a/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt b/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt
index a7878a8bb2..46ee2cb467 100644
--- a/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt
+++ b/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt
@@ -24,7 +24,7 @@ private class ScriptedHttpClient : HttpClient {
Expected("POST", "https://cyclops.invalid/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxclaims", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), "{\"apiVersion\":\"osgym.cua.ai/v1alpha1\",\"kind\":\"OSGymSandboxClaim\",\"metadata\":{\"namespace\":\"default\",\"name\":\"claim-1\",\"labels\":null},\"spec\":{\"sandboxTemplateRef\":{\"name\":\"default\"},\"bindDeadline\":900},\"status\":null}".encodeToByteArray(), 201u, "{\"apiVersion\":\"osgym.cua.ai/v1alpha1\",\"kind\":\"OSGymSandboxClaim\",\"metadata\":{\"namespace\":\"default\",\"name\":\"default\",\"labels\":null},\"spec\":{\"sandboxTemplateRef\":{\"name\":\"default\"}},\"status\":{\"phase\":\"Bound\",\"sandbox\":{\"name\":\"offline-sandbox\"}}}"),
Expected("GET", "https://cyclops.invalid/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxclaims/default", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), null, 200u, "{\"apiVersion\":\"osgym.cua.ai/v1alpha1\",\"kind\":\"OSGymSandboxClaim\",\"metadata\":{\"namespace\":\"default\",\"name\":\"default\",\"labels\":null},\"spec\":{\"sandboxTemplateRef\":{\"name\":\"default\"}},\"status\":{\"phase\":\"Bound\",\"sandbox\":{\"name\":\"offline-sandbox\"}}}"),
Expected("GET", "https://cyclops.invalid/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxtemplates/default", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), null, 200u, "{\"apiVersion\":\"osgym.cua.ai/v1alpha1\",\"kind\":\"OSGymSandboxTemplate\",\"metadata\":{\"namespace\":\"default\",\"name\":\"default\",\"labels\":null},\"spec\":{\"vmTemplate\":{\"containerDiskImage\":\"registry.example/desktop:offline\",\"services\":[{\"name\":\"mcp\",\"targetPort\":8080}]}}}"),
- Expected("POST", "https://cyclops.invalid/api/svc/default/offline-sandbox-mcp/mcp", listOf("X-Cua-Fleet-Claim" to "default", "authorization" to "Bearer offline-token"), "{\"offline\":true}".encodeToByteArray(), 202u, "offline service accepted"),
+ Expected("POST", "https://cyclops.invalid/api/svc/default/offline-sandbox-mcp/mcp", listOf("authorization" to "Bearer offline-token"), "{\"offline\":true}".encodeToByteArray(), 202u, "offline service accepted"),
Expected("DELETE", "https://cyclops.invalid/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxclaims/default", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), null, 204u, ""),
Expected("DELETE", "https://cyclops.invalid/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxwarmpools/default", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), null, 204u, ""),
Expected("DELETE", "https://cyclops.invalid/api/namespaces/default", listOf("accept" to "application/json", "content-type" to "application/json", "authorization" to "Bearer offline-token"), null, 204u, "")
diff --git a/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb b/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
index d496fbe2ad..766e8447eb 100644
--- a/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
+++ b/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
@@ -21,7 +21,7 @@ def template_json; { apiVersion:'osgym.cua.ai/v1alpha1',kind:'OSGymSandboxTempla
def claim_json(bound=false); value={apiVersion:'osgym.cua.ai/v1alpha1',kind:'OSGymSandboxClaim',metadata:{namespace:'default',name:'default',labels:nil},spec:{sandboxTemplateRef:{name:'default'}},status:nil}; value[:status]={phase:'Bound',sandbox:{name:'offline-sandbox'}} if bound; value; end
def queue
pool_url="#{BASE}/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxwarmpools/default"; template_url="#{BASE}/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxtemplates/default"; claim_url="#{BASE}/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/default/osgymsandboxclaims/default"; pool_body=JSON.generate(pool_json).b; claim_body='{"apiVersion":"osgym.cua.ai/v1alpha1","kind":"OSGymSandboxClaim","metadata":{"namespace":"default","name":"claim-1","labels":null},"spec":{"sandboxTemplateRef":{"name":"default"},"bindDeadline":900},"status":null}'.b
- [Expected.new('POST',TOKEN,[['accept','application/json'],['content-type','application/x-www-form-urlencoded'],['authorization','Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=']], 'grant_type=client_credentials'.b,200,{access_token:'offline-token',expires_in:3600}),Expected.new('POST',"#{BASE}/api/namespaces",JSON_HEADERS,'{"name":"default"}'.b,201,{}),Expected.new('POST',pool_url.sub(%r{/default\z}, ''),JSON_HEADERS,pool_body,201,pool_json),Expected.new('POST',claim_url.sub(%r{/default\z}, ''),JSON_HEADERS,claim_body,201,claim_json),Expected.new('GET',claim_url,JSON_HEADERS,nil,200,claim_json(true)),Expected.new('GET',template_url,JSON_HEADERS,nil,200,template_json),Expected.new('POST',"#{BASE}/api/svc/default/offline-sandbox-mcp/mcp",[['X-Cua-Fleet-Claim','default'],['authorization','Bearer offline-token']],'{"offline":true}'.b,202,'offline service accepted'),Expected.new('DELETE',claim_url,JSON_HEADERS,nil,204,''),Expected.new('DELETE',pool_url,JSON_HEADERS,nil,204,''),Expected.new('DELETE',"#{BASE}/api/namespaces/default",JSON_HEADERS,nil,204,'')]
+ [Expected.new('POST',TOKEN,[['accept','application/json'],['content-type','application/x-www-form-urlencoded'],['authorization','Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=']], 'grant_type=client_credentials'.b,200,{access_token:'offline-token',expires_in:3600}),Expected.new('POST',"#{BASE}/api/namespaces",JSON_HEADERS,'{"name":"default"}'.b,201,{}),Expected.new('POST',pool_url.sub(%r{/default\z}, ''),JSON_HEADERS,pool_body,201,pool_json),Expected.new('POST',claim_url.sub(%r{/default\z}, ''),JSON_HEADERS,claim_body,201,claim_json),Expected.new('GET',claim_url,JSON_HEADERS,nil,200,claim_json(true)),Expected.new('GET',template_url,JSON_HEADERS,nil,200,template_json),Expected.new('POST',"#{BASE}/api/svc/default/offline-sandbox-mcp/mcp",[['authorization','Bearer offline-token']],'{"offline":true}'.b,202,'offline service accepted'),Expected.new('DELETE',claim_url,JSON_HEADERS,nil,204,''),Expected.new('DELETE',pool_url,JSON_HEADERS,nil,204,''),Expected.new('DELETE',"#{BASE}/api/namespaces/default",JSON_HEADERS,nil,204,'')]
end
class ScriptedHttpClient < FleetSdk::HttpClient
diff --git a/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt b/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt
index 1628e41118..8d73711b31 100644
--- a/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt
+++ b/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt
@@ -52,7 +52,7 @@ private fun tokenExpected() = textExpected(
private fun serviceExpected(body: ByteArray?, response: ByteArray) = Expected(
"POST",
"https://cyclops.invalid/api/svc/default/offline-sandbox-mcp/mcp",
- listOf("X-Cua-Fleet-Claim" to "default", "authorization" to "Bearer offline-token"),
+ listOf("authorization" to "Bearer offline-token"),
body,
202u,
response,
diff --git a/libs/fleet/sdk-bindings/python/contract_fixture.py b/libs/fleet/sdk-bindings/python/contract_fixture.py
index 7562ab7c72..e112ed1240 100644
--- a/libs/fleet/sdk-bindings/python/contract_fixture.py
+++ b/libs/fleet/sdk-bindings/python/contract_fixture.py
@@ -10,7 +10,7 @@ from fleet_sdk import (ClaimSpec, CreateClaimRequest, CreatePoolRequest, Cyclops
BASE = 'https://cyclops.invalid'
TOKEN = 'https://keycloak.invalid/realms/offline/protocol/openid-connect/token'
JSON_HEADERS = [('accept', 'application/json'), ('content-type', 'application/json'), ('authorization', 'Bearer offline-token')]
-SERVICE_HEADERS = [('X-Cua-Fleet-Claim', 'default'), ('authorization', 'Bearer offline-token')]
+SERVICE_HEADERS = [('authorization', 'Bearer offline-token')]
SERVICE_URL = f'{BASE}/api/svc/default/offline-sandbox-mcp/mcp'
@dataclass(frozen=True)
diff --git a/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb b/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
index 7eee3680e2..8c9a8becc8 100644
--- a/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
+++ b/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
@@ -36,7 +36,7 @@ def token_expected
end
def service_expected(body, response)
- Expected.new('POST', "#{BASE}/api/svc/default/offline-sandbox-mcp/mcp", [['X-Cua-Fleet-Claim', 'default'], ['authorization', 'Bearer offline-token']], body, 202, response)
+ Expected.new('POST', "#{BASE}/api/svc/default/offline-sandbox-mcp/mcp", [['authorization', 'Bearer offline-token']], body, 202, response)
end
def lifecycle_queue
diff --git a/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift b/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift
index f3ae63b1ef..dd536c0f2d 100644
--- a/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift
+++ b/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift
@@ -34,7 +34,7 @@ private func serviceExpected(body: Data?, response: Data) -> Expected {
Expected(
method: "POST",
url: "https://cyclops.invalid/api/svc/default/offline-sandbox-mcp/mcp",
- headers: [HttpHeader(name: "X-Cua-Fleet-Claim", value: "default"), HttpHeader(name: "authorization", value: "Bearer offline-token")],
+ headers: [HttpHeader(name: "authorization", value: "Bearer offline-token")],
body: body,
status: 202,
response: response
diff --git a/libs/fleet/sdk/src/services.rs b/libs/fleet/sdk/src/services.rs
index c3d0f533f7..596578eb45 100644
--- a/libs/fleet/sdk/src/services.rs
+++ b/libs/fleet/sdk/src/services.rs
@@ -27,7 +27,7 @@ impl CyclopsClient {
let request = HttpRequest {
method: request.method,
url: url.to_string(),
- headers: fleet_headers(filtered_headers(request.headers), &sandbox.claim),
+ headers: filtered_headers(request.headers),
body: request.body,
timeout_secs: request.timeout_secs,
};
@@ -35,22 +35,6 @@ impl CyclopsClient {
}
}
-fn fleet_headers(mut headers: Vec<HttpHeader>, claim: &str) -> Vec<HttpHeader> {
- // Correlation is the exact claim returned in Sandbox; it is never inferred.
- if !claim.is_empty()
- && claim.len() <= 128
- && claim
- .bytes()
- .all(|b| b.is_ascii_alphanumeric() || b"._~-".contains(&b))
- {
- headers.push(HttpHeader {
- name: "X-Cua-Fleet-Claim".into(),
- value: claim.into(),
- });
- }
- headers
-}
-
fn filtered_headers(headers: Vec<HttpHeader>) -> Vec<HttpHeader> {
let mut blocked: HashSet<String> = [
"connection",
diff --git a/libs/fleet/sdk/tests/service_flow.rs b/libs/fleet/sdk/tests/service_flow.rs
index 47a2d1bfa7..5362700cc6 100644
--- a/libs/fleet/sdk/tests/service_flow.rs
+++ b/libs/fleet/sdk/tests/service_flow.rs
@@ -36,12 +36,6 @@ async fn routes_known_service_under_base_prefix_and_forwards_query() {
"https://cyclops.example:8443/control/api/svc/pool-test/sandbox-1-mcp/tools?cursor=next"
);
assert_eq!(requests[1].method, "PATCH");
- assert!(
- requests[1]
- .headers
- .iter()
- .any(|h| h.name == "X-Cua-Fleet-Claim" && h.value == "claim-1")
- );
}
#[tokio::test]
@@ -209,7 +203,6 @@ async fn filters_hop_by_hop_and_connection_nominated_headers_without_reordering_
header("X-Keep", "first"),
header("x-keep", "second"),
header("Cookie", "session=kept"),
- header("X-Cua-Fleet-Claim", "claim-1"),
header("authorization", "Bearer service-token"),
]
);