Skip to content

Execution contracts and side-effect classes

Every export in a block manifest carries an execution contract. It states what calling the export does to the world, whether its output is repeatable, and whether a call needs an idempotency key. When a project that uses the block is applied, governance checks each workflow step that calls the export against this contract.

Generation writes the contract for every export in the manifest:

{
  "symbol": "charge",
  "export_ordinal": 7,
  "entrypoint": "capsule.acme.billing.ledger_adapter_dispatch:dispatch",
  "execution_contract": {
    "side_effect_class": "read_only",
    "output_stability": "stable",
    "idempotency": {"required": false, "scope": "node", "key_fields": []}
  }
}

The three fields

  1. side_effect_class is what a call changes: read_only, idempotent_write (repeating the call reaches the same end state) or non_idempotent_write (repeating it writes again).
  2. output_stability is whether the same input gives the same output: stable, bounded_nondeterministic or non_deterministic.
  3. idempotency.required is whether each workflow step calling the export must supply an idempotency key.

The method-level behaviour a caller relies on, effect and retry, is declared in the block's interface. See Effect and retry declarations.

What is checked when a project is applied

Each workflow step that calls an export is checked against the export's contract:

Code Kind Raised when
INVALID_OR_MISSING_EXECUTION_CONTRACT_SIDE_EFFECT Error The side-effect class is missing or outside the three values
INVALID_OR_MISSING_EXECUTION_CONTRACT_OUTPUT_STABILITY Error The output stability is missing or outside the three values
INVALID_OR_MISSING_EXECUTION_CONTRACT_IDEMPOTENCY Error idempotency.required is missing or not a boolean
MISSING_NODE_IDEMPOTENCY_KEY Error The contract requires a key and the step sets no idempotency_key
UNSAFE_RETRY_NON_IDEMPOTENT_WRITE Error The step retries more than once and the export is a non_idempotent_write
NON_DETERMINISTIC_CONDITIONAL_FANOUT Warning A non_deterministic export feeds a conditional branch
NON_DETERMINISTIC_RETRY Warning A non_deterministic export is retried

Any error refuses the apply, naming each failing step:

project violates execution safety contracts: …

Warnings are reported with the apply. See Policy & Governance and Bounded non-determinism.