e7f08052f4ddb7ded974e68bd77a21f198650b5c
100
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0ba15b7862 |
fix(graph): report a self-dependency as the cycle it is (GitHub #43)
A node that needs the token it provides is a cycle of one, so say so in the same words as every other cycle (`cycle detected: a -> a`), and name the token and the fix: cycle detected: auth -> auth (it needs 'user', which only it provides). Remove 'user' from its needs, or move the work that produces 'user' into a step it needs. "missing dependency … it provides it itself" pointed the reader at a missing producer, when the producer is there and the problem is the loop. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
b005d6a44a |
fix(graph)!: fail boot when a node needs the token it provides (GitHub #43)
topoSort validated each need with producedBy.has(key), and the visit skipped a dependency whose producer was the node itself. So a step with needs: ['user'] and provides: ['user'], and nothing else providing user, passed the graph check and booted. At request time it read a value nobody had written, where every other missing dependency fails at boot. The check now treats a node's own token as missing unless it is seeded. The issue also allowed "provided by another node", but since CARD-18 (GitHub #35) a token has exactly one producer, so a second node that provides it fails boot on its own; the self-producer is the only producer there can be. A seeded token (req, params) still satisfies the need, because the step reads the seed from the context before its output is merged over it. The visit keeps skipping the node itself for that case, so it is not reported as a cycle. overrides do not exempt the node. They replace a runner after finalizeGraph has run topoSort, and change no needs, so the graph check sees the same node either way. BREAKING CHANGE: an app with a node that needs a token only it provides now fails createApp with "missing dependency: <token> needed by <node> — it provides '<token>' itself". Remove the token from the node's needs, or move the work that produces it into a separate provider or step. Refs: GitHub #43 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
510e9c4863 |
fix(container): cache the in-flight promise of an app-scoped binding (GitHub #46)
Container.resolve marked an app-scoped binding resolved only after its factory settled. Two resolutions that started before then both found nothing cached and both ran the factory, so one token could open two pools. The binding now caches the promise as soon as the factory starts, and every resolution returns that promise. Retry semantics are unchanged: before, a rejected factory set nothing and the next resolution ran it again. Now a rejection clears the cached promise, so the next resolution still retries, and only the callers already waiting on the failed attempt share its rejection. The factory runs inside an async wrapper so a synchronous throw takes the same path. createApp was not exposed to this in practice. bootProvider runs each provider's runner once, inside the memoized boot, and registers the finished value as a constant factory, and Container is not exported. The fix makes the container's own guarantee hold instead of relying on that. Refs: GitHub #46 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
dae052f400 |
fix(metadata): keep a subclass's decorators off its base class (GitHub #44)
record in params.ts read the argument map with Reflect.getMetadata, which walks the prototype chain, then pushed into the list it got back and defined that same object on the subclass. On a subclass with no metadata of its own, that object was the base class's, so a @query on Child.list also showed up in getArgs(Base, 'list'). routeDecorator in metadata.ts had the same pattern with the routes array, so a @Get on a subclass was also served by the base controller. It is the same bug in the same shape, so it is fixed here too. Both now write a copy onto the decorated class: a shallow copy of the map and a new list for the method in params.ts, a new array in metadata.ts. getMetadata returns the class's own metadata once it has some, so later decorators on that class copy its own data, not the base's. A subclass still starts from what it inherits, as before. The other decorators in metadata.ts (@Provider, @Step, @Route, @Module, @Transformer, @Html) define a fresh value per class or per method and never mutate what they read, so they are unaffected. Refs: GitHub #44 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
1daa4f3cd1 |
fix(http): end an idle stream as soon as the client leaves (GitHub #40)
Both stream adapters waited for the source's pending next() after the client had disconnected. A source idle between events, such as an SSE feed with nothing to send, may never settle that next(), so on Node pipeStream never reached its finally: stream:close did not fire and the closer stayed registered, which graceful shutdown then still treated as a live stream. Through app.fetch, the ReadableStream's cancel awaited return(), which an async generator only runs once its pending next() settles, so cancelling the body did not settle either, with or without compression wrapping it. Each pull is now raced against the disconnect: the response's close event on Node, and the stream's cancel on the fetch path. The source's return() is called without being waited on, through a small releaseIterator helper that also guards a return() that throws synchronously, which on Node escaped from the close listener as an uncaught exception. The WebSocket abort listener already released its iterator this way and now uses the same helper. The new cases in stream-lifecycle-parity drive both adapters, with and without compression, against an async generator, a return() that never settles and a return() that throws. All twelve need the fix except the uncompressed fetch case with a generator, which already passed. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
51fa7c1a88 |
fix(shutdown): treat a graceful close that throws synchronously as a rejection
closeWithDeadline called graceful() directly inside the Promise executor. A graceful path that threw before returning its promise escaped the executor, so the close() that serveDeno and serveBun return rejected on the spot. The deadline timer had already been armed and nothing cleared it, so it later fired anyway: it logged a timeout and forced a server whose close() had already given up. graceful() now runs inside Promise.resolve().then(), so a synchronous throw becomes a rejection and takes the same path one already took: the shutdown ends, close() resolves, and the timer is cleared. GitHub #47. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
212d2fa5c4 |
fix(lifecycle): make a concurrent close() wait for the teardown in flight
TeardownRegistry.run set a `drained` flag and returned at once to any later caller. That kept teardown from running twice, but a second close() made while the first was still awaiting its callbacks resolved straight away. A signal handler and a test hook closing together could then move on with a database the first call had not closed yet. This reached every close path: app.close() with or without a listen()ed server, and serveDeno/serveBun, which hand over to app.close(). The registry now keeps the promise of the teardown it started and returns it to every caller, so the callbacks still run once and each caller resolves only after they finish, within its own runTeardown budget. The drain window and closeApp needed no change: the health drain already shares one window, and a second server.close() waits for the same 'close' event. close() after a failed listen() still has no server and only runs teardown. GitHub #45. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
79925595b5 |
fix(http): parse every +json media type as JSON (GitHub #36)
Exact matching left `application/json-patch+json` arriving as text, where the old substring check had parsed it, and still left the other `+json` types (`application/problem+json`, `application/vnd.api+json`) as text, as they always were. `+json` is the structured-syntax suffix for JSON (RFC 6839), so any media type ending in it is parsed as JSON. `application/jsonx` and parameters that only mention JSON still are not. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
e303cb3a4b |
fix(http): choose the body parser by the media type (GitHub #36)
parseRequestBody picked JSON, urlencoded or multipart with contentType.includes() on the raw header. That is case-sensitive, so a valid `Application/JSON` reached the handler as a string, and it matches anywhere in the header, so a parameter could choose the parser: `text/plain; x=application/json` was parsed as JSON. The media type is now taken from the part before any `;`, trimmed and lowercased (RFC 9110 §8.3.1), and compared exactly. The boundary is still read from the full header. A type that merely contains one of the three no longer selects its parser. `application/json-patch+json` used to be parsed as JSON and now arrives as text, as other `+json` types always have. CHANGELOG says so. test/http.test.ts sends both cases from the issue, plus their urlencoded equivalents, through the Node server. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
7c2454fe43 |
fix(app): an empty mountpoint mounts at the root again (GitHub #31)
GitHub #32 (merged from contrib) made `createApp` fail with a message naming the module when its `@Module` metadata has no `mountpoint`, instead of a TypeError from `joinPath`. The check tested falsiness, so it also refused `mountpoint: ''`, which the type allows and which has always mounted at the root (`joinPath('', '/hi')` is `/hi`). Test for `typeof … !== 'string'` instead: a missing or non-string mountpoint still fails with the new message, and `''` boots as before. The CHANGELOG entry for #31 that #32 did not add is included. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
dc88fdef10 |
Merge pull request #32 from otrumb/fix/module-mountpoint-error
fix(app): validate module mountpoints at runtime |
||
|
|
f494fc283d |
docs(changelog): say how to migrate off the two new boot failures (CARD-22)
Two Breaking entries in [Unreleased] described a new boot failure without the step that fixes it. Found in the second pre-freeze review. - #127, constrained route params that tie: make the constraints disjoint, keep one route and branch in the handler, or give one its own static segment. A plain param reported unreachable never served a request, so delete it or narrow the constraint that shadows it. For a WebSocket pair, declare the constrained route first. - #126, reserved `/__mesh__/control`: move the route to another path. Nothing replaces the reserved one, which never reached a route on Deno, Bun or the edge. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
92d54dcc45 |
feat: name every type the public signatures use, before the freeze (CARD-22, D19)
D19 as amended 2026-10-24: nothing that shipped in 26.9.0-beta.2 is removed. Every symbol D19 had listed for removal or review is in that release, so this change only adds exports and marks scope. - Export `AppOptions`, `ExplainNode`, `WsRequest` and `WsSocket`. Each appears in a public signature (`createApp`, `Explain.chain`, `app.upgrade`) but could not be imported. `AppOptions` is the former inline options type of `createApp`, moved verbatim into an interface. - Add `RequestHeaders`. `Headers` shadows the Fetch global wherever it is imported, so it stays only as a `@deprecated` alias of the same type. - Mark the mesh exports and `MeshConfig` `@experimental`. They stay exported and unchanged, but sit outside the freeze, like the `experimental: true` flag the mesh already needs. - The seven review candidates (`withConsoleFallback`, `UNMATCHED_ROUTE`, `HTTP_ERROR`, `VALIDATION_ERROR`, `TransportMismatchError`, `isAsyncIterable`, `buildOpenApi`) stay as they are. CHANGELOG: `### Added` for the types, `### Changed` for the mesh tag, and a new `### Deprecated` for `Headers`. No `### Breaking`. test/types/public-surface.test.ts fails to compile if any of the new names stops being exported. `deno publish --dry-run` passes. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
411c7ef3f5 |
fix(mesh): cap what an unauthenticated control peer can send on Node (#120)
Before a peer's hello is accepted, `boundInbound` refuses any frame over 64 KiB, but only once it has the whole frame. On Node, the control channel's `WebSocketServer` takes the authenticated bound as its `maxPayload` (about 7 MB at the defaults, so an RPC body fits), and `maxPayload` is fixed per server. So `ws` assembled a frame up to that size for a peer that had not yet authenticated. Found in the second pre-freeze review. The existing pre-auth tests use a fake socket and never reached `ws`'s own limit. The Node adapter now counts the raw socket bytes from the upgrade until the hello is accepted (`boundInbound` gains an `onWiden` hook for that moment). Past a hello's worth (64 KiB + 1 KiB), it sends close 1009, as every runtime does for an oversized frame, pauses the socket so `ws` reads nothing more, and ends it. The counter is installed in the `handleUpgrade` callback, after `ws` attaches its own `data` listener, so no chunk is lost. Bun and Deno have no per-socket limit for this. The CHANGELOG #120 entry now says so, and says to limit frame size at the proxy if untrusted peers can reach a Bun or Deno teapot's control path. Test: a raw client announces a 5 MB frame before its hello and sends 200 KiB of it. The teapot answers with a 1009 close frame and closes the connection. Without the fix it waits for the rest of the frame. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
1ae4c6f865 |
fix(mesh): queue RPC sends per socket so one drain releases one frame (#41)
#152 made each mesh RPC send wait for `drained()`, but each one waited on its own. A drain on a backed-up socket releases every waiter at once (`nodeSocket` keeps them in one list), so they all sent and the buffer overshot the 1 MiB mark by one frame per concurrent RPC: bounded, but not what #152 claims. Found in the second pre-freeze review. `sendWhenDrained` (ws-core, internal) chains sends per socket, and each one waits for `drained()` when its turn comes. The buffer then peaks at the mark plus one frame, however many RPCs wait, and frames go out in call order. The teapot's `reply` and the link's `sendRpc` both use it. The frame is built at send time, so a call that timed out while queued sends nothing, and nothing is sent after the close. Tests: a burst of five 100-byte frames behind a backed-up socket sends one frame per drain, in order, with the buffer at most one frame. It fails when each sender waits on its own. Also: a withdrawn frame is skipped, and a frame queued at close is dropped. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
2fc7bab78a |
test(mesh): keep T2's refused body inside the socket buffer (#120)
T2 sent a 1,000,001-byte body against the 1 MB default. The teacup answers 413 with `connection: close` while the client is still uploading, so the client sometimes saw EPIPE instead of the 413: about 1 run in 10, on develop too. That is the transport racing the answer, not a different answer. Run it against a 1,000-byte limit, the way the edge suite already does. CARD-24's T2 asks only for "body > maxBodyBytes". 0 failures in 30 runs, against 2 in 20 before. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
bca6fd09eb |
fix(app): listen() rejects when the port is taken (#138)
`listen()` awaited `server.listen(port, cb)` without an `error` listener. A bind failure (EADDRINUSE, EACCES) never calls the callback, so the promise hung and the error went unhandled. That is the 30 s timeout #138 saw on CI: owner.test.ts reserved a port with `freePort()` (listen on 0, close, reuse the number), another process on the shared runner took it, and the teapot's `listen` hung instead of failing. - core: `bind()` rejects on the `error` event. On failure `server` goes back to undefined, so `close()` resolves and `listen()` can retry. - owner.test.ts: lifetime A listens on port 0 directly, since its teapot is up before the teacup needs the port. Lifetime B has to boot its teacup against a port nobody holds yet, so it keeps `freePort()` and reruns on a fresh port on EADDRINUSE, up to three times. Tests: listen on a taken port rejects with EADDRINUSE, then the same app listens on 0 and serves; close() after a failed listen resolves. Both hung without the fix. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
b23b4e4161 |
docs(changelog): static revalidation is a breaking change (CARD-15, D12)
Every static file now goes out with `Cache-Control: no-cache`, where
before it sent no Cache-Control at all. A browser or proxy that reused
static files for a lifetime guessed from `Last-Modified` now revalidates
each one, and keeping the old behaviour needs a config change (`static:
{ cacheControl }`). That is a breaking change, so the entry moves from
`### Changed` to `### Breaking`, word for word.
D12 had filed it under `### Changed`. CARD-22's gate table already said
a breaking entry was due if the default turned on, and it did. The
pre-freeze review flagged the mismatch.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
07d9b7441c |
fix(mesh): RPC frames wait for the send buffer too (CARD-26, #41)
CARD-26 made the WebSocket route pump await `drained()` before each pull, but mesh RPC traffic sends outside that pump, so it never waited: - teapot: `handleRpc` runs concurrently per rpc-req, so a teacup that keeps sending requests and stops reading grows the teapot's buffer by one response each. - link: `sendRpc` sent each rpc-req at once, whatever the buffer held. Both now wait for `drained()` before sending. The teapot drops a response whose socket closed while waiting. The link starts its timeout before waiting, so a teapot that stops reading still answers 504, and a call that settles while waiting (timeout or close) is never sent late. Found in the pre-freeze integrated review. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
0017093626 |
chore: mirror the new overrides in deno.lock
deno.lock records package.json's overrides, so the runtimes (deno) job's publish dry-run found it out of date after the bump and aborted. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
3efe049bb5 |
fix(http): a handler-set ETag array is still the handler's (CARD-15)
With `etag: true`, `tagged()` only recognised a handler ETag given as a string. Given as an array, it compared If-None-Match against the body's computed tag while sending the handler's array, so a client revalidating with the tag it was sent got a 200 instead of a 304, and two ETag values went on the wire. ETag is single-valued, so the last value of an array wins, as a repeated `setHeader` would. It is sent alone and drives the comparison. Found in the pre-freeze integrated review. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
74dbbe0b1a |
chore: clear the dependency advisories blocking CI
`npm audit --audit-level=moderate` fails on develop: six advisories, all in devDependencies, none in what ships. - body-parser (high) and fast-uri (moderate): a plain `npm audit fix`. - undici (high): the existing override pinned 7.29.1, now inside the advisory range. Move it to 7.30.1. `--force` wanted a miniflare downgrade instead. - multer (high): reached through @nestjs/platform-express, the bench's Nest comparison. 2.5.0 carries the fix. `--force` wanted a Nest downgrade, so add an override like the others. Verified: audit reports 0 vulnerabilities; lint, typecheck, `npm test` (1149), test:edge (exercises miniflare on the new undici), test:bun, test:deno and build all pass. test/mesh/large-body.test.ts T2 fails about 1 run in 10 with EPIPE. That rate is the same with and without this change (2/20 each), and Node's fetch uses its bundled undici, not this one. Tracked separately. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
a9a4f6c6ef |
fix(ws): wait for the send buffer before pulling the next outbound value (CARD-26, #41)
The outbound pump pulled a @Ws handler's iterator as fast as it yielded, whatever the peer read. With a slow client, 10,000 frames of 64 KiB were all pulled at once and sat in the send buffer: 640 MiB. WsSocket gains one optional member, drained(): it resolves once the socket's send buffer is at or below the adapter's high-water mark (WS_HIGH_WATER_MARK, 1 MiB, internal), or the socket has closed. The pump awaits it before each pull, so the buffer peaks at the mark plus one frame. A close ends the wait and the abort path runs the iterator's return(), as before. A socket without drained() is never waited on. Per runtime: - Node: ws.bufferedAmount, released by each send's write callback; - Bun: getBufferedAmount(), released by the server's drain callback; - Deno: polls bufferedAmount every 10 ms, only while over the mark; - workerd reports no buffered amount, so the edge never waits. The Deno poll also waits while the socket is CONNECTING. Deno hands the socket over before it opens, and a handler that yielded at once had its first value pulled into a socket that was not open yet. The pump then gave up, so the client saw no frame and a 1005 close. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
8f73779a21 |
fix(mesh): hold the control channel to hello size until the peer authenticates
boundInbound(socket, meshBounds) runs before ensureBooted() and before the hello is checked, and meshBounds allowed 4,096 queued frames of up to 7 MB each. During a slow boot nothing reads that queue, so an unauthenticated peer could make the process buffer tens of GB. The control channel's bounds are now phased (controlBounds() replaces controlLimits()): - until the hello is accepted: frames of at most HELLO_FRAME_BYTES (64 KiB) and the default 16-frame queue, so about 1 MiB per connection; - after: the frame bound from #120 and the queue bound from #148. boundInbound takes the second set as an optional `widened` argument and keeps the switch on the bounded socket under a Symbol.for key. The teapot calls widenInbound() when the handshake succeeds. The teapot's own parse check follows the same phases, so a standalone createMeshControl also refuses a pre-auth frame over hello size. This is an auth-phased bound rather than a total-bytes cap: the only unauthenticated frame with a purpose is the hello, and phasing keeps the trusted path free of a second accounting rule. No new option. On Node the control path's native maxPayload stays at the authed bound, because ws cannot change it per phase. A pre-auth peer can still make ws assemble one frame of up to that size before boundInbound closes the connection with 1009. That frame is transient and never queued. Tests: during a delayed boot, a 1 MB pre-auth frame closes 1009 at once and a flood closes 1013 within 17 frames; after the hello, large frames and a 64-ping burst are accepted. On Node, Deno and Bun, an unauthenticated 1 MB frame over a real socket closes 1009. The #148 64-RPC test stays green. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
e98d5d33eb |
fix(mesh): size control frames for the worst escaping a body can get (#120)
A 999,000-byte text/plain body of U+0001, within maxBodyBytes, still failed 503: the envelope carries a text body as a JSON string, each control character escapes to six characters, and the ~6 MB frame was over the 4,000,000 the channel was sized to. controlFrameLimit() is now 6 x maxBodyBytes plus 1 MiB for headers, params, query and the envelope: 7,048,576 at the 1 MB default. Six is the worst growth of any body byte; quotes and backslashes double, JSON numbers like 1e20 grow about fivefold, multipart Buffers at most fourfold, and non-ASCII text is not escaped. The fixed MAX_FRAME_CHARS goes away with it. Test (T1c) on Node, Deno and Bun: the control-character body now answers 200 and the channel stays open. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
cad81223e5 |
fix(mesh): give the control channel its own inbound queue bound (#148)
The control channel also inherited limits.maxWsQueue (16 undelivered frames, close 1013) from #107. On Node, ws emits every frame of one socket read synchronously, so a teacup with more than 16 RPCs in flight sent a burst the teapot's queue refused: the link dropped and every pending request failed 503. Deno and Bun deliver one frame per task and did not trip. controlLimits() now also raises maxWsQueue for the control channel, to an internal 4,096 frames or maxWsQueue if larger, alongside the size bound from #120. The teapot's frame loop never awaits between frames, so the queue only holds one delivery burst, and one read (at most 64 KiB) holds fewer than 4,096 of the smallest control frame. The bound stays finite, so a peer flooding a channel nobody is reading is still cut off. No new option. User @Ws routes keep closing 1013 at maxWsQueue. Tests: 64 RPCs in one tick through app.fetch on one link all answer 200 (red on Node before), and a user route on the same teapot still closes 1013, on Node, Deno and Bun. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
713122d53a |
fix(mesh): bound the control channel by maxBodyBytes, not the 1 MiB ws cap (CARD-24, #120)
The 1 MiB inbound cap from #107 applied to every WebSocket, the mesh control channel included. An RPC carries a whole request body, so a body inside maxBodyBytes could still overflow the cap once wrapped in an rpc-req frame, and the teapot then closed the whole channel with 1009: every request through that link failed 503 until it reconnected. The test asked for by the card (T1, a 1 MB JSON body at defaults) passes on Node, Deno and Bun, because a JSON body re-encodes to about its own size. Two other cases fail on all three before this change: - T1b: a 999 KB text body of quotes doubles under JSON escaping; - T4: maxBodyBytes raised to 4 MB, a 3.9 MB JSON body. The control channel's bound is now derived from the teapot's limits.maxBodyBytes via controlFrameLimit(): MAX_FRAME_CHARS (4,000,000) at the 1 MB default, scaled by the same ratio above it, never below maxWsMessageBytes. No new option. User @Ws routes keep maxWsMessageBytes: Node gets a second WebSocketServer for the control path, app.upgrade picks the bound from the path before subscribing, and Bun's single native maxPayloadLength is raised on a teapot only, leaving app.upgrade to close user routes 1009 itself. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
3296189093 |
feat(http): response compression with gzip and br (CARD-16, #112)
Text responses went out uncompressed unless a proxy sat in front of every
runtime. createApp({ compression: true | { threshold, encodings } }), off
by default, implements D13 strategy B as accepted on 2026-10-22.
- One function, compressOutcome, runs after handle() and before either
adapter writes, so Node and the fetch runtimes cannot diverge.
- Accept-Encoding negotiation with q-values, identity, * and q=0; ties go
to server preference (br before gzip). Vary: Accept-Encoding is merged
wherever the request decided the outcome, including every 304. Skips:
existing Content-Encoding or Content-Range, no or an incompressible
Content-Type (ndjson is compressible), Cache-Control: no-transform.
HEAD and bodies under threshold keep Vary; 204 gets none.
- Node, Deno, Bun: node:zlib only, loaded lazily through nodeRequire.
Buffered bodies use the async API, never the sync one; br at quality 4.
Content-Length is dropped from an encoded body.
- Streams (SSE, ndjson): a zlib stream flushed after every frame, error
frame and ping, piped into res on Node and wrapped around the
ReadableStream on fetch runtimes. Backpressure follows the compressor;
a client leaving destroys it.
- Edge: core never encodes and sets Vary only. Edge is recognised by
edgeHandler, which marks the app through an internal symbol, and by
createApp detecting workerd (navigator.userAgent, or node:zlib failing
to load), which covers a bare app.fetch export.
- ETags from CARD-15 are taken on the identity body and stay weak, so the
tag does not change with the coding.
Deno runs zlib's async API on the main thread; that is documented and
pinned by a test, not worked around.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
d32fc9f8d7 |
feat(http): ETag and 304 for static files and buffered responses (CARD-15, #114)
Conditional GETs were never answered: every revalidation re-downloaded
the file or response.
- Static (D12, always on): a hit carries W/"<size>-<mtimeMs base36>",
Last-Modified and Cache-Control from the stat the resolver already did.
A matching If-None-Match, or If-Modified-Since when If-None-Match is
absent, answers 304 before the file is read. StaticHit now carries the
stat and a read() for the bytes, and HEAD no longer reads either.
- static: { dir?, cacheControl? } (rule 1a): Cache-Control defaults to
no-cache so browsers revalidate rather than reuse a file for a lifetime
guessed from Last-Modified. An unknown key or CR/LF throws at boot.
- createApp({ etag: true }) (off by default, boolean only): a buffered 200
to GET/HEAD gets a weak tag from a 32-bit FNV-1a hash of its UTF-8 bytes
plus its length, computed before HEAD blanks the body. A handler-set
etag is kept and only compared. Weak comparison, lists split outside
quotes, and * are supported.
- Every buffered 304 leaves dispatch bodiless, with its content-* headers
dropped, so NotModified matches the ETag path on every adapter.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
7f9a0eef0f |
feat(http)!: cookie decorators, setCookie, and string | string[] response headers (CARD-14, #113)
Reading a cookie meant parsing the Cookie header by hand, and a response
could not carry more than one Set-Cookie: response header values were
Record<string, string>, and the fetch adapters would have stringified an
array into one broken "a,b" cookie anyway.
- @cookie('name') / @cookies() sit next to @header/@headers as a new
'cookies' arg source. The header is parsed on first use per request and
cached on the context, so a route without a cookie argument never parses
it. RFC 6265: first value wins, %-sequences decoded, malformed pairs
skipped (never a 400), undecodable values kept raw. Several cookie lines
are joined with "; ". The map has no prototype. @needs('cookies') reads
the same map, and 'cookies' joins the seed-key allow-list.
- setCookie(name, value, options) serialises one Set-Cookie value with
HttpOnly, SameSite=Lax, Path=/ and Secure by default (D10), and throws,
naming the field, on anything that could inject a header or that browsers
reject (sameSite none / partitioned without secure).
- Response header values widen to string | string[] (D11) across
TransformerFn, ErrorResponse, HttpError(Like).headers, ResponseShape and
the neutral outcome. Node writes a set-cookie array as one line per
element and joins every other array with ", " before writeHead; the
fetch adapters build a Headers and append each set-cookie element.
mergeInjectedHeaders keeps arrays by reference and joins a vary array
before merging it.
- OpenAPI maps a cookie argument to an in: cookie parameter.
BREAKING CHANGE: code that reads a header value from TransformerFn,
ErrorResponse, HttpError or ResponseShape as a string must handle string[].
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
9ea1365b66 |
test(router-parity): a late teapot is served after it connects for CARD-19 (owner approval required)
owner-mesh-lifetime.json froze phase B2 (teapot absent at boot, then up) at 404 for GET and POST /api/remote/ping. The table was built once at boot, so a late teapot was never spliced in. CARD-19 (#124, D15) changes that. B2 now answers GET 200 {"from":"teapot"} and POST 405 with Allow: GET, HEAD, OPTIONS, the same as A1. Only those two entries change. A1, A2 and B1 are identical. The fixture's teacup goes from reconnect: false to reconnect with a fast backoff (20-60ms). Under D15, reconnect: false makes a dropped teapot "gone" (404), and an absent one is not retried. The card's phases describe the reconnecting teacup: A2 stays 503 and B2 becomes 200. B2 now waits for the mesh:routes event before probing. The fixture comment and the corpus README line describing "built once at boot" are updated. Owner approval required (CARD-08 rule): this edits a frozen file and the fixture under test/router-parity/. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
6bbd78fc8e |
feat(mesh): remote routes follow teapot membership (CARD-19, #124)
The teacup built its route table once at boot. A teapot that started
late was never served, and one that was gone for good stayed advertised.
Implement D15 (accepted 2026-10-18):
- A teapot that missed bootTimeoutMs is retried in the background with
the reconnect backoff (not with reconnect: false). On connect its
routes join the remote table. Its steps do not, because the graph
was validated at boot without them.
- While a link is reconnecting, its routes stay and answer 503, now
with retry-after (seconds until the next attempt).
- A link that gives up for good (dropped with reconnect: false, or a
permanent refusal while reconnecting) has its routes removed: 404,
and Allow drops its methods. A refused reconnect no longer retries
forever.
- A returning manifest replaces the teapot's routes. missingFromManifest
now checks steps only, so a dropped route is removed instead of
refusing the reconnect.
- A late route that conflicts with another teapot's is refused and
logged. The table keeps serving. At boot the same conflict still
fails boot.
- Each change emits mesh:routes with { url, added, removed }.
- The reserved-path check from CARD-21/CARD-17 (#141, #145) runs in
the table for every remote route: at boot a route on /__mesh__/control
(or /__live__ and /__ready__ with health on) fails boot as before. A
late or returning one is refused and logged, and the teapot's other
routes are served.
Mechanics: the remote table publishes a new array per change
(copy-on-write). app.fetch and listen() share one table through a
getter, and buildFetch/createHttpServer read it once per request, so a
request sees the old table or the new one, never a mix. The router
reuses local trees when the local entries are identical, so a
membership change rebuilds only the remote trees. Dev routes now sit
before remote ones in the table to keep the local positions stable.
Tests cover T1-T8 on Node (test/mesh/membership.test.ts), plus the
local-tree build counter and late reserved-path routes, and T1/T2 on
Deno and Bun.
The frozen owner-mesh-lifetime.json capture changes in the next commit.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
ae9e5529e8 |
test(router-parity): HEAD on a remote GET answers 200 for CARD-20 (owner approval required)
owner-mesh-allow.json froze HEAD /api/x at 404 on both adapters: the teacup forwarded HEAD to the teapot, which has no HEAD plan for the route. CARD-20 (#125, D16) fixes that, so HEAD now answers 200 with the GET's headers and an empty body, like a local route. Only those two entries change (fetch and node), status 404 -> 200. Headers and the empty body are identical. The fixture comment in owner.test.ts that described the old behaviour is updated to match. Owner approval required (CARD-08 rule): this edits a frozen file under test/router-parity/. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
5783212377 |
fix(mesh): answer HEAD on a remote GET route (CARD-20, #125)
The teacup's router resolves HEAD to a remote buffered GET through the implicit-HEAD fallback, and OPTIONS advertises HEAD. But the remote route handler forwarded req.method, so the teapot got a HEAD envelope, found no HEAD plan in resolveRoute, and answered 404. Forward a HEAD that matched a remote GET as GET. dispatch already drops the body for HEAD, so the client gets the GET's status and headers and no body, the same as a local route. An explicit remote HEAD route is matched first and is still forwarded as HEAD. The fix is teacup-side (D16, accepted 2026-10-22): the teapot and the wire protocol are unchanged, so a new teacup works against an older teapot during a rolling deploy. Tests cover app.fetch and the Node listener (200 + GET headers + empty body, OPTIONS, explicit HEAD precedence, 404/500 kept with no body, the teapot handler called once as GET) and Deno and Bun. The frozen owner-mesh-allow.json capture changes in the next commit. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
f0530b15bb |
feat(http): liveness and readiness probes with a drain window (CARD-17, #115)
createApp({ health: true }) serves GET/HEAD /__live__ and /__ready__.
Ready reports booting until boot() resolves, ok or degraded (from
app.degraded()) after that, and draining from the moment close() starts.
Probes are answered by the adapters, ahead of the request gate and of
handle(): Node in serve() (src/http/server.ts), the Fetch path in
app.fetch before it awaits the boot. Otherwise ready could never say
booting. Being ahead of the gate means maxConcurrentRequests never sheds
a probe (D14). Being ahead of handle() means no step, provider, plugin or
onError runs, and no lifecycle event is emitted, so logRequests and
metrics never see a probe. Security headers still apply, plus
cache-control: no-store. Other methods get 405 with Allow: GET, HEAD.
A probe through app.fetch before any boot starts the boot without
awaiting it. On the edge, or under a bare Deno.serve(app.fetch), nothing
else may boot the app, and an orchestrator that waits for ready before
sending traffic would wait forever.
health: { drainDelayMs } (D14) marks the app draining and keeps the
listener open for that long before connections drain. Without it, Node
closes idle keep-alive sockets at once, and a probe sees a reset rather
than the 503. The window is spent out of the close budget. serveDeno and
serveBun start the same window, through a symbol-keyed hook on the app,
before server.shutdown() / server.stop(false). workerd has no close(),
so it never reports draining.
While health is on, /__live__ and /__ready__ join the reserved-path
boot check that CARD-21 introduced, for local and mesh-spliced routes.
Invalid health values throw at createApp.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
9977d14605 |
test(router-parity): reserved mesh path refused on Node for CARD-21 (owner approval required)
Golden update for ws-node-upgrade.json, needs owner approval (CARD-08
rule). The WS parity fixture declared @Ws('/__mesh__/control') to
capture the old adapter split: the Node listener served it (101, the
route's frame, close 1005), app.upgrade refused it (1008). Under D17
that route fails createApp, so the fixture drops it and keeps the path
in UPGRADE_PATHS. The Node row now matches the app.upgrade row: 101, no
frame, close 1008 with the shared reason.
ws-app-upgrade.json is unchanged: app.upgrade already refused the path
before matching, so removing the route does not change its answer.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
2c00cc3407 |
feat(mesh)!: reserve /__mesh__/control on every adapter (CARD-21, #126)
The Node upgrade listener only intercepted /__mesh__/control when a mesh control channel was configured; otherwise a user @Ws route there was served. app.upgrade (Deno, Bun, edge) always checked the path first and closed 1008. The same app therefore worked on Node and was refused everywhere else. D17 makes the path reserved in every app, mesh or not: - createApp fails when a @Ws, @Stream or HTTP route claims the path, naming the declaration. A literal pattern is checked by equality, a parameterised one (/__mesh__/:x, /__mesh__/:rest*) by matching the reserved path against it. Patterns whose first segment is not the literal __mesh__ (/:org/:repo, /:rest*) still boot: the adapters answer the path before route matching, so those routes never see it. - A route exported by a teapot is checked during the teacup splice. - The Node listener, with no control channel, accepts the upgrade and closes 1008 with the reason app.upgrade gives. The reason is now one shared constant. The check lives in src/http/reserved-paths.ts so CARD-17 can add /__live__ and /__ready__ to the same list. BREAKING CHANGE: an app that declares a route at /__mesh__/control, or a pattern under /__mesh__/ that matches it, now fails createApp. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
56f953f0bb |
feat(graph)!: fail boot when a token has a second producer (CARD-18, GitHub #35)
topoSort, topoLevels and subgraphFor built their token -> node map with
producedBy.set(key, node), so the last node registered for a token won.
Plugin nodes are registered after module nodes, which let a plugin's
scope.add({ name: 'shadow', provides: ['user'] }) silently replace the
app's own @Provider({ provides: 'user' }) for every route that needed
it. setRunner only rejects duplicate names, and scope.add is the one
path where a name and its tokens differ.
D9 settles it graph-wide: topoSort now throws when a token already has
a producer, naming both nodes and their origins (module:..., plugin,
mesh:<url>, builtin). One check on the whole node set covers every
current and future registration path. It also protects the built-ins
(logger, rooms, events) by rule rather than by registration order.
topoSort runs at finalize, after the mesh splice, so remote steps are
checked too. topoLevels and subgraphFor only ever see nodes topoSort
has already validated, so they keep their plain maps.
overrides replace the runner of an existing token and add no node, so
they are unaffected. Steps that provide nothing (plugin observers) are
not producers. The official plugins (jwt, metrics, rate-limit) pass
their suites against this build.
BREAKING CHANGE: an app whose graph has two nodes providing one token,
e.g. a plugin scope node providing a token a module or built-in
already provides, now fails createApp instead of letting the later
node win.
Refs: GitHub #35
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
88cbe41f72 |
feat(edge)!: trust cf-connecting-ip only under trustProxy, for HTTP and WebSocket (CARD-23, #119)
edgeHandler copied cf-connecting-ip into ctx.ip on every WebSocket upgrade, so any client that sent the header chose its own address, and it never read the header for HTTP, so IP-keyed plugins saw '' there. D21 settles both: the header counts only under trustProxy, on both paths, with no new option. The adapter cannot make that call, because trustProxy is an app option. So edgeHandler records the header against the object it hands the app (the Request for HTTP, the WsRequest for an upgrade) in an internal registry next to the Deno/Bun peer one, and app.fetch and app.upgrade both consult it through one helper, trustedProxyClient(), which returns '' unless trustProxy is on. Under trustProxy it takes precedence over x-forwarded-for, since Cloudflare sets it itself and XFF can carry client-supplied hops. Nothing else records into the registry, so the Node, Deno and Bun adapters, and a bare app.fetch or app.upgrade, ignore the header as before. BREAKING CHANGE: an edge WebSocket upgrade no longer takes ctx.ip from cf-connecting-ip unless the app sets trustProxy: true; without it, ctx.ip is ''. Refs: #119 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
8bf54ec168 |
fix(http): keep every ? after the first in the query string (CARD-25, GitHub #48)
parseQuery took `url.split('?')[1]`, so a second `?` ended the query
string and `/search?q=what?now` gave `q: 'what'`. RFC 3986 §3.4 allows
`?` inside a query. The query string is now everything after the first
`?` and before `#`, if one is present. The early return for URLs without
a query is kept, and so is its measurement note. The comment that
deferred this behaviour question is removed because the question is now
decided (D23).
Path extraction already split on the first `?` and is unchanged.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
e112819f64 |
chore(deps): patch vite, vitest and fastify dev-dependency advisories
`npm audit --audit-level=moderate` failed on develop: vite <=6.4.3 (high: cross-origin script execution in custom middleware, fs.allow bypass, launch-editor), vitest/@vitest/mocker <=4.1.11 (moderate: code injection via manual mock registration) and fastify 5.12.2-5.12.5 (low, benchmark only). All are devDependencies; the published package is unaffected. Lockfile-only: vite 6.4.5, vitest 4.1.12, fastify 5.12.7, all inside the existing ranges. Generated with npm 11 because npm 10.9.7's arborist crashes on this tree (`Cannot read properties of null (reading 'edgesOut')`). Verified: npm ci, audit (0), lint, format, typecheck, test (915), build, complexity, test:deno, test:bun, test:edge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
69bdc8adec |
test(bun): expect 1009 for oversized WebSocket frames on Bun 1.4+
CI picked up Bun 1.4.4 (`oven-sh/setup-bun@v2`, latest), which now sends a real `1009` close frame when `maxPayloadLength` refuses a frame. Bun 1.3 dropped the connection instead, so the peer saw `1006` — the difference D1 documented and these two assertions pinned on purpose so a Bun upgrade would be noticed. It was: `runtimes (bun)` fails on develop. The assertion now follows `Bun.version` (1006 before 1.4, 1009 from 1.4), so a further change in either direction still fails. JSDoc, README and the #107 CHANGELOG entry say which Bun versions do what. Verified with Bun 1.3.14 and 1.4.4 (26/26 each); lint, format, typecheck, npm test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
169ffe6b88 |
Merge pull request 'ci: move workflow actions off the deprecated Node 20 runtime' (#133) from chore/ci-node24-actions into develop
CI / dco (push) Has been skipped
CI / runtimes (edge) (push) Successful in 14s
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 27s
CI / runtimes (deno) (push) Successful in 20s
Promote → GitHub / push-github (push) Successful in 5s
|
||
|
|
7bc402a1fb |
ci: move workflow actions off the deprecated Node 20 runtime
actions/checkout and actions/setup-node v4 -> v5, softprops/action-gh-release v2 -> v3; all three run on Node 24. setup-deno@v2, setup-bun@v2 and crates-io-auth-action@v1 already resolve to Node 24 releases. Jobs keep node-version 22. Refs #103 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
539f287a67 |
Merge pull request 'feat(router)!: fail boot on unreachable or ambiguous constrained params (CARD-13, #127)' (#132) from feature/fprd-001b-constraint-ambiguity into develop
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (edge) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 20s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 17s
CI / build (push) Successful in 26s
|
||
|
|
84e6f0752e |
docs(readme): describe radix route lookup
The README still said matching was a linear scan with a radix tree as post-beta work; CARD-07 (#128) shipped the radix index. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
63f60134ea |
feat(router)!: fail boot on unreachable or ambiguous constrained params
Before, when two sibling routes could match the same request, the router
picked one by registration order or precedence, and nothing reported it.
Boot now refuses two cases between routes of the same method that branch at
the same segment under the same prefix:
- ambiguous: both params are constrained, the constraints accept a common
segment, and the rest of both patterns can match one request. The error
names both declarations and a witness segment with an example path.
- unreachable: a plain param sits next to a constraint that accepts every
segment, and the constraint wins every request the plain param could take.
A plain param next to a constraint that leaves some segments over is the
documented fallback pattern and still boots.
The check is exact. assertSafeConstraint admits only a linear, group-free
subset, so every constraint reads back as a sequence of (character set, min,
max) blocks. Atom sets follow u-flag semantics. \p{...} is the one construct
that is not modelled, and for it the engine is asked once per code point. A
product walk over two block sequences finds a common segment, or proves none
exists, in O(|A|*|B|*(|A|+|B|)*K) with K <= 2048. "Accepts every segment" is
a closed-form test on the blocks. Both are measured against what the router
hands a param: a decoded, non-empty segment that is never "." or "..".
The check runs per table under that table's own precedence. HTTP ranks by
specificity. WebSocket takes the first declared match. @Stream routes sit in
both tables. Routes exported by different teapots are checked against each
other. Local against remote keeps the local override and its warning.
The lookup path is unchanged. router.ts only exports the two token regexes,
so the boot check and assertSafeConstraint read atoms the same way.
BREAKING CHANGE: an app that declares two overlapping constrained siblings
(e.g. /u/:id(\d+) and /u/:n(\d{1,3})), or a plain param beside a constraint
that accepts every segment, now fails createApp. So do a plain WebSocket param
declared before a constrained sibling, and such pairs across mesh teapots.
Refs: #127
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
e41d9560ba |
test(router-parity): make the app fixture's hex route disjoint for CARD-13 (owner approval required)
The frozen app fixture declares GET /n/:num(\d+) and GET /n/:code([0-9a-f]+). Both constraints accept digits, so CARD-13 (#127) makes this pair a boot error, and the fixture app could no longer start. That would fail app-fetch.json and app-node.json, and the Deno, Bun and workerd parity runs that boot the same app. Narrow nCode to [a-f]+. The two frozen requests on this pair still get the captured answers: /n/42 goes to nNum and /n/ff goes to nCode, with the same params. No frozen JSON file changes. What is lost at app level is the equal-rank registration tie between two overlapping constraints. CARD-13 now forbids that tie at boot. The tie stays covered by matcher-hand.json, which calls the matcher without booting an app. Owner approval required (CARD-08 rule): this edits a file under test/router-parity/. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
c2db4f69c6 |
Merge pull request 'test(router): record D4 lookup evidence and no miss-time recompilation (CARD-10, #109)' (#130) from feature/fprd-001b-lookup-evidence into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 26s
CI / runtimes (edge) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 20s
Promote → GitHub / push-github (push) Successful in 5s
|
||
|
|
2e2c68de07 |
test(bench): record D4 lookup evidence at ed19f16 (CARD-10, #109)
Formal D4 run after the walk-stack fix (#131) and the router-order fix in
the harness, 16 x 21 rounds on jarvis. Every cell passes; the 10-route
late param hit passes with its CI lower bound at +4.9%. Marks the
|
||
|
|
ed19f16c70 |
test(bench): alternate the whole router order per lookup run
Only the import order alternated between processes; warm-up order and the shared lookup call site always saw the first-listed router first. CARD-10's A/A run (oracle vs a byte-identical copy) showed a steady bias of up to +8.3% against the second-listed router at 10 routes. Reversing the whole order per process brings the same A/A to -0.1% (8 x 21 rounds on jarvis). Owner-approved D4 method change (2026-10-12). Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
a64f514db2 |
test(bench): record D4 lookup evidence for the radix router (CARD-10, #109)
Formal D4 run on jarvis with the baseline's harness, image, and cpuset: oracle (pre-radix linear matcher) against the radix router at |
||
|
|
7a9932f095 |
test(router): prove misses after index build recompile nothing (CARD-10, #109)
The linear matcher answered every 404, 405 and automatic OPTIONS by compiling the whole route table. The radix index compiles each pattern once, when the index for an array is built. Nothing asserted that, so a regression to per-request compilation or per-request index builds would only show up as a slower benchmark. compilePattern is called inside router.ts, where a spy on the module export cannot see it, so the router gains two internal counters (compilePattern calls, index builds), exposed as @internal routerSeamCounts() next to walkStackSize. router.ts is not a package entry. The new test warms the index, then repeats 404, 405 and OPTIONS misses through resolveRoute/allowedMethods, buildFetch and app.fetch, and asserts both counts stay constant while status and Allow stay correct. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
72f591dd21 |
Merge pull request 'test(router): prove introspection parity after the radix index (CARD-09, #109)' (#129) from feature/fprd-001b-introspection-parity into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / runtimes (deno) (push) Successful in 19s
CI / build (push) Successful in 25s
CI / runtimes (edge) (push) Successful in 14s
Promote → GitHub / push-github (push) Successful in 6s
|
||
|
|
d07d6add04 |
Merge pull request 'perf(router): reset the walk stack only when a lookup throws (#109)' (#131) from fix/router-walk-stack-reset into develop
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 25s
Promote → GitHub / push-github (push) Successful in 7s
CI / dco (push) Has been skipped
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 14s
|
||
|
|
1b30f15c02 |
perf(router): reset the walk stack only when a lookup throws
The finally block added in
|
||
|
|
fcee6892bf |
test(router): prove introspection parity after the radix index (CARD-09, #109)
The frozen CARD-08 goldens already hold graph(), explain(), openapi() and
the mesh teacup. This adds what they do not cover, with expectations
captured from the pre-radix code at
|
||
|
|
cb123e3774 |
Merge pull request 'perf(router): radix index for HTTP route lookup (CARD-07, #109)' (#128) from feature/fprd-001b-radix-index into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / runtimes (deno) (push) Successful in 20s
CI / build (push) Successful in 25s
CI / runtimes (edge) (push) Successful in 14s
Promote → GitHub / push-github (push) Successful in 7s
|
||
|
|
a2b71e2472 |
fix(router): drop pending walk frames when a segment fails to decode
The walk stack is shared across lookups. A malformed % escape threw out of decodeSegment with frames still pushed, so repeated direct matcher calls on such paths retained them. Truncate both arrays back to the entry length in a finally block, and check it with a test. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
4de9f32e31 |
test(router-parity): retarget walk mutants to the iterative walk
Same four mutants (no-backtrack, catch-all-needs-segment, prune-bound-off-by-one, zero-catch-all-after-static-dead-end), patched at their new sites in the stack-based walk. 21/21 still killed. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
5e0ae94ba2 |
fix(router): walk the radix index without recursion
The lookup walk recursed once per path segment, so a valid deep route such as 4,999 static segments followed by /:x threw RangeError where the linear matcher matched. Walk on an explicit stack instead, visiting frames in the same order, and cover the case through buildFetch. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
996fb3f7a5 |
test(router-parity): retarget mutants to the radix index (owner-approved)
The owner approved editing this one file under test/router-parity/ so the PR ends with a single mutant check. The original search texts targeted lines of the linear scan that CARD-07 removed, so the script refused to run against the new router. The parity tests, oracle, frozen JSON and manifest are untouched. The twelve original mutants keep their names and the bug each models; six apply their original edit, six are rewritten against the index. Nine new mutants cover risks the index introduced: the static-route map ignoring the method or shadowing an earlier route, an off-by-one pruning bound, the empty-collection skip pruning a real match, a local/remote tie going remote, Allow and implicit HEAD from the local tree only, the stale-index guard removed, and a zero-segment catch-all skipped where the path ends on a static continuation. The suite now also runs test/router-index.test.ts, which covers the local/remote split and index lifetime the corpus cannot reach. Each edit must match exactly once and must change the file; a failed edit restores the copy before the run aborts. The script still ends with git diff --exit-code src. Removes test/router-index-mutants.ts and parity:mutants:index, which this replaces. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
55a4e282ad |
test(router): cover pruning across a static branch and a param sibling
The walk takes the static branch first, so for `GET /a/:rest*` and `GET /:x/b` it reaches the catch-all on `/a/b` before the exact param route that outranks it. The corpus has no such pair, and a pruning bound off by one went unnoticed there. Checked against the oracle in both declaration orders. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
d76afd7f25 |
docs(changelog): note the radix route index
An internal change with no behaviour difference, recorded under Changed with the lookup numbers from the jarvis run. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
815f76116f |
perf(router): index HTTP routes in a radix tree
Replace the linear, specificity-sorted scan behind matchRoute, resolveRoute and allowedMethods with a segment trie per HTTP method, built once per route array from the compiled segments compilePattern already produces. Ranking stays global: every terminal carries its position in the old sorted bucket (moreSpecific, declaration order on ties), and the walk keeps the lowest rank it can reach, pruning subtrees that cannot beat it. The tree decides which routes can match; the rank alone decides which one does. A static branch that dead-ends deeper backtracks into its param, constrained and catch-all siblings. All-static routes are also kept by exact path per method. A hit there is provably the tree's best match, so a static request is answered without splitting the path; a miss falls through to the walk. Mesh-spliced remote routes go in a second tree, per the owner's design decision. Both trees answer, the more specific match wins and an equal one goes to the earlier declaration, so local still beats remote on a tie. Allow, 405 and implicit HEAD run over the union. An app without remote routes does one lookup. allowedMethods walks the index instead of recompiling every route on a miss, and an implicit HEAD no longer builds a fresh index from a filtered array on every request. The frozen parity corpus passes unchanged. The frozen mutant script cannot run against the new layout by design, so test/router-index-mutants.ts re-targets its twelve bug classes at the new code and runs the same untouched suite. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
7ee7ab7ec5 |
Merge pull request 'test(router): freeze radix-router parity corpus and baseline (CARD-08, #109)' (#123) from feature/fprd-001b-router-corpus into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 25s
CI / runtimes (deno) (push) Successful in 20s
CI / runtimes (edge) (push) Successful in 14s
Promote → GitHub / push-github (push) Successful in 6s
|
||
|
|
fdd762b081 |
test(router): freeze local/remote Allow and remote implicit HEAD for mesh
CARD-07 will index local and remote mesh routes as two radix trees and keep
today's unified precedence: the most specific route wins across both trees, a
tie goes to the local route, and Allow is the union. This freezes that behaviour
from
|
||
|
|
71fc027134 |
perf(bench): re-baseline lookup on jarvis with the interleaved harness
The first baseline came from a laptop on battery, with one router per process, run one after the other. It moves to battery-run/ for reference. The new baseline is the interleaved A/A run (live matcher as A, byte-identical oracle as B) on jarvis. Setup: Ryzen 7 3700X, cpuset 6,7,14,15 (two idle physical cores and their SMT siblings), node:22 container, Node 22.23.1, load average 0.27-0.79, no CI job running. 4 processes x 21 rounds give 84 paired rounds per cell. Live medians in ns per lookup (static hit, late param, method miss, path miss): 10 routes: 185, 328, 800, 626 100 routes: 201, 878, 2525, 3054 500 routes: 202, 2931, 11904, 15514 A/A noise floor (oracle/live median ratio, 95% CI): at 10 routes, static hit -13.7..+11.9% and late param -1.6..+9.8%; misses within +-4.4%. At 100 and 500 routes, offsets are systematic but within about 3%. In-process, the module imported first runs about 20% faster on the 10-route static hit. Alternating import order per process removes the bias from the median but not from that cell's CI. A 5% limit there cannot be resolved with this method and sample size, so this is recorded for the D4 decision. The 20% improvement target at 500 routes is far outside the noise. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
ee7fdec541 |
perf(bench): interleave lookup comparisons and report B/A with a bootstrap CI
The first baseline ran each router in its own process, one after another, so drift and background load landed on whichever side ran later. Comparing two medians taken minutes apart cannot resolve a 5% threshold. bench:lookup now loads every router into one process. In each cell it warms every router, then takes one sample from each per round, alternating the order: AB, BA, AB. There are at least 15 rounds per cell per run (default 21) over 4 fresh processes, and module import order also alternates per run. Every router after the first is reported against the first as the median of the per-round paired B/A ratios, with a percentile-bootstrap 95% CI (4000 resamples, fixed seed, so the same samples always give the same interval). With a single router it reports absolute medians as before. The record now includes hostname, the effective cpuset when run in a Linux container, and any LOOKUP_* note variables. The harness still runs on any machine with Node 22. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
32caa21308 |
test(router): add a mutation check for the parity corpus
A frozen corpus is only worth what it catches. npm run parity:mutants applies 12 targeted mutants to a temporary copy of src/, one at a time, and runs the parity suite against each. Every mutant models a bug a radix rewrite could plausibly introduce: no backtracking to a param branch static/param precedence swapped equal-rank tie to last-registered constraint ignored decode before splitting (%2F) catch-all needs a segment implicit HEAD from a streaming GET Allow from one pattern only Allow in discovery order trailing slash not normalized WS ranked like HTTP case-insensitive static match All 12 are killed (4 to 74 failing tests each), so no corpus case had to be added. A mutant whose search text is not found exactly once fails the run rather than silently testing an unmutated copy. The real src/ is never written, and the run ends with git diff --exit-code src. It is not part of npm test because it runs the suite once per mutant. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
684795a2de |
test(router): run the parity differential on Deno, Bun and workerd
The matcher comparison does not depend on the runtime, so it should run on every
runtime core supports. Only the Node suite ran it before.
The comparison and the app.fetch fixtures move into differential.ts and
app-fixture.ts, which use neither vitest nor a file API. Each runtime passes in
a loader for the frozen JSON. The vitest files use the same modules, plus a
Node check that the neutral runners report no mismatch, so the two paths cannot
drift.
- Deno and Bun: test/{deno,bun}/router-parity.test.ts run all 1158 frozen
matcher cases (hand-picked, owner, generated v1 and v2, WS) through the oracle
and the live router, plus the 55 app.fetch cases.
- workerd: test/edge/parity-worker.ts bundles the frozen JSON and runs the
same checks; test/edge/run.ts adds the phase after its existing assertions.
The Node-socket, WS-upgrade, boot and mesh captures stay Node-only: they need
http.request, the ws client, or a mesh peer on a port.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
a4562b2b23 |
perf(bench): record the pre-radix lookup baseline at ed47836
The baseline CARD-10 compares the radix index against, captured before any router change. Kept with its environment record and every raw sample. bench:lookup on the linear matcher, five runs of 105 samples per cell. Median ns per lookup: routes static hit late param method miss path miss 10 61.3 123.3 313.1 247.1 100 67.6 343.4 1263.7 1463.3 500 67.8 1326.8 6732.2 8973.4 Run-to-run spread of the per-run medians is 2.0-17.5%. An A/A run (live router against the byte-identical oracle, same protocol) differs by +5.2% on the 10-route static hit and by at most 2.7% elsewhere, so D4's 5% limit at 10 routes sits at the noise floor for that cell. That is recorded for the D4 decision, not resolved here. bench:compare, run once A/A, is stored separately as end-to-end req/s only: every case within 1.9%. Measured on an Apple M4 Max on battery power, load average 2.4-3.4 on 16 cores; the comparison run should use the same power source. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
a47c6564ab |
test(router): add owner-requested parity cases and a shared-prefix generator
Additions requested in CARD-08 review, captured from
|
||
|
|
98ea948ffa |
perf(bench): add a focused route-lookup benchmark for D4
bench:compare reports end-to-end req/s with 50 and 200 filler routes. Lookup is a few percent of a request there, so it cannot judge D4's thresholds (at most 5% median regression at 10 routes, at least 20% improvement at 500), which are stated in median lookup time. bench:lookup measures exactly what dispatch does with a normalized path: resolveRoute, and on a miss allowedMethods. It covers 10, 100 and 500 total HTTP routes from a recorded generator, with static hit, late parameter hit, method miss and path miss workloads. Each answer is checked before timing, so an implementation that answers wrongly cannot post a number. Warm-up is time-boxed and calibrates the iterations per sample; every sample is kept. The router under test is a module path. LOOKUP_ROUTERS takes several, and each run measures them in separate child processes, alternating which goes first, so CARD-07/10 can run this same harness on base and head. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
5d0e544878 |
test(router): capture graph, explain and OpenAPI goldens before indexing
graph(), explain() and openapi() read routePlans in declaration order. A
radix index must stay a lookup structure and never become their source, so
their output is frozen from
|
||
|
|
c30cf7e457 |
test(router): freeze the differential, application, WS and boot-error corpus
The parity corpus from ROUTER-CORPUS §2, with every expected output captured
from
|
||
|
|
adce82beaa |
test(router): pin the retained-test manifest and a frozen pre-radix oracle
CARD-07 replaces the linear HTTP matcher with a radix index. Before any of that code changes, the behaviour it must preserve has to exist somewhere the new code cannot quietly move it. manifest.json names the existing tests retained unchanged (ROUTER-CORPUS §1), pinned to |
||
|
|
ed47836c98 |
Merge pull request 'chore!: require Node 22 and clear dev audit advisories' (#122) from chore/audit-dev-deps into develop
CI / dco (push) Has been skipped
CI / build (push) Successful in 26s
CI / runtimes (deno) (push) Successful in 30s
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (edge) (push) Successful in 13s
Promote → GitHub / push-github (push) Successful in 6s
|
||
|
|
77a99e83ce |
chore(deps): vitest 4
vitest 3.2.7 carried the last three dev audit advisories: tinypool (critical, prototype pollution to RCE in worker options), vitest itself (critical, through tinypool and @vitest/mocker) and @vitest/mocker (moderate, path traversal through a redirected mock). 4.1.11 is the first stable release outside every affected range; vitest 4 no longer depends on tinypool at all. It needs Node 20 or newer, which the Node 22 floor now guarantees. vitest 5 would need Node 22.12, and 4.1.11 is enough to clear the advisories. vite stays on ^6.4.3, which vitest 4 accepts. The one change the bump requires: vitest 4 types `vi.fn()` with no arguments as a mock of a function *or* a constructor, so `ReturnType<typeof vi.fn>` is no longer callable as a plain function. listener-boundary.test.ts now types its spies as `Mock<(...args: unknown[]) => void>`. npm 10.9 crashes in arborist's #loadPeerSet resolving this tree, so the lockfile was produced with npm 11.6.2; `npm ci` on Node 22's bundled npm 10 installs it cleanly. npm audit: 3 -> 0. npm audit --omit=dev stays at 0. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
bd478ce09c |
build!: require Node 22
Node 18 and Node 20 are end-of-life and receive no security patches, so supporting them before RC.1 would mean promising a runtime nobody can patch. Node 22 is the oldest line still maintained. engines.node moves to >=22, @types/node to ^22, the tsup target to node22, and CI's build job from Node 18 to 22, so every workflow now runs Node 22 only. The docs, the bug report example and the comments that stated 18 as the floor follow. The node:crypto fallback in the HTTP core existed only for Node 18, which lacked the global crypto; it goes with its regression test, which said as much. The ws fallback for the WebSocket client stays: Node 22 has the global, but it can still be switched off with a flag. Moving off Node 18 and 20 also unblocks vitest 4, which the remaining dev audit advisories need. BREAKING CHANGE: Node 18 and Node 20 are no longer supported. The minimum is Node 22. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
4c3b4d29c4 |
chore(deps): move the benchmark's fastify to 5.12.5
fastify <= 5.12.4 carries seven advisories (high), and it reaches us twice, both benchmark-only: as a direct devDependency and through @nestjs/platform-fastify 11.2.7, which pins fastify 5.11.3 exactly. `npm audit fix --force` would move to @nestjs/platform-fastify 12, which is ESM-only and needs @nestjs/core and @nestjs/common 12 as well: a migration of the Nest benchmark servers, not a dependency fix. Raise the direct range to ^5.12.5, a patch inside the major we already use, and point nest's copy at it with `"fastify": "$fastify"` so the tree holds a single, patched fastify. Checked with `BENCH_SMOKE=1 npm run bench`: fastify, nestjs-fastify and nestjs-express all boot and serve every scenario with 0% errors. npm audit: 5 (2 critical, 1 high, 2 moderate) -> 3 (2 critical, 1 moderate), all of them vitest. `npm audit --omit=dev` stays at 0. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
445738e830 |
chore(deps): override miniflare's undici and sharp to patched releases
miniflare 4.20260730.0 is still the newest stable release, and it pins undici 7.28.0 and sharp 0.35.2. The existing undici 7.29.0 override is now inside a new advisory range (7.0.0 - 7.29.0, high), and sharp is under two libheif/librsvg advisories (<= 0.35.5-rc.1, high). `npm audit fix --force` would install miniflare 5.20261006.1-alpha: a major and a prerelease, for a test-only dependency. Move the undici override to 7.29.1 and add sharp 0.35.5, both patch releases and the exact versions the next miniflare ships with. Same approach already used for find-my-way, hyperid's uuid and undici. `test:edge` is the suite that drives workerd through miniflare and it passes unchanged. npm audit: 8 (2 critical, 4 high, 2 moderate) -> 5 (2 critical, 1 high, 2 moderate). `npm audit --omit=dev` stays at 0. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
352ba477b4 |
chore(deps): apply non-breaking dev-dependency audit fixes
`npm audit fix` without --force: every bump stays inside the ranges package.json already declares, so only the lockfile changes. Clears proxy-addr (critical), multer and @nestjs/platform-express, qs, brace-expansion, fast-uri, js-yaml and source-map-js. All of them are dev or benchmark dependencies; `npm audit --omit=dev` was and stays at 0. npm audit: 16 (3 critical, 11 high, 2 moderate) -> 8 (2 critical, 4 high, 2 moderate). Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
4d1639f7c5 |
Merge pull request 'FPRD-001a: core safety and adapter correctness (#104 #105 #106 #107 #108 #116)' (#117) from feature/fprd-001a into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 30s
CI / runtimes (deno) (push) Successful in 21s
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (edge) (push) Successful in 14s
|
||
|
|
26bacdb304 |
fix(ws): bound inbound frames synchronously and all-or-nothing
Two gaps in boundInbound, both from review of #117. The bound ran in an async pump reading the adapter's channel. `ws` emits a whole TCP read's worth of frames synchronously, so the unbounded channel took the burst before the pump saw the first frame: with maxWsQueue 2, a 2,000-frame burst reached the channel in full before close(1013). boundInbound now taps the channel through an internal, non-exported hook that runs inside push(), so each frame is bounded before it is queued. Measured on the Node listen() path, the same burst now closes on the 3rd frame. accept() also offered a frame to consumers in order and closed 1013 when a later queue was full, so the rejected frame had already reached earlier consumers. Capacity is now checked for every consumer before any delivery. Refs #107 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
7fa02d16be |
fix(ws): give every inbound consumer its own bounded queue
boundInbound returned one shared FIFO to every `inbound` iterator, with a single waiter slot. Two consumers waiting at once left one hanging forever, sequential consumers split frames, and one consumer's return() ended the stream for all. Node used to fan out through `channel`; Deno, Bun and edge already shared one iterator before #107, so the bug was older there. Each iterator now gets its own queue, and maxWsQueue bounds each one. Frames that arrive before anyone reads still go to the first consumer, which keeps the mesh `hello`. Refs #107 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
f78c9dc6fd |
fix(runtime): give ctx.ip the socket peer on Deno and Bun
buildFetch had no channel for a peer address, so ctx.ip was '' for
every HTTP request served by serveDeno or serveBun unless trustProxy and
x-forwarded-for supplied one. Everything keyed on the address shared one
value: the rate-limit plugin put every client in a single bucket, and
one client could exhaust the limit for all of them.
The adapters now record the peer in a WeakMap keyed by the Request
object (src/http/peer.ts, not exported) and pass that same object to
app.fetch. A header would be visible to handlers and spoofable; a second
fetch parameter would be public API. buildFetch derives ctx.ip as Node's
deriveIp does: the first x-forwarded-for hop when trustProxy is on and
the header is present, the peer otherwise. trustProxy without the header
therefore falls back to the peer instead of answering ''.
The map hangs off globalThis under Symbol.for('@green-tea/core:peer')
rather than living in the module. tsup's CommonJS build bundles index,
deno and bun as separate files with no shared chunk, so each gets its
own copy of peer.ts; with a module-private map, serveBun from
@green-tea/core/bun recorded peers that app.fetch from @green-tea/core
never saw, and ctx.ip stayed ''. A test loads a second instance of the
module to pin this.
A bare app.fetch from user code, or a Request copied from the adapter's,
has no entry and answers exactly what it did before. Addresses are
passed through unnormalised. WebSocket and the edge adapter are
unchanged; trusting cf-connecting-ip is a separate decision.
Closes #116
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
ae60cd68a2 |
fix(http): enforce maxBodyBytes while reading fetch request bodies
The fetch adapter read every body through request.arrayBuffer() and compared the length afterwards, so Deno, Bun and the edge buffered an oversized upload in full before refusing it. readFetchBytes now reads request.body chunk by chunk, stops at the chunk that crosses the limit and cancels the reader, so no further chunk is pulled. A content-length that already declares more than the limit is refused before anything is read, on both adapters. On Node the request used to wait for its first chunk, which a client that sends only headers never delivers. A malformed or absent header is ignored and the running count enforces the limit. The response is the same 413 through onError, and the route-over-server precedence for maxBodyBytes and maxParts is untouched; the new tests pin it. The over-read is proven with a counting stream rather than a status code, which is the same 413 either way. The stream uses a high-water mark of 0: the default of 1 pulls a chunk at construction, before any reader exists, which would make "nothing was read" unprovable. Socket-level tests on Deno, Bun and workerd use a 1000-byte route limit so every refused body fits in the socket buffer. With a multi-megabyte body the client is still writing when the 413 lands and sometimes sees ECONNRESET instead, which is the transport racing the answer. The Bun socket test also disables keep-alive: Bun's own fetch client reuses a socket after a response that arrived before the body was read, and its next request on it comes back 400 or 431. Node's fetch against the same Bun server does not. Closes #105 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
0540bef07b |
feat(ws)!: bound inbound WebSocket message size and queue
Inbound WebSocket traffic was unbounded per connection: Node used ws's 100 MiB default payload, the other runtimes had no cap of their own, and the queue behind `inbound` was an unbounded channel on every runtime, so one client could exhaust memory with large messages or a slow consumer. Add `limits.maxWsMessageBytes` (default 1 MiB, close 1009) and `limits.maxWsQueue` (default 16 unread messages, close 1013), as recorded in D1. Both are server-wide and validated by createApp, which throws a TypeError for anything but a positive integer. Enforcement is shared in `boundInbound`, which subscribes immediately and replaces the subscribe-before-boot trick in app.upgrade. Node and Bun also get the native pre-buffer cap; Bun drops the connection without a close frame, so its peer sees 1006, which is documented and tested. Deno and workerd expose no such option and check the size after receipt. BREAKING CHANGE: messages over 1 MiB now close the connection with 1009, and a connection with 16 unread inbound messages is closed with 1013 on the next one, including a handler that never reads `inbound`. Closes #107 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
59763c9af5 |
fix(ws): reject malformed upgrades instead of crashing the server
The Node 'upgrade' listener matched the raw request path without the normalization HTTP runs. A bad percent escape in a param segment threw URIError synchronously inside the listener, an uncaught exception that ends the process, and '//' silently matched a route HTTP refuses. Upgrades now normalize the path first: malformed escapes and repeated slashes get a 400, an unknown route a written 404 instead of a bare destroy, and any other throw in the listener a 500. app.upgrade (Deno/Bun/edge) closes 1008 'invalid request path' rather than 1011. On Deno the adapter's socket is still CONNECTING when an early 1008 is sent, and that close was a no-op that left the peer hanging; eventSocket now defers such a close to 'open'. Closes #104 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
1069c727c8 |
fix(http): catch failures at the Node request-listener boundary
The Node request listener was an async function, and http.createServer ignores the promise a listener returns. Anything that rejected outside the region where errors convert to a response - a custom static resolver, a handler header value Node refuses to write (ERR_INVALID_CHAR), a stream that fails between flushing its headers and its first frame - became an unhandled rejection, which Node's default mode turns into a process exit. The listener now hands the request to serve() and catches its rejection in failSafe(), per refinement decision D2: - writable: a fixed 500 with connection: close, written through the patched writeHead so the security headers still land, without calling onError again; - headers or body already sent, or the client gone: destroy the socket; - the failure is logged through logger.error first, guarded, with String(err) for non-Error values. No request:end is emitted for these requests: observers do not alter the response, and the core never completed it. The request gate slot is already released by the existing finally, which the tests prove. Deno, Bun and the edge are unaffected: they receive app.fetch's promise and the runtime answers a rejection itself. Closes #108 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
53660adcce |
fix(views): confine static serving to the root's real path
The static resolver's traversal guard compared paths lexically, and the read that followed it resolved symlinks, so a link inside the root such as `public/leak -> /etc/hosts` served a file outside it. Containment now compares real paths. The root's real path is resolved on the first request and cached (a failed lookup is not, so a root created after boot still starts serving); the requested file and a directory's `index.html` are each realpath'd and must lie at or beneath it, with the `root + sep` rule keeping a sibling such as `root-evil` out. The lexical guard stays in front, since it rejects `..` without a syscall. An escape or a dangling link is a plain miss: 404 through `onError`, or 405/204 where the path has routes. Not 403, so a probe cannot tell a file outside the root from one that does not exist. Re-pointing a root symlink at runtime needs a restart. The realpath-to-read race is left open and marked; closing it needs per-component O_NOFOLLOW, which is not portable across Node, Deno and Bun. Closes #106 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
42376c6693 |
Merge pull request 'docs(agents): stop publishing the address of the private forge' (#102) from docs/scrub-forge-host into develop
CI / build (push) Successful in 30s
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (edge) (push) Successful in 14s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 18s
|
||
|
|
9761b40eb5 |
docs(agents): stop publishing the address of the private forge
The promotion example I added in #101 carried the development forge's full hostname, and this file is mirrored to GitHub — `develop` reaches the public `contrib` branch on every merge, so it has been readable by anyone since it landed. That host resolves from the public internet, unlike the internal registry named elsewhere in this repository, so it is a reachable endpoint rather than an internal naming detail. Replaced with `$GITEA_URL` and `$REPO`, which costs a reader nothing: `fast-forward-only` was always the part worth documenting, and it is the part the CLI does not offer. Not a rewrite of history — the commit stays where it is. Anyone who wanted the address can still read it there, so this is tidiness going forward rather than a recall. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
7255b8ec30 |
Merge pull request 'docs(agents): say how the promotion is actually merged' (#101) from docs/promotion-via-api into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 17s
CI / build (push) Successful in 29s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 12s
Promote → GitHub / push-github (push) Successful in 8s
|
||
|
|
ca78f0a8e5 |
docs(agents): say how the promotion is actually merged
The section tells you promotions are fast-forward-only and never says which tool does that. `tea pr merge` does not: it offers merge, rebase, squash and rebase-merge, and each one births a commit on main — the exact drift the rule exists to prevent. Reaching for the obvious command therefore produces the thing the paragraph above it forbids. Gitea's API takes the style the CLI omits, so the promotion for 26.9.0-beta.2 went through curl. Recording the call, and the 405 that precedes it: main is protected and a promotion PR runs its own checks rather than inheriting the ones develop already passed, so the first attempt is refused for checks that simply have not finished yet. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
a16be6a832 |
Merge pull request 'chore(release): cut 26.9.0-beta.2' (#99) from chore/cut-26.9.0-beta.2 into develop
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 30s
CI / runtimes (bun) (push) Successful in 14s
CI / build (push) Successful in 32s
CI / runtimes (deno) (push) Successful in 18s
Promote → GitHub / push-github (push) Successful in 5s
CI / runtimes (edge) (push) Successful in 14s
Release → npmjs / publish-prod (push) Has been skipped
Stage → Verdaccio / publish-stg (push) Successful in 27s
CI / dco (pull_request) Successful in 5s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / dco (push) Has been skipped
|
||
|
|
b0a9f3bfc9 |
chore(release): cut 26.9.0-beta.2
Dated 2026-09-22, the day the tag goes up, rather than the day the version was decided — package.json has said 26.9.0-beta.2 since the staging bump on the 17th, and that is the difference the heading records. A version number is a plan; a changelog heading is a receipt. Last commit before the tag, which is the order AGENTS.md asks for and the one the beta.1 slip taught: everything merged, the release gate measured, the suites green on all four runtimes, and only then the date. Held here rather than written with the bump, so nothing accumulated underneath a heading that claimed to have shipped it. The section covers what landed since beta.1: the plugin contract, app.boot(), async serveDeno/serveBun, errors recognised by brand, and the mesh moving to steps-and-routes-only exports. `release.yml` reads this section by version to build the GitHub release notes, and does so after npm and JSR have published, so the heading has to exist before the tag rather than after it. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
9a8677d5c2 |
fix(bench): date the run in project time, and let the harness typecheck again
Two things the release run surfaced, neither of them visible from CI. `npm run typecheck:bench` has been failing since serveDeno and serveBun became async: the bench servers gained a top-level await, which `module: commonjs` rejects outright, and bench/tsconfig.json inherited commonjs from the root config it extends. The servers are ES modules run by tsx, Deno and Bun and never by the CommonJS build, so the config was describing the wrong thing even before the await arrived. CI runs `typecheck`, not `typecheck:bench`, which is why a break in the harness waited for someone to run it by hand. The date came from the runner's clock through toISOString, which is UTC. The table was measured on the evening of the 22nd over ssh against a box keeping UTC and dated itself the 23rd, a day ahead of the commit and of the changelog entry it sits beside. It now reads project time. tsx transpiles with this tsconfig too, so the module change was verified by running the smoke pass again on that box: all six frameworks, the secure run and all three runtimes still boot, and the regenerated header reads 2026-09-22. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
8c95ae8bfb |
docs(bench): regenerate the cross-framework tables on a box that was not busy
Measured on an otherwise idle Ryzen 3700X over ssh, with the same Node, Deno and Bun versions the laptop runs, after two attempts here were thrown away. The absolute numbers drop to roughly a third — a 2019 desktop part against an M4 Max — and that is the trade: a slower box whose numbers mean something beats a faster one whose numbers track what else was on screen. The shape reproduced across both machines, which is the result worth having. green-tea is behind Fastify on hello, param and pipeline, ahead of it on validate, and ~2.8x ahead of Express, on the M4 and on the Ryzen alike. The size of the gap did not reproduce (2-8% there, 7-15% here), so the README now says the direction and points at the table for the number, rather than quoting a percentage that is really a fact about somebody's hardware. CV lands between 0.1% and 1.3% across every row, against 4-6% on the contended runs. Fixes a sentence added an hour ago claiming the ordering inside the fast group moves between runs by more than the gap between its members. It does not — it held on both boxes — and the claim happened to be the one that flattered us. Cross-framework tables and the runtime table are regenerated; the hand-written section below the marker, including the release gate, is untouched. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |