execution-plane-client 0.1.19__tar.gz → 0.1.21__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 (27) hide show
  1. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/PKG-INFO +17 -10
  2. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/README.md +16 -9
  3. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/_version.py +2 -2
  4. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/catalog.py +7 -8
  5. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/base.py +5 -20
  6. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/control.py +17 -7
  7. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/credentials.py +16 -5
  8. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/results.py +6 -2
  9. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/work.py +26 -7
  10. execution_plane_client-0.1.21/models/runtime_context.py +22 -0
  11. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/models/work_item.py +26 -2
  12. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/protocol.py +22 -25
  13. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/.gitignore +0 -0
  14. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/LICENSE +0 -0
  15. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/__init__.py +0 -0
  16. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/__init__.py +0 -0
  17. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/clusters.py +0 -0
  18. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/commands/targets.py +0 -0
  19. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/errors.py +0 -0
  20. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/handlers.py +0 -0
  21. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/models/__init__.py +0 -0
  22. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/models/cluster.py +0 -0
  23. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/models/execution_target.py +0 -0
  24. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/models/shared.py +0 -0
  25. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/py.typed +0 -0
  26. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/pyproject.toml +0 -0
  27. {execution_plane_client-0.1.19 → execution_plane_client-0.1.21}/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: execution-plane-client
3
- Version: 0.1.19
3
+ Version: 0.1.21
4
4
  Summary: Shared execution-plane command, response, and handler contracts
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -47,12 +47,19 @@ Every concrete command supports this method, including `ClusterDelete`,
47
47
  `TargetDelete` and `TargetHealth`. Partial updates serialize only supplied fields, retaining explicit
48
48
  nulls and placement discriminators without resetting omitted configuration.
49
49
 
50
- By default, each call generates a command UUID and UTC timestamp; `message_id`
51
- defaults to that command UUID. Keep the returned message for retries. To rebuild
52
- it from existing domain state, pass `command_id` and `occurred_at` explicitly,
53
- plus `message_id` if it differs. `parent_command_id` and `sequence` are optional;
54
- `Completion` requires a parent work command UUID. Source, destination and client
55
- scope are always supplied by the caller; the helper does not authenticate them.
50
+ By default, each call generates an independent message UUID and UTC timestamp.
51
+ Keep the returned message for retries, or pass `message_id` and `occurred_at` to
52
+ reconstruct a delivery. Message IDs correlate receipts, not resource identity
53
+ or deduplication. Source, destination and client scope are always supplied by
54
+ the caller; the helper does not authenticate them.
55
+
56
+ `WorkExecute` requires a caller-assigned `work_item_id`, which becomes the new
57
+ WorkItem's primary key. Submitting an existing ID returns HTTP 409. Use that same
58
+ ID for `WorkCancel`, `Completion`, and `CredentialResolveWorkload` requests.
59
+
60
+ Work execution accepts optional non-secret `runtime_context`, passed to the
61
+ plugin and included in work-item reads and completion notifications. See
62
+ [runtime context](../../docs/integration.md#runtime-context) for examples and filtering.
56
63
 
57
64
  ## Handling messages
58
65
 
@@ -66,10 +73,10 @@ result = await handler.handle(message, payload, context)
66
73
  ```
67
74
 
68
75
  Handlers implement `handle(message, payload, context)`. The catalog selects the
69
- payload model by command type and revision, validates it and checks required
70
- parent correlation. Handlers narrow the payload to their supported command
76
+ payload model by command type and revision and validates its fields. Handlers
77
+ narrow the payload to their supported command
71
78
  types without parsing the raw dictionary again. The original envelope remains
72
- available for identity and correlation; partial-update payloads retain which
79
+ available for routing and receipt correlation; partial-update payloads retain which
73
80
  fields were supplied. Authentication, authorization and domain-state validation
74
81
  (including validation after merging a patch) remain participant responsibilities.
75
82
 
@@ -37,12 +37,19 @@ Every concrete command supports this method, including `ClusterDelete`,
37
37
  `TargetDelete` and `TargetHealth`. Partial updates serialize only supplied fields, retaining explicit
38
38
  nulls and placement discriminators without resetting omitted configuration.
39
39
 
40
- By default, each call generates a command UUID and UTC timestamp; `message_id`
41
- defaults to that command UUID. Keep the returned message for retries. To rebuild
42
- it from existing domain state, pass `command_id` and `occurred_at` explicitly,
43
- plus `message_id` if it differs. `parent_command_id` and `sequence` are optional;
44
- `Completion` requires a parent work command UUID. Source, destination and client
45
- scope are always supplied by the caller; the helper does not authenticate them.
40
+ By default, each call generates an independent message UUID and UTC timestamp.
41
+ Keep the returned message for retries, or pass `message_id` and `occurred_at` to
42
+ reconstruct a delivery. Message IDs correlate receipts, not resource identity
43
+ or deduplication. Source, destination and client scope are always supplied by
44
+ the caller; the helper does not authenticate them.
45
+
46
+ `WorkExecute` requires a caller-assigned `work_item_id`, which becomes the new
47
+ WorkItem's primary key. Submitting an existing ID returns HTTP 409. Use that same
48
+ ID for `WorkCancel`, `Completion`, and `CredentialResolveWorkload` requests.
49
+
50
+ Work execution accepts optional non-secret `runtime_context`, passed to the
51
+ plugin and included in work-item reads and completion notifications. See
52
+ [runtime context](../../docs/integration.md#runtime-context) for examples and filtering.
46
53
 
47
54
  ## Handling messages
48
55
 
@@ -56,10 +63,10 @@ result = await handler.handle(message, payload, context)
56
63
  ```
57
64
 
58
65
  Handlers implement `handle(message, payload, context)`. The catalog selects the
59
- payload model by command type and revision, validates it and checks required
60
- parent correlation. Handlers narrow the payload to their supported command
66
+ payload model by command type and revision and validates its fields. Handlers
67
+ narrow the payload to their supported command
61
68
  types without parsing the raw dictionary again. The original envelope remains
62
- available for identity and correlation; partial-update payloads retain which
69
+ available for routing and receipt correlation; partial-update payloads retain which
63
70
  fields were supplied. Authentication, authorization and domain-state validation
64
71
  (including validation after merging a patch) remain participant responsibilities.
65
72
 
@@ -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.19'
22
- __version_tuple__ = version_tuple = (0, 1, 19)
21
+ __version__ = version = '0.1.21'
22
+ __version_tuple__ = version_tuple = (0, 1, 21)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -4,10 +4,10 @@ from dataclasses import dataclass
4
4
 
5
5
  from execution_plane_client.commands.base import CommandPayload
6
6
  from execution_plane_client.commands.clusters import ClusterDelete, ClusterRegister, ClusterUpdate
7
- from execution_plane_client.commands.control import CancelCommand, Completion
7
+ from execution_plane_client.commands.control import Completion, WorkCancel
8
8
  from execution_plane_client.commands.credentials import CredentialResolve, CredentialResolveWorkload
9
9
  from execution_plane_client.commands.targets import TargetDelete, TargetHealth, TargetRegister, TargetUpdate
10
- from execution_plane_client.commands.work import WorkExecute
10
+ from execution_plane_client.commands.work import WorkDelete, WorkExecute
11
11
  from execution_plane_client.errors import UnsupportedCommand
12
12
  from execution_plane_client.protocol import MessageEnvelope
13
13
 
@@ -25,9 +25,10 @@ class CommandCatalog:
25
25
  """Validate known commands independently of installed handlers."""
26
26
 
27
27
  def __init__(self) -> None:
28
- """Install version-one work, resource and completion contracts."""
28
+ """Install supported work, resource and completion contracts."""
29
29
  payloads = (
30
30
  WorkExecute,
31
+ WorkDelete,
31
32
  Completion,
32
33
  CredentialResolve,
33
34
  CredentialResolveWorkload,
@@ -38,7 +39,7 @@ class CommandCatalog:
38
39
  TargetUpdate,
39
40
  TargetDelete,
40
41
  TargetHealth,
41
- CancelCommand,
42
+ WorkCancel,
42
43
  )
43
44
  self._definitions = {
44
45
  (schema.command_type, schema.command_revision): CommandDefinition(
@@ -55,8 +56,6 @@ class CommandCatalog:
55
56
  raise UnsupportedCommand from None
56
57
 
57
58
  def validate(self, message: MessageEnvelope) -> CommandPayload:
58
- """Validate the payload and completion parent, returning the typed payload."""
59
+ """Validate the typed command payload, returning the typed payload."""
59
60
  definition = self.definition(message.command.command_type, message.command.command_revision)
60
- payload = definition.payload_schema.model_validate(message.command.payload)
61
- definition.payload_schema.validate_parent(message.command.parent_command_id)
62
- return payload
61
+ return definition.payload_schema.model_validate(message.command.payload)
@@ -4,7 +4,6 @@ from datetime import UTC, datetime
4
4
  from typing import ClassVar
5
5
  from uuid import UUID, uuid4
6
6
 
7
- from execution_plane_client.errors import ProtocolConflict
8
7
  from execution_plane_client.protocol import Command, CommandScope, MessageEnvelope, WireModel
9
8
 
10
9
 
@@ -13,13 +12,6 @@ class CommandPayload(WireModel):
13
12
 
14
13
  command_type: ClassVar[str]
15
14
  command_revision: ClassVar[int] = 1
16
- requires_parent: ClassVar[bool] = False
17
-
18
- @classmethod
19
- def validate_parent(cls, parent_command_id: UUID | None) -> None:
20
- """Require correlation for commands that report another command's outcome."""
21
- if cls.requires_parent and parent_command_id is None:
22
- raise ProtocolConflict
23
15
 
24
16
  def _message_payload(self) -> dict[str, object]:
25
17
  return self.model_dump(mode="json")
@@ -30,32 +22,25 @@ class CommandPayload(WireModel):
30
22
  source_id: str,
31
23
  destination_id: str,
32
24
  client_id: str,
33
- command_id: UUID | None = None,
34
- parent_command_id: UUID | None = None,
35
25
  occurred_at: datetime | None = None,
36
26
  message_id: UUID | None = None,
37
27
  sequence: int = 0,
38
28
  ) -> MessageEnvelope:
39
- """Build a validated message, generating a command UUID and UTC time if omitted.
29
+ """Build a delivery message with an independent UUID and UTC timestamp.
40
30
 
41
- The message ID defaults to the command ID. Retain the returned message for
42
- retries, or supply the original IDs and timestamp when reconstructing it.
43
- Routing, authentication, HTTP delivery and persistence belong to the caller.
31
+ Retain the returned message or supply message_id and occurred_at to
32
+ reconstruct a delivery. Resource identity belongs to the typed payload;
33
+ message_id only correlates the transport receipt, not deduplication.
44
34
  """
45
- self.validate_parent(parent_command_id)
46
35
  payload = self._message_payload()
47
36
  type(self).model_validate(payload)
48
- identity = uuid4() if command_id is None else command_id
49
37
  return MessageEnvelope(
50
- message_id=identity if message_id is None else message_id,
51
- command_id=identity,
38
+ message_id=uuid4() if message_id is None else message_id,
52
39
  source_id=source_id,
53
40
  destination_id=destination_id,
54
41
  scope=CommandScope(client_id=client_id),
55
42
  sequence=sequence,
56
43
  command=Command(
57
- command_id=identity,
58
- parent_command_id=parent_command_id,
59
44
  command_type=self.command_type,
60
45
  command_revision=self.command_revision,
61
46
  payload=payload,
@@ -7,16 +7,19 @@ from uuid import UUID
7
7
  from pydantic import Field, field_validator
8
8
 
9
9
  from execution_plane_client.commands.base import CommandPayload
10
+ from execution_plane_client.models.runtime_context import RuntimeContext
10
11
  from execution_plane_client.models.work_item import WorkItemStatus
11
- from execution_plane_client.protocol import ResourceReference, validate_json
12
+ from execution_plane_client.protocol import validate_json
12
13
 
13
14
 
14
- class CancelCommand(CommandPayload):
15
- """Cancel an existing work command, whose UUID is its work-item UUID."""
15
+ class WorkCancel(CommandPayload):
16
+ """Request cancellation of an existing work item."""
16
17
 
17
- command_type: ClassVar[str] = "command.cancel"
18
+ command_type: ClassVar[str] = "work.cancel"
18
19
 
19
- target_command_id: UUID
20
+ work_item_id: UUID = Field(
21
+ description="Primary key (WorkItem.id) of the existing EP work item to cancel within the authenticated client."
22
+ )
20
23
 
21
24
 
22
25
  class CompletionStatus(StrEnum):
@@ -32,11 +35,18 @@ class Completion(CommandPayload):
32
35
  """Terminal or uncertain work outcome delivered to the initiating client."""
33
36
 
34
37
  command_type: ClassVar[str] = "work.execute.completed"
35
- requires_parent: ClassVar[bool] = True
38
+ command_revision: ClassVar[int] = 1
39
+
40
+ work_item_id: UUID = Field(
41
+ description=(
42
+ "Primary key (WorkItem.id) supplied when this work was created; identifies the item whose outcome "
43
+ "is reported. Syntara uses it to look up ActivityExecution.id."
44
+ )
45
+ )
46
+ runtime_context: RuntimeContext = Field(default_factory=dict, repr=False)
36
47
 
37
48
  status: CompletionStatus
38
49
  result: dict[str, object] = Field(default_factory=dict, repr=False)
39
- resource: ResourceReference | None = None
40
50
  error_code: str | None = None
41
51
 
42
52
  @field_validator("result", mode="before")
@@ -23,15 +23,26 @@ class CredentialResolve(CommandPayload):
23
23
 
24
24
 
25
25
  class CredentialResolveWorkload(CommandPayload):
26
- """Resolve one credential reference for the work item named by its parent command."""
26
+ """Resolve one credential reference for the identified work item."""
27
27
 
28
28
  command_type: ClassVar[str] = "credential.resolve.workload"
29
- requires_parent: ClassVar[bool] = True
30
- attempt_id: Identifier = Field(description="Execution attempt that owns the workload invocation.")
29
+ command_revision: ClassVar[int] = 1
30
+ work_item_id: UUID = Field(
31
+ description=(
32
+ "Primary key (WorkItem.id) of the EP work item requesting credentials. Syntara uses it to look up "
33
+ "ActivityExecution.id and verify the credential binding for that work."
34
+ )
35
+ )
36
+ attempt_id: Identifier = Field(
37
+ description="EP dispatch-attempt identifier, sent to the plugin as invocation_id; distinct from WorkItem.id."
38
+ )
31
39
  credential_ref: UUID = Field(
32
40
  repr=False,
33
41
  description="Opaque AO credential reference bound to the requested recipe.",
34
42
  )
35
43
  credential_recipe_id: CredentialRecipeId = Field(description="Logical Plugin SDK recipe requested by the workload.")
36
- workflow_run_id: StepIdentity = Field(description="Caller-owned workflow run containing the active step.")
37
- step_revision_id: StepIdentity = Field(description="Workload revision that requested the credential.")
44
+ step_revision_id: StepIdentity = Field(
45
+ description=(
46
+ "Handler identifier from this work item's invocation; identifies the implementation requesting credentials."
47
+ )
48
+ )
@@ -26,7 +26,9 @@ class CredentialResolveWorkloadCommandResult(WireModel):
26
26
  """Typed result returned for a workload credential-resolution command."""
27
27
 
28
28
  command_type: Literal["credential.resolve.workload"] = "credential.resolve.workload"
29
- command_revision: Literal[1] = 1
29
+ command_revision: Literal[1] = Field(
30
+ default=1, description="Payload contract version for credential.resolve.workload; matches the request revision."
31
+ )
30
32
  credential: dict[
31
33
  Annotated[StrictStr, Field(min_length=1, max_length=128)],
32
34
  Annotated[StrictStr, Field(min_length=1, max_length=8192)],
@@ -69,6 +71,8 @@ class TransportReceipt(WireModel):
69
71
  """Receipt of a handled request, without a persisted command record."""
70
72
 
71
73
  received: Literal[True] = True
72
- message_id: UUID
74
+ message_id: UUID = Field(
75
+ description="The received delivery message's UUID, echoed so the sender can match this receipt."
76
+ )
73
77
  resource: ResourceReference | None = None
74
78
  result: CommandResult | None = None
@@ -6,6 +6,7 @@ from uuid import UUID
6
6
  from pydantic import Field, StrictStr, field_validator
7
7
 
8
8
  from execution_plane_client.commands.base import CommandPayload
9
+ from execution_plane_client.models.runtime_context import RuntimeContext
9
10
  from execution_plane_client.protocol import PositiveInt, WireModel, validate_json
10
11
 
11
12
  StepIdentity = Annotated[StrictStr, Field(min_length=1, max_length=256, pattern=r"^[A-Za-z0-9._:-]+$")]
@@ -36,17 +37,15 @@ class WorkloadInvocation(WireModel):
36
37
  claim that arbitrary file paths have been mounted by EP.
37
38
  """
38
39
 
39
- workflow_run_id: StepIdentity = Field(description="Caller-owned identity of the workflow run containing this step.")
40
40
  step_revision_id: StepIdentity = Field(
41
- description="Workload-advertised revision of the step implementation to execute."
41
+ description=(
42
+ "Handler identifier advertised by the selected workload image. The plugin runtime uses it to select "
43
+ "the step implementation; it does not identify this work item or an execution."
44
+ )
42
45
  )
43
46
  inputs: dict[str, object] = Field(
44
47
  description="Step inputs defined by the selected workload; never use this field for credential bindings."
45
48
  )
46
- runtime_context: dict[str, object] = Field(
47
- default_factory=dict,
48
- description="Non-secret execution context supplied to the workload; not for credential bindings.",
49
- )
50
49
  credential_bindings: list[WorkCredentialBinding] = Field(
51
50
  default_factory=list,
52
51
  max_length=16,
@@ -61,7 +60,7 @@ class WorkloadInvocation(WireModel):
61
60
  ),
62
61
  ]
63
62
 
64
- @field_validator("inputs", "runtime_context", mode="before")
63
+ @field_validator("inputs", mode="before")
65
64
  @classmethod
66
65
  def check_json(cls, value: object) -> object:
67
66
  """Keep nested invocation data finite, portable, and bounded."""
@@ -82,6 +81,18 @@ class WorkExecute(CommandPayload):
82
81
  """Schedule one workload implementing the SDK container service."""
83
82
 
84
83
  command_type: ClassVar[str] = "work.execute"
84
+ command_revision: ClassVar[int] = 1
85
+
86
+ work_item_id: UUID = Field(
87
+ description=(
88
+ "Caller-assigned UUID used as the primary key (WorkItem.id) of the new EP work item. "
89
+ "It must be unique across EP work items, including other clients' work. An existing UUID returns "
90
+ "HTTP 409 and never overwrites or reruns that item. On an uncertain submission retry, retain the UUID "
91
+ "and read the existing item after a conflict. Use it for reads, cancellation, completion, and credential "
92
+ "callbacks. Syntara supplies ActivityExecution.id, not the containing Execution.id."
93
+ )
94
+ )
95
+ runtime_context: RuntimeContext = Field(default_factory=dict, repr=False)
85
96
 
86
97
  image: Annotated[
87
98
  StrictStr,
@@ -107,3 +118,11 @@ class WorkExecute(CommandPayload):
107
118
  default="container",
108
119
  description="Workload execution family; container is the only supported value.",
109
120
  )
121
+
122
+
123
+ class WorkDelete(CommandPayload):
124
+ """Request asynchronous cancellation, resource cleanup, and removal of owned work."""
125
+
126
+ command_type: ClassVar[str] = "work.delete"
127
+
128
+ work_item_id: UUID
@@ -0,0 +1,22 @@
1
+ """Non-secret caller context shared with the workload."""
2
+
3
+ from typing import Annotated
4
+
5
+ from pydantic import BeforeValidator, Field
6
+
7
+ from execution_plane_client.protocol import validate_json
8
+
9
+ RUNTIME_CONTEXT_DESCRIPTION = (
10
+ "Optional caller-defined JSON object, defaulting to {}. Stored once, unencrypted, on the work item and "
11
+ "passed to the plugin as context.runtime_context; also returned in work-item reads and completion notifications. "
12
+ "Do not include secrets. Syntara supplies project_id (Project.id), workflow_id (Workflow.id), and execution_id "
13
+ "(the containing Execution.id); EP does not require these keys. These values do not authorize access, select "
14
+ "placement, identify the work item, or control its lifecycle. List filters runtime_context[key]=value match "
15
+ "exact JSON strings at literal top-level keys; an empty value checks key existence and multiple keys use AND."
16
+ )
17
+
18
+ RuntimeContext = Annotated[
19
+ dict[str, object],
20
+ BeforeValidator(validate_json),
21
+ Field(description=RUNTIME_CONTEXT_DESCRIPTION),
22
+ ]
@@ -7,6 +7,7 @@ from uuid import UUID
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field, StringConstraints
9
9
 
10
+ from execution_plane_client.models.runtime_context import RuntimeContext
10
11
  from execution_plane_client.models.shared import _SORT_PATTERN, EPListParams, ResourcesResponse
11
12
 
12
13
  # Work item query metadata - single source of truth for EP and client
@@ -36,7 +37,6 @@ class WorkItemStatus(StrEnum):
36
37
  CLAIMED = "claimed"
37
38
  DISPATCHED = "dispatched"
38
39
  RUNNING = "running"
39
- CANCEL_REQUESTED = "cancel_requested"
40
40
  RECONCILIATION_REQUIRED = "reconciliation_required"
41
41
  COMPLETED = "completed"
42
42
  FAILED = "failed"
@@ -48,8 +48,32 @@ class WorkItemRead(BaseModel):
48
48
 
49
49
  model_config = ConfigDict(from_attributes=True)
50
50
 
51
- id: UUID = Field(description="Work item unique identifier")
51
+ id: UUID = Field(
52
+ description=(
53
+ "Primary key of this EP work item, equal to work.execute.payload.work_item_id supplied at creation. "
54
+ "Use it to read or cancel this item and correlate completion or credential callbacks. "
55
+ "Syntara uses ActivityExecution.id; runtime_context.execution_id identifies its containing execution."
56
+ )
57
+ )
58
+ runtime_context: RuntimeContext = Field(default_factory=dict)
52
59
  status: WorkItemStatus = Field(description="Work item lifecycle status")
60
+ cancellation_requested: bool = Field(
61
+ default=False,
62
+ description=(
63
+ "Whether cancellation intent has been persisted. A true value does not confirm that execution "
64
+ "has stopped: status remains dispatched or running until an outcome is known. A result may "
65
+ "win the cancellation race. This flag remains true after completion and is also set by deletion."
66
+ ),
67
+ )
68
+ deletion_requested: bool = Field(
69
+ default=False,
70
+ description=(
71
+ "Whether deletion intent has been persisted. Always implies cancellation_requested=true. "
72
+ "Active work is cancelled asynchronously, and the record remains readable until resource "
73
+ "cleanup is confirmed and the record is removed. This flag does not change an existing "
74
+ "terminal outcome or confirm that deletion has completed."
75
+ ),
76
+ )
53
77
  result: dict[str, Any] | None = Field(default=None, description="Work execution result payload")
54
78
  result_omitted: bool = Field(default=False, description="Whether result was omitted due to size")
55
79
  result_size_bytes: int | None = Field(default=None, description="Size of the result in bytes")
@@ -4,10 +4,10 @@ from __future__ import annotations
4
4
 
5
5
  import json
6
6
  from datetime import UTC, datetime
7
- from typing import Annotated, Literal, Self
7
+ from typing import Annotated, Literal
8
8
  from uuid import UUID # noqa: TC003 - Pydantic resolves these model fields at runtime.
9
9
 
10
- from pydantic import BaseModel, Field, StrictInt, StrictStr, ValidationInfo, field_validator, model_validator
10
+ from pydantic import BaseModel, Field, StrictInt, StrictStr, ValidationInfo, field_validator
11
11
 
12
12
  MAX_PAYLOAD_BYTES = 512 * 1024
13
13
  Identifier = Annotated[StrictStr, Field(min_length=1, max_length=255, pattern=r"^[A-Za-z0-9_.:@/-]+$")]
@@ -56,10 +56,16 @@ class CommandScope(WireModel):
56
56
  class Command(WireModel):
57
57
  """One versioned operation; participants persist only its domain effects."""
58
58
 
59
- command_id: UUID
60
- parent_command_id: UUID | None = None
61
- command_type: Annotated[StrictStr, Field(pattern=r"^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$")]
62
- command_revision: PositiveInt
59
+ command_type: Annotated[
60
+ StrictStr,
61
+ Field(
62
+ pattern=r"^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$",
63
+ description="Operation to perform; selects the payload contract.",
64
+ ),
65
+ ]
66
+ command_revision: PositiveInt = Field(
67
+ description="Version of this operation's payload contract, not a resource revision."
68
+ )
63
69
  payload: dict[str, object] = Field(repr=False)
64
70
  occurred_at: datetime
65
71
 
@@ -79,35 +85,23 @@ class Command(WireModel):
79
85
  raise ValueError(message)
80
86
  return value.astimezone(UTC)
81
87
 
82
- @model_validator(mode="after")
83
- def check_parent(self) -> Self:
84
- """Reject a command naming itself as its parent."""
85
- if self.parent_command_id == self.command_id:
86
- message = "A command cannot be its own parent"
87
- raise ValueError(message)
88
- return self
89
-
90
88
 
91
89
  class MessageEnvelope(WireModel):
92
90
  """Participant identity around one logical command."""
93
91
 
94
- message_id: UUID
92
+ message_id: UUID = Field(
93
+ description=(
94
+ "UUID assigned by the sender to this delivery message and echoed in its transport receipt. "
95
+ "It does not identify a work item or deduplicate submissions; resource IDs in the payload do that."
96
+ )
97
+ )
95
98
  message_type: Literal["command.submit"] = "command.submit"
96
- command_id: UUID
97
99
  sequence: Sequence = 0
98
100
  source_id: Identifier
99
101
  destination_id: Identifier
100
102
  scope: CommandScope
101
103
  command: Command
102
104
 
103
- @model_validator(mode="after")
104
- def check_identity(self) -> Self:
105
- """Keep the envelope and nested command identity consistent."""
106
- if self.command_id != self.command.command_id:
107
- message = "Envelope command_id must match command.command_id"
108
- raise ValueError(message)
109
- return self
110
-
111
105
 
112
106
  class ResourceReference(WireModel):
113
107
  """Safe reference from a command to a participant-owned resource."""
@@ -121,5 +115,8 @@ class ResourceReference(WireModel):
121
115
  class CapabilitiesRead(WireModel):
122
116
  """Command revisions installed by this participant."""
123
117
 
124
- protocol_revision: Literal[1] = 1
118
+ protocol_revision: Literal[1] = Field(
119
+ default=1,
120
+ description="Envelope contract version; remains 1 during development of the resource-addressed protocol.",
121
+ )
125
122
  commands: dict[str, list[int]]