# ADR 0049: `std/file` — whole-file reads and writes **Status:** Proposed (2026-10-18); needs engineering review (#44). The `/ ` call surface below is amended by [ADR 0084](0084-capability-roots.md): the same operations are now `/ ` runtime-root effects, with `read`/`write` as UTF-8 wrappers over byte operations. ## Context The HTTP demo could not serve a file: std had no file IO at all (`std/io` is the console, `std/os` the environment). Meanwhile the runtime grew a **blocking pool** ([ADR 0005](0005-ffi.md)): externs can be declared `blocking`, running on a few worker threads while the actor waits, so a slow call never stalls a scheduler thread — its module doc already named file IO as a motivation, and `argon2` uses it for hashing. ## Decision A new module, **`std/file`**, with whole-file operations only: ```louise pub fn read :: path: String -> Result / // UTF-8 checked pub fn read_bytes :: path: String -> Result / pub fn write :: path: String content: String -> Result<(), String> / pub fn write_bytes :: path: String content: Bytes -> Result<(), String> / pub fn exists :: path: String -> Bool / // a file, not a directory pub fn size :: path: String -> Result / ``` - **Every operation is `/ `** and reports `Error` with the OS's message — the conventions of `std/net` and `std/tls` (OS services); `ffi` stays for foreign libraries. Nothing panics; a missing file is `Error("No such file or directory (os error 2)")`. - **All four externs are `blocking`** (`runtime/louise_rt/src/fs.rs`): they run on the blocking pool while the actor is parked. They never panic, perform or drop, as the pool requires; the interpreter implements them inline (`std::fs`), so `louise run` and interpreted tests see files too. - **No sandbox.** Which paths a request may reach is the program's decision; the demo's `static_file` rejects `..` and answers 404 for anything missing, mapping the extension to a content type (`GET /static/robots.txt` serves `./static/robots.txt`). ### Not in v0 Directory listing, removal, rename, permissions, append, and handles with streaming reads/writes. Streaming wants a `Resource` design (close semantics under the Perceus discipline and actor stops) and its own ADR section when a use case asks for it. ## Consequences - Five touch points per extern, as `docs/runtime-abi.md` lists: the std `@extern`s, `louise_rt`'s `fs.rs`, `louise_rt.h`, the interpreter, and the table in `louise_core::externs` (marked `blocking`, which implies `may_unwind`) — cross-checked by `louise_codegen_c/tests/externs.rs`. - `write` never creates directories; `Result` keeps that explicit. - The demo serves its pages as pug templates (ADR 0048) and its assets — the stylesheet included — from disk under `/static/` (`GET /static/style.css` → `./static/style.css`): a request path with `..` is a 404.