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
.tmpsibling,sync_all, then rename. - Forward-compatible schema: unknown receipt versions are best-effort deserialized.
- v1 → v2 receipt migration fills missing
git_context(null) andenvironmentfields and rewritesreceipt_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