Summary
ioModeWrite uses O_CREATE | O_WRONLY without O_TRUNC in engine/stream.go:463-474. Append mode is distinct, so reopening an existing file with write can retain stale trailing bytes.
Why it matters
Prolog open(..., write, ...) must replace existing file contents. Retained suffixes make output depend on a file's previous contents.
Scope
Make write mode truncate existing files. Preserve append behavior and do not truncate files opened in read-write mode.
Acceptance criteria
Verification
Prefill a file with a longer payload, write a shorter payload through open(..., write, ...), close it, and assert that reading the file returns exactly the shorter payload.
Summary
ioModeWriteusesO_CREATE | O_WRONLYwithoutO_TRUNCinengine/stream.go:463-474. Append mode is distinct, so reopening an existing file withwritecan retain stale trailing bytes.Why it matters
Prolog
open(..., write, ...)must replace existing file contents. Retained suffixes make output depend on a file's previous contents.Scope
Make write mode truncate existing files. Preserve append behavior and do not truncate files opened in read-write mode.
Acceptance criteria
open(..., write, ...)and closing leaves exactly that shorter payload.Verification
Prefill a file with a longer payload, write a shorter payload through
open(..., write, ...), close it, and assert that reading the file returns exactly the shorter payload.