Skip to main content

Crate pacta_contract

Crate pacta_contract 

Source
Expand description

The isolated core contract for Pacta.

Pacta operates on three axioms:

  1. Registry is Lifecycle (no business logic, no retry/delay logic).
  2. Execution is Middleware.
  3. This contract has no dependency on other workspace crates.

Modules§

kernel
The sans-I/O lifecycle kernel.
lifecycle
The pure lifecycle state machine every Registry backend composes over.

Structs§

Claim
A claimed pact and the retainer required to settle it.
Pact
A durable obligation, generated from a Signal, ready to be executed. Note the deliberate absence of attempts, delay, and priority.
Retainer
A retainer: the authority token a registry issues with a claim and validates when settling it. Authority is registry-validated — a forged identifier does not match an issued claim — not proven by the type system. Construct via Retainer::new and read the identifier via Retainer::id. Derives PartialEq/Eq/Hash so a durable backend can index lease state by holder identity — the orphan rule makes providing these the contract’s responsibility.
Timestamp
A point in time as milliseconds since an epoch the runtime chooses. This is a pure value: the core names time but never reads it. There is deliberately no now constructor — a runtime obtains the current time and injects it, keeping lease decisions deterministic and testable.
Uuid
The identifier type the durable records and the fencing token are built on, re-exported from the uuid crate. A backend needs it to build a Pact (Pact::new(id, …)) and to mint a fresh Retainer (Retainer::new(Uuid…)), so it is part of the backend-author surface. A Universally Unique Identifier (UUID).

Enums§

Outcome
The lifecycle outcome an execution produces for a claimed pact.

Traits§

Registry
The Registry is the durable lifecycle-authority port: it preserves pacts and decides claim, lease, and settlement authority over them. It is not itself the pure state machine — the pure, colorless machine is lifecycle, which every backend composes over; a Registry implementation is the I/O-owning port that persists that machine’s states and enforces its authority (the async twin is [AsyncRegistry]).

Type Aliases§

Settlement
The lifecycle conclusion applied to a claim, currently a fulfilled or breached Outcome.
Transition
A pure kernel transition decision — a lifecycle on_X — passed to the transition port Registry::apply (and its async twin). The same type is used by both bindings, so the port is literally one shape.