primus.command_worker.models module

Provider-neutral command and lease value objects.

class primus.command_worker.models.AnnouncementDisposition(value)

Bases: str, Enum

CONFLICT = 'CONFLICT'
EXISTING = 'EXISTING'
NEW = 'NEW'
class primus.command_worker.models.AnnouncementResult(command: 'CommandRecord', disposition: 'AnnouncementDisposition')

Bases: object

__init__(command: CommandRecord, disposition: AnnouncementDisposition) → None
command: CommandRecord
disposition: AnnouncementDisposition
class primus.command_worker.models.AuditEvent(event_type: AuditEventType, occurred_at: datetime, tenant_id: str, principal_id: str, principal_type: str, authentication_method: str, correlation_id: str, outcome: str, policy_version: str | None = None, command_id: str | None = None, target: str | None = None)

Bases: object

Structured payload-free security and command audit event.

__init__(event_type: AuditEventType, occurred_at: datetime, tenant_id: str, principal_id: str, principal_type: str, authentication_method: str, correlation_id: str, outcome: str, policy_version: str | None = None, command_id: str | None = None, target: str | None = None) → None
authentication_method: str
command_id: str | None
correlation_id: str
event_type: AuditEventType
occurred_at: datetime
outcome: str
policy_version: str | None
principal_id: str
principal_type: str
target: str | None
tenant_id: str
class primus.command_worker.models.AuditEventType(value)

Bases: str, Enum

AUTHORIZATION_DENIED = 'AUTHORIZATION_DENIED'
CANCELLATION = 'CANCELLATION'
IDEMPOTENCY_CONFLICT = 'IDEMPOTENCY_CONFLICT'
READ = 'READ'
SUBMIT_CREATED = 'SUBMIT_CREATED'
SUBMIT_EXISTING = 'SUBMIT_EXISTING'
class primus.command_worker.models.AuthenticatedCommandContext(tenant_id: str, principal_id: str, principal_type: str, authentication_method: str, correlation_id: str)

Bases: object

Identity asserted only by a future authentication adapter.

__init__(tenant_id: str, principal_id: str, principal_type: str, authentication_method: str, correlation_id: str) → None
authentication_method: str
correlation_id: str
principal_id: str
principal_type: str
tenant_id: str
class primus.command_worker.models.AuthorizationDecision(allowed: 'bool', policy_version: 'str')

Bases: object

__init__(allowed: bool, policy_version: str) → None
allowed: bool
policy_version: str
class primus.command_worker.models.CancellationResult(command: 'CommandRecord', changed: 'bool')

Bases: object

__init__(command: CommandRecord, changed: bool) → None
changed: bool
command: CommandRecord
class primus.command_worker.models.Claim(token: str, owner: str, expires_at: datetime, cancellation_requested: bool = False)

Bases: object

A lifecycle-store-issued fencing lease.

__init__(token: str, owner: str, expires_at: datetime, cancellation_requested: bool = False) → None
cancellation_requested: bool
expires_at: datetime
owner: str
token: str
class primus.command_worker.models.CommandEnvelope(schema_version: int, command_id: str, tenant_id: str, target: str, idempotency_key: str, created_at: datetime, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]])

Bases: object

Immutable, versioned command contract shared by all providers.

CURRENT_SCHEMA_VERSION: ClassVar[int] = 2
__init__(schema_version: int, command_id: str, tenant_id: str, target: str, idempotency_key: str, created_at: datetime, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]]) → None
command_id: str
created_at: datetime
classmethod from_message(message: Mapping[str, Any]) → CommandEnvelope

Validate and deserialize a transport message.

idempotency_key: str
payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]]
schema_version: int
target: str
tenant_id: str
to_message() → dict[str, Any]

Create a strict JSON-serializable transport message.

class primus.command_worker.models.CommandLimits(max_identifier_length: int = 256, max_idempotency_key_length: int = 512, max_json_depth: int = 32, max_json_containers: int = 10000, max_json_bytes: int = 1048576)

Bases: object

Provider-neutral safety limits; adapters may impose stricter values.

__init__(max_identifier_length: int = 256, max_idempotency_key_length: int = 512, max_json_depth: int = 32, max_json_containers: int = 10000, max_json_bytes: int = 1048576) → None
max_idempotency_key_length: int
max_identifier_length: int
max_json_bytes: int
max_json_containers: int
max_json_depth: int
class primus.command_worker.models.CommandRecord(command_id: str, tenant_id: str, target: str, idempotency_key: str, idempotency_namespace: str, created_at: datetime, updated_at: datetime, submitted_by: str, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]], status: CommandStatus, request_digest: RequestDigest)

Bases: object

Immutable durable command snapshot.

__init__(command_id: str, tenant_id: str, target: str, idempotency_key: str, idempotency_namespace: str, created_at: datetime, updated_at: datetime, submitted_by: str, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]], status: CommandStatus, request_digest: RequestDigest) → None
command_id: str
created_at: datetime
property envelope: CommandEnvelope
idempotency_key: str
idempotency_namespace: str
payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]]
request_digest: RequestDigest
status: CommandStatus
submitted_by: str
target: str
tenant_id: str
updated_at: datetime
class primus.command_worker.models.CommandRequest(target: str, idempotency_key: str, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]])

Bases: object

Work requested by a trusted adapter; tenant identity is intentionally absent.

__init__(target: str, idempotency_key: str, payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]]) → None
idempotency_key: str
payload: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]]
target: str
class primus.command_worker.models.CommandStatus(value)

Bases: str, Enum

ANNOUNCED = 'ANNOUNCED'
CANCELLED = 'CANCELLED'
CANCEL_REQUESTED = 'CANCEL_REQUESTED'
FAILED = 'FAILED'
RUNNING = 'RUNNING'
SUCCEEDED = 'SUCCEEDED'
property is_terminal: bool
class primus.command_worker.models.ProgressUpdate(fraction: 'float', message: 'str | None' = None, details: 'Mapping[str, JSONValue] | None' = None)

Bases: object

__init__(fraction: float, message: str | None = None, details: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]] | None = None) → None
details: Mapping[str, str | int | float | bool | None | Mapping[str, str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]] | tuple[str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], ...]] | None
fraction: float
message: str | None
class primus.command_worker.models.RequestDigest(algorithm: 'str', canonicalization_version: 'int', value: 'str')

Bases: object

__init__(algorithm: str, canonicalization_version: int, value: str) → None
algorithm: str
canonicalization_version: int
value: str
class primus.command_worker.models.SubmissionDisposition(value)

Bases: str, Enum

EXISTING = 'EXISTING'
NEW = 'NEW'
class primus.command_worker.models.SubmissionResult(command: 'CommandRecord', disposition: 'SubmissionDisposition')

Bases: object

__init__(command: CommandRecord, disposition: SubmissionDisposition) → None
command: CommandRecord
disposition: SubmissionDisposition
primus.command_worker.models.freeze_json(value: Any, path: str = 'payload', limits: CommandLimits = CommandLimits(max_identifier_length=256, max_idempotency_key_length=512, max_json_depth=32, max_json_containers=10000, max_json_bytes=1048576)) → str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...]

Validate JSON-compatible input and return an immutable snapshot.

primus.command_worker.models.request_digest(target: str, payload: Mapping[str, Any], limits: CommandLimits = CommandLimits(max_identifier_length=256, max_idempotency_key_length=512, max_json_depth=32, max_json_containers=10000, max_json_bytes=1048576)) → RequestDigest

Digest strict, bounded, canonically ordered request content.