Skip to content
C.W.K.
Stream
Lesson 01 of 05 · published

Write Before Show

~12 min · loop, durability, record

Level 0Cold Stick
0 XP0/41 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

The Screen Is Not the Authority

A chat window teaches the wrong physics. Tokens appear, therefore they happened. A coding engine that believes that will lie after every crash. Firebrand inverts the order. A request is durable before the call leaves. A completed tool-call block is durable before anything runs. A result is durable before the model or the operator sees it. Deltas are written before they are drawn. The terminal may pretty-print Markdown after that write. Pretty-print is projection. It is not source.

The primitive under that rule is boring on purpose. A short write is not an error; the writer loops until the last byte lands. A replaced file is published through a temp on the same filesystem, a flush, a replace, and a parent flush so the rename survives power loss. A reader sees the old body or the new body, never a hybrid. A content-addressed artifact is read back and hashed after publication. A body that does not hash to its own name is unlinked and the step fails closed.

If it was shown, the record already has it. The opposite sentence — if it was shown, we will write it down later — is how a crash invents a turn nobody can replay.

What a Failed Write Means

Disk full or I/O error during a record write aborts the stream and closes the step as a record-write failure. Because render follows write, the operator did not see the missing bytes. After a process crash, nothing shown is missing. After power loss, at most the last unflushed delta batch is gone, and that step loads as an interrupt with its partial kept out of the transcript.

Code

The sandwich, one boundary at a time·text
intent durable  ->  stream  ->  commit  ->  show

request     fsynced before the call leaves
tool_call   fsynced before execute
tool_result fsynced before the model is fed
delta       written before the terminal draws it

External links

Exercise

Trace one feature in a tool you ship that displays model output. Mark the moment the bytes hit the screen and the moment they hit disk. If the screen comes first, write the crash that would invent a turn.
Hint
The invented turn is usually the last streaming sentence, the one everybody remembers and nobody can prove.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.