Title here
Summary here
Status: Accepted Date: 2025-12-01 Supersedes: N/A Superseded by: N/A
AWF persists workflow state to JSON files during execution. Workflows can be long-running (minutes) and may be interrupted by signals, crashes, or concurrent access. A partial write would corrupt the state file, making workflow resumption impossible.
| Option | Pros | Cons |
|---|---|---|
| Atomic write (temp + rename) | Corruption-proof, OS-guaranteed atomicity on same filesystem | Requires same-filesystem temp, slightly more code |
| Direct write with fsync | Simpler code | Partial writes on crash, no protection against concurrent access |
| SQLite WAL | ACID transactions, concurrent reads | CGO dependency (already present), heavier for simple state |
Use temp file + rename pattern for all state file writes:
Rules:
flock for concurrent JSONStore accessWhat becomes easier:
awf status reads never see partial stateWhat becomes harder:
| Principle | Status | Justification |
|---|---|---|
| Security First | Compliant | Prevents data corruption, ensures integrity |
| Go Idioms | Compliant | Uses os.Rename which is atomic on POSIX |
| Error Taxonomy | Compliant | Write failures map to exit code 4 (system error) |