Skip to main content

Module execution_state

Module execution_state 

Source
Expand description

Execution state and receipt persistence (atomic write + schema-versioned migration).

Layer: state (layer 3).

Absorbed from the former shipper-state microcrate (Phase 2 decrating). This module provides atomic persistence for ExecutionState and Receipt with schema-versioned migration.

§Invariants

  • Writes are atomic: write to .tmp sibling, sync_all, then rename.
  • Forward-compatible schema: unknown receipt versions are best-effort deserialized.
  • v1 → v2 receipt migration fills missing git_context (null) and environment fields and rewrites receipt_version.

Constants§

CURRENT_PLAN_VERSION
Current plan schema version
CURRENT_RECEIPT_VERSION
Current receipt schema version
CURRENT_STATE_VERSION
Current state schema version
MINIMUM_SUPPORTED_VERSION
Minimum supported receipt schema version
RECEIPT_FILE
STATE_FILE

Functions§

clear_state
Clear state file (state.json) from state directory
fsync_parent_dir
Best-effort fsync of the parent directory after a rename, ensuring the directory entry update is durable on crash. Errors are silently ignored because not all platforms support opening a directory for sync (e.g. Windows).
has_incomplete_state
Check if there’s incomplete state (state.json exists but receipt.json doesn’t)
load_receipt
Load receipt from state directory with migration support
load_receipt_encrypted
Load receipt with encryption support
load_state
load_state_encrypted
Load state with encryption support
migrate_receipt
Migrate a receipt from an older schema version to the current version
receipt_path
save_state
save_state_encrypted
Save state with encryption support
state_path
validate_receipt_version
Validate receipt schema version
write_receipt
write_receipt_encrypted
Write receipt with encryption support