Skip to main content

write_completion

Function write_completion 

Source
pub fn write_completion(
    records_root: &WorkdirRoot,
    outcome: &DelegationOutcome,
) -> Result<(), String>
Expand description

Write outcome to COMPLETION_FILE in the child’s records directory, replacing whatever was there.

Written to a sibling temporary file and renamed into place, never truncated in place. The parent reads this file once the completion has reached the delegating task, and report_completion rewrites it immediately after posting that completion — so a plain truncating write leaves a window in which the parent reads an empty or half-written file and records the delegation’s outcome as unknown. The rename makes every reader see either the whole previous content or the whole new content; WorkdirRoot::write_file’s temporary name is unique, because the child and the watcher behind it can both reach this function.

completion.json.seal is written beside it after every write (crate::record_seal::seal_listed); a seal that cannot be written leaves the file reading as unsealed and does not fail the write.