Skip to content

How the lifecycle works

The lifecycle is deliberately more precise than “approved” and “done.” Each state answers a different operational question.

State Meaning
awaiting_authority A proposal exists, but sufficient bound authority has not been recorded.
authorized Current recorded evidence satisfies the host authority policy. Execution has not started.
blocked A live safety check failed, such as permission being revoked or authority expiring.
stale Material application state differs from the approved snapshot. This proposal is terminal and a fresh proposal is required.
superseded A stale proposal was replaced by a fresh proposal. The old proposal remains terminal.
executing This proposal owns local admission for the semantic effect. The external outcome may still be unknown.
verification_pending The effect may exist, but authoritative completion is not proven yet.
verified The host verifier observed terminal completion at the authoritative target.
failed_known The executor or verifier reported a definite failure.
failed_unknown The call failed without proving whether the effect occurred. Verify; do not blindly resend.
verification_unresolved The bounded verification attempts were exhausted. Human or scheduled follow-up is required.
partially_succeeded An explicitly itemized action produced different item outcomes.
expired The proposal lifetime ended before execution admission.
denied A confirming authority rejected the proposal.

Normal path

async def main() -> None:
    demo = build_refund_application()
    contract = demo.actions.inspect(demo.refund)
    print(contract.action_type)
    demo.ledger.add(
        PaymentOrder(
            order_reference="order:42",
            payment_reference="payment:private:42",
            customer_contact="private@example.test",
            captured=money("100.00"),
            refunded=money("20.00"),
        )
    )

    prepared = await demo.prepare(
        RefundCommand(
            intent_reference="intent:refund:42",
            order_reference="order:42",
            amount=money("30.00"),
        )
    )
    print(prepared.display_preview)

    # The host authenticates the manager and records exact authority evidence.
    await demo.approve(prepared.proposal_reference)

    # Execution re-reads the order and refuses material drift.
    accepted = await demo.execute(prepared.proposal_reference)
    demo.clock.advance(demo.specification.verification_delay)
    verified = await demo.reconcile(prepared.proposal_reference)
    print(accepted.outcome, verified.outcome, verified.safe_result)

    view = await demo.read(
        prepared.proposal_reference,
        context=ReadContext(
            tenant_reference=TENANT,
            consumer=EvidenceConsumer(reference="operator:auditor"),
        ),
    )
    print([receipt.receipt_type for receipt in view.receipts])

execute() returning the verification_pending operation outcome is normal. Keep the proposal reference and schedule reconcile() at or after the persisted next_verification_at. The runtime bounds concurrent leases and total attempts.

An executing lifecycle status means an executor still owns an active recovery lease. An early reconcile() returns the in_progress operation outcome without changing the record. Crash recovery may move executing to verification_pending only after the persisted due time, which is set from verification_lease_duration when execution is admitted.

The runtime deliberately timestamps durable admission after the awaited live can_execute() check. Time spent in that authorization call consumes proposal and authority validity; both are checked again when it returns. It does not consume the execution recovery lease, which starts only when the store admits the proposal as executing. If the admission write itself consumes that lease, dispatch is refused. This separates expiring authority from crash-recovery ownership without granting extra time to either.

An authorization refusal during prepare() raises AuthorizationDeniedError because no proposal exists to transition. A failed live check for an existing proposal records the terminal blocked lifecycle state. Decision and read denials intentionally use ProposalNotFoundError so unauthorized and unknown proposal references remain indistinguishable.

Lifecycle status versus operation outcome

lifecycle_status is the durable state of the proposal. outcome describes what a particular runtime call observed or did. They are related but are not the same vocabulary. For example, an early reconciliation call can return the in_progress outcome while the proposal remains in the executing lifecycle status.

The lifecycle groups are:

  • Positive terminal: verified.
  • Negative terminal: denied, expired, blocked, stale, superseded, failed_known, or verification_unresolved.
  • Mixed terminal: partially_succeeded; inspect the item outcomes before compensating or retrying anything.
  • Needs authoritative reconciliation: executing, failed_unknown, or verification_pending, subject to the persisted due time and lease.
  • Still actionable but not reconcilable: awaiting_authority or authorized.

If an operation returns the stale outcome, follow fresh_proposal_reference when it is present. Otherwise call prepare() again from current application state. Never execute the stale proposal again.

Outcomes such as authority_pending, in_progress, and conflict describe a call result; inspect the accompanying lifecycle_status before scheduling the next operation. An execute caller that loses admission to another active executor receives in_progress; a conflict whose winner has already moved elsewhere remains a replay result carrying that current lifecycle.

Do not translate accepted, an HTTP 2xx, a queue acknowledgement, or model text into verified. Only the configured verifier can do that.

Use result.is_terminal instead of copying states that have no reconciliation or recovery path into an application. Use result.automatic_processing_closed to stop unattended polling while leaving authorized operator recovery available, and result.needs_reconciliation to decide whether the runtime can advance the proposal through authoritative reconciliation. All three properties are derived from the lifecycle state, including replay and conflict results.