pub fn write(
root: &Path,
snapshot: &ContextSnapshot,
) -> Result<StateWriteResult, String>Expand description
Write all artifacts. Each file is staged to a sibling *.tmp.<pid>.<nanos>
path, fsynced, then renamed into place, so an agent reading
.context-bar/AGENT.md (or any brief) never observes a truncated mid-write
file and the renamed bytes are durable on disk. Renames on the same
filesystem are atomic on POSIX and Windows ReplaceFileW.