execution-plane-client 0.1.22__tar.gz → 0.1.24__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.22 → execution_plane_client-0.1.24}/PKG-INFO +1 -1
  2. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/_version.py +2 -2
  3. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/catalog.py +3 -0
  4. execution_plane_client-0.1.24/commands/bulk_work.py +60 -0
  5. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/clusters.py +68 -10
  6. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/control.py +21 -3
  7. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/results.py +21 -3
  8. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/targets.py +101 -16
  9. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/work.py +12 -3
  10. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/execution_target.py +90 -32
  11. execution_plane_client-0.1.24/types.py +22 -0
  12. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/.gitignore +0 -0
  13. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/LICENSE +0 -0
  14. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/README.md +0 -0
  15. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/__init__.py +0 -0
  16. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/__init__.py +0 -0
  17. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/base.py +0 -0
  18. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/commands/credentials.py +0 -0
  19. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/errors.py +0 -0
  20. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/handlers.py +0 -0
  21. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/__init__.py +0 -0
  22. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/cluster.py +0 -0
  23. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/runtime_context.py +0 -0
  24. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/shared.py +0 -0
  25. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/models/work_item.py +0 -0
  26. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/protocol.py +0 -0
  27. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/py.typed +0 -0
  28. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/pyproject.toml +0 -0
  29. {execution_plane_client-0.1.22 → execution_plane_client-0.1.24}/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: execution-plane-client
3
- Version: 0.1.22
3
+ Version: 0.1.24
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.22'
22
- __version_tuple__ = version_tuple = (0, 1, 22)
21
+ __version__ = version = '0.1.24'
22
+ __version_tuple__ = version_tuple = (0, 1, 24)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -3,6 +3,7 @@
3
3
  from dataclasses import dataclass
4
4
 
5
5
  from execution_plane_client.commands.base import CommandPayload
6
+ from execution_plane_client.commands.bulk_work import WorkCancelBulk, WorkDeleteBulk
6
7
  from execution_plane_client.commands.clusters import ClusterDelete, ClusterRegister, ClusterUpdate
7
8
  from execution_plane_client.commands.control import Completion, WorkCancel
8
9
  from execution_plane_client.commands.credentials import CredentialResolveCluster, CredentialResolveWorkload
@@ -28,6 +29,8 @@ class CommandCatalog:
28
29
  """Install supported work, resource and completion contracts."""
29
30
  payloads = (
30
31
  WorkExecute,
32
+ WorkCancelBulk,
33
+ WorkDeleteBulk,
31
34
  WorkDelete,
32
35
  Completion,
33
36
  CredentialResolveCluster,
@@ -0,0 +1,60 @@
1
+ """Transactional intent requests for a client-owned set of existing work items."""
2
+
3
+ from typing import ClassVar, Self
4
+ from uuid import UUID
5
+
6
+ from pydantic import Field, JsonValue, model_validator
7
+
8
+ from execution_plane_client.commands.base import CommandPayload
9
+ from execution_plane_client.protocol import WireModel
10
+
11
+
12
+ class WorkItemSelector(WireModel):
13
+ """Select by exactly one ID list or a non-empty runtime-context containment filter.
14
+
15
+ Selection is always restricted to the authenticated client. Missing IDs,
16
+ foreign IDs, and zero filter matches are successful no-ops. A filter selects
17
+ existing rows at execution time, not work submitted after the command.
18
+ """
19
+
20
+ work_item_ids: list[UUID] | None = Field(default=None, min_length=1, max_length=100)
21
+ runtime_context: dict[str, JsonValue] | None = Field(
22
+ default=None,
23
+ min_length=1,
24
+ description=(
25
+ "Non-empty JSON object matched using PostgreSQL JSONB containment (@>). "
26
+ "All supplied key/value pairs must be contained in the stored runtime_context. "
27
+ "Nested objects may contain additional keys; arrays use JSONB containment semantics. "
28
+ "Keys and values are caller-defined; EP assigns them no domain meaning."
29
+ ),
30
+ )
31
+
32
+ @model_validator(mode="after")
33
+ def require_one_selector(self) -> Self:
34
+ """Reject unscoped requests and ambiguous combinations of selectors."""
35
+ if (self.work_item_ids is not None) == (self.runtime_context is not None):
36
+ message = "Exactly one of work_item_ids or runtime_context is required"
37
+ raise ValueError(message)
38
+ return self
39
+
40
+
41
+ class WorkCancelBulk(CommandPayload):
42
+ """Commit cancellation intent for all matches in one transaction.
43
+
44
+ Success acknowledges durable intent, not stopped execution. Lifecycle and
45
+ results are unchanged, including for terminal work. Repeating is safe.
46
+ """
47
+
48
+ command_type: ClassVar[str] = "work.cancel_bulk"
49
+ selector: WorkItemSelector = Field(description="Exactly one selector; filter matches have no row-count limit.")
50
+
51
+
52
+ class WorkDeleteBulk(CommandPayload):
53
+ """Commit deletion and cancellation intent together for all matches.
54
+
55
+ Success follows the transaction commit, not resource cleanup or physical
56
+ removal. EP workers own completion. Repeating after a lost receipt is safe.
57
+ """
58
+
59
+ command_type: ClassVar[str] = "work.delete_bulk"
60
+ selector: WorkItemSelector = Field(description="Exactly one selector; filter matches have no row-count limit.")
@@ -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
@@ -62,9 +62,21 @@ class TargetHealthCommandResult(WireModel):
62
62
 
63
63
  command_type: Literal["execution_target.health"] = "execution_target.health"
64
64
  command_revision: Literal[1] = 1
65
- healthy: StrictBool
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
+ )
66
72
  message: StrictStr | None = None
67
- skipped: StrictBool = False
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
+ )
68
80
 
69
81
 
70
82
  CommandResult = Annotated[
@@ -76,7 +88,13 @@ CommandResult = Annotated[
76
88
  class TransportReceipt(WireModel):
77
89
  """Receipt of a handled request, without a persisted command record."""
78
90
 
79
- received: Literal[True] = True
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
+ )
80
98
  message_id: UUID = Field(
81
99
  description="The received delivery message's UUID, echoed so the sender can match this receipt."
82
100
  )
@@ -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"