# Changelog
Notable changes to `mojo-http`: the m0serve wheel, and the `m0` wheel,
which is versioned apart ([DECISIONS](docs/DECISIONS.md) D43) and recorded
in the m0serve release it ships beside. Format follows
[Keep a Changelog](https://keepachangelog.com/); versions follow
[SemVer](https://semver.org/). From 1.0.0 the served contract does not break
in a minor release: `m0serve`'s flags and environment variables, the
`M0-Hold`/`M0-Channel` response headers, and `m0pub.publish()`. A minor
leaves every other Thursday, and a behaviour change one ships on by
default is listed under **Behaviour changes**
([Releases](docs/RELEASES.md)).
## [Unreleased]
### Added
- **`m0 check` type-checks every function under `src/`, called or not**
(SPEC N58).
- A build skips a function nothing calls in the modules `server.mojo`
imports, so a misspelled method or a malformed `def` there builds.
- On an M4 (2026-12-03, mojo 1.2.0, the `auth` template): 0.3 s to the
first error, 2.7 s when there is none. It links nothing and writes no
binary.
- It instantiates nothing: a failing `comptime assert` is still found by
a build alone.
- **`Html.text` and `escape_html_into` take bytes**, so a column read into a
reused buffer (`m0_sqlite`'s `column_blob_into`) reaches the page with no
`String` per cell.
- On a page of 50 SQLite rows, three rounds on an M4 (2026-12-03, mojo
1.2.0), a prototype of it answered 18% more requests per CPU-second
than the released `m0`, 4% of it from the escaper below.
- **`m0_sqlite.TableWitness`: whether a table's pages were written**
(SPEC O32, [DECISIONS](docs/DECISIONS.md) D71).
- It reads the wal-index header and the headers of the WAL frames
committed since its last look, with no SQL.
- `look()` answers UNCHANGED, CHANGED or UNKNOWN. Anything it can't read
is UNKNOWN: page 1 written, a log reset, no `-shm`, another wal-index
version, no `dbstat`, a name no table answers to, a virtual table.
- Table names resolve as SQLite resolves them, without regard to case.
- Call `look()` before the read transaction a rendering uses, and
`settle()` after it.
- It sees every write path, a connection with triggers turned off and blob
I/O included, which a stamp doesn't.
- WAL mode only; it opens a read-only connection of its own.
- **`m0_sqlite.raise_floor(db)`: every client starts over** (SPEC O33,
[DECISIONS](docs/DECISIONS.md) D72).
- The head moves past every stamp given and the floor up to it, in a
transaction of its own. It answers the new head.
- `raise_floor_within(db)` does the same inside the caller's write
transaction, so the raise lands with what the caller writes beside it.
- "Past every stamp given" includes stamps a backup restore took back.
The head lands on the current time in microseconds (at SQLite's
millisecond resolution), or one past itself if that is later. It stays
below 2^53, so JavaScript reads it exactly. A clock set back can land
it below stamps given since the last raise.
- For a program that saw a write no stamp recorded. Below the floor, no
delta is vouched for, whether it was pruned or raised.
### Fixed
- **A note whose id comes back is one row on a live page** (SPEC N50).
- A note deleted and inserted again under its id, both above a
subscriber's stamp, is one stamp entry, born above it. The feed
appended it while the page still showed the old row, so Chromium
showed two `
` with one id.
- Each row the feed appends now comes after an out-of-band delete of its
id, which htmx skips when the id is not on the page.
- `poe browser-table-notes` (pre-release, not in CI) counts the rows in
Chromium under htmx 4.0.0.
- **A destroyed `TableWitness` no longer drops this process's SQLite locks**
(SPEC O32).
- The witness closed its `-shm` descriptor when it was destroyed. A POSIX
close of any of a file's descriptors drops every lock the process holds
on that file, SQLite's WAL locks included.
- On a POSIX-locking libsqlite3 (Ubuntu's, Debian's, Homebrew's), another
process could then run a TRUNCATE checkpoint under a reader that was
still reading. That is the corruption SQLite's "How To Corrupt" page
describes. Apple's libsqlite3 is not affected.
- The descriptor is now kept for the life of the process, which costs one
descriptor per witness.
- **`poe smoke-table-notes`' schema step no longer races the feed's tick**
(SPEC N48, N57).
- The step creates a table from another program, which moves the schema
version, and asked for the list at once, wanting a 304 and one
rendering. That holds only when the answer's own check is the one that
finds the change. The feed's tick checks too, every 50 ms, subscribers
or not.
- When the tick came first, the list already carried the raised head
(a 200). When it came between the answer and the count, two renderings
were counted. On an M4 (2026-12-02), the step failed 1 of 50 runs at its
shipped timing, and 5 of 5 with the tick made to come first.
- The step now waits up to 3 s for the floor to rise, by whichever check,
then wants the list at 200 under the raised head, two renderings, page 1
read again once (the witness's UNKNOWN), and the head the page carries
equal to the database's. It passed 50 of 50 runs, and 10 of 10 with the
tick first. Against a server whose check ignores a moved schema version,
it failed 3 of 3.
- The step no longer shows which check found the change: in it, the tick
always finds it first. Both checks run the same `_check`.
### Behaviour changes
- **`apps/table_notes` starts every client over when a write no stamp saw
reaches its first 100 rows** (SPEC N57, D72).
- The table's own triggers keep a copy of each row's title
(`notes_seen`), so such a write leaves the two different in the file.
- Each answer that serves the first page or what changed, and the feed's
tick, compares the first 100 rows with their copies. A difference
raises the floor: `/notes/changes` answers `reset`, and the feed sends
`resync`.
- A restore puts rows and copies back together, so it is found from a
head below the highest a thread has read, or from a moved schema
version. **A migration moves the schema version too, and starts every
client over.**
- Each thread's state also raises the floor as it starts. **So a client
from before any restart starts over once, and `since=0` after a start
is `reset`.**
- A write no stamp saw to a row beyond the first 100 is not seen until
the row comes into them.
- A raise takes the write lock, so it waits up to the busy timeout for
another writer.
- `GET /notes/changes` is now registered with `add_write`, still on the
pool, since the check updates the thread's state.
- Measured on an Apple M4 at 10,000 rows: a write's `GET /notes` costs
about 30 µs more, and each write 2–6 µs more for its copy.
- **A Mojo host view that answers `M0-Hold` is a 500, named on stderr**
(SPEC E45). The hold instruction is m0serve's, and a view on a Mojo mount
takes one there under `--realtime` (SPEC N11). On the Mojo host nothing
read it: the view's
short response went to the client with both instruction headers, the
connection was not held, and the server said nothing, on the loop and on
a pool thread alike. A view `ViewsApp` serves that answers `M0-Hold` is
now answered 500 without either header, and the host prints one line naming
the request and the fix, to open the stream on the loop with a
`DatastarStream` or a `Feed`. There is no switch: it would only put the
silent answer back. A handler of the application's own is unchanged.
It reaches applications built with `m0` in its next release.
### Changed
- **HTML escaping copies eight bytes at a time.** Per value on an M4
(2026-12-03, mojo 1.2.0): 61 to 34 ns for a 90-byte sentence with two
characters to escape, 133 to 21 ns for 200 bytes with none. A short value
dense with them is up to 17% slower (39 to 46 ns).
- **`apps/table_notes`' check reads the rows and their copies as two
ordered scans** (SPEC N57).
- The first 100 rows and their copies in `notes_seen` are read in id
order, on statements kept between answers, and merged as they are read.
A pair whose titles differ, a row with no copy at its id, and a copy
whose row is gone are each a difference, as before.
- No row is probed for its copy, nor a copy for its row, and the window's
bound needs no subquery. The page is rendered from the rows the check
read.
- A write's `GET /notes` goes from 106.3–107.8 µs to 79.9–80.1 (Apple M4,
`experiments/checked-page/results-merge-cost-2026-11-27.txt`).
- What the check finds is unchanged. The pressure harness passes as
before, on macOS and once on Linux, and every sabotage of it fails.
`poe sabotage-checked-page` has 23 rules, among them one for each of
the merge's three findings.
- **`apps/table_notes` renders its first page only when `notes` changed**
(SPEC N48, D71).
- On a moved clock it asks a `TableWitness`. A commit to another table now
costs no rendering, where it cost a whole one (68–78 µs against 3, Apple
M4).
- When `notes` changed, only the rows whose title changed are rendered.
- The page is never kept on a stamp, so a write with triggers turned off,
or by blob I/O, reaches it.
- `/stats` gains `looks`, `unchanged`, `changed`, `unknown` and
`rows_rendered`.
- **The server package is `m0_server`, renamed from `lightbug_http`**
([DECISIONS](docs/DECISIONS.md) D70). The hard fork of lightbug_http in
`packages/m0-http/`, and the package the `m0` wheel installs, no longer
take the name of the archived upstream, which still publishes a package
of its own under it. Breaking for a Mojo application, the `m0 new`
templates included: `from lightbug_http import ...` and every
`lightbug_http.` become `m0_server`, with the same names and
submodules, and nothing else changes. One command makes the edit in an
application's tree, with GNU or BSD tools:
```bash
grep -rl --include='*.mojo' lightbug_http . | xargs perl -pi -e 's/\blightbug_http\b/m0_server/g'
```
m0serve's served contract is unchanged. lightbug_http's licence ships in
both wheels as before, as `LICENSE.lightbug_http.txt`.
## [1.18.0] — 2026-11-19
The second release on the two-weekly train ([Releases](docs/RELEASES.md)),
with `m0 0.15.0` beside it. Five changes of behaviour are listed under
Behaviour changes. Three bring an ASGI application's answers to uvicorn's:
a response's head goes out when the application sends it, a streamed body
keeps the `Content-Length` its head declared, and a request not yet
answered hears its client leave. A WebSocket hold carries the cookies of
the view that approved it, and every line the server prints about itself
is on stderr. An ASGI application's requests all overlap, up to the
loop's connections, and the 257th no longer runs on the loop's thread.
`m0 0.15.0` carries the same framework and server: a Mojo host
application takes `--max-connections` and `M0_MAX_CONNECTIONS`, says on
stderr why a full loop refused, prints its notices on stderr, and its
handler pool reserves 28 B a connection slot where it reserved 2380. The
Mojo pin is unchanged at 1.2.0.
### Behaviour changes
- **An ASGI response's head is sent when the application sends it** (SPEC
L40). m0serve answered a response at its first body. A response whose
body follows its head at once, which is every plain response of
Starlette, FastAPI, FastHTML and Django, is unchanged. One that waits
between the two now has its head on the wire while it waits, as under
uvicorn:
- a stream nobody has written to yet (FastHTML's `EventStream`, a
`StreamingResponse` over a queue) opens in the browser, where
`EventSource` used to wait for the first event;
- when its client leaves, the application is cancelled, where it used
to keep the stream and its subscription until the next event;
- it no longer counts against the requests a loop hands its executor
at once (SPEC L43, under Fixed);
- an error raised after such a head truncates the response, where it
used to become a 500.
A response whose head declares a `Content-Length` is held for its body
as before, so Starlette's `FileResponse` keeps its length.
`M0_ASGI_HEAD_AT_START=0` puts the old answer back.
- **A streamed ASGI body keeps the `Content-Length` its head declared**
(SPEC L41). Every stream was framed chunked and its length dropped, so
Starlette's `FileResponse` lost the length of any file larger than one
64 KB chunk. Such a body is now sent under its length, unchunked, as
under uvicorn, and its connection is kept once it is whole; one that
ends short is closed, and a send that would pass the length raises
uvicorn's `RuntimeError: Response content longer than Content-Length`
in the application and aborts the stream. A stream that declares no
length is chunked as before. No switch: the response is the one the
application declared.
- **An ASGI application hears its client leave a request not yet
answered** (SPEC L42). `receive()` answers `http.disconnect` once the
client has finished sending, as under uvicorn, where it used to wait
for the life of the process: a long poll now ends when nobody is
listening. The request is not cancelled and its connection is not
closed, so a client that half-closes and waits is still answered,
unless its handler chooses to stop on the notice. No switch: an
application that never calls `receive()` after its body sees nothing.
- **A WebSocket hold carries the approving view's cookies** (SPEC I49).
A view that answers `M0-Hold: websocket` has its response discarded for
the `101` the server computes, and its `Set-Cookie` lines went with it:
a session written while approving a socket never reached the browser,
lost outright under signed-cookie sessions and an orphaned row under a
session store. Each line is now on the `101`, verbatim, as a `stream`
hold's head has always carried them, from the loop and from a pool
thread alike; a handshake the server refuses carries none. The
response's status, body and other headers are still discarded, and
[Running m0serve](docs/RUNNING.md#the-realtime-contract) now says so.
An application that set a cookie on that response and relied on it not
arriving will see it arrive. No switch: the cookies are the ones the
application set.
- **What the server says about itself goes to stderr.** m0serve and a
Mojo host application keep stdout for what was asked of them:
`--help`, `--version`, the report `--doctor` prints (still its last
line), the banner and the access log. Every other line they print is
on stderr, where it was on stdout:
- the usage and the reason for a command line that cannot be read
(exit 2);
- a configuration refused (exit 78: m0serve's checks, the host's
`host_checks`, and a handler's or a producer's `make` that raises);
- a startup that fails (exit 1: an application that cannot be loaded,
an address that cannot be bound, an event loop or a serving thread
that raised);
- the notices of a server that runs: each worker's `armed for a
graceful stop`, the supervisor's `[parent]` lines, an `M0_*` value
it could not read, an open-file limit it could not raise far enough,
an error it survives while serving, and what a drain left behind.
A supervisor or a script that read one of these lines from stdout
reads it from stderr now; `2>&1` puts them back on the one stream.
### Added
- **A FastHTML broadcast that reaches every worker** (SPEC L38).
[FastHTML on m0serve](docs/FASTHTML.md#reach-every-workers-sockets)
shows the lines: an `app.ws` connect hook subscribes its socket to
`scope["state"]["m0"]`, and a route publishes there. No server change;
`smoke-fasthtml` now serves those lines on two workers and counts what
each socket receives.
- **A page for FastHTML, and a weekly comparison behind it** (SPEC L36).
[FastHTML on m0serve](docs/FASTHTML.md) is the command, what to change
in an application, and each response that differs from uvicorn's. That
table is rendered from the list `uv run poe fasthtml-canary` holds the
server to: it installs the newest python-fasthtml and uvicorn, serves
FastHTML's example applications and four probe applications from both
servers, and fails on a difference the page does not list or a listed
one that is gone. It runs weekly in CI and files an issue when it fails.
`apps/fasthtml_demo` now ends in `serve()`, so the pull-request smoke
holds that the call does nothing under m0serve.
- **A Mojo host application takes `--max-connections` and
`M0_MAX_CONNECTIONS`** (SPEC E43, #658), as m0serve does: the
connections each loop holds, 1024 by default, 1 to 65536. A count
outside that is refused with 78 whichever way it came, the doctor too,
and the doctor reports the count, where it came from and what each loop
holds. A host loop now says once on stderr why it refused, as m0serve's
does: a stream answered `503` at the reserve, a connection that found
every slot in use, a body over its cap, and one that stopped arriving.
Before, a host application held 1008 streams a loop unless it set
`max_connections` in code, and printed nothing when a loop filled.
`AppConfig.server_config()` carries the variable's count, so an
application that builds its own `ServerConfig` from it reads it too
([Mojo host](docs/MOJO_HOST.md#configuration)).
- **An ASGI application on the buffered path says why a WebSocket did
not open** (SPEC L35). Under `--blocking-threads` above 0 an ASGI
application has no `websocket` scope: an upgrade reaches it as a plain
GET, which a FastAPI or Starlette socket route answers 404, and
nothing said why. The first upgrade a handler thread sees now prints
one line on stderr naming the path, the setting and the way back to
the executor. What the client is answered has not changed.
### Changed
- **m0serve compiles its Python shim once per process, where it compiled
it once per serving thread** (SPEC E44). Each pool thread, executor and
`--threads` loop, and each protocol detection at startup, executes a
copy of the one compile of its own. On an M4 under `--realtime` with
eight pool threads and 16384 connections, m0serve idles at 39.3 MB where
it idled at 41.0, and starts on 0.03 s of CPU where it took 0.07. Its
idle memory no longer moves from one start to the next: 30 starts under
14 spinning processes spanned 0.7 MB, where they spanned 14.1 MB, in
steps of a parse's freed memory the allocator kept
([the note](docs/notes/one-compile-a-process.md)).
- **An ASGI application on the asyncio executor reserves 1156 B a
connection slot idle, where it reserved 1696** (SPEC C27, #682): the
executor thread's own handler no longer sizes stream tables it never
drains, and a request's method, path and held WebSocket 101 are kept per
job in flight, at most as many as the executor takes at once (256, or
1024 for a lone executor: SPEC L43), instead of per slot. What remains
over a WSGI application served inline is the loop's stream outboxes,
which ASGI responses stream through
([the note](docs/notes/a-loop-keeps-slots-for-requests.md)).
- **A loop's handler pool reserves 28 B a connection slot, where it
reserved 2380** at the default eight threads (SPEC C26, #657). Its
request and response tables hold an entry per job in flight, at most
256, instead of one per slot, and a pool thread's handler no longer
sizes stream tables it never used. m0serve under `--realtime` with
eight threads holds 1145 B a slot idle where it held 3493, so
`--max-connections 65536` (fitted to 61136 on an M4) costs 102.7 MB
idle where it cost 239.6 MB. The Mojo host's pool
(`M0_BLOCKING_THREADS`) shares the tables and the change
([the note](docs/notes/a-loop-keeps-slots-for-requests.md)).
- **The m0serve wheel is classified
`Development Status :: 5 - Production/Stable`** on PyPI, matching the
1.x contract; it read `4 - Beta` since before 1.0.
- **`poe smoke-sim-loop` gates on the second-worst of 32 samples** (SPEC
N15). Its off-the-loop arm required the WORST of 24 `/now` samples under
100 ms, and `Tests` run 43811357500 failed it at 113 ms on macOS, on a
change that did not touch the app. Over 45 runs every Ubuntu job read
0 ms and macOS a tail of 8 to 40 ms beside it; on an M4 the same tail
appears with the cores taken, step or no step. Both arms now read
`second_now_ms` through `probelib.placement_summary`, as `smoke-ramp`
and `smoke-host` do, and the probe takes 32 samples so the on-the-loop
arm, which needs two of them to land early in a step, misses about one
run in 14,000 (one in 850 at 24). That arm still fails the bound: its
second-worst was 152 to 198 ms in 20 runs of 20. Each line carries the
worst sample and where it spent its time, and CI records
`sim.off_loop_second_now_ms` against the limit and the worst without one.
### Fixed
- **An ASGI application's requests all overlap, as under uvicorn, and the
257th no longer stops the server** (SPEC L39, L43, L44). A loop handed
its asyncio executor 256 requests at a time and ran the next on its own
thread: a handler that awaited there stopped every connection on the
loop, and SIGTERM, until it returned, and one that never returned
stopped them for good. 264 requests to a handler that sleeps did it, and
so did 264 `EventStream`s that had sent nothing. A loop serving one ASGI
application now hands over as many requests as it has connections, up
to 1024, the default `--max-connections`: 300 requests to a handler
that sleeps 3 s take 3.0 s, and 1,000 took 3.1 s. It costs 672 KB of
idle memory a loop. A request past that bound, or one whose submit the
executor's channel refuses, waits for room, oldest first, and never runs
on the loop's thread, and the loop says once on stderr that requests
are waiting. On Linux the channel holds 555 requests, so an application
that blocks its own asyncio loop with more than that behind it is
refused; what was refused is offered again after a wait that doubles to
64 ms, or as soon as a request is answered, and the loop spends about 1%
of a core meanwhile (SPEC L44). `M0_EXECUTOR_INFLIGHT=N` sets the bound,
never past the loop's connections (`256` puts the old bound back, with
the wait in place of the loop's thread); a value that is not a whole
number of requests is named on stderr and the default kept, and
`--doctor` reports the bound as `executor_inflight`. A mount set keeps
256 ([Running m0serve](docs/RUNNING.md#which-mode)).
- **A `def` handler of a FastAPI, FastHTML or Starlette application no
longer starts a thread per request** (SPEC L37). Starlette runs a `def`
handler on anyio's thread pool, and anyio ends each of the pool's threads
with the task it calls the root, which it finds by the callback
`run_until_complete` leaves. The ASGI executor served from a bare
`run_forever`, so the root was each request's own task: its thread was
told to stop as the request ended and the next request started another.
The executor's serving run is now one `run_until_complete`. State an
application keeps per thread (a `threading.local` connection) is kept
across requests, as under uvicorn. What it cost and what it costs now
is in [the note](docs/notes/a-root-task-for-the-executor.md).
- **An ASGI `websocket.accept` carries its headers and subprotocol**
(SPEC L34). The message's `headers` and `subprotocol` were not read:
the `101` went out with neither, so a cookie set while accepting a
socket was lost and a client that offered subprotocols was told none
was chosen.
The headers are now on the `101`, each `set-cookie` on its own line,
and the subprotocol is its `Sec-WebSocket-Protocol`. The handshake's
own headers stay the server's: an accept that names `connection`,
`upgrade`, `sec-websocket-accept`, `sec-websocket-extensions`,
`content-length` or `transfer-encoding` has them dropped, and a
`sec-websocket-protocol` among its headers gives way to the
`subprotocol` field. The subprotocol is not checked against what the
client offered.
## [1.17.0] — 2026-11-05
The first release on the two-weekly train ([Releases](docs/RELEASES.md)),
with `m0 0.14.0` beside it. Eight changes of behaviour or default are
listed under Behaviour changes; three of them change what a server does
before an application's code runs. It listens on `127.0.0.1` unless
`--host` or `M0_HOST` says otherwise, a held WebSocket opens only from its
own origin unless `--ws-origin` names more, and a full loop takes a slot
back from a connection idle a second. A loop holds the connections
`--max-connections` names, 1024 by default, raises the open-file limit to
fit them, and leaves its last slots to requests. `m0 0.14.0` carries the
same framework and server: a Mojo application listens on loopback, raises
its open-file limit, drains only the streams with output (the
`take_ready_streams` hook, which `ViewState` and `ViewsApp` carry), and
is refused with 78 when it leaves a view on one-process state to the
handler pool (SPEC E42). `m0 build --release` puts the licences in
`dist/licenses/`. The Mojo pin is unchanged at 1.2.0.
### Behaviour changes
- **A comment follows each SSE event, on by default** (SPEC I47, #641).
150 ms after the server writes an event on a stream it holds, it sends
`: flush`, unless another event went first, so a burst is followed by
one comment and a stream at 7 Hz or faster is sent none. Behind an
HTTP/2 proxy that forwards an event in two pieces, Safari's `fetch`
reader holds the second piece until a third arrives. On a quiet stream
the third piece was the next heartbeat, so a Datastar patch could wait
the full 15 s. A parser skips a comment line, so no client sees an
event it did not before; one that reads the stream's bytes sees the
comment. `M0_SSE_FLUSH_MS` sets the delay and `0` turns it off. A
stream an application writes through the chunk channel gets none, as it
gets no heartbeat ([the note](docs/notes/a-comment-after-an-event.md)).
- **Streams leave a loop's last slots to requests** (SPEC C20). Held SSE
streams and WebSockets take all but a sixteenth of a loop's
connections, at most 16, and the stream after that is answered `503`
with `Retry-After: 5`. Before, streams could take every slot, and each
connection after the last was reset at accept, the health check's among
them, so a load balancer marked a busy realtime server dead. The
default now holds 1008 streams per loop where it held 1024;
`--max-connections 1040` holds 1024 as before. The Mojo host has no
such flag yet (#658): a host application holds 1024 again by setting
`max_connections` to 1040 on `config.server_config()` and passing that
to `serve` as its second argument, or by serving another loop. A
browser's
`EventSource` does not reconnect after a `503`, so a page that should
keep trying reconnects on `error` itself
([the note](docs/notes/a-loop-keeps-slots-for-requests.md)).
- **A full loop takes a slot back for a new connection, on by default**
(SPEC C23). A connection that finds every one of a loop's slots in use
is given the slot of the connection idle longest between requests, once
that is a second, closed as the idle timeout would close it, or else of
the one that has been sending a request's head longest, once that is a
second, answered `408` as the header timeout answers it. A connection
answered a moment ago is never taken, since its next request may be in
its socket unread, so busy keep-alive clients lose nothing to newcomers,
and neither kind is taken while its timeout is off. Before, the new
connection was reset at accept while slots it could have had sat idle:
1008 streams beside the 16 idle connections of the page loads that
opened them reset the health check C20 keeps the reserve for, and 1024
idle keep-alive connections from one client reset every connection for
the 60 s of their idle timeout. A stream, a body arriving, a response
going out and a request being answered are never taken, and a loop
holding only those still resets the next connection. m0serve prints one
line the first time a loop is full, saying what it takes back, and the
Mojo host prints nothing yet (#658); `/__metrics` counts
`http_connections_reclaimed_total` and `http_connections_refused_total`;
`M0_RECLAIM=0` turns it off
([the note](docs/notes/a-full-loop-takes-back-an-idle-slot.md)).
- **The Mojo host refuses a pool view on one-process state** (SPEC E42).
Under `M0_BLOCKING_THREADS`, an application whose `max_threads()` is 1
(its state in one handler's memory, as `max_workers() -> 1` says) and
whose table leaves a view given the state off the loop exits 78, naming
the route: each pool thread builds a state of its own, so the m0
scaffold's list with one `on_loop=True` forgotten lost items to another
thread's copy, silently. Every template keeps its state's views on the
loop and is served as before; `on_loop=True`, a shared state with a
larger `max_threads()`, or no pool is the way out.
- **`x-thread` is off by default** (SPEC F26). Every response from a
handler-pool thread named the thread, which told every client the
server's thread layout. `M0_THREAD_HEADER=1` puts it back, for matching
interleaved log lines to responses.
- **The default `Server` header is `mojo-http`**, where it named the
archived upstream the server was forked from, `lightbug_http`. An
application that sets its own `Server` still sends only its own (A26).
- **The server listens on `127.0.0.1` unless told otherwise** (SPEC M31),
m0serve and the Mojo host alike, as uvicorn, gunicorn and Django's
runserver do. It listened on `0.0.0.0`, so a server tried on a laptop
answered the network the laptop was on. `--host 0.0.0.0` or
`M0_HOST=0.0.0.0` puts it back, and is what a container needs: every
image in this repository and the m0 scaffold's already set it.
- **A held WebSocket opens from its own origin** (SPEC I48). A handshake
whose `Origin` names another host than the request's `Host`, or the
first `X-Forwarded-Host`, is answered `403` before the upgrade, whatever
the view approved, and the first refusal prints a line naming the origin
and the switch. A browser attaches the site's cookies to a WebSocket
whatever page opens it, and the quickstart's view checked nothing. A
handshake with no `Origin`, which no browser sends, is still upgraded.
`--ws-origin ORIGIN` (repeatable; `M0_WS_ORIGIN`, comma-separated) names
more origins, and `*` allows every one, the old behaviour. An ASGI
application's sockets are its own to check, as under uvicorn.
### Added
- **`--max-connections N`** (`M0_MAX_CONNECTIONS`): the connections one
loop holds, 1024 by default and at most 65536 (SPEC C20). It was a
constant. The handler's per-slot tables follow it, `/__metrics` counts
`http_streams_held` and `http_streams_refused_total`, and `--doctor`
reports `max_connections` and `stream_limit`. Only m0serve reads the
flag and the variable; the Mojo host reads neither yet (#658).
- **`--ws-origin ORIGIN`** (`M0_WS_ORIGIN`): an origin a held WebSocket may
be opened from beside the server's own, `*` for any (SPEC I48); the
doctor reports `ws_origins`.
- **Releases leave on a train** ([Releases](docs/RELEASES.md)). A minor
every second Thursday, from 1.17.0 on 2026-11-05, with `m0` the same day
whenever anything it bundles changed, and a patch any time for a
security fix or a regression in the latest minor, the one version
supported. A behaviour change a minor ships on by default needs an off
switch and an entry under **Behaviour changes**, and a contract break
waits for a major after one minor of deprecation. Each of the next two
trains is a GitHub milestone. The policy page and `llms.txt` name the
next train, which `check-docs` holds to the version, and
`poe milestones` reports the days to it and any soak that would be stale
at its version ([the note](docs/notes/a-two-weekly-train.md)).
- **A Datastar stream can be compressed** (SPEC I45, I46; DECISIONS D69).
`DatastarStream.open(req, url, compress=True)`, or
`sse_response(zstd=accepts_zstd(req))`, sends the stream in zstd to a
client that accepts it. It uses one context for the stream's life and
flushes a block at every write, the heartbeat and the farewell
included, so each event decodes as it lands. libzstd is opened at run
time (`M0_LIBZSTD` names it), and where it cannot be opened the stream
goes out as written. A proxy still compresses buffered responses (J8),
and the deploy target's leaves streams alone
([the note](docs/notes/compressing-a-stream.md)).
- **The blobs demo compresses its stream with `M0_BLOBS_ZSTD=1`**, for a
client that offers zstd. Any other value is refused with exit 78. The
deploy leaves it unset. Measured at 100 and 400 viewers on an M4 core,
it costs 2.6 times the loop's CPU and 160 KB a stream, for 3.4:1. On
the deploy's own shared-cpu-1x x86, 150 compressed viewers took 21 % of
a core, against 6 % for 400 plain. If `fly.toml` sets the variable, the
deploy job's probe checks the coded stream, on a uv-managed Python
3.14. `bench_blobs_modes.py`'s client decodes a stream that a proxy
sends chunked.
`smoke-blobs-image` runs the image with it on. It checks that the
image's loader names a readable `libzstd.so.1`, and that the stream
decodes frame by frame. Its `--url` mode checks the same through the
proxy with `--zstd`. `bench_blobs_modes.py` gains `+zstd` and `before`
arms and counts the bytes on the wire, and `bench_hello_ab.py`
interleaves two hello builds
([the measurements](docs/notes/compressing-a-stream.md)).
### Changed
- **Held streams no longer slow a loop's other requests** (SPEC C24). Each
pass of the event loop asked the handler for the pending bytes of every
stream it held, idle or not, so on m0serve 1008 idle streams cost a loop
13% of its requests a second, and 15000 took a request's median from
0.035 ms to 0.37 ms. A pass now drains the streams with something to
send, and the health path under `--realtime` counts its subscribers as
they change rather than walking every slot: it answers 225k requests a
second at 0, 1008 and 4000 idle streams alike, where it answered 158k,
137k and 66k, and the 15000-stream median is 0.043 ms. A handler names
them through a new `HTTPService.take_ready_streams` hook, which defaults
to naming none, so a handler written for an earlier release keeps the
sweep of every stream and works as before. `SSERegistry`, `DatastarStream`,
`WSHub` and `Feed` keep the list, and a handler forwards their
`take_ready`; `ViewState` and `ViewsApp` carry the hook for a Mojo
application. `/__metrics` counts `http_stream_drain_visits_total`
([the note](docs/notes/a-pass-drains-only-what-has-output.md)).
- **CI runs on GIL-enabled CPython 3.14**, moved from 3.13. A setup step
fails a job whose pin resolved to a free-threaded build, and py-canary's
restore checks the build rather than the version string, which is the
same for 3.14 and 3.14t. m0serve's refusal of an ASGI application on a
free-threaded build now names the uv fix for a venv on 3.14t,
`uv python install 3.14 && uv sync --python 3.14+gil`
([RUNNING](docs/RUNNING.md)).
- **The macOS wheel is built and installed on `macos-15`**, GitHub having
retired every macOS 14 image on 2026-11-02. Its floor is the deployment
target the build sets, macOS 13.0, measured from the binaries as before.
### Fixed
- **A loop the open-file limit cannot hold at its count holds what the
limit leaves** (SPEC C25). Where the hard limit stopped the server's
raise short, a loop kept its count, and streams took every descriptor
before they reached the reserve C20 keeps for requests: under a hard
limit of 300, 400 holds got 276 answers and 124 resets, and the health
check read an EOF. Each loop is now cut to the limit less the server's
own descriptors and a margin for the application's files, and its
reserve is kept from that: under 300 a loop holds 242, streams 227 of
them (121 and 114 on Linux), and the health path is answered. The notice
names the count, and `--doctor` reports it. The raise counts two
descriptors a connection on Linux, where a stream's heartbeat timer is a
timerfd beside its socket: counted as one, a server raised under
systemd's soft 1024 would have run out near 640 of its 1008 streams. It
asks for the server's own descriptors too, which came out of the 256 of
headroom, and on macOS stops at
`kern.maxfilesperproc`, which Darwin 27 enforces above a soft limit it
accepts: `--max-connections 65536` reported a limit of 65792 that no
descriptor past 61440 could reach. The Mojo host does the same
([the note](docs/notes/a-loop-keeps-slots-for-requests.md)).
- **An m0 release artifact carries its licences** (SPEC N56). `m0 build
--release` put the Mojo runtime in `dist/` beside a binary that compiles
in the MIT-licensed framework and fork, and no licence text with either.
`dist/licenses/` now holds both MIT texts, the runtime's Apache 2.0 with
LLVM Exceptions, the MAX License copy m0serve has shipped since 1.16.0,
and a `NOTICE.txt` saying which covers what; `m0 image` copies it in
with the rest of `dist/`.
- **The server raises its own open-file limit** to what its connections
need, before it binds (SPEC C21). The soft limit, not the connection
count, was the real ceiling. Under launchd's default of 256, m0serve
held 208 streams while its banner said 1024, and the next connection and
every health check after it were reset. Raised only as far as needed,
never past the hard limit, and with one line when the hard limit stops
it short; `--doctor` reports `descriptor_limit`. The Mojo host does the
same.
- **A descriptor limit too low to start under is refused, not spun on**
(SPEC C22). Under a hard limit below what the server holds before its
first connection, a descriptor ran out somewhere in the startup: on
macOS the loop's `kqueue` failed after the pool had started, the unwind
freed the pool under its threads, and one spun on the freed job ring
holding the GIL, a core at 100 % that ignored SIGTERM (1.16.0 too); on
Linux the stdlib's print flush crashed. The server now exits 78 before
it starts anything, naming the limit, what the configuration holds
(about 8, and 16 more a loop plus 4 a pool thread) and the fix, and the
doctor says the same. A loop that still cannot start exits 1 naming the
call, unwinding nothing. The limit notice also stopped saying a loop
would hold "about 0" connections of a server that served
([the note](docs/notes/a-loop-keeps-slots-for-requests.md)).
- **A thread that cannot start is no longer joined** (SPEC E41). On
glibc, a `pthread_create` that `clone` refused, at a process or thread
limit, had already stored a descriptor in its id slot and freed it.
`ThreadSet.spawn` raised with that id left in place, so a caller that
cleaned up with `join_all` joined a freed descriptor, which is undefined
behaviour. The slot is zeroed now, which `join_all` and `join_within`
read as never spawned. datastar-builder's review found it, and nothing
in m0 joined after a failed spawn.
- **A state stream catches a stalled subscriber up at its next drain**
(SPEC I44). Under `DatastarStream(send_latest=True)`, a subscriber whose
full outbox refused a frame was left on the state before it until the
producer broadcast again, which a paused producer never did; `drain`
now queues the newest frame for a slot that is behind it. The change
stream is unchanged ([the note](docs/notes/latest-wins-after-a-stall.md)).
## [1.16.0] — 2026-10-23
The toolchain moves to Mojo 1.2.0, and nothing served changes. The m0serve
wheel bundles the 1.2.0 runtime, and now a copy of the MAX License beside
it. `m0 0.13.0` is gated on Mojo 1.2.0, and,
where MAX is installed, on `max-core` 26.7.0: `m0 0.12.0` refuses a project
on 1.2.0 and 0.13.0 refuses one still on 1.1.0, so an application built
with `m0` moves both pins together, and `m0 new` writes `mojo==1.2.0` from
now on. Application code that names `FileDescriptor`, `std.hashlib` or
`std.io.write`'s `Writable` meets the same renames the tree did (see
Changed).
### Changed
- **The pinned toolchain is Mojo 1.2.0** (was 1.1.0), with `max-core`
26.7.0 in the `max` group. Nothing served changes. Its parser rounds
correctly: the shortest forms of 120,000 doubles each parse to the
double they name, where 1.1.0 parsed 3,442 of the same decimals to a
neighbour, so m0-postgres's text-mode `float()` and m0-core's
`parse_json_number` read what they are given. Printing still misses by
one unit in the last place, so the ROADMAP known issue now names the
printer alone. What the move cost in source: `RawFileDescriptor` for
`FileDescriptor` (43 files), built from a `c_int` (260 sites) and read
back as one (28); a `c_int` descriptor in the tree's six `read` and
`write` declarations, to match the stdlib's, which changed; `std.hash`
for `std.hashlib` and `std.format` for `std.io.write` (one each); seven
`^` transfers to a borrowed argument, which 1.2.0 warns are no-ops — the
warning ratchet's floor stays 0; and three test helpers that build a
`String` from bytes without a `StringSpan`, which 1.2.0 can refuse to
compile depending on what it elaborated first (CLAUDE.md pattern 11).
The `mut` copy-back rule, the `cc` the linker needs, and the output the
sabotage harnesses parse were re-measured and are unchanged. The wheels
still declare `LicenseRef-MAX-Platform-Software-License`, which now names
the MAX License of 2026-10-21 (docs/FFI_DISTRIBUTION.md). 1.2.0 does not
fix the free-threaded `PyObject` header (modular/modular#5726): building
the executor's Python type under 3.14t still crashes, so an ASGI
application on a free-threaded build is still refused with exit 78.
`scripts/probes/free_threaded_module_probe.mojo` is the re-test, since
the refusal hides the crash from every smoke. The write-up
is [docs/notes/the-pin-moves-to-1-2-0.md](docs/notes/the-pin-moves-to-1-2-0.md).
- **The m0serve wheel and bundle ship a copy of the MAX License**
(`LICENSE.max.txt`, the terms of 2026-10-21) beside the Apache text the
bundled Mojo runtime already carried. Modular's `mojo-compiler` 1.2.0
wheel names that licence in its metadata, and the licence permits
shipping the runtime inside an application on condition that a copy of
its terms goes with it; the Apache compliance is unchanged
([docs/FFI_DISTRIBUTION.md](docs/FFI_DISTRIBUTION.md)). An application
that distributes an `m0 build --release` artifact or an `m0 image`
carries the same runtime, and `m0` does not yet add the copy to those.
## [1.15.0] — 2026-10-11
The fixes from a review of the WSGI and ASGI gateway, the SQLite and
PostgreSQL bindings, the `m0` wheel and m0-core, and the two issues
reported against 1.14.0. A client could forge a header that a proxy sets:
a request header whose name holds an underscore reached a WSGI application
under the same `HTTP_*` key as its dashed spelling, so `X_Forwarded_For`
could overwrite the proxy's `X-Forwarded-For`. m0-sqlite handed SQLite a
closed connection's handle, which crashes the process on Debian's and
Ubuntu's libsqlite3. A SIGTERM no longer waits out its 5 s budget for a
keep-alive connection holding a stray CRLF (#611), and `m0serve` installed
from the wheel no longer aborts when its interpreter's sysconfig names a
library directory that is not there (#612). Two changes touch the served
contract (see Changed): a request header whose name holds an underscore is
dropped before it reaches a WSGI application, or an ASGI application
served through `--blocking-threads`; and `--replay-frames` or
`M0_REPLAY_FRAMES` above 4096 is refused at startup with exit 78. The `m0`
wheel ships the framework's source, so an application built with `m0`
takes the framework's fixes by rebuilding against `m0 0.12.0`; the template
fixes reach the projects `m0 new` writes from now on.
### Changed
- **The README states only what no other page owns, and links the rest.**
Its m0serve reference (flags, discovery, the ready line, modes, mounts,
`--doctor`, limits, exit codes), its benchmark block, its history and its
repeated statements of the contract, the platforms and TLS are links to
the pages that own them; it went from 974 lines to 583 and from 23
unsourced figures to none. Four facts only the README held moved to
RUNNING.md: which `libpython` m0serve loads, how a mount's prefix reaches
its application, which WSGI bodies stream, and what `--doctor`'s JSON
carries ([the note](docs/notes/the-readme-points.md)).
- **A request header whose name holds an underscore no longer reaches a
WSGI application.** CGI's mapping turns `-` into `_`, so
`X_Forwarded_For` and `X-Forwarded-For` both became
`HTTP_X_FORWARDED_FOR`, and the environ kept whichever the request
carried later: behind a proxy that forwards underscore names (HAProxy,
Caddy and Traefik do; nginx drops them by default), a client could
replace the address, scheme or identity header the proxy set, the
CVE-2015-0219 class. Such a header is now dropped from the environ, as
gunicorn has dropped it by default since 22.0 and as Django's runserver
does. Dashed names pass as before, `X-Forwarded-*` included. An ASGI
application under the executor still receives every name as sent; the
buffered ASGI path (`--blocking-threads` on an ASGI application), whose
scope is built from the environ, drops them with it (SPEC G29).
- **`--replay-frames` (and `M0_REPLAY_FRAMES`) above 4096 is refused with
exit 78.** Under `--realtime` each loop keeps up to that many frames of up
to 64 KB each, and a full journal shifts its entries on the loop thread for
every publish, so a depth like 100000 pinned hundreds of megabytes and
slowed every publish with nothing said. The refusal is a rule in the list
`--doctor` reads, so the doctor exits 78 too, with or without `--realtime`.
It is asked after the rules a flag combination can fail, so `--pg-listen`
without `--realtime` beside a deep journal is still the usage error's
exit 2. 0 and every depth up to 4096 are accepted as before (SPEC I43).
### Fixed
- **A keep-alive connection holding a stray CRLF or the start of its next
request no longer holds the SIGTERM drain to its 5 s budget** (#611).
The drain closed a connection between requests only when its receive
buffer was empty, and the buffer keeps an answered request's bytes
whenever anything follows them, so one extra CRLF after a request, or a
head still arriving, kept the process up 5.1 s where it otherwise exits
in under 0.1 s, past a Fly machine's default `kill_timeout`. A head that
has not wholly arrived is a request not yet made: the drain now closes
its connection as it closes an idle one, as uvicorn does, and waits
only for requests whose head has arrived, a body still arriving among
them (D9). When the budget does end a drain, it now prints one line
saying what it leaves (SPEC D14, D15).
- **`m0serve` from the wheel no longer aborts when sysconfig's `LIBDIR`
is not on disk** (#612). A relocatable interpreter can report the
build machine's `LIBDIR` (python-build-standalone's 3.12.7 says
`/install/lib`), so the console shim named no libpython, and the
binary's runtime, finding none either, aborted at its first Python call
with a native stack dump and exit 133, `--doctor` included. The shim now
also searches `LIBPL` and `sys.base_prefix`'s `lib/`, a search that
holds every path the runtime's own lookup tries; where it still finds
nothing it exits 78, naming `MOJO_PYTHON_LIBRARY`, before the binary
runs. It no longer skips an interpreter that reports
`Py_ENABLE_SHARED=0`: a macOS framework build (python.org's installer,
Apple's command-line tools) does, and keeps a library to name. A static
build with no shared library, which used to abort the same way, now
gets the 78 (SPEC M30).
- **An ASGI application's `state["m0"].publish` numbers its frames as
`m0pub` does, from 1.** It took the shared counter's previous value
where every other publisher (`m0pub`, `--pg-listen`, the Mojo side)
takes that value plus one, so on a server where an ASGI application
publishes beside one of them, two frames could carry one id: a hold
that received the first dropped the second with nothing logged, and a
reconnect the replay journal could have served whole was sent
`m0-gap` instead. A fresh server's first ASGI publish was id 0, which
no first-visit subscriber receives (SPEC L12).
- **A WebSocket hold that presents a `Last-Event-ID` ahead of the
counter is no longer silent.** Since 1.12.0 an SSE hold clamps an id
this server never allocated, a previous incarnation's, to the head; a
socket hold still subscribed at the id it presented, so every
numbered frame was suppressed until the counter passed it, under a
clean log. A socket hold is now clamped the same way, inline and from
a pool thread alike, and is still not caught up. A browser cannot put
the header on an upgrade, so this reached other clients only (SPEC
I12).
- **A `--max-body` or `M0_MAX_BODY` too large for an integer is refused, not
wrapped.** `17179869184g` (2^64 bytes) wrapped to a 0-byte cap, so every
request with a body got a 413, and `9999999999g` wrapped negative and left
the 4 MB default standing with no message. The flag now exits 2, and
`M0_MAX_BODY` is ignored out loud like any unreadable `M0_*` value, the
4 MB cap standing (SPEC C1).
- **`--doctor` reports `replay_frames` as 0 without `--realtime`**,
where the server keeps no journal whatever `--replay-frames` says. It
reported the flag's value, 64 by default.
- **m0-sqlite: a `Connection` used after `close()`, or a `Statement` after
`finalize()`, no longer crashes the process on Debian's libsqlite3.**
`in_transaction`, `last_insert_rowid`, `changes`, `total_changes`,
`busy_timeout` and `register_array_module` handed SQLite the closed
connection's NULL handle, which a library built without
`SQLITE_ENABLE_API_ARMOR` dereferences, so the process died of SIGSEGV
on Debian 12's, the base of `deploy/mojo/Dockerfile`. Apple's and
Homebrew's builds carry the armor and answered wrongly instead:
`in_transaction()` was True after the close, and
`register_array_module()` leaked its module buffer. The four accessors
now answer False or 0 on a closed connection without calling SQLite,
and `busy_timeout` and `register_array_module` raise "… on a closed
connection", as `create_function` already did. A finalized statement's
handle is NULL too, and `clear_bindings()` handed it to SQLite the same
way, where Apple's library answered success and did nothing: it now
raises "… on a finalized statement", and so does `column_name()`,
whose entry point checks for NULL only under the armor too (SPEC O29).
- **m0-sqlite: `execute` and the `Connection` constructors refuse a NUL
byte instead of running what comes before it.** `sqlite3_exec` and
`sqlite3_open_v2` read C strings, so `execute("DELETE FROM t\0 WHERE
id = 5")` emptied the table and reported success, and a path holding a
NUL opened the path cut there, losing a suffix the caller had checked
for. Both now raise before SQLite sees the text, with the byte's offset
and `(rc=21)`, so `error_code` answers `SQLITE_MISUSE`, as a function
name holding one already was (SPEC O30). `prepare` was not affected.
- **m0-sqlite: `prune_stamps` raises the error that stopped it.** When
SQLite had already cancelled the transaction (`SQLITE_FULL`,
`SQLITE_IOERR`, `SQLITE_NOMEM`), the prune's own ROLLBACK raised
"cannot rollback - no transaction is active" in its place, so
`error_code` read 1 instead of the real code. It now rolls back only a
transaction that is still open, and always raises the original error
(SPEC O26).
- **m0-postgres: `notifies()` delivers every notification libpq already
holds before it reports a lost connection.** A burst of NOTIFYs followed
by the server's close (a restart, a failover, `pg_terminate_backend`) was
read off the socket in one go, and the next call raised on the close with
the rest still queued; `reset()`, the recovery, then freed them, so all
but the first were lost and nothing logged them. `notifies()` now takes
from libpq's queue first, reads the socket only when the queue is empty,
and raises only when nothing is left. The `--pg-listen` listener drains
until None and resets on a raise, so it now publishes the whole burst
before it reconnects (SPEC O15).
- **m0-postgres: a `reset()` whose re-`LISTEN` fails no longer forgets
channels, or stops at the first.** `reset()` emptied its list of
channels before listening on them again, so when one re-`LISTEN` raised
(a reconnect that landed on a standby, a second drop), every channel not
yet restored left the list, and each later `reset()` restored fewer,
silently. It now re-`LISTEN`s every channel, collects the ones that fail
and raises once at the end naming each, so a channel that cannot be
restored leaves the others listening; the list is kept whole, so the
next `reset()` tries every channel again (SPEC O15).
- **m0-postgres: `Result.int` raises for a text-mode value past 64 bits
instead of wrapping.** The `sum()` of an `int8` column is `numeric`, and
a total beyond 9223372036854775807 read as a plausible number (2^64 as 0)
with no error. It now raises "… does not fit in a 64-bit integer";
-9223372036854775808 still parses (SPEC O31).
- **`parse_json_int` no longer wraps an integer past `Int`'s range, and
`parse_json_bool` no longer reads `truex` as true.** `{"n":18446744073709551617}`
came back as 1; it is now `None`, as is any value outside
-9223372036854775808..9223372036854775807. A boolean literal must end at
whitespace, `,`, `}`, `]` or the end of the body, so `trueish` and
`falsehood` are `None`. The m0 wheel ships `m0-core`, so an m0 application
takes the fix by rebuilding.
- **`m0` command-line fixes** (the `m0` wheel, not m0serve):
- `m0 doctor` run on a `bin/server` that dies by a signal (an `abort()`,
a crash before `serve`) no longer exits 250 or 245, outside the
documented 0, 1, 2 and 78; it is exit 1, saying
`bin/server --doctor died of signal N`.
- `m0 new m0` and `m0 new mojo` (and `max-core`, `mojo-compiler`) are
refused with exit 2: the scaffold pins a requirement of that name, so
the project would depend on itself and `uv sync` could never meet it.
- `m0 dev` asks the toolchain checks again before each rebuild. After
`uv add --dev 'm0==X'` moved the watched `pyproject.toml` it compiled
the new framework with the old `mojo`; now it prints the refusal and
the old server keeps serving.
- `m0 build --release` on Linux checks for `patchelf` first (exit 78
naming `apt-get install patchelf`; `m0 doctor` does not ask), where
it used to fail after the whole compile; `docs/MOJO_DEPLOY.md` names it.
- A failed `install_name_tool -add_rpath` or `codesign` in the release
build (`relocate.py`, `bundle_artifact.py`) now fails it, and a binary
that lacks a search path it was to carry is refused, instead of a
`dist/server` that cannot load its runtime.
- `m0 new .` accepts a directory holding only `.git`, as after
`git init` or `gh repo create --clone`, and leaves it untouched.
- `m0 image` tags with the project's name from `pyproject.toml` rather
than the directory's, so a checkout under `Shop` no longer fails on
docker's lowercase rule.
- **The `board` template no longer builds a board frame bigger than a
slot's 64 KB outbox** (the `m0` wheel). Fifty messages of 1500
bytes, each escaped, rendered to several times that, and a frame over
the cap is refused for every slot: the poster got a 200 and no tab was
updated, with nothing logged. `render_board` now renders the newest
messages that fit a byte budget, so the frame always goes out. A full
state frame fitting the outbox is now a line of the scaffold's
`AGENTS.md`.
- **The `views` and `auth` templates no longer split their list across
pool threads under `--blocking-threads`** (the `m0` wheel). Their
views ran on the pool, where each thread builds a state of its own, so
an item created on one thread was missing from a list another answered.
Every view that touches the list is now `on_loop=True`, as `board`'s
are. The scaffold's `.gitignore` also lists the four files its smokes
and `m0 build` leave behind (`.dist.next/`, `smoke.one`, `smoke.two`,
`smoke.jar`), and the `views`, `auth` and `live` smokes serve on
`127.0.0.1` rather than every interface. All of this reaches
the applications `m0 new` scaffolds from now on; one already scaffolded
applies it by hand, since a template is written once.
- **README's "SSE replay is journal-deep" limit still said a WSGI hold
replays nothing**, and that an application keeps its own catch-up. 1.12.0
made that false (SPEC I33): the bullet now says a hold is caught up from
the per-loop `--replay-frames` journal and sent one `m0-gap` frame when it
cannot be, as RUNNING.md and the `m0pub` docstring do. Its
`DatastarStream` half said a client further behind than the journal
resumes live; since SPEC I30 it is sent no history and `caught_up(slot)`
answers false, so the view resyncs it with `send_to`. The same section
gave the Mojo pin as 1.0; it is 1.1.
- **Six more README claims the tree had moved past.** A handler's
optional hooks were "the empty defaults shown here" beside an example
that shows none; `m0-http` "uses three functions" of `m0-core`, where it
imports from ten files; m0serve's exit codes omitted 78, which the
`--doctor` example below them exits with; uploads were raised through
`ServerConfig.max_request_body_size`, a field an m0serve user cannot
reach, rather than `--max-body`; a buffered `FileResponse` was "the
recorded follow-up", with no record anywhere; and "Two more things it
does" listed three. RUNNING.md offered `--threads` from 3.13t, which is
a dead end; it is 3.14t.
## [1.14.0] — 2026-10-10
The fixes and the smaller code of a review of the framework and the fork
for quality. Two of its findings were defects no gate had seen. Under
`--max-keepalive-requests`, a streamed response served as a connection's
last request left the connection open, and the next stream on it was cut
off after its head; a stream now carries the cap to its end and says
`Connection: close`. Under `--reload`, a worker forked into an index the
supervisor had given up on could outlive its supervisor. A static mount
answers `304` to an `If-None-Match` that drops the weak `W/`, a `Range`
bound that is not plain digits is no range at all, and a stream whose
client has gone is closed by the send that fails rather than a pass of the
loop later. Nothing in the served contract changes. The rest is the code
made smaller: what was written twice is written once, names nothing read
are gone, and two fork names say what they are, so a Mojo application that
imported one of those changes an import (see Changed and Removed). The
`m0` wheel ships the framework's source, so an application built with `m0`
takes these by rebuilding against `m0 0.11.0`.
### Fixed
- **A reload no longer orphans a worker it forked into an index the
supervisor had given up on.** Under `--reload`, a worker that crashed
past its respawn budget left its index vacant and the polling supervisor
counting one worker fewer; the next reload forked a replacement into that
index with the rest, as it should (the edit may be the fix), but the count
stood, so once the rest had gone the supervisor exited, with 1, and the
replacement served on with nothing supervising it. The supervisor now
counts what it supervises from the live pids after every reload, and a
give-up a reload has undone no longer sets the exit.
- **A stream frame whose write registration the kernel refuses closes its
connection from every path.** A frame the socket took only in part waits
for writability; when that registration failed, the heartbeat and the
outbox drain left the slot as it stood, half a frame sent and no event to
finish it, until the idle deadline, if any, where the WebSocket reader
closed it. One rule now: the slot closes and its handler is told, as for
a client that is gone. The write-ready path's own retry closes on the same
refusal.
- **The keep-alive cap lands on a stream as it lands on any response.**
Under `--max-keepalive-requests N`, a chunked stream served as request N
skipped the cap and ended kept-alive with the connection's count at N;
the next stream on that connection skipped it too, and a second check in
the loop closed the connection once that stream's head had landed: a
chunked head and nothing after it, and an ordinary request there was
served, one past the cap. Now the cap is applied before the
head goes out, for a stream as for anything else, and a stream carries
it to its end: the head says `Connection: close`, the stream arrives
whole, and the connection ends after it. The count check that cut the
second stream is gone. A WebSocket upgrade on the cap request is as it
was: its handshake cannot say `close`, and its connection ends with the
socket.
- **A static mount compares `If-None-Match` weakly** (RFC 9110 §13.1.2).
`StaticFiles` tags each file with a weak `ETag` (`W/"…"`) and compared a
client's `If-None-Match` with it as written, so a client or cache that
sent the tag back without its `W/` read the whole file with `200` where
the RFC's weak comparison answers `304`. `StaticFiles`, `etag_matches`
and `conditional` now share one rule: the opaque tags are equal,
whichever side is marked weak. An application that calls `etag_matches`
gets the weak comparison too.
- **The `409` a pool thread answers for a streaming response reads
`thread's`**. A Mojo handler that begins a stream on a pool thread (the
Mojo host under `M0_BLOCKING_THREADS`, or a `--mount PREFIX=mojo`
mount) is refused with a JSON body that ended `not this thread s`; it
ends `not this thread's`.
### Changed
- **A stream whose client has gone is closed by the send that fails.**
When a frame an application queued (an SSE event, a WebSocket message, a
piece of a streamed body) failed to send for any reason but a full
socket buffer, the connection waited to be reported writable and closed
a pass of the event loop later. It now closes in that pass, and the
handler is told then (`sse_slot_disconnected`), as it already was when
a heartbeat or a WebSocket pong found the client gone.
- **A `Range` bound is digits alone, as RFC 9110 writes it.** `StaticFiles`
read a bound with Mojo's `Int()`, which takes a sign and blanks around
the number: `bytes=+0-1` and `bytes= 0-1` were served as ranges, and
`bytes=--5` answered `416`. A bound that is not plain digits now makes
the header no range at all, and the whole file is served with `200`.
- **The fork's kqueue, epoll, pipe, socketpair and process wrappers raise
`SysError`**, the error the socket wrappers raise, so the message the
server prints when one fails reads as the socket calls' do:
`pipe() failed, errno: 24` is now `pipe: Too many open files (errno 24)`.
- **`m0_http` exports what the hosts import.** `from m0_http import`
names `EX_CONFIG`, `SharedAtomics`, `shared_store`, `parse_int`,
`read_long_flag`, `is_long_flag`, `DOCTOR_OK`, `Report` and
`parse_env_int`, which m0serve and the Mojo host reached into modules
for. Ten names that nothing outside their module read are no longer
re-exported from the package; import each from its module:
`STANDARD_VERBS` (`m0_http.html`), `LOGIN_KEY_MIN` (`m0_http.login`),
`find_key` and `GRANT_COOKIE_ENV` (`m0_http.grant`),
`CSRF_MESSAGE_PREFIX`, `SESSION_SIG_CHARS`, `SESSION_SUBJECT_MAX` and
`SESSION_VERSION` (`m0_http.session`), and `int_list_env` and
`spawned_worker_index` (`m0_http.prefork`). Nothing served changes.
- **Sessions and grants share one key ring.** `KeyRing` (`m0_http.grant`,
exported from `m0_http`) holds the keys a signed token may carry;
`SessionKeys` is its alias and is used as before, and `GrantKeys` holds
one as `ring`, so code that read `GrantKeys.keys` reads
`GrantKeys.ring.keys`. Nothing served changes.
- **Two fork names say what they are.** Nothing served changes; an
application built with the `m0` wheel that named one renames it: the
request side's `URIParseError` (`lightbug_http.http.request`, an arm of
`RequestBuildError`) is `RequestURIError`, no longer sharing a name with
`lightbug_http.uri.URIParseError`, and `OffloadPool.stream_active()` is
`executor_active()`, which is what it answers.
- **Code `m0-http` carried twice is written once.** Nothing served changes
beyond the entries above. In the fork: the response's span constructor and
`encode()` go through the owning constructor and `encode_into`; the
chunked decoder's byte moves are one `_shift_down`; the two WebSocket
frame encoders share `_frame_header`; the backends' `try_add_read` and
`try_add_write_oneshot` are `EventLoopBackend` defaults, so a backend an
application writes may drop its copies; the macOS close-on-exec mark of a
fresh descriptor is `mark_fresh_cloexec` at its seven sites; the RFC 9110
list walk under `Transfer-Encoding`, `Connection`, `If-None-Match`,
`Accept`, `Vary`, `Allow` and the form check is `lightbug_http.strings`'
`trim_ows` and `next_list_member`; the event loop's descriptor-to-slot
lookup, its chunked-body decode and its "body is complete" tail are one
function each, the heartbeat, the WebSocket reader's replies and the
outbox drain send a stream frame through one, and its pass raises nothing;
the offload channels' tags, little-endian codec and bounded send are
`lightbug_http.offload_wire`, which `offload.mojo` imports back name for
name; and `ProvisionPool` counts with `std.bit`. In the framework: the
supervisor's exit accounting and the post-fork prologue, the integers the
environment readers and the `Range` parser read (`parse_env_int`), the
HTTP token check (`is_token_char`), the outbox bound `WSHub` shares with
SSE, and the Mojo host's two serve paths, which build the same pre-fork
pieces and refuse in the same words.
### Removed
- **Fork and framework names nothing read.** Nothing served changes. The
`m0` wheel ships the source, so an application built with `m0` that
named one of these needs its own copy: `HTTPRequest.server_is_tls` and
its constructor argument; `lightbug_http.websocket`'s `WS_CLOSE_NORMAL`
and `base64_encode` (the handshake encodes with the standard library's
`std.base64.b64encode`); `lightbug_http.loop.state.TIMER_HEADER`, whose
timer nothing armed; `OffloadLoopState.slot_is_executor` (ask
`OffloadPool.slot_is_executor`); the `ProvisionError` arm of
`lightbug_http.server.ServerError`, never raised; `m0_http.sse`'s
`format_sse_heartbeat_bytes`; and `StaticFiles.matches`. The
`server_is_tls` argument sat just before `invent_headers` in
`HTTPRequest.__init__`, so a caller that passed it by position now sets
`invent_headers` with that value. No caller in the tree passes
`invent_headers` by position.
## [1.13.0] — 2026-10-09
The rest of the fixes from the review of the server's HTTP core, the
`lightbug_http` fork, whose security fixes shipped in 1.12.1. A client
pipelining a burst of requests could hold the event loop for more than a
second, stalling every other connection on it. On Linux a `100 Continue`
could be cut short ahead of its response when the send buffer was full,
and a client still sending its headers at the header timeout read a reset
instead of its `408`. Half-closed and pipelined connections are answered
in full, a stream open when the server stops ends cleanly, the memory a
large upload grew is reused by later connections, and requests the RFCs
call malformed are refused, a `CONNECT` with `501` among them. One change
touches the served contract: a port outside 1-65535, from `--port` or
`M0_PORT`, is refused at startup with exit 78, where `M0_PORT=0` served on
a port the kernel chose and `--port 0` exited 2 (see Changed). The fork's
unused code is gone, which changes nothing served but removes names a Mojo
application could import. The `m0` wheel ships the framework's source, so
an application built with `m0` takes these fixes by rebuilding against
`m0 0.10.0`.
### Fixed
- **A request head is answered the same however its bytes arrive** (SPEC
B29, fork review LF66; A3's LF59 is its duplicate). A request sent after
two empty lines was refused with 400 when it
arrived in one read and served when a read ended between the empty
lines: where the server looked for the end of the head depended on how
much the read before had brought. It is refused either way now. Where a
head ends and how its body is framed is decided in one place, which the
request fuzzer that runs on every change holds to this, and to a chunked
body read a piece at a time (SPEC B30).
- **A carriage return before a request's first line is refused** (SPEC
B29, fork review LF67). A request whose first line came after a lone
carriage return (a CR with no line feed behind it) was served when it
arrived in one piece, its method read from the byte after the CR, and
refused when it arrived in two. RFC 9112 makes a lone CR invalid; it is
answered 400 either way now. Empty lines before a request, each a CR and
a line feed, are still skipped.
- **A client that half-closes is answered with `Connection: close`, and
its connection ends behind the answer** (SPEC A27). A client that shuts
down its write side after its request has sent its last one, but when
the request did not itself ask for a close the answer said `keep-alive`,
and on Linux the connection was then held until the idle timeout (for
good with `--idle-timeout 0`) waiting for a request that could not come.
Requests pipelined ahead of the last one are still answered first.
- **A half-closed request with a long head is answered** (SPEC A29). A
client that sent a request whose headers were longer than 4 KB (a large
cookie, a long token) and then shut down its write side could have its
connection closed with no answer, the rest of its headers still unread.
It is now read to its end and answered.
- **A client that pipelines and half-closes gets every answer when the
first comes from a pool thread or the ASGI executor** (SPEC A30). With
`--blocking-threads` or an ASGI application, when that answer went out
only in part and the client's half-close was seen in the same moment,
the connection closed as soon as the answer finished, and the requests
pipelined behind it were never answered. They are now, and the
connection closes after the last. Answers the event loop runs itself
were not affected.
- **A streamed response honours `Connection: close`** (SPEC A28). An ASGI
application's streamed body, or a WSGI application's streamed iterable
on a pool thread, goes out chunked over HTTP/1.1, and when the request
asked for `Connection: close` the response still said `keep-alive` and
the connection stayed open after the body ended. It now says `close`
and closes once the body is complete, as an unstreamed response does.
- **A stream open when the server is told to stop ends cleanly** (SPEC
D12, D13). The drain says goodbye to every open stream before closing
it, and wrote that goodbye where nothing may be written: into a streamed
ASGI or WSGI body, where a client's chunked parser failed on it; into a
WebSocket that had already sent its Close, as a second one; and into the
middle of a frame still going out. Those streams now close as they
stand, and the client reads the end of the connection; an SSE stream or
WebSocket the server writes itself still gets its goodbye.
- **The access log times a keep-alive request when the header timeout is
off** (SPEC F22). A server whose `ServerConfig` set
`header_read_timeout = 0` logged the `dur_us` of every request after a
connection's first as the time since the machine booted, and recorded
no latency for them on `/__metrics`. They now run from the request's
first bytes, as they always did with the timeout on; a connection's
first request is timed from its accept, as before. m0serve and the Mojo
host keep the default of 10 s, and were not affected.
- **A WebSocket the application has stopped reading stays stopped while
its close completes** (SPEC I41). When an application falls behind the
messages a client sends, the server stops reading that socket until the
application catches up. Once the server's Close went out it started
reading again, so the messages queued for a slow application kept
growing for as long as the client went on sending. The socket now waits
for the client's Close without reading until the application resumes
it, or until the two-second close linger ends it.
- **A `CONNECT` request is answered 501 and its connection closed** (SPEC
B18). It reached the application, and one that answers every method
answered it 200, which a proxy forwarding `CONNECT` reads as an open
tunnel: whatever the client sent next would pass through it unparsed.
This server implements no tunnel, so no application, on m0serve or the
Mojo host, receives `CONNECT` any more.
- **A chunked request body in another transfer coding as well is answered
501 and its connection closed** (SPEC B21). `Transfer-Encoding: gzip,
chunked` was de-chunked and the body handed to the application still
gzipped. The server decodes `chunked` only, and now says so with 501, as
RFC 9112 §6.1 asks. A `Transfer-Encoding` whose last coding is not
`chunked` (a lone `gzip`, `chunked, gzip`) is still 400, as RFC 9112
§6.3 requires.
- **A request target that is not a URI the server serves is answered 400**
(SPEC B19). `GET p` and `GET host:80` reached the application as a path
with no leading slash, and a target holding a raw byte above ASCII
(`/caf\xe9`) as a path that is not UTF-8. A target now opens with `/`,
is an `http` or `https` URI, or is `*` on an `OPTIONS` request; a
non-ASCII character must be percent-encoded, as every browser does, and
the escape still reaches the application undecoded.
- **A server-wide `OPTIONS *` reaches the application as `*`** (SPEC
B19). It arrived as `OPTIONS /`, so an application could not tell a
question about the whole server from one about its root page. A Mojo
application reads `*` as `req.uri.path`; a WSGI application reads it as
`PATH_INFO` and an ASGI one as `path` and `raw_path`, as gunicorn and
uvicorn hand it on. Under m0serve the root mount answers it; with no
root mount it is answered 404, as any path no mount claims. The view
table (`Views`) reads `*` as a path of one segment: a table with a
one-segment parameter route such as `/:slug` answers `OPTIONS *` as that
route's preflight, 204 with its `Allow`, and a route registered for
`OPTIONS` there runs with `*` as its parameter; a table with no such
route answers 404.
- **`URI.parse` reads a query that follows the host directly** (SPEC A35).
Exposed: an m0 application whose tests build a request with
`URI.parse("http://127.0.0.1?x=1")`. The host was `127.0.0.1?x=1` and
the request carried no query; with a port, `http://127.0.0.1:80?x=1`,
the query was dropped. The path is `/` and the query `x=1`, as for
`http://127.0.0.1/?x=1`. A `#` right after the host ends it too:
`http://127.0.0.1#top` is host `127.0.0.1` and path `/`, where the host
was `127.0.0.1#top`. A request from the wire was never affected.
- **`URI.parse` refuses a port that is not one** (SPEC A36). Exposed: an
m0 application that parses a URL with `URI.parse`, its tests' request
builders among them. `:99999` was read as port 34463, `:65536` as port
0 and `:8x` as port 8; each now raises. An empty port
(`http://127.0.0.1:/x`), which raised, is read as no port, the scheme's
default, as RFC 3986 §3.2.3 allows.
- **A cookie a Mojo view builds can no longer add attributes of its own**
(SPEC G2). Exposed: an m0 application that builds a `Cookie` from
request data and sets it with `ResponseCookieJar.set_cookie`. Each field
was written as given, so `Cookie("theme", "dark; Domain=evil.test")`
went out as `theme=dark; Domain=evil.test`, a cookie for another site.
A built cookie whose name is not a token (`a b`, `c=d`, an empty name),
or whose value, `Domain` or `Path` holds a `;` or a control byte, is now
dropped from the response, silently, as a header holding a line break
is: nothing is logged. Every other value is written as before, a space,
a comma, quotes, a backslash or a byte above 0x7F included, so a base64
or JSON value goes out unchanged. A `Set-Cookie` line an application
hands `add_raw`, which is how every WSGI and ASGI application's cookies
arrive, is still sent as given.
- **A built cookie with no `Path` and one with `Path=/` are two cookies.**
Exposed: an m0 application that sets the same cookie name twice in one
response through `ResponseCookieJar.set_cookie`, once without a `Path`
and once with `Path=/`. The jar treated a missing `Path` as `/` and kept
only the second. A browser gives a cookie with no `Path` the request's
directory (RFC 6265 §5.1.4), so it stores both. Both are now sent. An
empty `Path`, or one not starting with `/`, means the same as none.
- **`NotFound(path)` no longer writes the path into its body.** Exposed:
an m0 application that answers with `lightbug_http`'s `NotFound`, as the
WebSocket examples do. The body was `path not found`, the
request's own bytes, markup included, in the server's answer; it is now
`Not Found`. The argument is still accepted, and may be left out.
- **An empty `Host` is accepted when the target names no host** (SPEC
B20). RFC 9110 §7.2 asks a client to send `Host` with an empty value
when the URI it requests has no authority, and every empty `Host` was
answered 400. It is accepted on an origin-form (`/path`) or `*` target,
and the application reads an empty `HTTP_HOST`; beside an absolute-form
target (`http://host/path`) it is still refused, as is a missing `Host`.
- **`Connection: close` closes the connection whichever `Connection` line
carries it** (SPEC B22). A request with two `Connection` lines was read
by its last alone, so `close` on the first was lost and the connection
kept open. The lines are now one list, in order, as RFC 9110 §5.3 reads
them, and the application sees them combined.
- **A request head with a bare LF is answered 400 as soon as it arrives**
(SPEC B23). A head of bare-LF lines (`GET / HTTP/1.1\nHost: x\n\n`) was
never served, but got no answer until the client closed or the header
timeout sent 408, holding a connection slot meanwhile.
- **A chunked body whose trailer value holds a control byte is refused
with 400** (SPEC B24), as a request header's value is. Trailers are
discarded, so no application ever read one; the two rules now agree.
- **An inbound WebSocket message no longer waits on a quiet pool lane for
the next request** (SPEC I39). Exposed: m0serve under `--realtime` with
a handler pool, its default, where a Python view holds a WebSocket with
`M0-Hold: websocket`. Each message is handed to the pool with a wake for
a thread that is parked, and one that arrived while none was (every
thread busy, spinning, or a moment from parking) woke nobody: the thread
that parked next did not look for it, and the view was handed it only
when a later request woke the pool, on a quiet server never. A thread now
looks for a message once more after it announces its park. Found by the
fork review; with a sleep holding that moment open, 24 messages of 24
waited.
- **A cross-worker bus frame is delivered whole or not at all** (SPEC
I40). Exposed: a publish whose channel name and frame together passed
about 69.6 KB, through `m0pub.publish()`, `scope["state"]["m0"]`,
`BroadcastBus.publish` or `DatastarStream` with the bus: a 5,000-byte
channel with a 64 KB frame reached the other workers' subscribers 904
bytes short, the end of the frame silently missing, though every
publisher had accepted it. Each loop now reads every datagram a
publisher can send whole, up to a 65,535-byte channel with a 65,536-byte
frame, into one buffer it keeps instead of allocating and zeroing 70 KB
on every drain. A datagram longer than that, or malformed, is refused
and counted: `http_bus_frames_refused_total` on `/__metrics`, which
counts the stream chunk channel's datagrams too (an ASGI executor and a
streaming `--blocking-threads` pool write that channel in the same
codec, and the same reader drains it).
- **A `DatastarStream` reads a `Last-Event-ID` the way the server's held
streams do.** Exposed: an m0 application that calls `DatastarStream.open`
with a request it built itself, whose `Last-Event-ID` carries whitespace
around the id. `open` read `" 12 "` as 0 and replayed the whole journal
where the client had seen up to 12; it now resumes after 12. The stream
and the server's held streams share one parser
(`lightbug_http.hold.request_last_event_id`), so the two cannot read an
id differently again. A request from the wire was never affected: the
server trims the whitespace before either parser sees the value.
- **WebSocket frames and upgrades the RFC calls malformed are refused with
1002 or 400** (SPEC I35-I38). A client frame whose 64-bit length has its
high bit set, or whose length is not in the shortest encoding that holds
it, now closes the connection with 1002 (it was 1009, or accepted). A
control frame (ping, pong, close) declaring more than 125 bytes is
refused when its header arrives, not after its payload. The upgrade
request must list `upgrade` as a whole token of `Connection`
(`Connection: notupgrade` was accepted) and must be HTTP/1.1; an
HTTP/1.0 request is answered 400.
- **On Linux, a connection on a descriptor numbered 65536 or above no
longer disturbs another's timer, or the application's tick** (fork
review LF18, SPEC C11). Exposed: Linux servers whose descriptor limit
(`ulimit -n`) lets a connection reach descriptor 65536, m0serve and Mojo
applications alike. The epoll backend kept each timer in one of five
regions of 65536 slots, so a higher descriptor's timer took another's
slot: an SSE stream on descriptor 65536 re-armed the `M0_APP_TICK_MS`
tick and, when it ended, stopped the tick for good; a request body read
on descriptor 131072 + k re-armed descriptor k's heartbeat; and a stream
at or above 131072 got no heartbeat, a body at or above 262144 no read
timeout. Every timer now has a slot of its own at any descriptor below
2^20, which a process reaches only with a descriptor limit
(`RLIMIT_NOFILE`) above a million.
- **A server that returns gives back its kqueue or epoll descriptor**
(fork review LF21, SPEC C13). Exposed: a Mojo application that serves,
returns and serves again in one process (`Server.serve_nonblocking`,
`listen_and_serve`), and the Mojo host's `M0_THREADS` loops as they
end; m0serve and a host process exit when their loops do, so they
never reached it. Each return left its multiplexer open, and on Linux
every timerfd the loop still held. The backend now closes them when the
loop is done with it. On Linux, an epoll registration the kernel
refuses is now reported with its own error: a refused ADD was retried as
a MOD, whose ENOENT was reported in its place.
- **On Linux, a burst of new connections queues instead of being
dropped** (fork review LF19, SPEC C12). Exposed: Linux servers, m0serve
and Mojo applications alike. The listener asked the kernel for an accept
queue of 128, so while the loop was busy -- a slow pass, a batch of
accepts -- connections past the 128th were dropped at the handshake, and
each client waited a second or more to retry. The queue is now up to
`SOMAXCONN` (4096 on Linux, 128 on macOS), or the system's setting if
that is lower. macOS's limit was and stays 128.
- **Two request cookie jars of two or more cookies compare equal** (fork
review LF30, SPEC G22). Exposed: an m0 application that compares
`RequestCookieJar`s with `==`. A jar of two or more cookies was unequal
even to a jar parsed from the same `Cookie` field, since every cookie of
one was compared with every cookie of the other. Jars are now equal when
they hold the same names with the same values, in any order. The server
itself never compares jars.
- **A bracketed listen address with a colon in its port is refused**
(fork review LF33, SPEC A31). Exposed: a Mojo application that passes
`Server.listen_and_serve` an IPv6 address such as `[::1]:8:0`. The port
was read after the last colon, so that address listened on a port the
kernel chose, and `[::1]:8:80` on port 80. It is now refused at startup
as too many colons, as Go's `net.SplitHostPort` refuses it.
- **A listen address of `localhost` with no port is refused** (fork review
LF45, SPEC A33). Exposed: a Mojo application that passes
`Server.listen_and_serve` (or `ListenConfig.listen`) the bare word
`localhost`. It was read as the loopback at port 0, so the server
listened on a port the kernel chose and named it to no one. It is now
refused at startup as missing its port, as `127.0.0.1` alone always
was; `localhost:8080` is unchanged. m0serve and the Mojo host always
pass a port.
- **A listen address's port must be digits** (fork review LF46, SPEC
A34). Exposed: a Mojo application that passes `Server.listen_and_serve`
(or `ListenConfig.listen`) an address whose port text is not plain
digits. The port was read the way `Int()` reads a number, taking a sign,
whitespace and underscores, so `127.0.0.1:-0` listened on a port the
kernel chose and `127.0.0.1:+80`, `127.0.0.1: 80` or `127.0.0.1:8_0` on
port 80. Such a port is now refused at startup. m0serve and the Mojo
host check `--port` themselves and pass it on as digits.
- **The "listening on" line names the port the server is bound to**
(fork review LF47, SPEC F25). Exposed: a Mojo application that passes
`Server.listen_and_serve` (or `ListenConfig.listen`) a port of 0, such as
an application not on the Mojo host, which takes a port the kernel
chooses. The line read `Lightbug is listening on http://127.0.0.1:0`, a
port nothing can connect to; it now names the port the kernel chose.
m0serve and the Mojo host refuse a port of 0 (LF56, below) and never
reach it.
- **A listen address with an IPv6 zone is refused on every platform, and
a refused listen address says why** (fork review LF48, SPEC E31, M5).
Exposed: m0serve or a Mojo host given `--host fe80::1%en0`, and a Mojo
application passing such an address to `Server.listen_and_serve`. On
macOS, whose libc reads the zone into the address, it listened on that
interface's link-local address and was reported without its zone; on
Linux it was refused as not an address. A listen host may not contain
`%` now, on either. m0serve and the host refuse such an address at
startup with exit 78, before anything is bound, as the new `address`
check that `--doctor` reports too: the server used to fail at the bind
with exit 1 while the doctor said 0. Every refused listen address now
names the rule it broke: the error read "Failed to parse listen address"
and stopped there, and now goes on with the reason ("a listen host may
not contain '%'", "missing port separator", "too many colons").
`AddressParseError` carries that reason (`AddressParseError(reason)`)
and is no longer a `CustomError` or `ImplicitlyCopyable`.
- **An `M0_*` number too large to hold is ignored, not wrapped** (fork
review LF49, SPEC F19). Exposed: m0serve and Mojo host applications
started with a numeric `M0_*` variable whose digits pass 2^63, such as
`M0_PORT=18446744073709551696`. The digits were added up with no
overflow check, so that value served on port 80, and
`M0_WORKERS=18446744073709551618` forked two workers. Such a value is
now read as unreadable, as `M0_PORT=80eighty` always was: the default
is used, and m0serve's startup says so, naming the largest number it
reads.
- **`Socket.receive` and `TCPConnection.read` into a full buffer read what
is waiting** (fork review LF34, SPEC A32). Exposed: an m0 application
that reads a socket through either, into a `Bytes` with no room past its
length (one already full, or a `Bytes()` never given a capacity). The
read asked for zero bytes and reported the peer's EOF with its bytes
still waiting. The buffer now grows by 4 KB before the read. The server
itself reads through its event loop and never called these.
- **`/__metrics` counts a 101 in a `1xx` status class** (fork review LF32,
SPEC F23). Exposed: m0serve and Mojo applications run with `--metrics`
that hold WebSockets. Each upgrade's 101 Switching Protocols was in
`http_requests_total` and in none of `http_responses_total`'s classes,
so the classes summed to less than the total. It is now in
`http_responses_total{status="1xx"}`, and `http_requests_total`'s help
text says what it has always counted: requests answered, as each
response's head lands, not requests received.
- **A `Host` that names no host is refused with 400** (fork review LF64,
SPEC B27). Exposed: m0serve and every Mojo application. A request whose
`Host` was not a host name, an IP address or a bracketed IPv6 address,
with an optional port of digits -- `Host: a b`, `Host: u@a`, a name in
raw UTF-8 -- was served, and an application that reads the site from
`Host` read it. RFC 9112 asks for 400, which is now the answer, and so
is it for an absolute-form target (`GET http://.../`) whose authority
has the same fault. An empty `Host` is still accepted where the target
names no authority. A client sends an internationalized name as
punycode, as browsers do. An IPv6 zone ID in `Host` (`[fe80::1%25eth0]`,
or the raw `%eth0` older Python `http.client` builds send) is refused
too, deliberately: browsers, curl and Go never send one.
- **A `Transfer-Encoding` that only Unicode reads as `chunked` is
refused** (fork review LF58, SPEC B3). Exposed: m0serve and every Mojo
application behind a front end that forwards a transfer coding it does
not know. Coding names were lowercased by Unicode's rules, which turn
the KELVIN SIGN (U+212A) into `k`, so `Transfer-Encoding: chuned`
was read as `chunked` and its body framed by chunks, where every other
server and proxy reads an unknown coding: two framings of one request,
the ingredient of request smuggling. Coding names are now compared in
ASCII, and that request is refused with 400 like any other whose last
coding is not `chunked`.
- **`req.uri.host` and `req.uri.port` no longer depend on the request's
target** (fork review LF54, SPEC A37). Exposed: a Mojo application that
reads them. With the server on `0.0.0.0:8973`, `GET /x` read host
`0.0.0.0:8973` and no port while `GET /x?q=1` read host `0.0.0.0` and
port 8973. Every request now reads the server's host and port. The host
a client asked for is the `Host` header, which for `GET http://h/p` is
`h`. `HTTPRequest.from_parsed` takes the server's host and port, split
once by `split_server_address`, where it took the whole address.
- **A chunked request body whose chunk header holds something other than
the size and an extension is refused** (fork review LF60, SPEC B28).
Exposed: m0serve and every Mojo application. Whatever followed a chunk's
size up to the line's end was skipped, so `5 5` was read as a chunk of
five bytes where other servers refuse it or read 0x55, and a control
byte inside a chunk extension was accepted. Such a body is now refused
with 400. A chunk extension (`5;name=value`) is still accepted and
ignored, and so, as a leniency (the grammar has none), is whitespace
between the size and the line's end.
- **`Upgrade`, `Range` and `Accept` are case-folded in ASCII only** (fork
review LF63, SPEC I38, J2, G14). Exposed: m0serve with WebSockets or
`--static`, and Mojo applications that negotiate a vendor media type.
Each was compared after Unicode lowercasing, which turns the KELVIN SIGN
(U+212A) into `k` and an overlong two-byte encoding into an ASCII letter:
`Upgrade: websocet` was answered 101 and the connection switched
to WebSocket where every other server and proxy reads an unknown
protocol, a `Range` whose unit was such a spelling of `bytes` was served
as a range, and an `Accept` naming such a spelling of a registered
vendor type matched it. Each is now refused or ignored as other servers
do, and `WebSocket`, `BYTES=` and `Application/VND.X` still match.
- **An `Accept` weight is read from the parameter named `q`, in any case**
(fork review LF69, SPEC N53). Exposed: Mojo applications that negotiate
with `parse_accept`. The weight was found by searching an entry's
parameters for the text `q=`, so `text/html;Q=0` did not refuse HTML, a
parameter such as `xq=0` refused its type, and `q= 0.5`, with a space
after the `=`, read as a refusal. The weight is now the first parameter
whose name is `q` in any case, and spaces around its `=` are read past.
- **`HTTPRequest.encode()` writes the target it was given** (fork review
LF62, SPEC A38). Exposed: a Mojo application that writes a request out
(a proxy view, a test), and `String(req)`. The request line carried the
percent-decoded path: `/a%20b` went out as `/a b`, an encoded CR LF in a
URL as a real line break that split the request, and `OPTIONS *` as
`OPTIONS /`. It now carries `req.uri.request_uri`, the target as it
arrived or as the URL spelled it.
- **The memory a large upload grew is reused by later connections, not
kept for its connection's slot** (fork review LF25, SPEC C17, I42).
Exposed: m0serve and Mojo applications that accept large request bodies.
A connection's receive buffer grows to the largest request it holds, and
closing the connection kept that buffer for the next connection on the
same slot alone: a burst of 64 concurrent 4 MB uploads pinned about
400 MB to the slots it used, and a second burst arriving while those slots
were busy added as much again. A buffer grown past 64 KB now goes back to
the allocator when its connection closes, as does the buffer a large
response left on a keep-alive connection, and a WebSocket's buffers when
the socket closes, so later bursts reuse that memory instead of adding
to it. On macOS the process's resident size after a burst can still
stay near its peak, the allocator keeping what is freed for reuse; on
Linux the freed buffers go back to the system. A fragmented WebSocket
message now reaches the application without being copied once more.
- **A request body read after its headers is measured by its own size**
(SPEC C18, fork review LF70). Three uploads within the limits were
refused depending on how the client's writes fell after its headers. A
body whose last bytes came in the same read as the next pipelined
request was answered `400 Bad Request` when the headers and body were
both near their limits; a chunked body at `--max-body` was refused
`413` when its chunks came after its headers, though accepted when
they came with them; and a chunked body over the limit behind long
headers got `400` and an immediate close, where every other oversized
body gets `413` and the lingering close that lets a client still
uploading read it. A body read after its headers is now measured by
its own size and, for a chunked one, by what its framing cost. Headers
are held to the receive buffer's limit on their own (fork review LF72,
below).
- **A client that pipelines a burst of requests no longer stalls the
server** (SPEC A41, C19, fork review LF72). A client that sent many
requests at once without waiting for the answers -- 20,000 small GETs,
about 540 KB -- held the event loop for more than a second and a half
while they were answered, every other connection on that loop waiting,
and the cost grew with the square of the burst. A connection now gets
one read's worth of the loop at a time and the rest on later turns, and
a burst costs the same per request whatever its size (1.2 µs a request
measured for both 2,500 and 20,000, where 20,000 cost 78 µs each).
Pipelining in moderation is cheaper too: 16 requests at a time cost
about a quarter less per request. With the limits an application can
lower in `ServerConfig`, such a burst was also refused
`400 Bad Request` partway through, and a request whose body, or a
request behind it, came in the same read as its headers was refused 400
where it was answered when they came apart. A request's headers are now
held to the receive limit on their own, whatever arrives behind them.
- **`100 Continue` is never cut short ahead of a response** (SPEC A42,
fork review LF73). A client that sends `Expect: 100-continue` (curl does
for a large upload) is told to go ahead with an interim response before
the final one. On Linux, when the connection's send buffer was nearly
full -- a client pipelining a request behind answers it had not read yet
-- the kernel could take only part of it, and the rest was dropped: the
client then read a fragment followed by the real response, which it
cannot parse. What the send does not take now goes out first: ahead of
the answer, so the client reads a whole `100 Continue`, late if the
buffer was full, then its response; and in one piece with an error that
ends the request, so a send cut short leaves the stream truncated before
the close, never an error behind a fragment.
- **A client still sending its headers when the header timeout passes
reads the `408`** (SPEC A5, fork review LF75). The server answered
`408 Request Timeout` and closed the connection with the rest of the
client's headers unread, which resets the connection: on Linux the
client saw "connection reset by peer" instead of the 408. The 408 now
goes out with the same lingering close a `413` gets -- the server stops
writing, reads and discards what the client is still sending for up to
five seconds, then closes -- so the client reads the answer.
### Changed
- **A port outside 1-65535 is refused with exit 78, from a flag or the
environment alike** (fork review LF56, SPEC E30, E31, M2). Affects
m0serve and Mojo host applications given `--port 0`, `M0_PORT=0`, or a
port past 65535. `M0_PORT=0` served on a port the kernel chose, which
m0serve's startup line named as `:0`, while `--port 0` was a usage error
(exit 2). Both are now read and then refused at startup with exit 78,
before anything is bound, as a count the server will not serve already
was: `M0_PORT must be between 1 and 65535, got 0` from m0serve and
`M0_PORT must be 1-65535, got 0` from the host, the fix naming `--port`
and `M0_PORT`. `--doctor` reports it as the `port` check, now the first
of each list. A script that read exit 2 for `--port 0` reads 78 now.
- **The fork's descriptor helpers live in the module that owns them**
(fork review LF28). Nothing served changes. An application built with
the `m0` wheel that imported one of these from the old place imports it
from the new: `set_nonblocking`, `is_nonblocking`, `F_GETFL` and
`F_SETFL` from `lightbug_http.c.fcntl`, no longer `lightbug_http.c.kqueue`
(they serve Linux too); `O_NONBLOCK` and `O_CLOEXEC` from
`lightbug_http.c.fcntl`, no longer `lightbug_http.c.socket`; and
`set_tcp_nodelay` from `lightbug_http.c.socket`.
- **`recv` and `send` take their length from the span they are given**
(fork review LF20, SPEC G21). Nothing served changes. The two calls in
`lightbug_http.c.socket` took a length beside the span, which the span
did not have to back: a count above the span's length was written past
its end. They now read or write `len(span)` bytes and no more, so an
application built with the `m0` wheel that called one drops the length
argument, slicing the span to the count it meant. To receive into a
list's spare capacity, pass `spare_capacity(list)` and grow the list by
what `recv` returns.
- **`HTTPRequest.from_parsed` takes the server's host and port** (fork
review LF54, SPEC A37). An application built with the `m0` wheel that
called `from_parsed(server_addr, parsed, body, max_uri_length)` passes
`from_parsed(host, port, parsed, body, max_uri_length)`, splitting its
address once with `split_server_address`. And `req.uri.host` no longer
carries the port on a request whose target has no query or escape:
with the server on `0.0.0.0:8973` it was `0.0.0.0:8973` there and
`0.0.0.0` elsewhere, and is `0.0.0.0` now, the port in `req.uri.port`.
- **`HTTPRequest.encode()` and `write_to` write `req.uri.request_uri`**
(fork review LF62, SPEC A38). An application that edits a parsed
request's `uri.path` or `uri.query_string` and then writes the request
out (a proxy-style view) sets `uri.request_uri` instead: the writers no
longer rebuild the target from the decoded path and the query.
### Removed
- **The fork's client connect path, and the last of its dead C bindings**
(fork review LF26). Nothing served changes: m0serve and the Mojo host
never open a connection, and reached none of it. The `m0` wheel ships
the fork's source, so an application built with `m0` that named one of
these needs its own copy: `Socket.connect` and
`lightbug_http.connection.create_connection`, with the `connect(2)`
binding in `lightbug_http.c.socket`; the `getaddrinfo` machinery under
them in `lightbug_http.address` (`getaddrinfo`, `get_ip_address`,
`CAddrInfo`, `AnAddrInfo`, `addrinfo_macos`, `addrinfo_unix`,
`freeaddrinfo`, `gai_strerror` and their three error types), whose
iterator never ended on Linux; `TCPConnection.set_recv_timeout`,
`Socket.set_timeout` and `SocketOption.SO_RCVTIMEO`; `NetworkType`'s
`SUPPORTED_TYPES`, `TCP_TYPES`, `UDP_TYPES` and `IP_TYPES`;
`lightbug_http.c.address.AddressInformation`, whose `AI_*` values were
Linux's on macOS too; `lightbug_http.c.network`'s `addrinfo`, laid out
as Linux's on every platform, `in6_addr` and `sockaddr_in6`;
`try_writev`; and `kevent_register`, `EV_ENABLE` and `EV_DISABLE`.
- **Dead parts of the fork's request, response and server types** (fork
review LF61). Nothing served changes. The `m0` wheel ships the fork's
source, so an application built with `m0` that named one of these needs
its own copy: `lightbug_http.StatusCode` (`lightbug_http.http.response.
StatusCode`), whose one reader was `HTTPResponse.is_redirect`, which left
303 out; `HTTPResponse.content_length()`, `connection_close()` and
`len(response)`; `lightbug_http.http.request.RequestMethod`,
`RequestBodyTooLargeError` and `CookieParseError`, which nothing raised
(`RequestBuildError` is `URITooLongError` or `URIParseError`);
`HTTPRequest.set_connection_close()` and its `==` and `is not`;
`Server.max_request_body_size()`, `max_request_uri_length()` and their
setters (set `ServerConfig`'s fields); `ProvisionPool.size()`;
`RequestParseError.is_incomplete()` (ask `isa[IncompleteHTTPRequestError]()`);
`parse_request_headers`' `last_len` argument, whose rescan for the end
of a head the server had already framed changed no answer; and
`lightbug_http.strings.http`, whose last reader went with `URI.is_http`.
- **`lightbug_http.c.epoll`'s `EPOLL_CLOEXEC`, `TFD_CLOEXEC` and
`TFD_NONBLOCK`** (fork review LF28), copies of the open flags under
Linux's other names. Nothing served changes; an application built with
the `m0` wheel that named one passes `O_CLOEXEC` or `O_NONBLOCK` from
`lightbug_http.c.fcntl`, the same values.
- **The fork's response parser, its `Set-Cookie` parser and unused
helpers** (fork review LF26). Nothing served changes: the server parses
requests, never responses, and writes an application's `Set-Cookie` as
given. The `m0` wheel ships the fork's source, so an application built
with `m0` that named one of these needs its own copy:
`HTTPResponse.from_bytes`, the `HTTPResponse` constructor from a
`ByteReader`, `read_body` and `read_chunks`;
`lightbug_http.header.parse_response_headers` and
`ParsedResponseHeaders`, `lightbug_http.http.parsing`'s
`http_parse_response_headers`, `get_token_to_eol` and `try_peek_at`;
the response parse errors, `lightbug_http.header`'s
`ResponseParseError`, `InvalidHTTPResponseError` and
`IncompleteHTTPResponseError`, and `lightbug_http.http.response`'s
`ResponseParseError`, `ResponseHeaderParseError` and
`ResponseBodyReadError`; `ResponseCookieJar.from_headers`;
`Cookie.from_set_header`, which dropped `expires`, a capitalised
`SameSite` and any attribute it did not know; `Cookie.clear_cookie`;
with `lightbug_http.cookie`'s `CookieParseError` (the request side's
went too, below),
`InvalidCookieError`, `Expiration.invalidate` and the `from_string` of
`Expiration`, `Duration` and `SameSite`;
`ParsedRequestHeaders.expects_body`, which missed a chunked
body on any method but POST, PUT and PATCH; `write_header_latin1`,
which wrote a header holding CR or LF where `Headers.write_latin1_to`
drops it; `HTTPChunkedDecoder.is_in_chunk_data`;
`lightbug_http.strings`' `find_all`, `is_printable_ascii`,
`IS_PRINTABLE_ASCII_MASK`, `BytesConstant.CRLF` and
`BytesConstant.DOUBLE_CRLF`; and
`lightbug_http.io.bytes`' `is_newline`, `is_space` and `bufis`, and
`ByteReader`'s `read_line`, `read_word`, `skip_whitespace`,
`skip_carriage_return` and `consume`. `parse_headers` and `scan_to_eol`
lose their `strict` parameter and always read a request head's rules;
the lenient reading was the response parser's.
- **`LoopState.fd_map_size`, and the event loop's handling of an idle
timer** (fork review LF26): the field was set and never read, and
nothing arms an idle timer (idle deadlines are swept), so its branch
could not run. Nothing served changes. A connection that closes with
part of a response still unsent now gives that buffer back at once,
rather than when its slot next answers someone.
- **The fork's network and address code that nothing calls** (fork review
LF44, LF45, LF48). Nothing served changes. The `m0` wheel ships the
fork's source, so an application built with `m0` that named one of these
needs its own copy: `NetworkType`'s `udp`, `ip`, `ip4`, `ip6`, `unix`
and `empty`, `is_ip_protocol` and `is_ipv4`, and
`ParseIPProtocolPortError`, which only an `ip` network raised;
`lightbug_http.address.DEFAULT_IP_PORT`; `validate_no_brackets`'
`end_idx` parameter, never passed; `TCPAddr`'s zone (the field and its
constructor), `address_family`, `is_v4`, `is_v6`, `is_unix`, `==`,
`__str__`, `__repr__` and `write_to`, with the `Addr` requirements
behind them; `binary_port_to_int` and `ntohs`; `Socket`'s
`remote_address`, with the `remote_address` parameter of both
constructors that remain, its constructor without a family,
`get_peer_name`, `__enter__`, `__str__`, `__repr__` and `write_to`, and
the `getpeername` binding; `NoTLSListener`'s constructor that made its
own socket, `shutdown`, `teardown` and `addr`; `TCPConnection`'s
`shutdown`, `teardown`, `local_addr` and `remote_addr`;
`ConnectionState.closed` and `ConnectionState.CLOSED`;
`AddressParseError`'s `CustomError` and `ImplicitlyCopyable` conformances
and its empty constructor (it now takes the refusal's text,
`AddressParseError(reason)`, and moves);
`ListenerError`'s `Error` arm and `SocketNameError`'s `InetNtopError`
arm, neither ever raised; the `__getitem__` and `__str__` of the
address, listener, socket and `inet_*` error variants, and the `isa` of
`ParseError`, `ListenerError`, `SocketNameError`, `InetNtopError` and
`InetPtonError`;
`SocketAddress.as_sockaddr_in` and `sockaddr`'s constructor;
`AddressFamily.is_inet`, `AddressLength.INET_ADDRSTRLEN` and
`ShutdownOption.SHUT_RD`; and the `write_to` and `__str__` of
`AddressFamily`, `AddressLength`, `ShutdownOption`, `SocketOption` and
`SocketType`, with the `==` of the last four.
- **The fork's unused URI, cookie, response and byte helpers** (fork
review LF52). Nothing served changes, and no application in the tree,
the `m0` templates or the one outside it named any of these; an
application built with `m0` that did needs its own copy. From
`lightbug_http.uri`: `URI`'s `username`, `password`, `full_uri`,
`_original_path` and `_hash` fields (always empty, or the path again),
its `__str__`, `__repr__`, `is_http` and `is_https`, the unused
`QueryDelimiters` and `URIDelimiters` constants, and
`URIParseError.__str__` (`String(error)` still writes it). From
`lightbug_http.cookie`: `Expiration`, a stub that could only say
"session", with `Cookie`'s `expires` field and argument (a `Cookie` sets
its lifetime with `max_age`); `Cookie.to_header` and `Cookie.__str__`;
`SameSite.__eq__`; `RequestCookieJar`'s constructor from cookies,
`parse_cookies`, `empty`, `encode_to` and its `in` for a `Cookie`; and
`ResponseCookieJar`'s constructors from cookies, its `[]`, `get` and
`in`. From `lightbug_http.http`: the two `OK` overloads taking `Bytes`,
`SeeOther` (also exported from `lightbug_http`; `m0_http.reply.redirect`
builds every redirect) and `BadRequest(message)`. From
`lightbug_http.io.bytes`: `OutOfBoundsError`, `EndOfReaderError.__str__`,
`ByteReader`'s `read_bytes(n)`, `as_bytes` and `in`, and `ByteView`'s
comparisons, `in`, truth test, `as_bytes` and `__str__`. From
`lightbug_http.strings`: `https`, `colonChar` and the seventeen
`BytesConstant` bytes nothing reads.
- **Unused names at the top of the fork, and `HTTPRequest.timeout`**
(fork review LF71). Nothing served changes. The `m0` wheel ships the
fork's source, so an application built with `m0` that named one of
these imports it from its own module instead: `URI`, `Cookie`,
`RequestCookieJar` and `ResponseCookieJar` are no longer re-exported
from `lightbug_http` (import them from `lightbug_http.uri` and
`lightbug_http.cookie`), nor `Bytes` from `lightbug_http.io` (import it
from `lightbug_http.io.bytes`). `HTTPRequest`'s `timeout` field and
constructor argument are gone, with `lightbug_http.io.sync.Duration`,
the alias for `Int` it was declared with: nothing read it.
## [1.12.1] — 2026-10-07
A patch release for the security fixes of a review of the server's HTTP
core, the `lightbug_http` fork. A header value could split a response built
in Mojo, and a request head ending a line with a bare LF put the parser and
the event loop's framing out of step in every server, m0serve included; on
macOS the page workers share could be created readable by other users. The
review's other fixes are here too: request heads, trailers and targets the
RFCs call malformed are refused or read as they say. The served contract is
unchanged. The `m0` wheel ships the framework's source, so an application
built with `m0` takes every fix by rebuilding against `m0 0.9.1`. This
section also records what `m0 0.9.0` published on its own: the `board`
template and `m0 new .`.
### Security
- **A header value can no longer split a response with an overlong UTF-8
sequence** (SPEC G19). Exposed: responses built in Mojo only; the
gateway's Python applications are not. The latin-1 transcoder that
writes every response head decoded three- and four-byte sequences as
well as two-byte ones, AFTER the check that drops a header carrying CR,
LF or NUL, so the overlong forms `E0 80 8D` and `E0 80 8A` went out as a
real CRLF. A Mojo view that redirected to a request's `next` with
`reply.redirect` could be
made to send a `Set-Cookie`, or a body, of the request's choosing:
`?next=/%E0%80%8D%E0%80%8ASet-Cookie:%20sid%3Dx` did it, and a header or
`Set-Cookie` value a view built from request data was open the same way.
Every response built in Mojo was exposed: a `Views` application's, the
Mojo host's, and a Mojo mount's in m0serve. Python applications on
m0serve were not: a `str` header reaches the server as CPython's UTF-8,
which is never overlong, and a `bytes` value is re-encoded byte by byte.
The transcoder now decodes only U+0080 to U+00FF and writes every other
byte as it was given, and the writers check the transcoded bytes again
before they send them. Upgrade m0serve if it serves a Mojo mount, and
rebuild every Mojo application against this release (an `m0`
application against `m0 0.9.1`).
- **A request head with a bare LF is refused with 400** (SPEC B12).
Exposed: every server, m0serve included, whatever it serves; the
parser and the event loop are the same under all of them. Upgrade
m0serve, and rebuild every Mojo application. The parser ended a head
at a bare-LF empty line (`\r\n\n`), while the event loop frames a head
by the first CRLFCRLF, and the bytes between the two were lost: a
request pipelined behind such a head got no
answer, and a `Content-Length` after the bare LF was never read, so the
body it described was answered as a request of its own. Every line of
a request head must now end in CRLF, and the loop also refuses any head
the parser ends at a different byte than its own frame, then closes the
connection. A client that ends request lines with a lone LF is refused;
none is known. `smoke-pipelining` sends both shapes.
- **The page workers share is created private on macOS** (SPEC G20).
Exposed: macOS only; the mode was measured world-readable once. The
server asked `shm_open` for mode `0o600` in a register, where Apple
silicon passes that argument on the stack, so the page took whatever
mode the stack held: measured as `0o000`, `0o001` and `0o744`, the last
readable by any user who opened it by name before the server unlinked
it a moment later. It is now created `0o600`. A page that cannot be
sized no longer leaks its descriptor. Linux was not affected.
### Added
- **`m0 0.9.1`, this release's framework, for applications built with
`m0`.** The wheel ships the framework's source, the server's HTTP core
included, so an application takes every fix under Security and Fixed by
rebuilding against it: raise its pin to `m0==0.9.1`, then `uv sync` and
`uv run m0 build`. Nothing in an application's own source has to
change. What changed since `m0 0.9.0` for someone writing an
application:
- Fixed, the response splitting under Security. Every response an `m0`
application builds is built in Mojo, so every application built with
an earlier `m0` is exposed until it is rebuilt.
- Fixed, the bare-LF framing desync under Security, and the request,
WebSocket and static-file fixes under Fixed.
- Changed, `m0 --help` names the templates, and an `m0 new` given no
template says it took the default (under Changed).
- **`m0 0.9.0`, published on its own**, for applications built with `m0`.
What changed since `m0 0.8.0` for someone writing an application:
- New, `m0 new --template board`: a list every tab shares, whose sender
is a view publishing through the state's `DatastarStream`.
- New, `m0 new .`: writes the empty current directory, named for it.
- The next step `m0 new` prints serves on `127.0.0.1`.
- Fixed, `live` behind a handler pool: a project `m0 0.8.0` or earlier
wrote takes the two lines under Fixed below.
- The scaffold's `AGENTS.md` changed, so `m0 doctor` names it in a
project an earlier `m0` wrote. The framework's own source is
unchanged since `m0 0.8.0`.
- **`m0 new --template board`, and `m0 new .`** (SPEC N27, N52, D66;
docs/notes/what-the-agent-runs-asked-for.md). The follow-ups from the
agent usability runs, where every Mojo run wrote `./NAME` and moved it
up a level, then deleted half of `live` to get a list a request pushes.
- `board` is a list every tab shares whose sender is a view: a POST
appends and publishes the whole board through the state's
`DatastarStream`, with no producer and no database. Its views run on
the loop, and the gate serves it behind a handler pool.
- `m0 new .` writes the empty current directory and takes its name.
- The printed next step serves on `127.0.0.1`.
- **Skills for m0serve and m0** in `skills/`, written from where the
agent runs looked.
### Fixed
- **A response whose application sets `Server` no longer carries two
`Server` lines** (SPEC A26). The server wrote its default `server: lightbug_http`
whatever the headers held, so an application that named itself, built
in Mojo or a Python application on m0serve, sent two. The default is now
written only when the application set none.
- **A folded field line is refused with 400** (SPEC B13). A request
field line opening with a space or a tab (obs-fold, RFC 9112 §5.2) was
accepted as a field with an empty name: a WSGI application saw an
environ key `HTTP_`, and the folded text never joined the field it
continued. Such a request is now refused.
- **A chunked request body's trailer is held to field lines ending in
CRLF** (SPEC B14). After the last chunk the trailer section skipped any
run of CR, took a bare LF as a line end, and took any line as a field,
so `0\r\n\n` ended a body that a stricter proxy in front still reads
as open, and a trailer line with no colon was served where Node's
llhttp and h11 refuse it. Each now makes the body invalid, answered
400, as a bare LF in a chunk extension already was. Trailers are still
discarded, never handed to the application.
- **An HTTP/1.0 request with a chunked body closes its connection behind
the answer** (SPEC B15). RFC 9112 §6.1 calls `Transfer-Encoding` on an
HTTP/1.0 message faulty framing, and asks for the connection to close
after it. Such a request was de-chunked and, with `Connection:
keep-alive`, kept alive, so a request pipelined behind it was answered
too. It is now answered and the connection closed. And `HTTP/1.2`
through `HTTP/1.9`, which are served as HTTP/1.1, now need a `Host`
field as HTTP/1.1 does; one without was served.
- **`Connection: close` closes wherever it stands in the list** (SPEC
B17). `Connection` is a list of options (RFC 9110 §7.6.1), and the
server compared the whole value with `close`: `Connection: close, TE`
kept the connection alive and answered the request pipelined behind
it. Each option is now read on its own, case-insensitively, and an
HTTP/1.0 client's `keep-alive` is read the same way. Under `--metrics`
the `/__metrics` answer kept its connection alive whatever the request
asked; it now closes as every other answer does, for this and for an
HTTP/1.0 chunked request alike.
- **A request whose target is a whole URL takes its host from the URL**
(SPEC B16). RFC 9112 §3.2.2 says a server receiving `GET
http://example.com/p HTTP/1.1` uses the target's host and ignores the
`Host` field. The server threw the target's host away and kept `Host`,
so an application routing on `Host` (Django's `HTTP_HOST`) read a site
the target never named. The target's `host[:port]` now replaces `Host`.
The scheme is matched in any case (`HTTP://h/p` reached the application
as the path `HTTP://h/p`), a query straight after the host is kept
(`http://h?q=1` lost it), and a target with no host (`http:///p`) or
with a userinfo (`http://user@h/`) is refused with 400.
- **A WebSocket message is no longer lost when a frame the server refuses
follows it in the same read** (SPEC I34). A frame the protocol forbids
(a reserved opcode, an unmasked frame, a text frame that is not UTF-8)
ends the connection with a Close, and that refusal discarded everything
parsed from the same read before it: a complete message never reached
the application, and a ping went unanswered. Whether a message arrived
depended on how TCP split the bytes. Both are now kept, the Close sent
after the pong.
- **A static file that shrinks while it is served no longer spins its
connection** (SPEC J15). When a file ended before the `Content-Length`
its response had already sent, the server read the end of the file as
a socket that could take nothing yet and waited for room it already
had: the connection spun on the event loop until the idle timeout
closed it, and for good with idle timeouts off. It now closes at once,
and the client sees a response shorter than its length, an error it
can detect.
- **The `live` scaffold's stream behind a handler pool.** Its `/events`
view was not `on_loop`, and its handler answered only stateless loop
routes, so under `--blocking-threads` (`M0_BLOCKING_THREADS`) every
stream was refused 409. A project an earlier `m0` wrote takes the same
two lines: `on_loop=True` on the `/events` registration in
`src/views.mojo`, and `self.views.answer_on_loop(req, self.state)` in
`LiveHandler.before_request`. `smoke-scaffold` now serves `live` behind
a pool.
### Changed
- **`m0 --help` names the templates** (SPEC N27;
docs/notes/what-the-agent-runs-asked-for.md). Every Mojo run without the
skill ran `m0 --help`, then a bare `m0 new .` before it knew a
template's name, took `views`, and wrote its application a second time.
The top-level help now lists the four, a line each, and an `m0 new`
given no template says it took the default and lists the others. It
ships in `m0 0.9.1`.
- **The pages say what the agent runs had to find out.** Both quickstarts
serve on `127.0.0.1`. The Python quickstart says where libpython comes
from, what `publish()` does with a line break, and that a form post
meets Django's CSRF check. The home page and the Mojo overview point an
agent at `llms.txt` and each page's Markdown. The overview maps the API
to its pages; the views page gives `reply`, `reply.problem`'s four
arguments, and Datastar 1.0's rule that an action's answer applies only
on a 200. The scaffold's `AGENTS.md` names the reference pages before
the installed source, so `m0 doctor` reports it as changed in a project
an earlier `m0` wrote.
## [1.12.0] — 2026-10-06
A held stream that reconnects is caught up on what it missed. Two of the
known issues were taken up: the first, a WSGI hold that replayed nothing,
is retired by a per-loop journal; the second, the RHEL 9 glibc floor, was
measured and found to be the Mojo runtime's, so its record is corrected
rather than closed. A `Last-Event-ID` from a previous incarnation is
clamped instead of starving the stream. The served contract is unchanged,
with one addition, the `m0-gap` event; the `m0` wheel ships as `m0 0.8.0`.
### Added
- **`m0 0.8.0`: this release's framework, for applications built with
`m0`.** What changed since `m0 0.7.0` for someone writing an
application: new, `m0_http.ReplayJournal` (`m0_http.sse.replay`), the
bounded journal m0serve's holds are caught up from, usable beside an
application's own `SSERegistry`. Nothing an application has to change.
- **A held stream that reconnects is caught up.** Each loop journals the
last `--replay-frames` published frames (`M0_REPLAY_FRAMES`, default 64;
0 keeps none), and a `M0-Hold: stream` that reconnects with
`Last-Event-ID` is sent every frame of its channel it missed, in order,
before the live feed — whether the hold was taken inline, on a pool
thread, by a Mojo mount or by a hold mount. When the journal cannot
supply all of them, the client is sent none and one unnumbered
`event: m0-gap` frame whose data names the id it presented and the
newest id allocated, so it can fetch instead of polling beside the
stream (SPEC I33; [the record](docs/notes/a-hold-that-replays.md)).
`--doctor` reports `replay_frames`.
### Changed
- **A `Last-Event-ID` ahead of the counter no longer starves the stream.**
A client holding an id from a server that has since restarted presented
one this incarnation never allocated, and the registry took it
literally, suppressing every frame until the counter passed it. It is
now clamped to the newest id and reported as an `m0-gap`.
- **The platform note on RHEL 9 is corrected.** The README and the known
issue said the Linux floor was the build host's and that a
`manylinux_2_34` container build would reach glibc 2.34. Measured on the
1.11.0 wheels, the floor is the Mojo runtime's own (`GLIBC_2.35` in
`libAsyncRTRuntimeGlobals.so`, GCC 12's libstdc++ in
`libKGENCompilerRTShared.so`), so no build of ours lowers it; the wheel
tag script now names the file that set the floor on every build
([the measurement](docs/notes/the-floor-is-the-runtime.md)).
- **The benchmark page's ASGI per-core verdict is corrected.** It said
uvloop leads the executor per core on macOS and that Linux answers at or
above parity. The macOS figure had crossed 1.0 at the 1.10.0 re-record,
and both a container and a rented x86-64 box put the default executor a
little behind uvloop per core (0.91x, 0.94x). The one-thread loop
(`M0_INVERTED=1`) leads uvloop per core everywhere measured, 1.27–1.42x,
and at 16 connections it also serves more than the default on Linux
([the record](docs/notes/asgi-per-core.md)).
### Fixed
- **A `--blocking-threads` stream's abort can no longer be lost beside its
head.** The loop read the completion ring and then the completion
channel. A pool thread completes a stream's head onto the ring and, when
the chunk channel refuses the body, sends that stream's abort on the
channel. If the push and the send both landed between the loop's two
reads, the loop met the abort with no head, dropped it as an abort for a
slot that is not streaming, and then opened the stream, which stayed
open, kept alive by its heartbeat. The loop now reads the channel first,
so an abort it takes always has its head on the ring
([the record](docs/notes/asgi-per-core.md)). The window is too narrow to
reproduce on demand; `test_offload.mojo` pins the new order.
## [1.11.0] — 2026-10-06
What an application moved from uvicorn met, fixed. franchise-assessment's
move onto m0serve found a lifespan startup that failed without a word, an
access log whose numbers were strings and whose byte count was the
response head, static files served without the security headers its
middleware set (and, for some types, as downloads where Starlette
displayed them), and two limits only a flag could reach. Each is fixed
here, and `docs/RUNNING.md` says in a few lines what a uvicorn command
line does not show. The access log's line changes shape (Changed, below);
the served contract is unchanged; the `m0` wheel ships as `m0 0.7.0`.
### Added
- **`m0 0.7.0`: this release's framework, for applications built with
`m0`.** What changed since `m0 0.6.0` for someone writing an
application:
- New: `StaticFiles(..., headers=...)` (J11), and `static_headers`,
`svg_policy_for` and `SVG_SANDBOX_POLICY` in `m0_http`. Every
`StaticFiles` answer carries `X-Content-Type-Options: nosniff` (J12),
an SVG carries a sandboxing `Content-Security-Policy` (J14), and the
type table follows Python's `mimetypes` (J13).
- What an application may have to change: whatever reads its access
log (`M0_ACCESS_LOG`), whose numbers are now JSON numbers and whose
`ts` is now `time` (F20, F21); and an SVG served by `StaticFiles` that
scripts itself, which stops scripting.
- Nothing an application built by `m0 0.6.0` must act on otherwise: the
templates are unchanged, and `m0 doctor` names no scaffold file.
- **Static files carry their types** (SPEC J13). The table behind
`--static` and `StaticFiles` knew 19 extensions and sent everything
else as `application/octet-stream`. An app moved from Starlette or
Django, both of which use Python's `mimetypes`, lost about 45 types,
and an image or audio file of one of those types downloaded when
opened directly, in Chromium, Firefox and WebKit, where it had been
displayed or played. The table adds fonts (`woff`, `ttf`, `otf`),
`avif` and `bmp`, audio and video (`mp3`, `m4a`, `ogg`, `wav`, `flac`,
`aac`, `mp4`, `webm`, `ogv`, `mov`), captions (`vtt`), the web app
manifest, source maps, feeds, calendars, CSV and TSV, JSON-LD,
GeoJSON, YAML (RFC 9512), Parquet, `zip` and `gz`. A proxy compresses
by type, and this server leaves compression to it, so text labelled
`octet-stream` used to go out uncompressed. Build inputs (`.jsx`,
`.tsx`, `.ts`), model weights and JSON Lines stay
`application/octet-stream` on purpose.
- **`--static-header 'Name: value'`** (SPEC J11): repeatable, adding a
header to every response a `--static` mount answers, errors included.
These are the security headers an application's middleware sets, which
static responses never pass through. franchise-assessment's
`X-Frame-Options`, `Strict-Transport-Security`, `Referrer-Policy` and
the rest were missing from its CSS, JS and icons. The flag is refused
with exit 2 for a name that is not a token, a control character, a name
given twice, a name the static server sets itself (`Content-Type`,
`ETag`, `Content-Range`, `Allow` and the framing headers), and
`Cache-Control`, which `--static-cache-control` sends on successes only.
In Mojo, `StaticFiles(..., headers=...)` is the same; there, a name the
response already carries is left as the response set it.
- **`M0_MAX_BODY` and `M0_BODY_TIMEOUT`, the environment forms of
`--max-body` and `--body-timeout`** (SPEC C1, A23), read with the flags'
own parsers (`8m`, `30`) and beaten by the flags. A container raises
either without a start script.
- **The first refusal of each kind names its knob.** The first time a
server answers 413 for a body over the cap, it prints one line naming
`--max-body`, the cap in effect and `M0_MAX_BODY`. The first time it
ends a body that stopped arriving, it prints the same for
`--body-timeout`. Each line is printed once per event loop. The 413
says only "Payload Too Large", and the application never sees the
request, so until now nothing in any log said which setting refused an
upload.
- **`docs/RUNNING.md`'s "Coming from uvicorn"**: the behaviour a uvicorn
command line does not show, one line each, linking to where each is
described: buffered and capped bodies, the body timer, the longer
keep-alive, the access log off and in JSON, forwarded headers not
applied, exit 1 for a failed lifespan startup, and ASGI refused on a
free-threaded CPython. That refusal now says how to pin a GIL build
with uv (`3.13` in `.python-version`); uv had picked 3.14t for
franchise-assessment.
### Changed
- **`wyhash64` multiplies once** (the ETag hash in `m0-core`). Its mixer
assembled the 128-bit product from four 32x32 partial products behind a
note that Mojo exposed no `UInt128`; it does at the 1.1.0 pin, and the
stdlib's own AHash folds a `UInt128` product the same way. The one
widening multiply gives the same value for every input — the pinned
vectors, every length to 300 and 20 million random pairs agree, so no
served ETag moves — at about twice the throughput at every size, measured
on an M-series Mac: 4.5 to 7.3 GB/s on 16 bytes, 11.6 to 22 GB/s on a
megabyte. A 20-byte vector joins the pinned set, covering the word path
between the short tail and the 32-byte block. `std.hashlib`'s AHash was
measured beside it and is the slower of the two above 64 bytes; the
ETag hash stays in `m0-core`, where its outputs are this repository's.
- **Short JSON strings are escaped a word at a time** (`m0-core`'s
`escape_json_string_into`). After its last full 64-byte block a string
was scanned byte by byte, so every string under 64 bytes took the scalar
loop, and those are most of what it escapes: access-log fields, Datastar
signal values, JSON reply fields. The tail is now scanned eight bytes per
step as one 64-bit word, and skipped when the 64-byte blocks covered it.
The output is byte-identical over 26,055 cases, every length to 300 in
five shapes among them; measured on an M-series Mac, 8-byte strings run
1.53x faster, 24-byte ones 1.56 to 1.85x, 64-byte strings with specials
1.37x, and clean 64-byte strings 0.96x.
- **An SVG from a static mount is sandboxed** (SPEC J14). Its 200, 206
and 304 carry `Content-Security-Policy: default-src 'none';
style-src 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:;
sandbox`. An SVG's `` ended the element whatever the
quoting. The location is now a string literal with `"`, `\`, `<`, every
control byte and U+2028/U+2029 escaped.
- **`m0-datastar` against the SDK's own cases** (SPEC I27, I28):
`read_signals` read a DELETE's signals from its body, where Datastar
sends none -- the bundle and the SDK's `ReadSignals` table put them in
`?datastar=`, as for GET -- and so returned `{}`; `patch_signals` wrote
multi-line JSON as one dataline, so the client received `{` and read
the other lines as fields of their own; and `remove` mode carried an
empty `elements` line.
- **Security: an ASGI application's message for a client that had left
could reach a different client** (SPEC L20). The executor decided whether
a connection was gone by asking about the task *making* a send, not the
connection the send addressed, and the loop reuses a slot the moment a
connection closes. So a `send` an application kept for a client that had
gone, called from any live task — a broadcast, another request, a
background task — was written into whichever client now held that slot.
FastAPI's documented multi-client chat room did it with no change: the
next client to connect received every message addressed to the one that
left, including its personal ones. A raw ASGI push hub's stale stream
`send` wrote into another client's response the same way. The same rule
also refused a disconnect hook's sends to the sockets still connected
("someone left" reached none of them). A send is now judged by the task
that owns the connection it addresses: a send to a socket that has gone
raises `ClientDisconnected` (an `OSError`, uvicorn's name for it), and one
to a stream that has gone is a no-op, as ASGI 2.3 specifies. Two paths
never told the executor a socket had gone at all, and are closed too: a
socket its application closed (each socket now keeps its own record of
its accept and its close, where the slot's record was the next client's —
a late `finally` closed that client, a second close rejected its
handshake), and a socket the server ended itself after a message over
its outbox cap (the loop now tags every connection an executor produced,
routed to that executor). And a task an application left behind, sending
after the application returned, could answer the slot's next request
with its response; a send once the response is over now answers nothing.
Found by serving FastHTML's and FastAPI's own examples beside uvicorn.
- **A process the application started inherited the server's connections
and channels** (SPEC G16). Nothing the server created was close-on-exec,
so a child that execs — `os.system`, `pty.fork`, `subprocess` with
`close_fds=False` — held every client connection open at that moment, the
listener, the channels between the loop and its pools, the bus and the
shutdown pipe: 8 to 46 descriptors, depending on the mode. A connection
the server closed stayed open in the child. FastHTML's terminal example
took 10 s to close a WebSocket, and a child that runs another user's
commands, like that terminal's shell, held every other client's
connection. Every descriptor is now close-on-exec, atomically on Linux.
`--spawn-workers` keeps exactly what its new image adopts across its own
exec, where the supervisor used to clear the flag for every exec in every
mode. And `m0pub` writes only to its own bus, which it recognises by
device and inode (`M0_BUS_WRITE_IDS`, exported beside the numbers). A
child handed no bus used to write its datagram into whatever file or
socket had the bus's old descriptor number.
- **An ASGI WebSocket's disconnect cancelled the application's task**
(SPEC L21). uvicorn delivers `websocket.disconnect` through `receive()`,
and FastAPI's documentation is written against that: its cleanup is an
`except WebSocketDisconnect:` after the receive loop, which a cancellation
skips, so the departed client stayed in the application's list for ever.
The disconnect now arrives through `receive()` (and again on every later
call), and the task is not cancelled for it. A handler blocked outside
`receive()` learns at its next send, or at shutdown, where the drain gives
in-flight tasks a second and then cancels the sockets still running.
- **An ASGI response waited for its background tasks** (SPEC L22).
Starlette runs a response's `BackgroundTask` after its final body, inside
the same call, and the executor answered only when the application
returned, so a response with background work was held for as long as the
work took, buffered or streamed. It is answered at its final body now,
and a client leaving afterwards does not cancel the work. Under the
escape hatch (`--blocking-threads N` with an ASGI application) each
request runs in its own event loop run, which cannot return early; the
response still waits there.
- **An ASGI application's error replaced its own error page and lost the
traceback; a raising WebSocket closed with 1000** (SPEC L23, L24).
Starlette's `ServerErrorMiddleware` sends a finished 500 — with
FastHTML's `debug=True`, the traceback page — and then re-raises; the
executor answered its own `Failed to process request` instead and logged
one line with no file or line. The application's response now stands,
and every application error the executor logs carries its traceback. A
WebSocket whose application raises is closed with 1011 ("an unexpected
condition", RFC 6455 §7.4.1), not the 1000 that told the client all went
well. A `ClientDisconnected` escaping an application is not logged; a
Starlette `WebSocketDisconnect` that an application lets escape is, as
uvicorn logs it. And `receive()` after a response is answered says
`http.disconnect` at once, where it used to wait for the life of the
process.
- **An ASGI application's WebSocket close could be answered with a second
Close frame** (SPEC L15). The executor sent the close as two datagrams,
the Close frame and then the socket's end marker. The loop wrote the
Close at the first but began waiting for the client's reply only at the
second, so an executor descheduled between them had the client's reply
read in between and echoed back: a Close after the closing handshake,
which a strict client reports as a protocol error. CI saw it twice, once
on each OS. The Close now rides inside the end marker, one datagram, so
the loop never writes it without knowing the socket is ending.
- **A response's head reached the client rewritten** (SPEC A21, K12). A
response the application sent without a `Content-Type` went out as
`application/octet-stream`: a redirect, a 204, FastHTML's default 404
page, which a browser may then download rather than show. A HEAD the
application answered with its body's `Content-Length` and no body went
out with `Content-Length: 0` (Starlette's `FileResponse`, WhiteNoise).
And every 204 and 304 carried `Content-Length: 0`, from the gateway and
from a native Mojo handler alike, which RFC 9110 §8.6 forbids on a 204. A
204 that brought its own length and a body (Django's `CommonMiddleware`
sets a length on every non-streaming response) sent both, and the body
began the connection's next response. The head now reaches the wire as
the application sent it, plus only the framing that is the server's: a
buffered body's measured length, and on a HEAD the application's own
length. No 1xx or 204 carries a length or a body, whoever set them, and a
304 keeps only a length its application gave.
- **A HEAD to a streaming ASGI route received the whole body** (SPEC L27).
The executor switched a response to streaming at its first chunk
whatever the request, so a HEAD to a Starlette `StreamingResponse`, which
answers HEAD as it answers GET, was streamed, and the loop, which never
frames a HEAD, wrote the body raw after the head: all 10,000 bytes of a
10,000-byte route, and an endless stream for ever. A keep-alive client
then read those bytes as the start of its next response. A HEAD is now
answered at its first streamed body with its head alone, and the
application's later sends are dropped. A `receive()` it parked before the
first body, as Starlette and Django do, is woken with `http.disconnect`,
which stops a `StreamingResponse` and still runs its background tasks;
an application that never listens is cancelled if it is still running a
second later. A 1xx, 204 or 304 streamed the same way is answered the
same way. And a HEAD to a hold, an `M0-Hold` view under `--realtime` or
a native SSE route, was held as the stream a GET opens, writing every
event and heartbeat after the head: it is answered with its head, and the
subscription it made is dropped.
- **A chunked request reached an application with `transfer-encoding:
chunked` and a `content-length` at once** (SPEC L25). The loop decodes a
chunked body before any application sees it, and the length it then
added sat beside the client's coding: a contradictory pair an
application proxying the request would forward. The body is now
described by its length and the `chunked` coding is gone, in the ASGI
scope on both bridges and in the WSGI environ. Any other coding, such as
the `gzip` of `gzip, chunked`, is kept.
- **Every chunked upload reached a Flask application empty** (SPEC L25).
Werkzeug reads `HTTP_TRANSFER_ENCODING: chunked` as a streaming request
of unknown length and, without `wsgi.input_terminated`, hands the
application an empty input stream, so `request.data` was `b''` however
much was sent. The environ now describes the decoded body by its
`CONTENT_LENGTH` and carries no `HTTP_TRANSFER_ENCODING`.
- **A module that calls `asyncio.create_task` at import failed to load
with a bare `RuntimeError: no running event loop`** (SPEC L26).
FastHTML's first official example does this. m0serve imports an
application before any event loop runs, as uvicorn does without
`--reload`, and now says what the module did and the fix: start that
work from a lifespan startup handler. The server, `--doctor` and
discovery all name it, with the traceback, and exit 1. Any other
import error keeps its own words.
- **An ASGI application's lifespan shutdown was skipped when background
work outlived the drain.** After the drain, the executor gave WebSocket
tasks a second and then waited on every HTTP task without bound, so work
that never ends -- a response's background task, a poller -- held it until
the 5 s thread join gave up and the process left without shutting the
application down. Every task now gets 3 s in all, is then cancelled and
counted in the log, and a task that swallows its cancellation is named and
left behind, never to reach the server again; lifespan shutdown runs
after. Work that finishes inside the 3 s finishes (SPEC D11).
- **A HEAD to a WSGI view that streams for ever never answered** (SPEC
K13). A HEAD took the buffered path, which joins the whole body, so a HEAD
to a WSGI SSE view hung and held its pool thread until shutdown; eight
of them were the whole zero-config pool. It is answered at the body's
first item, with no length, and the body is closed.
- **Two ASGI executor edge cases.** A body an ASGI
application sent before its `http.response.start`, then caught the error
for and answered properly, reached the client at the front of the real
body; and a stream still winding down on a recycled slot was cancelled a
second time by the next connection's disconnect.
- **An ASGI application heard 1006 for every WebSocket disconnect** (SPEC
L28). The code a client closed with now reaches it, as uvicorn passes it:
1000, 1001 for a closed tab, any other code the client sent, 1005 for a
Close with no code; 1006 means no Close arrived. And a Close, or a last
message, sent in the same instant as the hang-up now reaches the
application: the loop closed a socket at EOF before reading what its
client had left buffered.
- **An inbound WebSocket message over 64 KB went silent** (SPEC I26). A
message larger than the channel's datagram could never reach the
application or a pool thread, and was parked and retried for ever: no
reply, no close, no log. It is refused with a Close carrying 1009, the
connection ends on the client's reply, nothing the client sent after it
is processed, the application hears 1009, and the log names the size
and the limit. On a `--realtime` hold this needed the loop to end a
socket the handler closed itself: `HTTPService.take_ws_closes()`.
- **A `413` for an oversized upload reached curl and browsers, but not
`http.client`** (SPEC A20). The server refuses a body over `--max-body`
as soon as it knows the size, while the client is still uploading, and
it closed the socket straight after. Closing with the rest of the body
unread makes the kernel send RST instead of FIN, so a client that writes
its whole body before reading — `http.client`, and therefore `urllib`
and `requests` — got `BrokenPipeError` instead of the status. Found by
a Flask application compared against Werkzeug. The refusal now shuts its
write side, reads and discards what is still coming for up to five
seconds (RFC 9112 §9.6's lingering close), then closes cleanly. And
every error the server answers on its own — 400, 408, 413, 414, 431 --
said `Connection: keep-alive` on a connection it was about to close; it
says `close`. `--max-body`'s help and `docs/RUNNING.md` now say that
the server answers over the cap before the application runs.
- **The nightly canary could not alert, and one break hid the rest.**
The 2026-09-02 fix created the missing `nightly-breakage` label, which was
one of two causes: the job declares no `permissions`, so the repository's
read-only token failed again on `GraphQL: Resource not accessible by
integration (createIssue)` — every run from 2026-08-18 to 2026-09-15 failed
and none of them said so, while the free-threaded canary next door had been
given `issues: write` on 2026-09-02 and its sibling was missed. It has them
now. The build step was also a `build-all` sequence, so the first broken
package ended the run: the 2026-09-15 canary reported `Atomic[DType...]`
and `_CTimeSpec.tv_subsec` and stopped, leaving m0-wsgi, the apps and the
whole suite unprobed. It now builds each package itself, carries on past a
failure, marks as skipped anything whose dependency broke, and renders a
per-package table into the run summary. An open `nightly-breakage` issue
gets a comment rather than a fresh issue every Tuesday.
- **`page_or_fragment(..., status=422)` answered `422 OK`.** `text`
defaulted to the literal `"OK"`, so a styled error carried the wrong
reason phrase unless the caller passed one. `text` left alone is now the
status's own RFC 9110 phrase (`reply.reason_phrase`); an explicit `text`
still wins (SPEC N29).
- **`mojo build` needing a C compiler on Linux, and saying so only after
the whole compile**, is retired as a known issue for an application built
with `m0`: the check runs first and names the fix. Measured on the way:
mojo 1.1.0 looks for the literal name `cc` and nothing else, so `gcc`
without `cc` is refused by name, and a `cc` that cannot link is caught by
linking one line of C.
- **The blobs demo's shapes twisted and popped** (`apps/blobs`, SPEC N16).
Measured on 1.5.0's live stream over 45 s: 64 of 1,758 slot steps
twisted, and 69 of 331 frames made a slot appear or vanish whole. The
cause was the kernel, not delivery (frames arrived 96–104 ms apart at
p5–p95), the server (0.5–1 ms a step) or the browser (60 fps, the main
thread about 4 % busy). CSS moves vertex `i` to vertex `i`, and vertex 0
was each step's topmost point, so when a blob's highest point moved to
another lobe every vertex was dragged around the outline. A continuing
slot is now turned to the rotation of its outline nearest its previous
polygon. `data-show` does not transition a slot it reveals or hides, so
now nothing appears or vanishes in one frame:
- a split starts as a copy of its parent's outline;
- a drop starts as a seed at 8 % of its size;
- an absorbed blob becomes the merged outline, then shrinks where it was;
- any other shape that ends shrinks to its centre before its slot hides.
The alignment adds about 25 µs to a 312 µs step on an M4 (the same
600-step world, best of five). Measured locally over 60 s after the fix:
no twist in 2,588 slot steps. All 40 splits began as their parent's copy,
and all 40 disappearances shrank first. The unit tests check every trace
against the one before. `smoke-blobs` checks
consecutive frames on the wire for a twist and a pop.
`sabotage-blobs` grows from 23 rules to 31, eight of them new: five
against the unit tests, three against the smoke.
## [1.5.0] — 2026-09-19
A host for Mojo applications — workers, loops on threads, a handler pool
and a producer from one `serve` call — and the first application written
for it, streaming from an image with no Python in it at
[blobs.m0serve.dev](https://blobs.m0serve.dev). The pin moves to Mojo
1.1.0, which lets an application conform to the layer's traits, and an
unmounted `--realtime` gets the handler pool every other WSGI app gets.
### Added
- **The Mojo host** (SPEC E21–E25). `m0_host.serve[H, P]` is
everything in a Mojo application's `main` that is not the application:
the listener, the pre-fork shared pages and bus, `M0_WORKERS` processes
sharing their accepts, signals armed after the fork, a handler built in
each worker by `AppHandler.make`, and one `Producer` on worker 0 whose
frames go to every worker's channel, stopped and joined within the
drain's 5 s. An application writes two conformances and
`serve[MyHandler, MyProducer](AppConfig())`. A producer numbers its
frames from the pre-fork shared word (`Publisher.next_id`), so a
respawned worker 0 continues above what every held stream has seen
rather than restarting at 1 and leaving them silent for the pre-crash
uptime. A `make` that raises, the handler's or the producer's, is a
refusal with 78 before the server listens, never a crash loop, and one
worker's refusal ends its siblings (DECISIONS D30). `M0_SPAWN_WORKERS` is
m0serve's and is refused with 78. Gated by `smoke-host` on
`apps/host_check` and by `test_host.mojo`; `sabotage-host` (46 rules
across the host and the pieces it shares) before a release. DECISIONS D26
is retired: the `Producer` trait is the helper it deferred, and D27
records its choices. The write-up is
[the-mojo-host](docs/notes/the-mojo-host.md).
- **A handler pool and route placement in the host** (SPEC E26, N19;
DECISIONS D31, D32). `M0_BLOCKING_THREADS=N` is served as N `MojoPool`
threads behind each worker's loop, on one lane the host marks GIL-free.
`PoolLane[H]` builds the application's handler again on each thread with
`AppHandler.make`, `HostContext.thread` naming the instance, so an
application conforms once; the host waits for every thread's handler
before it serves, and a raising pool `make` is the same 78. A stream
begun in `func` on a pool thread is refused 409, as on a Mojo mount; one
opened on the loop works under the pool. `Views.add_read` and `add_write`
take `on_loop=True`, which keeps a route in the table (one `Allow`, one
`url_for`, one 404) and answers it on the loop with the loop instance's
state before it becomes a pool job; `m0serve`'s loop holds no Mojo table
and answers such a route one round trip later (D32). The shutdown bounds
overlap: the loop stamps the producer's stop word as its drain begins and
the pool and producer joins count from that stamp, so a request in flight
at SIGTERM beside a long step leaves inside one 5 s bound, not two.
- **The Mojo host serves `M0_THREADS=N`: N event loops on N threads of one
process** (DECISIONS D35; SPEC E27–E29). The listener, the shared page,
the bus and the accept-share channels are made once and sized by the loop
count; each thread builds its own handler with
`AppHandler.make`, its own pool under `M0_BLOCKING_THREADS`, and runs its
own loop; fan-out across loops rides the bus and accepts are shared
across the threads (without it, 30 of 32 connections sat on one loop of
four). `HostContext.worker`/`workers` count loops and the new
`HostContext.threaded` names the kind, so an application is served by
either mode unchanged. New on `AppHandler` and `ViewState`:
`max_threads()`, **defaulting to `max_workers()`** — an application whose
state lives in one handler refuses loops exactly as it refuses workers,
without being asked. `M0_WORKERS>1` with `M0_THREADS>1` is refused. No
loop takes a connection until every loop's `make` has returned, so a
raising `make` is still a 78 before anything is served. There is no
supervisor in this mode: a loop that dies takes the process. Measured
against prefork on `apps/ramp` (`poe bench-host-modes`): the same
throughput and tail on macOS and Linux, and 20–35 % less RSS — so prefork
stays what the documentation reaches for first
([loops-on-threads](docs/notes/loops-on-threads.md)). On a Linux x86-64
GitHub runner, threads over workers measured the same throughput and
tail and 0.56–0.59x the RSS; at 256 connections on the loop route
threads used more CPU per request, 0.86–0.94x workers' per core in
every round, which is prefork's side of the decision.
- **One views module on two hosts** (SPEC N20). `apps/ramp/views.mojo` is
one `Views[Ramp]` table built from its mount prefix alone; two adapters a
page long build it into `m0serve` under `--mount /x=mojo` and into a host
binary. `smoke-ramp` diffs nine requests across the two (only `Date`
differs), follows a rendered link on each, and measures where a request
waits behind a slow view: with the lane full the host's loop route still
answers, while `m0serve`'s waits for a thread, which is D32's divergence
recorded on every run. New on `build-serve`: `M0SERVE_INCLUDE` puts an
application's own module root on the include path beside
`M0SERVE_MOUNT_DIR`. The write-up is
[the-ramp-test](docs/notes/the-ramp-test.md).
- **Every Mojo app that forked or streamed now runs on the host.**
`sim_loop` (`main` 105 → 19 lines), `datastar_counter` (56 → 7),
`datastar_todo` (18 → 7) and `fragment_notes` (15 → 10). The counter
now shares its accepts across workers. The todo list now serves
`M0_WORKERS=2` over one SQLite file (SPEC N17), holding the write lock
from a change until its frame is published, so a tab's newest frame
never misses an older one's change. `ViewsApp[S]` serves a `Views` table
with no handler struct (SPEC N18), and an application whose state is
per process declares `max_workers`: `fragment_notes`, which used to
ignore `M0_WORKERS=2`, now refuses it with 78.
- **`apps/blobs`: a live world the page cannot hold** (SPEC N16). The first
application written for the Mojo-native stack. A producer thread steps up
to sixteen metaballs at 10 Hz — samples their field on a 192 × 192 grid,
traces the outlines where blobs merge, and resamples each to 48 vertices
in the slot it held last step — and publishes each step as one
full-state Datastar frame of `polygon()` clip-paths; a click drops a
blob for every open tab. A step costs ~0.2–0.4 ms on an M4. It is the
first app that is both a `Views` table and a streaming handler, and the
first on the Mojo host: its `main` is fifteen lines, and `M0_WORKERS=2`
serves from two processes, a click on either reaching the one producer.
Sixteen separate blobs make a 9.6 KB frame, ~96 KB/s per viewer; merged
ones make less. `uv run poe serve-blobs`; gated by `smoke-blobs` and the
kernel's unit tests, with `browser-blobs` and `sabotage-blobs` (23 rules)
before a release.
- **A Mojo application ships as an image with nothing under it, gated on
every pull request** (SPEC M26, M27;
[the-demo-in-its-own-image](docs/notes/the-demo-in-its-own-image.md)).
`deploy/mojo/Dockerfile` is one Dockerfile for every Mojo app, `APP`
naming the directory: the pinned toolchain compiles it in a builder
stage, and the runtime stage carries the binary, at `/app/server` and
PID 1, and the three Mojo runtime libraries beside it, with no
interpreter and no toolchain. Its last layer measures the image into
`/app/about.json`: the unpacked bytes, and no interpreter anywhere,
failing the build if one is found. `apps/blobs` reads the file through
`M0_IMAGE_FACTS` for a footer and a new `/about`, and refuses a malformed
one with 78. `poe smoke-blobs-image` builds it from the tree in CI's
`pid1` job, the first x86-64 Mojo build CI makes, and probes it from
outside with `scripts/mojo_image_probe.py`: PID 1, no interpreter, the
page's claims, the whole of `smoke-blobs`' main run through the published
port, and a held stream ended by `docker stop` with exit 0. On arm64 the
blobs image is 102.1 MB unpacked (29.3 MB compressed), 3.0 MB of it the
app, against 184.6 MB (60.3 MB) for the Django demo's image; on x86-64 it
is 80.1 MB unpacked and holds 20.1 MiB of RSS idle and 24.2 MiB with 100
streams held. `deploy/mojo/README.md` names each figure's unit and
architecture. Before a release, `poe probe-mojo-image` records the floor
under every Mojo image (`apps/hello` from the same Dockerfile) and `poe
sabotage-mojo-image` breaks ten of the image's rules.
- **D36: the blobs deploy serves one loop.** On one core, one loop, two
workers and two threads measure the same CPU, delivery and fan-out, on
arm64 and on x86-64 (`scripts/bench_blobs_modes.py`). Only memory
differs: 1.11–1.25x one loop's for threads, 1.79–2.29x for workers.
- **The Mojo demo's deploy: `blobs.m0serve.dev`**, made by each release
from this one. `deploy/blobs/` (the Fly app `m0serve-blobs`: one machine,
one loop per D36, connection-counted concurrency at soft 200 and hard
400) and a `deploy-blobs` job in `deploy-site.yml`. The job builds the
release's commit, or a dispatched version's tag, since the image compiles
its checkout. It verifies the deploy with `mojo_image_probe.py --url` and
skips a tag older than the deploy with a notice. `poe deploy-blobs`
deploys by hand. The site links it beside the Django demo.
- **An application defines its own frontend vocabulary** (DECISIONS D7,
retired 2026-09-18; D34; SPEC N21). `Vocabulary` was exported but not
implementable from outside: `Datastar` read a private field of `Html`
and both built-in conformances called a module-private verb check. New,
all exported from `m0_http`: `Html.open_kind()` answering an
`ElementKind` (`is_form`, `is_field`, `is_link`), a static
`Vocabulary.verbs()` with a default (`STANDARD_VERBS`, the five), and
the verb check moved into the layer — `Html.swap` and
`Fragment.swap`/`.el` refuse a verb outside `V.verbs()` before `V.swap`
runs, naming that vocabulary's list. A conformance that checks nothing
still refuses a typo, and one for htmx 4 allows `query` in one line.
`Vocabulary.swap`'s signature did not change and both built-in
vocabularies emit what they emitted, checked byte for byte across
`fragment_notes`' four swapping call sites and `datastar_todo`'s three.
`poe check-app-vocabulary` (inside `test-all`) builds an htmx 4
vocabulary from a directory outside the repository and reads its output
with `hxlint`, vendored from hx-flask (MIT; NOTICE, and a recorded-hash
guard in `check-docs`). The write-up is
[a-vocabulary-an-application-defines](docs/notes/a-vocabulary-an-application-defines.md).
- **`DatastarStream(send_latest=True)`: a stream of states** (SPEC I24).
Every subscriber, new or reconnecting, is sent the newest frame for its
url at open and then the live feed, never a replay. Without it a page
fed by a paused or slow producer stays blank until the next frame.
- **A bus publish reports what it delivered** (SPEC I25).
`publish_to_channels` and `BroadcastBus.publish` return how many channels
took the frame, 0 for a frame over `BUS_MAX_FRAME`, a reserved channel or
an over-long name. Each of those was dropped without a word.
- **`poe test-apps`** runs an application's own tests from
`apps//test/`, inside `test-all`; `apps/blobs` is the first.
### Changed
- **The page shell is a trait** (DECISIONS D12, retired 2026-09-18).
`page_or_fragment` takes an application struct conforming to
`m0_http.PageShell` — one method, `wrap(fragment)`, called only when a
document is wanted — in place of the `thin` function and the separate
context argument it took through v1.4.0. The context and the function
travel as one value, and a shell that carries no context is a struct
with no fields, which is why no second form was kept. The migration is
mechanical: the context struct conforms, the shell function becomes its
`wrap` method, and the argument goes. `PageShell` is now exported from
the package. It was a `thin` function because on Mojo 1.0 an app's
conformance to a trait behind a `.mojoc` got no witness table; that was
a package-name-against-directory bug, fixed in Mojo 1.1.0 and pinned on
2026-09-18. `check-mojoc-trait`'s `mismatch` arm now passes an app's
shell through the real API, and `wrap_with`, the helper that existed
only for it, is gone. `apps/fragment_notes` is on the trait with its
wire byte-identical across all nine of its call sites; the write-up is
[the-page-shell-becomes-a-trait](docs/notes/the-page-shell-becomes-a-trait.md).
- **`PoolContext`, `PoolHandler`, `MojoPool` and `JOIN_TIMEOUT_NS` import
from `m0_http`, not `lightbug_http`** — a source break for a Mojo mount
module built through `M0SERVE_MOUNT_DIR` (SPEC N14), whose first line
becomes `from m0_http import PoolContext, PoolHandler`. The old import
is a compile error naming the missing name, at the build that adopts
this tree; nothing served changes, and a Mojo import path is outside the
served contract stated above. `mojo_pool.mojo` and the Mojo host were
placed in the `lightbug_http` fork because Mojo 1.0 emitted no witness
table for an application's conformance to a trait behind a `.mojoc`;
Mojo 1.1.0 fixed that, and both have left. The pool is
`m0_http.mojo_pool`. The host is a package of its own, `m0_host`
(`from m0_host import serve, AppHandler, ...`; it was
`lightbug_http.host`, which no release carried), resolved from source
beside the fork — it cannot be inside `m0_http`, because it calls the
event loop, `event_loop.mojo` imports `m0_http.log`, and that resolves
through the `.mojoc` the build would be writing (DECISIONS D33). `poe
check-host-package` compiles it whole inside `test-all`. The fork's
imports of `m0_http` fall from eight to one. DECISIONS D28 is retired.
The write-up is
[docs/notes/the-host-leaves-the-fork.md](docs/notes/the-host-leaves-the-fork.md).
- **The pinned toolchain is Mojo 1.1.0** (was 1.0.0). It carries the
upstream fix for the `PythonObject` reference leak
(modular/modular#6833) and for the witness-table bug that cost a trait
its conformance when a package's name differed from the directory it was
compiled from. Both were measured in this tree against 1.0.0 as the null
case: 1000 operations leak 1001 references there and 0 here, and all four
arms of `check-mojoc-trait` compile where two were refused. That check
was written as a countdown and is now a regression guard whose failure
says what the constraint's return would cost. Nothing served changes.
What the move cost in source: `Atomic[Int64]` for
`Atomic[DType.int64]` (20 sites), `_CTimeSpec.tv_nsec` for `tv_subsec`
(2), `Array` for `InlineArray` (2), a `Span[UInt8]` for `Hasher.update`
(2), and `ptr`/`as_c_string_span` for the deprecated
`unsafe_ptr`/`as_c_string_slice` (7 lines) — the warning ratchet's floor
stays 0. The ROADMAP known issue for the leak is retired, and DECISIONS D7,
D12 and D28, each decided on the witness-table bug, are retired in this
release (the entries above). That bug had been recorded here as a
language limitation for three weeks (`PoolHandler` 2026-08-28,
`PageShell` 2026-09-10); the error named the cause all along
(`trait 'src::fragment::PageShell'`), and
[a-trait-and-a-directory-name](docs/notes/a-trait-and-a-directory-name.md)
records how it was found. Free-threaded `PyObject` layout
(modular/modular#5726) is NOT known to be fixed — it needs a 3.14t
interpreter, so `py-canary` answers it. The write-up is
[docs/notes/the-pin-moves-to-1-1-0.md](docs/notes/the-pin-moves-to-1-1-0.md).
- **One pre-fork preparation for both hosts** (SPEC E24). `m0_http.prefork`
makes the shared page, the bus and the accept-share channels, exports
each by descriptor, and adopts all three in a spawned worker; `m0serve`
and the Mojo host both call it, where `m0serve` used to keep its own
copy and the host a second one. Nothing served changes: the flags, the
`M0_*` names `m0pub` reads and an exec'd worker's environment are as
they were. The Mojo host's page is now file-backed and exported, as
`m0serve`'s already was, and a spawned worker handed no page descriptor
is refused rather than served from an address that is not its own
(the old `m0serve` path skipped the adoption silently and would have
bound accept sharing to its parent's address). Six of
`sabotage-host`'s rules run against `test_prefork.mojo`.
- **An unmounted `--realtime` gets the zero-config handler pool.** It
used to turn the pool off, so `m0serve app:application --realtime` — the
Quickstart's own command — ran every view on the event loop, and one slow
view stalled every held stream (measured on textshelf at 0.12.0: a
1 543 ms fast-path p50 against 0.3 ms with a pool). `--doctor` reported
`blocking_threads: 0` with `blocking_threads_source: default` and nothing
else said so. The reason was the demo's smokes, which were written
against the single loop; holds have been taken on pool threads since
0.12.0 for SSE and since 2026-08-26 for WebSockets, and the mounted
`--realtime` already took the pool. Now the flag composes with the same
`min(cores, 8)` default every WSGI app gets, the smokes that ran the
single loop run pooled, and `--blocking-threads 0` (or
`M0_BLOCKING_THREADS=0`) is that shape by name — which is how SPEC E20's
gate serves it. Found running desk on m0serve 1.4.0.
- **The live demo shows the bus crossing it exists to demonstrate.** Each
line names the worker that published it and the worker that delivered it
to this tab, marks the ones that crossed between them, and the page counts
them; before, a visitor had to compare two numbers in different places,
and a tab whose connections and publishes all landed on one worker looked
the same as one they had crossed. The page links to a second tab of
itself, the visitor cookie is `HttpOnly` and `Secure` over HTTPS, and the
CSP allows the inline script and stylesheet by sha256 instead of
`'unsafe-inline'`. `scripts/demo_probe.py` asserts each, sabotaged eight
ways against a local server on the 1.4.0 wheel.
### Fixed
- **A JSON number read from a request body could kill the server** (SPEC
G14). `m0_core.json_parse.parse_json_number` cut the number out with a
`String` slice, which asserts a codepoint boundary, so a body such as
`{"x":1<0x80>}` trapped the thread that read it. Nothing in the tree
called it until `apps/blobs`' drop view; the cut is now a byte-span slice.
- **Two processes opening one fresh SQLite file could not both get WAL**
(m0-sqlite, SPEC O1). `open` switches a new file out of the rollback
journal with `PRAGMA journal_mode=WAL`, and SQLite answers the loser of
that race with `SQLITE_BUSY` at once, without consulting the busy handler
set the line before, so `open` raised `database is locked`. It now
retries the switch within `DEFAULT_BUSY_TIMEOUT_MS`. About one pair in
two lost the race on an M4 (`test_two_processes_open_one_fresh_database`
forks twelve), and `apps/datastar_todo` refused 29 of 30 two-worker
starts once the host stopped hiding the raise behind a respawn; the todo
list also creates its schema inside `BEGIN IMMEDIATE`.
- **A supervisor told to stop no longer respawns a worker that fails its
drain** (SPEC D10). After a SIGTERM to the supervisor alone — what
`docker stop` sends — a worker that exited non-zero, or died of any
signal but the one forwarded, was replaced. Nothing ever signalled the
replacement, so the supervisor served it until SIGKILL. The supervisor now
lets it go and exits 1 once the rest are gone. `m0serve --workers N` and
every Mojo app that forks share the supervisor. Found while gating the
Mojo host.
- **Ten unchecked bodies in the lightbug fork, one of them a stack write
past the end.** Mojo type-checks method bodies lazily and `build-http`
precompiles `src` only, so the fork's 56 files were checked only where an
app instantiated them — and nothing compiled them whole. `poe
check-fork-package` now does, inside `test-all`: `Int` where `Int32` was
wanted at `_getsockopt`, `_recvfrom` and `_writev`, a `socklen_t` from
`size_of`, an origin mismatch in the dead `ProvisionPool.get_ptr` (removed),
four hand-written copy/move dunders in the cookie types (removed, the
compiler derives them), and `getsockopt` landing the kernel's reply in a
one-byte allocation it had described as `size_of[Int]()` bytes. All ten
sat in paths nothing instantiates, so no shipped behaviour changes; the
gate is what stops the next one.
- **`poe deploy-site` and `poe deploy-demo` failed without a version
argument.** Their default, the tree's own version, was a Python one-liner
whose `\"` escapes TOML consumed, leaving a syntax error; a version given
on the command line never evaluated it, which is how it went unnoticed.
Both now read the version with the `grep`/`sed` pair another task already
uses, as does the new `poe deploy-blobs`.
- **The live demo's deploy built from main, not from the release it
pinned.** `deploy-site.yml`'s `deploy-demo` job checked out the default
branch and pinned the release's wheel, so `deploy/demo/Dockerfile`, the
demo application and the probe that verifies the deploy came from
whatever had merged since the release -- or, for the `release/v*` branch
form, from a main that might not hold the release's commit. It now checks
out the release's own commit (`head_sha`) after a release and the
version's tag on a dispatch, and refuses to deploy when the tree's
version is not the pinned one. The docs site's job builds from the
release's commit after a release too; a dispatch still renders the ref it
ran on, which is how prose merged after a release is published.
- **The docs promised `Last-Event-ID` replay on a WSGI hold, which keeps no
journal.** RUNNING.md and the `m0pub` docstring said a numbered frame was
"covered by replay"; the plain `SSERegistry` a hold subscribes to only
suppresses an event a reconnecting client already has, and events
published while it was gone are not delivered — an application that
trusted the sentence and dropped its own catch-up lost messages every
time a phone slept. Both now say suppression only, README's "journal-deep"
limit names the hold, the Quickstart says to keep a catch-up path, and a
Known issue records what a journal would take. Two more from the same
notes: RUNNING.md read as if SSE heartbeats were off until
`M0_SSE_HEARTBEAT_MS` was set (they default to 15 s, so its 25000 example
made them rarer), and `m0pub.publish` did not say that `data` is a payload
rather than a frame, so pre-framed text was framed again and reached the
client as `data: data: ...` with nothing logged; its docstring now says
so and points at `publish_frame`. Not detected at run time, because a
payload may legitimately begin with `data:`. Found running desk on
m0serve 1.4.0.
- **The live demo's WebSocket status line described another tab's socket**
(`apps/demo`, SPEC M17). It updated on any message that arrived over a
WebSocket, and every tab's socket messages reach every tab on the
visitor's channel, so after tab A sent one, both tabs said "slot 1 on
worker 647 answered a message" -- tab A's socket, measured in Chromium and
WebKit against demo.m0serve.dev on 1.4.0. Each tab now sends
`{"text", "tab"}` with a random tab id, the view echoes the id, and a tab
learns its socket's worker only from its own echo. A client that sends
plain text, or JSON that is not the envelope, still has it broadcast
verbatim.
- **`apps/sim_loop` delivered its steps to worker 0's streams only under
`M0_WORKERS>1`** (SPEC N15). The simulation thread published to
`bus.write_fds[0]` alone, while the app's own comments said every
worker's loop received the frames; its gate ran one worker, where the
first channel is every channel. The thread now holds every write fd. The
app also shares accepts (SPEC E16) — without it one worker takes nearly
every connection — and `/events` names its worker in `x-worker`.
`smoke-sim-loop` gains a two-worker phase: four held streams must span
both workers and each carry the steps, so a run that lands them all on
one worker fails as vacuous rather than passing. The reference for
periodic work off the loop is what a Mojo application copies, which is
why this is a fix and not a footnote.
## [1.4.0] — 2026-09-15
Mounts that start are mounts that can be served, a Mojo mount that uses
every thread it is given, a pool-less loop that lets an application's own
threads run, and a child process that can publish without crashing.
### Added
- **A reference for periodic work that does not run on the event loop**
(SPEC N15, `apps/sim_loop`). `HTTPService.tick` fires on the loop thread,
so what it costs is its duty cycle — work over period — and that transfers
into p99 about one for one; the docstring now says so, and this is the
other half: where the work goes instead, as an application and a gate
rather than a paragraph. A 4 Hz simulation runs on a thread of its own and
publishes each step through the `BroadcastBus` with `skip_worker = -1`,
which the loop drains into `sse_peer_frame`. Three things in it are easy to
get wrong elsewhere: the bus is created unconditionally, at ONE worker too,
because here it is the thread-to-loop channel rather than only
worker-to-worker (`apps/datastar_counter` joins it only above one worker
and reads as though that were the rule); `skip_worker` is `-1`, since
nothing has queued the step locally and passing the worker index publishes
to nobody without saying so; and the thread is joined within a bound,
`pthread_join` having no timeout, so an unbounded join is a SIGTERM that
does nothing until SIGKILL. `M0_SIM_ON_LOOP=1` moves the identical step
onto `tick` — same work, same cadence, same publish, only the thread
differs — and is both the A/B knob and the gate's negative arm: a trivial
request measured 0–1 ms off the loop against up to 200 ms on it. Only a
request that lands in a step's first half waits the gate's 100 ms, so the
on-loop arm's margin is the probe's sample count: it took three samples
and failed 19 of 60 local runs once their phases were random, as a slow
runner makes them (it failed a CI run at 98 ms); it takes 24 at random
gaps. `poe smoke-sim-loop` also
asserts the step ids arrive contiguous (the bus is best-effort; at this
cadence it must not drop) and that SIGTERM with a step in flight still
exits 0. Building it found two defects of the class it exists to prevent:
the on-loop arm silently did nothing, `tick` never firing unless
`M0_APP_TICK_MS` is set — zero steps and a fast `/now`, reading as "the
loop coped fine" — and the first probe never joined its thread at all.
D26 records the framework helper deliberately NOT built: one application
is not evidence of which cadence, shutdown and publish choices are right.
- **A `SessionStart` hook, so a fresh container can build and test the
tree** (`.claude/hooks/session-start.sh`). Three things are missing from a
bare Linux container and each fails in a way that reads as a code problem
rather than a setup problem. Without patchelf, `poe build-serve` aborts the
whole sequence as the LAST step of `test-all`, after every test has passed,
and nothing earlier in the run hints that the tree is fine. Without
`uv sync` there is no `mojo` at all, since the toolchain comes from the
venv. And the `.mojoc` artifacts are gitignored, so a fresh clone has none
and every cross-package import fails to resolve until `build-all` runs —
which CLAUDE.md notes appears as unresolved imports in the editor, i.e.
indistinguishable from a broken checkout. The hook is best effort
throughout and always exits 0: a session that refuses to start because apt
could not reach the network is worse than one that starts with a loud note
saying what is missing, and the failure this exists to prevent is a silent
one. Remote-only (`CLAUDE_CODE_REMOTE`), so a developer's own machine, and
macOS, which needs none of it, are untouched.
### Fixed
- **A child process can publish from a view without crashing** (#322, SPEC
I23). The bus descriptors survive `exec` but the event-id page did not:
`M0_SHARED_ID_ADDR` is an address in the parent's memory, and a child
that inherited the environment took an id there on its first publish. On
Linux that was SIGSEGV. On macOS the address was often mapped in the
child, which incremented eight bytes of its own memory and published the
result as an event id; a subscriber that had seen a higher id then
silently dropped the frame. The page is now file-backed in every mode and
exported as `M0_SHARED_ID_FD` too, and carries a magic word. `m0pub`
numbers only from a page it has verified: mapped from the descriptor, or
at an address the kernel reports readable. Anything else publishes
unnumbered, with one line on stderr saying why. The new
`m0pub.child_fds()` is what to pass as `pass_fds`, and a child given it
publishes numbered frames from the same counter, so `Last-Event-ID`
replay covers them. A server that cannot file-back the page (no
`/dev/shm`) starts anyway and says so, except under `--spawn-workers`,
where that was already fatal.
- **`bench-mojo-mount` runs on a fresh clone, and its artifact says what it
measured.** Four defects, each confirmed on `main` before being fixed.
`build-serve` linked four packages through `.mojoc` files a fresh clone
does not have, so that bench — and every smoke that depends on
`build-serve` — failed with `unable to locate module 'm0_http'` until
`build-all` ran by hand; CI never saw it because every job runs `build-all`
first. A MISSING artifact is now built in dependency order, the
`[ -f ] || uv run poe build-ffi` idiom the tree already uses, while a stale
one is not, so a smoke does not pay for the chain on every call. The bench
left `mojo_mount_bench.log` at the root unignored, so every run stamped
`git_dirty: true` — the 2026-09-10 artifact among them — and about thirty
other root logs written by tasks were missing from the per-name list too;
one `/*.log` replaces it. The recorder stamped no machine conditions: macOS
artifacts now carry power source, Low Power Mode, pmset's thermal report,
the performance / efficiency core split, memory and the OS build, every
artifact numpy's version, and Linux ones memory. And "per core" had two
definitions — the headline (1.65x / 1.41x) was the median of each round's
ratio while the artifact's medians block divides median rps by median cores
(1.61x / 1.39x), and one table mixed them — so artifacts now carry
`definitions`, `medians.*.rps_per_core_rounds` beside the existing figure,
and this bench a `comparisons` block with both ratios per selectivity.
- **A benchmark artifact without its comparator rows is refused, and the
Mojo mount's table is rendered.** The mixed workload recorded for this
release under the free-threaded swap had no Granian row: the swap's venv is
built from the default dependency groups, Granian is the `bench` group, and
`bench_mixed_workload.sh` skipped the row without a word. The drift check
then found no comparator in common with the previous artifact and passed,
a leniency meant for older artifacts, so a table would have lost its
reference row with its contamination check vacuous. `render_bench_docs.py`
now refuses a rendered kind's newest artifact that holds none of its
comparator rows, and the bench refuses to start without Granian
(`BENCH_NO_GRANIAN=1` to mean it). docs/SERVER_PERFORMANCE.md renders the
Mojo-mount table from `bench-mojo-mount`'s artifact, printing both
definitions of per core and naming them, and every rendered table's
environment line now carries the machine conditions the recorder stamps.
- **Stopping the WSGI handler pool right after starting it no longer
hangs.** Each `BlockingPool` thread registered on its lane as the first
act of its own body. `stop` pills registered threads on their own wake
channels and sends the remainder to the lane socket, so a thread that
registered after a racing `stop` parked on its own channel while its
pill sat on the lane socket. Its join then waited out the 5 s bound and
the process left naming a thread it had abandoned. The Mojo pool had
the same body and the same fix earlier in this release. Threads are now
registered in `start`, on the spawning thread, before any exists. The
window in a server is small, since `stop` follows a loop that has
served and returned; SIGTERM during startup on a loaded host was the
way in. The new `test_blocking_pool.mojo` counts the threads the moment
`start` returns and stops at once: 0 counted and a 5,072 ms join
before, 4 and about 70 ms after, 10 runs of 10.
- **`M0_POOL_SPIN_US` does what its documentation says.** It was
documented from 0.19.0 (2026-09-07) as overriding the handler pool's
10 µs idle spin (`POOL_SPIN_NS`), in CLAUDE.md, NOTICE, this changelog
and `docs/notes/pool-tail.md`, whose measurements used it. But the patch
that read it was never committed, so setting it changed nothing. It is
now read once when the pool is built, like `M0_POOL_WAKE_AGE_US`. A
value that does not parse, or a negative one, keeps the default. With
one handler thread at four connections, lane wakes went from 39k by
default to 93k at `0` and 4 at `1000`.
- **Mounts under `--threads` are tested where they can run** (SPEC M23).
`smoke-hybrid`'s `--threads` phase served ASGI mounts, which a
free-threaded build refuses with exit 78 (modular/modular#5726). So it
could not pass on the only interpreter where it ran, and no scheduled
job ran it. It is now `poe smoke-mounts-threads`, phase G of the weekly
free-threaded canary. There, Django and Flask mounts serve with their
prefixes under `--threads 2`, a slow Django mount does not stall the
Flask one (`hybrid_isolation.py` takes `ISOLATION_FAST_PATH` to measure
a WSGI mount), SIGTERM ends both loops, and the ASGI refusal is pinned.
On a GIL-enabled interpreter the task checks only that a mounted
`--threads` server is refused.
- **A Mojo mount no longer slows down as its handler pool grows** (SPEC
M22). `MojoPool` threads never registered on their lane, so the pool's
elastic wake rules read the lane as "every thread parked" whenever its
one awake thread was busy, and `submit` woke a sibling on nearly every
request. The reservation of per-thread wake channels was also sized for
the WSGI pool alone. On `/native/probe` at 16 connections beside a WSGI
mount, the zero-config eight threads served 104k rps on 2.04 cores
(202k lane wakes); with one thread, 132k on 1.42. Mojo pool threads now
register, park on their own channels and unregister on exit, and
`_serve_offloaded` reserves records for every pool before starting any.
Eight threads now serve 133k rps on 1.35 cores with 61k wakes, which
beats the WSGI route beside it per core.
- **A Mojo mount's compute route runs on all its threads again** (SPEC
M25). Registering the Mojo pool's threads (M22, above) put its lane under
the elastic rule's stall check, which leaves a ring alone while its pop
count moves: a sibling woken beside a draining lane only queues for the
GIL. A Mojo mount's threads never take the GIL, and the check held its
lane to one of four threads — `bench-mojo-mount`'s search served 15k rps
on 1.2 cores where the unregistered pool served 42k on 4.2. Waking eagerly
on every push restores that and costs the trivial `/native/probe` 21 %, so
only the stall check changes: on a lane whose threads never attach, a job
that has waited past the idle spin (10 µs) since its push gets a parked
sibling, moving ring or not. The search serves 43k rps again, and 76k at
a quarter selectivity where it had fallen to 37k. The lightest routes pay
for it: the probe gives up about 2 % (195k against 199k) and the lightest
search about 4 %, each on more CPU. `M0_POOL_PARALLEL=0` restores the GIL
rule on every lane.
- **A path no mount claims gets the server's own 404, whatever the first
mount is** (SPEC M21). The loop sends a path that matches no mount to
the first mount's lane, and only a WSGI pool thread checked the path
again. So on a server with no root mount whose first mount was ASGI,
`GET /zzz` got that application's answer (a 200 from the fixture app,
and a 403 for a WebSocket upgrade), a lone ASGI mount did the same, and
a Mojo mount listed first answered with its own router's 404 rather
than the server's. The miss
is now decided on the loop, before a mount's lane is chosen, against
every mount's prefix including `mojo` and `hold` mounts. The check
covered WSGI-first servers all along, which is the only shape
`smoke-hybrid` tested; its new phase 2b tests the other three.
- **A mount set that some mount cannot be served in is refused instead of
started half-served, and one that needs handler threads gets them**
(SPEC M20). Four configurations used to start and then answer wrongly or
not at all:
- a `--mount PREFIX=mojo` with no handler pool (`--workers N`,
`--blocking-threads 0`) served inline, where the loop knows only the
Python mounts, so its requests were answered by the root application;
- an ASGI mount beside a Mojo mount on zero config gave the Mojo mount
no threads, and its requests hung;
- more WSGI mounts than handler threads (`--blocking-threads 1` with two,
or zero config on a one-core host) left a mount with no thread, and
its requests hung;
- an ASGI mount beside a WSGI mount under `--workers N` gave the WSGI
mount no thread, with the same result.
Every mount now gets at least one thread from the default pool. Unless
`--blocking-threads` is given, that default also applies under
`--workers N` or `--threads N` to a mount set that cannot run inline: a
compiled mount, or an ASGI mount beside a WSGI one. So
`--workers 4 --mount /=django --mount /native=mojo` now serves both.
`--workers N` with only WSGI mounts keeps its meaning of no pool.
An explicit `--blocking-threads` is used as given. If it's below the
compiled mounts of a kind, the server exits 2; if it leaves a WSGI mount
without a thread, it exits 78 once detection has run. A compiled mount
under `--threads`, which was never served, also exits 2.
The three existing mount refusals (only compiled mounts, a hold mount
without `--realtime` or `M0_GRANT_KEY`) moved before the fork. Under
`--workers N` they ran in every worker and ended in "5 rapid crashes"
and exit 1, and `--doctor` answered 0 for the first of them. `main` and
`--doctor` now refuse through one function. `smoke-doctor` holds nine
mount rows to both agreement and a named exit code.
- **A thread a WSGI application starts runs while the server is idle, with
or without a handler pool** (#310, SPEC E20). With no pool — an unmounted
`--realtime`, `--blocking-threads 0`, or `--workers N` given explicitly —
the event loop calls the application itself, and it waited for I/O still
holding the GIL its thread has held since `Py_Initialize`. A
`threading.Thread` the app started, or an `asyncio.run` inside one, then
ran only when a request happened to run some Python: measured at 1 tick
in 1.5 s idle where 150 were due, and an agent turn publishing progress
with `m0pub.publish` never got past its first line. The loop now releases
the GIL around each wait and takes it back before touching the
application, the shape `--threads` already had. Throughput is unchanged
(hello-world at 16 and 256 connections, A/B within run-to-run noise).
On 1.3.0, `--blocking-threads N` with any N above 0 avoids it.
`poe smoke-app-threads` serves an app with a ticking thread in all three
shapes on both CI legs and counts its ticks over an idle window.
- **The weekly free-threaded canary hung on Linux in every run that reached
its last phase since 2026-08-23, and the hang was the gate's own shell.** Phase 2 of
`smoke-blocking-threads` (a handler pool behind each `--threads` loop,
run only on 3.14t) waited for its two slow requests with
`wait $(jobs -p | grep -v "^$pid$")`. poe runs shell tasks with `sh`,
which is dash on Linux, and dash gives a command substitution's subshell
no job table — so the list was empty, the `wait` was bare, and it waited
on the server until the phase watchdog fired. macOS's `sh` is bash, which
answers the list, so the macOS leg passed and the server was never at
fault: reproduced locally by running the task under `/bin/dash` against
3.14t (hung at the same line, SIGALRM at the deadline) and green in 20 s
with the pids recorded, as phase 1 already did. The phases proving SPEC
E5 and L18 passed, but the run both rows cite as their weekly evidence
was red for three weeks, which `poe milestones` cannot see. `check-docs`
now refuses `jobs` inside `$(...)` in any
task, with selftest cases that put the defect back into the committed
file, because `dash -n` parses the line without complaint.
## [1.3.0] — 2026-09-13
A PostgreSQL binding, a second door onto the bus, and a mount an
application brings itself.
### Added
- **A gate on the `_ = x` keep-alives at the FFI sites.** Roughly thirty
of them end a sequence that hands a buffer's address to C, and nothing
proved they still worked. `poe check-keepalive-barrier` (inside
`test-all`) compiles `scripts/keepalive_probe.mojo` to LLVM IR and reads
four exported bodies: with the line, the allocator free lands after the
call; without it, before — which is the measured hazard, and the half
that keeps the gate evidence rather than ceremony. The probe also
records what is NOT at risk, since only an owning value is: a stack
local whose address escapes is kept alive by LLVM without help.
`poe sabotage-keepalive` reverts each of the probe's own rules and
insists the check reports every one.
- **An application's own Mojo mount, without copying `m0serve.mojo`** (SPEC
N14). The demo mount moved out of the entry file into a module,
`m0serve_mount` (`packages/m0-wsgi/mount/`), and `poe build-serve` takes
`M0SERVE_MOUNT_DIR` to build the same entry file against an application's
own directory instead, plus `M0SERVE_OUT` to name the binary. The directory
replaces the default rather than joining it: with both on the include path
the first root wins silently, measured as a clean build serving the demo.
- **A Postgres `NOTIFY` reaches a held stream** (SPEC I22). `--pg-listen URL`
(`M0_PG_LISTEN`) holds one `LISTEN` on worker 0 and publishes what arrives
onto the broadcast bus, so a writer that cannot reach the datagram bus at
all — a trigger, a cron job, a management command, `psql` — reaches every
subscriber with an id, an event type and its data. The payload is three
JSON string fields, and one present as anything else — the object
`'data', row_to_json(NEW)` makes — is refused and counted rather than
delivered as an empty event (m0-core gains `parse_json_string` and
`has_json_field`, which can tell a real `""` from a wrong type);
`m0pub.notify_sql` builds the statement for a caller
that already has a database cursor, with no driver imported into a
stdlib-only module. Refused without `--realtime`, which is what creates
the bus, and `--doctor` reports both that refusal and which libpq it
found. Nothing is resolved from libpq when the flag is absent — the
server binary's dynamic dependencies are unchanged, which is what keeps
the wheel installable on a machine with no PostgreSQL client. Started in
both execution modes: worker 0 under `--workers`, and once per process
under `--threads`, where the bus is one channel per thread. Refused on
macOS wherever a worker is forked — `--workers N`, and `--reload`, which
supervises even one — because libpq's connect reaches Kerberos through
GSSAPI and Objective-C aborts a forked child; `--spawn-workers` is the
escape, as it is for Core ML, and composes with `--reload`. The SSE line
splitter and frame decoder a payload passes through slice by bytes now
(SPEC G14): a `data` from a `SQL_ASCII` database with a continuation byte
after a newline trapped the listener's thread on worker 0. The listener
drains once after connecting and after every reset, so a notification
libpq read during the `LISTEN` round trip is not left waiting for the
next one to wake `poll`. A host with no libpq exits 78
naming every path tried, rather than serving with no listener — held on
the wheel's own binary, since its users have neither a toolchain nor a
PostgreSQL client.
- **`m0-postgres`, a PostgreSQL binding over libpq** (SPEC O6–O16). A
sibling of `m0-core`, `m0-http` and `m0-sqlite` that imports nothing else
here and links nothing: libpq is opened with `dlopen` at run time, so no
binary in this repo — `bin/m0serve` and the wheel included — carries a
libpq dependency, and an absent library is one error naming every path
tried. `Connection` owns its handle, `Result` owns a complete `PGresult`
and so can outlive its query, `Params` binds positionally with an explicit
OID per value, and every error carries a SQLSTATE that `sqlstate()`
recovers. `open()` applies a connect timeout, a statement timeout,
`client_encoding=UTF8`, an application name, and TCP keepalives of 30 s
idle, 10 s interval and 3 probes with a 60 s `tcp_user_timeout` — libpq's
own keepalives use the OS's timings, measured at 7200 s idle, so a
listener behind a NAT that dropped its idle connection went deaf for two
hours — merging rather than appending so each stays overridable; `open_readonly()` adds a read-only
transaction default; every URL is redacted before it reaches an error, a
log or the doctor, including the ones `redact` cannot parse — an
unencoded `/`, `?` or `@` in a password, a key/value string with quoted
or spaced values, a keyword libpq does not know — which come back masked
whole, with libpq's own message beside them withheld, because libpq
quotes what it cannot parse. `sslpassword` and `oauth_client_secret` are
masked as `password` is. `LISTEN`/`NOTIFY` is supported, including restoring
subscriptions across a reset. No pool, no retry, no `COPY`, and `numeric`,
dates, intervals and arrays read as text — each a deliberate absence, with
the reason in the README.
Three Mojo 1.0 findings are recorded in `lib.mojo` and pinned by
`test_lib.mojo`, all found by crashing: a `dlopen` handle held apart from
the pointers loaded from it is closed at its last mention, a `thin`
pointer field cannot be called as `table.field()` from outside the struct
that holds it even though its address is unchanged, and a `Result` that
reached libpq through its connection's address faulted once that
connection was gone. libpq is now pinned with `RTLD_NODELETE` once opened
and a `Result` holds the entry points it calls by value, so
`var rows = db.query(...)` with no later use of `db` reads correctly
(SPEC O16) — before the fix it was a segmentation fault on the first
read.
- **`m0-sqlite` gets its rows** (SPEC section O, O1–O5). The storage
packages had no capability rows at all, so nothing in the sheet noticed
the three invariants CLAUDE.md calls "look like bugs and are not": that
`open` raises rather than delivering less than the WAL concurrency it
promises, that a `Statement` outlives the `Connection` that prepared it
because every close path uses `sqlite3_close_v2`, and that error text is
trusted only when `sqlite3_errcode` corroborates the code being
described. Each is now a row against the test that already proved it,
beside `m0_array`'s borrow safety and the todo demo's persistence across
a kill and a restart. No behaviour changed; five gates that were running
are now recorded, and the sheet's own sabotage suite covers them.
- **A Datastar form, end to end** (SPEC N12). The todo demo renames a todo
in place: `Fragment[Datastar]` on the `