Skip to content

🐛 Truncate existing files opened in write mode #89

Description

@ccamel

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

  • Opening an existing file in write mode truncates it before output is written.
  • Writing a shorter payload through open(..., write, ...) and closing leaves exactly that shorter payload.
  • Append mode preserves existing contents before appended output.
  • Read-write mode does not truncate existing contents.

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions