Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.threadify.dev/llms.txt

Use this file to discover all available pages before exploring further.

Contracts define business rules and validation logic that enforce how steps should execute and relate to each other. They provide real-time validation and ensure business processes follow defined patterns.

Contract Properties

  • Name - Unique identifier for the contract
  • Version - Supports contract evolution
  • Rules - Validation logic for steps and transitions
  • Entry Points - Valid starting steps
  • Terminal Steps - Steps that complete the thread
  • Timeouts - Maximum duration for steps and threads

Contract Structure

contract_name: order_fulfillment
version: 1
description: E-commerce order fulfillment workflow

# Entry points - where threads can start
entry_points:
  - order_placed

# Parties involved in the workflow
parties:
  - merchant
  - logistics

# Steps in the workflow
steps:
  - id: order_placed
    owner: merchant
    type: managed
    timeout: 5m
    business_context:
      required:
        - order_id
        - product_id
        - quantity
      optional:
        - customer_notes

  - id: inventory_checked
    owner: merchant
    type: managed
    timeout: 1m
    business_context:
      required:
        - in_stock
        - warehouse_id

  - id: shipment_created
    owner: logistics
    type: managed
    timeout: 24h
    business_context:
      required:
        - tracking_number
        - carrier_name

# Transitions define valid step flows
transitions:
  - from: order_placed
    to:
      - inventory_checked

  - from: inventory_checked
    to:
      - shipment_created
      - order_cancelled

# Terminal steps - where threads can end
terminal_steps:
  - order_delivered
  - order_cancelled

# Thread-level timeout
max_duration: 7d

Key Components

ComponentDescription
contract_nameUnique identifier for the contract
versionContract version number (supports evolution)
entry_pointsValid starting steps for threads
partiesRoles involved in the workflow
stepsStep definitions with timeouts and required fields
transitionsValid step-to-step flows
terminal_stepsSteps that complete the thread
max_durationThread-level timeout

Next Steps

Working with Contracts

Learn how to use contracts in your code

Tracking Workflows

Record steps in your workflow