execution-plane-client 0.1.21__tar.gz → 0.1.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/PKG-INFO +1 -1
  2. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/_version.py +2 -2
  3. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/catalog.py +2 -2
  4. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/clusters.py +68 -10
  5. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/control.py +21 -3
  6. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/credentials.py +3 -3
  7. execution_plane_client-0.1.23/commands/results.py +102 -0
  8. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/targets.py +101 -16
  9. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/work.py +12 -3
  10. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/execution_target.py +90 -32
  11. execution_plane_client-0.1.23/types.py +22 -0
  12. execution_plane_client-0.1.21/commands/results.py +0 -78
  13. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/.gitignore +0 -0
  14. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/LICENSE +0 -0
  15. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/README.md +0 -0
  16. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/__init__.py +0 -0
  17. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/__init__.py +0 -0
  18. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/commands/base.py +0 -0
  19. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/errors.py +0 -0
  20. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/handlers.py +0 -0
  21. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/__init__.py +0 -0
  22. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/cluster.py +0 -0
  23. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/runtime_context.py +0 -0
  24. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/shared.py +0 -0
  25. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/models/work_item.py +0 -0
  26. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/protocol.py +0 -0
  27. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/py.typed +0 -0
  28. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/pyproject.toml +0 -0
  29. {execution_plane_client-0.1.21 → execution_plane_client-0.1.23}/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: execution-plane-client
3
- Version: 0.1.21
3
+ Version: 0.1.23
4
4
  Summary: Shared execution-plane command, response, and handler contracts
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.1.21'
22
- __version_tuple__ = version_tuple = (0, 1, 21)
21
+ __version__ = version = '0.1.23'
22
+ __version_tuple__ = version_tuple = (0, 1, 23)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -5,7 +5,7 @@ from dataclasses import dataclass
5
5
  from execution_plane_client.commands.base import CommandPayload
6
6
  from execution_plane_client.commands.clusters import ClusterDelete, ClusterRegister, ClusterUpdate
7
7
  from execution_plane_client.commands.control import Completion, WorkCancel
8
- from execution_plane_client.commands.credentials import CredentialResolve, CredentialResolveWorkload
8
+ from execution_plane_client.commands.credentials import CredentialResolveCluster, CredentialResolveWorkload
9
9
  from execution_plane_client.commands.targets import TargetDelete, TargetHealth, TargetRegister, TargetUpdate
10
10
  from execution_plane_client.commands.work import WorkDelete, WorkExecute
11
11
  from execution_plane_client.errors import UnsupportedCommand
@@ -30,7 +30,7 @@ class CommandCatalog:
30
30
  WorkExecute,
31
31
  WorkDelete,
32
32
  Completion,
33
- CredentialResolve,
33
+ CredentialResolveCluster,
34
34
  CredentialResolveWorkload,
35
35
  ClusterRegister,
36
36
  ClusterUpdate,
@@ -21,12 +21,40 @@ class ClusterConfigBase(WireModel):
21
21
  """Registration configuration fields used by handlers to copy and compare clusters."""
22
22
 
23
23
  name: Annotated[StrictStr, Field(min_length=1, max_length=255)]
24
- endpoint: Annotated[StrictStr, Field(max_length=2048)]
25
- credential_ref: UUID
26
- ca_certificate: Annotated[StrictStr, Field(max_length=65536)] | None = Field(default=None, repr=False)
24
+ endpoint: Annotated[StrictStr, Field(max_length=2048)] = Field(
25
+ description=(
26
+ "Kubernetes API HTTPS URL used for namespace probes and workload management; embedded "
27
+ "credentials, query strings, and fragments are prohibited."
28
+ )
29
+ )
30
+ credential_ref: UUID = Field(
31
+ description=(
32
+ "Reference resolved through the initiating client for the cluster management "
33
+ "credential; must be nonzero when registering an enabled cluster."
34
+ )
35
+ )
36
+ ca_certificate: Annotated[StrictStr, Field(max_length=65536)] | None = Field(
37
+ default=None,
38
+ repr=False,
39
+ description=(
40
+ "PEM CA certificate bundle used to verify the cluster API TLS certificate. Omit on "
41
+ "registration to use the default trust store."
42
+ ),
43
+ )
27
44
  labels: dict[str, str] = Field(default_factory=dict)
28
- enabled: StrictBool = True
29
- is_default: StrictBool = False
45
+ enabled: StrictBool = Field(
46
+ default=True,
47
+ description=(
48
+ "Whether the cluster can supply targets for new work. A disabled cluster is excluded from placement."
49
+ ),
50
+ )
51
+ is_default: StrictBool = Field(
52
+ default=False,
53
+ description=(
54
+ "Promote this cluster to the default used for fallback placement. An existing default "
55
+ "cannot be demoted or disabled directly; promote another cluster first."
56
+ ),
57
+ )
30
58
 
31
59
 
32
60
  class ClusterRegister(ClusterConfigBase, ResourceIdentity, CommandPayload):
@@ -73,12 +101,42 @@ class ClusterUpdate(ResourceIdentity, CommandPayload):
73
101
  command_type: ClassVar[str] = "cluster.update"
74
102
 
75
103
  name: StrictStr | None = None
76
- endpoint: StrictStr | None = None
77
- credential_ref: UUID | None = None
78
- ca_certificate: StrictStr | None = Field(default=None, repr=False)
104
+ endpoint: StrictStr | None = Field(
105
+ default=None,
106
+ description=(
107
+ "Kubernetes API HTTPS URL used for namespace probes and workload management; embedded "
108
+ "credentials, query strings, and fragments are prohibited."
109
+ ),
110
+ )
111
+ credential_ref: UUID | None = Field(
112
+ default=None,
113
+ description=(
114
+ "Reference resolved through the initiating client for the cluster management "
115
+ "credential; must be nonzero when registering an enabled cluster."
116
+ ),
117
+ )
118
+ ca_certificate: StrictStr | None = Field(
119
+ default=None,
120
+ repr=False,
121
+ description=(
122
+ "Replacement PEM CA certificate bundle for cluster API TLS verification. Omission or "
123
+ "null currently leaves the stored certificate unchanged."
124
+ ),
125
+ )
79
126
  labels: dict[str, str] | None = None
80
- enabled: StrictBool | None = None
81
- is_default: StrictBool | None = None
127
+ enabled: StrictBool | None = Field(
128
+ default=None,
129
+ description=(
130
+ "Whether the cluster can supply targets for new work. A disabled cluster is excluded from placement."
131
+ ),
132
+ )
133
+ is_default: StrictBool | None = Field(
134
+ default=None,
135
+ description=(
136
+ "Promote this cluster to the default used for fallback placement. An existing default "
137
+ "cannot be demoted or disabled directly; promote another cluster first."
138
+ ),
139
+ )
82
140
 
83
141
  def _message_payload(self) -> dict[str, object]:
84
142
  return self.model_dump(mode="json", exclude_unset=True)
@@ -45,9 +45,27 @@ class Completion(CommandPayload):
45
45
  )
46
46
  runtime_context: RuntimeContext = Field(default_factory=dict, repr=False)
47
47
 
48
- status: CompletionStatus
49
- result: dict[str, object] = Field(default_factory=dict, repr=False)
50
- error_code: str | None = None
48
+ status: CompletionStatus = Field(
49
+ description=(
50
+ "Reported work outcome. reconciliation_required means the outcome is uncertain and "
51
+ "must not be treated as a confirmed terminal result."
52
+ )
53
+ )
54
+ result: dict[str, object] = Field(
55
+ default_factory=dict,
56
+ repr=False,
57
+ description=(
58
+ "Persisted workload output or failure details sent back to the initiating client; its "
59
+ "contents depend on the invoked step and output mapping."
60
+ ),
61
+ )
62
+ error_code: str | None = Field(
63
+ default=None,
64
+ description=(
65
+ "Optional machine-readable failure classification. The current EP completion notifier "
66
+ "leaves this null; failure details are carried in result."
67
+ ),
68
+ )
51
69
 
52
70
  @field_validator("result", mode="before")
53
71
  @classmethod
@@ -12,10 +12,10 @@ from execution_plane_client.commands.work import CredentialRecipeId, StepIdentit
12
12
  from execution_plane_client.protocol import Identifier # noqa: TC001
13
13
 
14
14
 
15
- class CredentialResolve(CommandPayload):
16
- """Resolve an opaque credential reference into a short-lived value."""
15
+ class CredentialResolveCluster(CommandPayload):
16
+ """Resolve an opaque cluster credential reference into its credential document."""
17
17
 
18
- command_type: ClassVar[str] = "credential.resolve"
18
+ command_type: ClassVar[str] = "credential.resolve.cluster"
19
19
  credential_ref: UUID = Field(
20
20
  repr=False,
21
21
  description="Opaque AO credential reference.",
@@ -0,0 +1,102 @@
1
+ """Typed command results and transport receipts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Annotated, Literal
7
+ from uuid import UUID # noqa: TC003 - Pydantic resolves this model field at runtime.
8
+
9
+ from pydantic import Field, StrictBool, StrictStr, field_validator
10
+
11
+ from execution_plane_client.protocol import ResourceReference, WireModel
12
+
13
+ MAX_CREDENTIAL_FIELDS = 32
14
+ MAX_CREDENTIAL_BYTES = 32 * 1024
15
+
16
+
17
+ def validate_credential_document(value: dict[str, str]) -> dict[str, str]:
18
+ """Bound credential field count and encoded response size."""
19
+ if not value:
20
+ message = "Credential document must not be empty"
21
+ raise ValueError(message)
22
+ if len(value) > MAX_CREDENTIAL_FIELDS:
23
+ message = "Credential document must contain at most 32 fields"
24
+ raise ValueError(message)
25
+ encoded = json.dumps(value, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
26
+ if len(encoded) > MAX_CREDENTIAL_BYTES:
27
+ message = "Credential document exceeds 32 KiB"
28
+ raise ValueError(message)
29
+ return value
30
+
31
+
32
+ class CredentialResolveClusterCommandResult(WireModel):
33
+ """Typed result returned for a cluster credential-resolution command."""
34
+
35
+ command_type: Literal["credential.resolve.cluster"] = "credential.resolve.cluster"
36
+ command_revision: Literal[1] = 1
37
+ credential: dict[
38
+ Annotated[StrictStr, Field(min_length=1, max_length=128)],
39
+ Annotated[StrictStr, Field(min_length=1, max_length=8192)],
40
+ ] = Field(repr=False)
41
+
42
+ check_document = field_validator("credential")(validate_credential_document)
43
+
44
+
45
+ class CredentialResolveWorkloadCommandResult(WireModel):
46
+ """Typed result returned for a workload credential-resolution command."""
47
+
48
+ command_type: Literal["credential.resolve.workload"] = "credential.resolve.workload"
49
+ command_revision: Literal[1] = Field(
50
+ default=1, description="Payload contract version for credential.resolve.workload; matches the request revision."
51
+ )
52
+ credential: dict[
53
+ Annotated[StrictStr, Field(min_length=1, max_length=128)],
54
+ Annotated[StrictStr, Field(min_length=1, max_length=8192)],
55
+ ] = Field(repr=False)
56
+
57
+ check_document = field_validator("credential")(validate_credential_document)
58
+
59
+
60
+ class TargetHealthCommandResult(WireModel):
61
+ """Typed result returned for an execution-target health command."""
62
+
63
+ command_type: Literal["execution_target.health"] = "execution_target.health"
64
+ command_revision: Literal[1] = 1
65
+ healthy: StrictBool = Field(
66
+ description=(
67
+ "Whether the namespace probe succeeded. For Kubernetes this checks namespace "
68
+ "readability, not workload execution. Check skipped first: a skipped probe also "
69
+ "returns true."
70
+ )
71
+ )
72
+ message: StrictStr | None = None
73
+ skipped: StrictBool = Field(
74
+ default=False,
75
+ description=(
76
+ "True when no health check ran because the backend, endpoint, or cluster/target "
77
+ "lifecycle is outside probe scope; healthy then does not establish readiness."
78
+ ),
79
+ )
80
+
81
+
82
+ CommandResult = Annotated[
83
+ CredentialResolveClusterCommandResult | CredentialResolveWorkloadCommandResult | TargetHealthCommandResult,
84
+ Field(discriminator="command_type"),
85
+ ]
86
+
87
+
88
+ class TransportReceipt(WireModel):
89
+ """Receipt of a handled request, without a persisted command record."""
90
+
91
+ received: Literal[True] = Field(
92
+ default=True,
93
+ description=(
94
+ "Confirms the command handler returned successfully. Asynchronous work, cancellation, "
95
+ "and deletion may still be in progress."
96
+ ),
97
+ )
98
+ message_id: UUID = Field(
99
+ description="The received delivery message's UUID, echoed so the sender can match this receipt."
100
+ )
101
+ resource: ResourceReference | None = None
102
+ result: CommandResult | None = None
@@ -11,6 +11,7 @@ from pydantic import Field, StrictBool, StrictStr, field_validator, model_valida
11
11
  from execution_plane_client.commands import ResourceIdentity, validate_endpoint
12
12
  from execution_plane_client.commands.base import CommandPayload
13
13
  from execution_plane_client.protocol import WireModel
14
+ from execution_plane_client.types import BackendType
14
15
 
15
16
  _LABEL_NAME = re.compile(r"^[A-Za-z0-9]([A-Za-z0-9_.-]*[A-Za-z0-9])?$")
16
17
  _DNS_LABEL = re.compile(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
@@ -40,9 +41,26 @@ class KubernetesPlacement(WireModel):
40
41
  """Kubernetes placement contract, independent of Kubernetes libraries."""
41
42
 
42
43
  type: Literal["kubernetes"] = "kubernetes"
43
- namespace: Annotated[StrictStr, Field(min_length=1, max_length=63, pattern=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")]
44
- node_selectors: list[str] = Field(default_factory=list)
45
- tolerations: list[str] = Field(default_factory=list)
44
+ namespace: Annotated[StrictStr, Field(min_length=1, max_length=63, pattern=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")] = (
45
+ Field(description="Existing Kubernetes namespace in which EP creates workload pods and checks target health.")
46
+ )
47
+ node_selectors: list[str] = Field(
48
+ default_factory=list,
49
+ description=(
50
+ "Pod nodeSelector entries in key=value form. Nodes must match every entry; an empty "
51
+ "list imposes no label restriction. On update, omission preserves the stored list and "
52
+ "[] clears it."
53
+ ),
54
+ )
55
+ tolerations: list[str] = Field(
56
+ default_factory=list,
57
+ description=(
58
+ "Pod taints to tolerate, using key=value:effect (Equal) or key:effect (Exists). Effect "
59
+ "may be NoSchedule, PreferNoSchedule, or NoExecute; omitting it matches all effects. "
60
+ "An empty key with Exists matches all keys. On update, omission preserves the list and "
61
+ "[] clears it."
62
+ ),
63
+ )
46
64
 
47
65
  @field_validator("node_selectors")
48
66
  @classmethod
@@ -88,11 +106,33 @@ class TargetDefinition(WireModel):
88
106
  """Desired execution-target configuration."""
89
107
 
90
108
  name: Annotated[StrictStr, Field(min_length=1, max_length=255)]
91
- backend_type: Literal["kubernetes", "openshell"]
92
- placement: Placement
93
- endpoint: Annotated[StrictStr, Field(min_length=1, max_length=2048)]
94
- credential_ref: UUID
95
- labels: dict[str, str] = Field(default_factory=dict)
109
+ backend_type: BackendType
110
+ placement: Placement = Field(
111
+ description=(
112
+ "Namespace and pod scheduling rules for this target. Updates require namespace; "
113
+ "omitted scheduling lists retain their stored values. The placement type cannot be "
114
+ "changed."
115
+ )
116
+ )
117
+ endpoint: Annotated[StrictStr, Field(min_length=1, max_length=2048)] = Field(
118
+ description=(
119
+ "HTTPS provider management endpoint, without embedded credentials, query, or fragment. "
120
+ "Kubernetes workloads use the parent cluster connection."
121
+ )
122
+ )
123
+ credential_ref: UUID = Field(
124
+ description=(
125
+ "Opaque management credential reference. Kubernetes execution resolves the parent "
126
+ "cluster credential instead; the AO facade supplies the zero UUID here."
127
+ )
128
+ )
129
+ labels: dict[str, str] = Field(
130
+ default_factory=dict,
131
+ description=(
132
+ "User labels matched by work.execute selectors when routing workloads. Updates replace "
133
+ "user labels; {} clears them. EP retains its reserved identity labels."
134
+ ),
135
+ )
96
136
 
97
137
  @field_validator("endpoint")
98
138
  @classmethod
@@ -103,7 +143,7 @@ class TargetDefinition(WireModel):
103
143
  @model_validator(mode="after")
104
144
  def check_backend(self) -> Self:
105
145
  """Reject backend/placement pairs unsupported by the provider adapters."""
106
- if (self.backend_type == "kubernetes") != isinstance(self.placement, KubernetesPlacement):
146
+ if (self.backend_type == BackendType.KUBERNETES) != isinstance(self.placement, KubernetesPlacement):
107
147
  message = "Backend does not support this placement"
108
148
  raise ValueError(message)
109
149
  return self
@@ -115,7 +155,14 @@ class TargetRegister(TargetDefinition, ResourceIdentity, CommandPayload):
115
155
  command_type: ClassVar[str] = "execution_target.register"
116
156
 
117
157
  cluster_id: UUID
118
- is_default: StrictBool = False
158
+ is_default: StrictBool = Field(
159
+ default=False,
160
+ description=(
161
+ "Promote this target to the cluster default, replacing the previous default. The "
162
+ "target and cluster must be active and enabled. To demote a default, promote another "
163
+ "target rather than setting this field to false."
164
+ ),
165
+ )
119
166
 
120
167
 
121
168
  class TargetDelete(ResourceIdentity, CommandPayload):
@@ -130,12 +177,50 @@ class TargetUpdate(ResourceIdentity, CommandPayload):
130
177
  command_type: ClassVar[str] = "execution_target.update"
131
178
 
132
179
  name: Annotated[StrictStr, Field(min_length=1, max_length=255)] | None = None
133
- endpoint: Annotated[StrictStr, Field(min_length=1, max_length=2048)] | None = None
134
- placement: Placement | None = None
135
- credential_ref: UUID | None = None
136
- labels: dict[str, str] | None = None
137
- is_default: StrictBool | None = None
138
- enabled: StrictBool | None = None
180
+ endpoint: Annotated[StrictStr, Field(min_length=1, max_length=2048)] | None = Field(
181
+ default=None,
182
+ description=(
183
+ "Replacement HTTPS provider management endpoint. Omit to keep the stored endpoint; "
184
+ "explicit null is rejected."
185
+ ),
186
+ )
187
+ placement: Placement | None = Field(
188
+ default=None,
189
+ description=(
190
+ "Namespace and pod scheduling rules for this target. Updates require namespace; "
191
+ "omitted scheduling lists retain their stored values. The placement type cannot be "
192
+ "changed."
193
+ ),
194
+ )
195
+ credential_ref: UUID | None = Field(
196
+ default=None,
197
+ description=(
198
+ "Replacement opaque provider management credential reference; Kubernetes continues to "
199
+ "use the parent cluster credential."
200
+ ),
201
+ )
202
+ labels: dict[str, str] | None = Field(
203
+ default=None,
204
+ description=(
205
+ "User labels matched by work.execute selectors when routing workloads. Updates replace "
206
+ "user labels; {} clears them. EP retains its reserved identity labels."
207
+ ),
208
+ )
209
+ is_default: StrictBool | None = Field(
210
+ default=None,
211
+ description=(
212
+ "Promote this target to the cluster default, replacing the previous default. The "
213
+ "target and cluster must be active and enabled. To demote a default, promote another "
214
+ "target rather than setting this field to false."
215
+ ),
216
+ )
217
+ enabled: StrictBool | None = Field(
218
+ default=None,
219
+ description=(
220
+ "Whether the scheduler may assign new workloads to this target; disabling it does not "
221
+ "request cancellation of work already assigned."
222
+ ),
223
+ )
139
224
 
140
225
  def _message_payload(self) -> dict[str, object]:
141
226
  payload = self.model_dump(mode="json", exclude_unset=True)
@@ -1,6 +1,7 @@
1
1
  """Scheduling commands for the SDK-owned container gRPC contract."""
2
2
 
3
- from typing import Annotated, ClassVar, Literal
3
+ from enum import StrEnum
4
+ from typing import Annotated, ClassVar
4
5
  from uuid import UUID
5
6
 
6
7
  from pydantic import Field, StrictStr, field_validator
@@ -10,6 +11,14 @@ from execution_plane_client.models.runtime_context import RuntimeContext
10
11
  from execution_plane_client.protocol import PositiveInt, WireModel, validate_json
11
12
 
12
13
  StepIdentity = Annotated[StrictStr, Field(min_length=1, max_length=256, pattern=r"^[A-Za-z0-9._:-]+$")]
14
+
15
+
16
+ class WorkloadType(StrEnum):
17
+ """Workload execution families the Execution Plane can dispatch."""
18
+
19
+ CONTAINER = "container"
20
+
21
+
13
22
  CREDENTIAL_RECIPE_ID_PATTERN = r"^[a-z][a-z0-9-]{0,62}(?:\.[a-z][a-z0-9-]{0,62})+$"
14
23
  CredentialRecipeId = Annotated[
15
24
  StrictStr,
@@ -114,8 +123,8 @@ class WorkExecute(CommandPayload):
114
123
  default=None,
115
124
  description="Optional result-field allowlist mapping output names to workload result keys.",
116
125
  )
117
- workload_type: Literal["container"] = Field(
118
- default="container",
126
+ workload_type: WorkloadType = Field(
127
+ default=WorkloadType.CONTAINER,
119
128
  description="Workload execution family; container is the only supported value.",
120
129
  )
121
130
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  import re
4
4
  from datetime import datetime
5
- from enum import StrEnum
6
5
  from typing import Annotated, Literal, Self
7
6
  from uuid import UUID
8
7
 
@@ -11,6 +10,7 @@ from pydantic.json_schema import SkipJsonSchema
11
10
 
12
11
  from execution_plane_client.commands.targets import KubernetesPlacement as CommandKubernetesPlacement
13
12
  from execution_plane_client.models.shared import EPListParams, ResourcesResponse
13
+ from execution_plane_client.types import BackendType, TargetStatus
14
14
 
15
15
  _LABEL_NAME = re.compile(r"^[A-Za-z0-9]([A-Za-z0-9_.-]*[A-Za-z0-9])?$")
16
16
  _DNS_LABEL = re.compile(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
@@ -46,25 +46,6 @@ EXECUTION_TARGET_SORTABLE_FIELDS = [
46
46
  ]
47
47
 
48
48
 
49
- class BackendType(StrEnum):
50
- """Supported execution target backends."""
51
-
52
- KUBERNETES = "kubernetes"
53
- OPENSHELL = "openshell"
54
-
55
-
56
- class TargetStatus(StrEnum):
57
- """Lifecycle states of an execution target."""
58
-
59
- REGISTERING = "registering"
60
- VALIDATING = "validating"
61
- BOOTSTRAPPING = "bootstrapping"
62
- ACTIVE = "active"
63
- DEGRADED = "degraded"
64
- DRAINING = "draining"
65
- FAILED = "failed"
66
-
67
-
68
49
  def _is_valid_label_key(value: str) -> bool:
69
50
  """Return whether a value uses Kubernetes label-key syntax."""
70
51
  prefix, separator, name = value.partition("/")
@@ -96,8 +77,23 @@ class KubernetesPlacement(BaseModel):
96
77
  pattern=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
97
78
  description="Kubernetes namespace reserved for execution workloads",
98
79
  )
99
- node_selectors: list[str] = Field(default_factory=list)
100
- tolerations: list[str] = Field(default_factory=list)
80
+ node_selectors: list[str] = Field(
81
+ default_factory=list,
82
+ description=(
83
+ "Pod nodeSelector entries in key=value form. Nodes must match every entry; an empty "
84
+ "list imposes no label restriction. On update, omission preserves the stored list and "
85
+ "[] clears it."
86
+ ),
87
+ )
88
+ tolerations: list[str] = Field(
89
+ default_factory=list,
90
+ description=(
91
+ "Pod taints to tolerate, using key=value:effect (Equal) or key:effect (Exists). Effect "
92
+ "may be NoSchedule, PreferNoSchedule, or NoExecute; omitting it matches all effects. "
93
+ "An empty key with Exists matches all keys. On update, omission preserves the list and "
94
+ "[] clears it."
95
+ ),
96
+ )
101
97
 
102
98
  @field_validator("node_selectors")
103
99
  @classmethod
@@ -195,9 +191,28 @@ class ExecutionTargetCreate(BaseModel):
195
191
  model_config = ConfigDict(extra="forbid")
196
192
 
197
193
  name: str = Field(min_length=1, max_length=255)
198
- placement: KubernetesTargetPlacement
199
- labels: dict[str, str] = Field(default_factory=dict)
200
- is_default: bool = False
194
+ placement: KubernetesTargetPlacement = Field(
195
+ description=(
196
+ "Namespace and pod scheduling rules for this target. Updates require namespace; "
197
+ "omitted scheduling lists retain their stored values. The placement type cannot be "
198
+ "changed."
199
+ )
200
+ )
201
+ labels: dict[str, str] = Field(
202
+ default_factory=dict,
203
+ description=(
204
+ "User labels matched by work.execute selectors when routing workloads. Updates replace "
205
+ "user labels; {} clears them. EP retains its reserved identity labels."
206
+ ),
207
+ )
208
+ is_default: bool = Field(
209
+ default=False,
210
+ description=(
211
+ "Promote this target to the cluster default, replacing the previous default. The "
212
+ "target and cluster must be active and enabled. To demote a default, promote another "
213
+ "target rather than setting this field to false."
214
+ ),
215
+ )
201
216
 
202
217
 
203
218
  class ExecutionTargetUpdate(BaseModel):
@@ -206,10 +221,36 @@ class ExecutionTargetUpdate(BaseModel):
206
221
  model_config = ConfigDict(extra="forbid", json_schema_extra={"minProperties": 1})
207
222
 
208
223
  name: Annotated[str, Field(min_length=1, max_length=255)] | SkipJsonSchema[None] = None
209
- placement: KubernetesTargetPlacement | SkipJsonSchema[None] = None
210
- labels: dict[str, str] | SkipJsonSchema[None] = None
211
- is_default: bool | SkipJsonSchema[None] = None
212
- enabled: bool | SkipJsonSchema[None] = None
224
+ placement: KubernetesTargetPlacement | SkipJsonSchema[None] = Field(
225
+ default=None,
226
+ description=(
227
+ "Namespace and pod scheduling rules for this target. Updates require namespace; "
228
+ "omitted scheduling lists retain their stored values. The placement type cannot be "
229
+ "changed."
230
+ ),
231
+ )
232
+ labels: dict[str, str] | SkipJsonSchema[None] = Field(
233
+ default=None,
234
+ description=(
235
+ "User labels matched by work.execute selectors when routing workloads. Updates replace "
236
+ "user labels; {} clears them. EP retains its reserved identity labels."
237
+ ),
238
+ )
239
+ is_default: bool | SkipJsonSchema[None] = Field(
240
+ default=None,
241
+ description=(
242
+ "Promote this target to the cluster default, replacing the previous default. The "
243
+ "target and cluster must be active and enabled. To demote a default, promote another "
244
+ "target rather than setting this field to false."
245
+ ),
246
+ )
247
+ enabled: bool | SkipJsonSchema[None] = Field(
248
+ default=None,
249
+ description=(
250
+ "Whether the scheduler may assign new workloads to this target; disabling it does not "
251
+ "request cancellation of work already assigned."
252
+ ),
253
+ )
213
254
 
214
255
  @model_validator(mode="after")
215
256
  def check_fields(self) -> Self:
@@ -224,7 +265,12 @@ class ExecutionTargetDeleteAccepted(BaseModel):
224
265
  """EP accepted deletion; draining and physical removal happen independently."""
225
266
 
226
267
  id: UUID
227
- accepted: Literal[True] = True
268
+ accepted: Literal[True] = Field(
269
+ default=True,
270
+ description=(
271
+ "Confirms that EP accepted the deletion request, not that draining or physical removal has finished."
272
+ ),
273
+ )
228
274
 
229
275
 
230
276
  class ExecutionTargetHealthResult(BaseModel):
@@ -232,6 +278,18 @@ class ExecutionTargetHealthResult(BaseModel):
232
278
 
233
279
  model_config = ConfigDict(extra="forbid")
234
280
 
235
- healthy: bool
281
+ healthy: bool = Field(
282
+ description=(
283
+ "Whether the namespace probe succeeded. For Kubernetes this checks namespace "
284
+ "readability, not workload execution. Check skipped first: a skipped probe also "
285
+ "returns true."
286
+ )
287
+ )
236
288
  message: str | None = None
237
- skipped: bool = False
289
+ skipped: bool = Field(
290
+ default=False,
291
+ description=(
292
+ "True when no health check ran because the backend, endpoint, or cluster/target "
293
+ "lifecycle is outside probe scope; healthy then does not establish readiness."
294
+ ),
295
+ )
@@ -0,0 +1,22 @@
1
+ """Type definitions."""
2
+
3
+ from enum import StrEnum
4
+
5
+
6
+ class BackendType(StrEnum):
7
+ """Supported execution target backends."""
8
+
9
+ KUBERNETES = "kubernetes"
10
+ OPENSHELL = "openshell"
11
+
12
+
13
+ class TargetStatus(StrEnum):
14
+ """Lifecycle states of an execution target."""
15
+
16
+ REGISTERING = "registering"
17
+ VALIDATING = "validating"
18
+ BOOTSTRAPPING = "bootstrapping"
19
+ ACTIVE = "active"
20
+ DEGRADED = "degraded"
21
+ DRAINING = "draining"
22
+ FAILED = "failed"
@@ -1,78 +0,0 @@
1
- """Typed command results and transport receipts."""
2
-
3
- from __future__ import annotations
4
-
5
- import json
6
- from typing import Annotated, Literal
7
- from uuid import UUID # noqa: TC003 - Pydantic resolves this model field at runtime.
8
-
9
- from pydantic import Field, StrictBool, StrictStr, field_validator
10
-
11
- from execution_plane_client.protocol import ResourceReference, WireModel
12
-
13
- MAX_WORKLOAD_CREDENTIAL_FIELDS = 32
14
- MAX_WORKLOAD_CREDENTIAL_BYTES = 32 * 1024
15
-
16
-
17
- class CredentialResolveCommandResult(WireModel):
18
- """Typed result returned for a credential-resolution command."""
19
-
20
- command_type: Literal["credential.resolve"] = "credential.resolve"
21
- command_revision: Literal[1] = 1
22
- credential: Annotated[StrictStr, Field(min_length=1, max_length=65536, repr=False)]
23
-
24
-
25
- class CredentialResolveWorkloadCommandResult(WireModel):
26
- """Typed result returned for a workload credential-resolution command."""
27
-
28
- command_type: Literal["credential.resolve.workload"] = "credential.resolve.workload"
29
- command_revision: Literal[1] = Field(
30
- default=1, description="Payload contract version for credential.resolve.workload; matches the request revision."
31
- )
32
- credential: dict[
33
- Annotated[StrictStr, Field(min_length=1, max_length=128)],
34
- Annotated[StrictStr, Field(min_length=1, max_length=8192)],
35
- ] = Field(repr=False)
36
-
37
- @field_validator("credential")
38
- @classmethod
39
- def check_document(cls, value: dict[str, str]) -> dict[str, str]:
40
- """Bound credential field count and encoded response size."""
41
- if not value:
42
- message = "Credential document must not be empty"
43
- raise ValueError(message)
44
- if len(value) > MAX_WORKLOAD_CREDENTIAL_FIELDS:
45
- message = "Credential document must contain at most 32 fields"
46
- raise ValueError(message)
47
- encoded = json.dumps(value, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
48
- if len(encoded) > MAX_WORKLOAD_CREDENTIAL_BYTES:
49
- message = "Credential document exceeds 32 KiB"
50
- raise ValueError(message)
51
- return value
52
-
53
-
54
- class TargetHealthCommandResult(WireModel):
55
- """Typed result returned for an execution-target health command."""
56
-
57
- command_type: Literal["execution_target.health"] = "execution_target.health"
58
- command_revision: Literal[1] = 1
59
- healthy: StrictBool
60
- message: StrictStr | None = None
61
- skipped: StrictBool = False
62
-
63
-
64
- CommandResult = Annotated[
65
- CredentialResolveCommandResult | CredentialResolveWorkloadCommandResult | TargetHealthCommandResult,
66
- Field(discriminator="command_type"),
67
- ]
68
-
69
-
70
- class TransportReceipt(WireModel):
71
- """Receipt of a handled request, without a persisted command record."""
72
-
73
- received: Literal[True] = True
74
- message_id: UUID = Field(
75
- description="The received delivery message's UUID, echoed so the sender can match this receipt."
76
- )
77
- resource: ResourceReference | None = None
78
- result: CommandResult | None = None