f62a791afcd5d50e12b49334ffa4752b66cb2a67
61
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f62a791afc |
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> |
||
|
|
0f4b88ab1e |
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> |
||
|
|
e0c47f16e1 |
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> |
||
|
|
9e3add7416 |
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> |
||
|
|
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>
|
||
|
|
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>
|
||
|
|
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>
|
||
|
|
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>
|
||
|
|
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> |
||
|
|
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>
|
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
9634ec73e8 |
feat(runtime)!: serveDeno and serveBun boot before they bind
Both were synchronous and left the boot to the first request, with the fix documented as something the caller should remember: `await app.boot()` before `Deno.serve` / `Bun.serve`. That made the correct use of a core helper depend on reading a README, in a framework whose whole argument is that order should not be something you have to get right. The failure it leaves is the bad kind. `app.fetch` boots lazily and the boot memo keeps the *rejection*, so a missing signing key does not fail the deploy: the port binds, every request is answered 500 by the runtime, and none of them reach `onError`. Anything that health-checks by asking whether the process is listening sees a healthy server. `listen()` has always awaited `bootApp()` before binding its socket, with a comment saying it exists so Node and Deno/Bun serve an identical graph. They did not. Now the three helpers agree, and the two adapters return promises. `edgeHandler` is deliberately unchanged: on workerd there is no startup outside a request, so there is no earlier moment to move the failure to. Both new tests were confirmed to fail with the gate commented out — without it `serveBun` resolves instead of rejecting, and serveDeno binds a port that 500s. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
7a01ca3068 |
docs: record the plugin contract change and app.boot()
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
f5d4d0cd74 |
docs(mesh): an absent teapot 404s, it does not 503
A teapot that never connected sent no manifest, so spliceRemoteScopes registers nothing for it — no step runner, no route. Its routes therefore take the ordinary unmatched path and 404, and a local node that needs one of its tokens still fails the boot naming it. The 503 belongs to a teapot that connected and later died, where the link and its exports exist and the dead-link guard answers. The previous commit said 503 for the absent case in five places, including the warning an operator reads during a deploy. All five now tell the same story, and the bootTimeoutMs JSDoc — stale in the other direction, still claiming an absent teapot fails the boot — with them. The connectUntilDeadline JSDoc also had a paragraph saying it still throws, contradicted three paragraphs later; that one is gone. No behaviour changed. Serving 503 for an absent teapot's tokens means knowing what it would have exported, which is the expects list in the degrade plan and is deliberately not built. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
03132b2048 |
docs(mesh): steps and routes are what a teapot exports
The CHANGELOG gains an [Unreleased] section — no version heading, no date — covering the three mesh changes on this branch and why each one follows from the first: a remote export is a step now, so it holds nothing between requests, so an absent teapot costs a 503 rather than a boot. The README says it in the Honest scope section, where the mesh caveats already live: what can be exported, what happens if you export a provider anyway, and why a missing token still fails the boot when an unreachable teapot no longer does. Two stale bits go with it. The JSDoc over assertNeedsSatisfiable still quoted the old unconditional message; the Deno and Bun fixtures still said a teapot exports its scopes. And the degrade plan's D6 planned to reuse a seam this branch deleted — a dated note says so, and why a degraded step never needed it. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
dfe71102ca |
docs(changelog): date the section for the day the tag actually ships
The heading was written for 2026-09-02, the day the cut was planned, then dated 2026-09-03 when it was closed. Neither day shipped anything, and the workflow split that has to land before the tag moved it once more. AGENTS.md is explicit that a dated heading is a receipt rather than a plan, and that this exact drift already happened once on beta.1 — a section claiming a release that did not exist, with a day of further work accumulating underneath it. Correcting the date is cheaper than being the second instance of the thing the guidance warns about. Today is the day the tag is created, so the receipt says today. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
0c099c7266 |
chore(release): cut 26.9.0-beta.1
`[Unreleased]` has been the heading since tier 3 closed, which was correct while entries were still arriving. They stopped: the matcher entry was the last one, and everything the section describes is merged and green. Holding the heading past that point only makes the file describe work as unreleased that is about to ship. `deno.json` moves in the same commit because `test/package-metadata.test.ts` pins the two together — bumping `package.json` alone ships one version to npm and a different one to JSR, and JSR versions are immutable. The release workflow reads the changelog section by version, so a tag pushed against an `[Unreleased]` heading fails after the publishes have already run. Dated 2026-09-03, the day the cut happens, rather than the day it was planned for. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
f18aa9a42a |
docs(changelog): record the matcher change, which landed after the tier was written
`[Unreleased]` was written when tier 3 closed and the route-ranking work came after it, so a user-facing improvement with a measured number had no entry. That is the omission the benchmark notes published in the same release are about — something measured that never reached the file where anyone would read it — and cutting the beta without it would have been a poor way to make the point. Placed in Changed beside concurrent provider boot. Both are savings that appear only once something grows, and reading them together says what neither says alone: what this release improved is what happens when an application gets bigger. The entry leads with what does not change, because "route ranking now happens somewhere else" is the sort of sentence that makes a reader check whether their routes still resolve the way they did. Equal specificity still keeps registration order; the ordering carries it through a stable sort instead of through a scan. The numbers are given per route-table size rather than as one figure. A single percentage would be wrong at both ends — nothing at six routes, +14.9% at two hundred — and the shape is the honest form of the claim. Heading still `[Unreleased]`. The version and the date belong to the cut. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
a84960a46a |
docs(changelog): record the tier-3 work in Unreleased
Concurrent provider boot, `sse()` and the `id:` it writes, and the stream events that three of the four runtimes never emitted. #83 and #84 share one entry. They are two defects but one symptom — the stream events were not usable — and a reader looking for "can I build a stream gauge on this" is served better by one entry than by two bullets that both open with `stream:`. The boot entry carries its two consequences rather than only its number, because "616ms becomes 210ms" is not the part that can surprise someone: a required provider's independent siblings now start, and `boot:provider:start` stops alternating with `:ok`. Heading still `[Unreleased]`. The version and the date belong to the cut. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
0adab69466 |
docs(changelog): record the tier-2 work in Unreleased
The event stream's contract, the read-only `events` token, the reserved framework names, the unmatched-route label, the budget bookkeeping, and the `onError` crash. Grouped by what a reader is looking for rather than one bullet per commit: the three observability issues describe one contract and read better as one entry plus the two fields it needed. The reserved names get their own paragraph saying plainly that they **can fail an app that boots today**, because a changelog that buries a breaking change under a feature heading is how someone finds it from a stack trace instead. Heading still `[Unreleased]`. The version and the date belong to the cut. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
4c9e606cfb |
docs(changelog): record the unreleased work, without cutting a version
Everything on `develop` since `26.8.0-beta.1` that a user would notice: the request budget and the connection-drop warning from the contribution merge, `handleSignals`, the extension-point type exports, the single header resolution, and the two crashes (the CORS predicate, and the JSR package's missing `require`). The heading stays `[Unreleased]`. The version bump and the dated section belong to the cut, not to the work. Left out on purpose: the two `ci(release)` commits. They change how the workflow spends a dist-tag and whether it publishes release notes — real, and invisible to anyone reading this file to find out what changed in the package they installed. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
e86051382d |
chore(release): close the changelog at 26.8.0-beta.1
Everything in `[Unreleased]` ships under this tag, so the section gets its date one step before the tag exists — the order AGENTS.md now prescribes. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
b8cb684a6b |
docs: close the changelog at the tag, not when the version is decided
The changelog said [26.8.0-beta.1] - 2026-08-17 with a date, above work that has never been tagged and is on no registry — npm still ends at beta.0 and neither forge has the tag. A day of further work then landed underneath it as [Unreleased], so the file asserted both that beta.1 shipped and that its contents had not. Folds that section back into [Unreleased], where all of it actually belongs, and writes the rule in AGENTS.md so the next version is closed one step before its tag rather than the day it is decided. A version number is a plan; a changelog heading is a receipt. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
46342a0aa2 |
fix(mesh): refuse to export a value the wire cannot carry, instead of delivering an empty object
Exporting a provider whose value was a connection pool produced HTTP 200 and on the other side. JSON keeps the shape and discards everything else, so what arrived was an object that passed every truthiness check and had no methods — and the failure surfaced as `db.query is not a function` at a call site arbitrarily far from the export that caused it. Nothing warned, at either end, at any point. The teapot now checks before sending, which is the only place the evidence still exists: past encode() a pool and an empty object are the same bytes. An allowlist rather than a denylist. Date is refused too — it would arrive as a string rather than the declared type, which is the same silent difference wearing a smaller costume. Bounded by a scan budget so a large legitimate payload is never turned into an error by the cost of checking it. The constraint this makes visible was never written down anywhere: a mesh export carries data, never behaviour. Export what the handle produces rather than the handle. That limit is what makes an 'executable provider' (#50) the missing shape rather than a nicety. 442 vitest / 12 Deno / 7 Bun / edge / JSR dry run. All 5 new tests verified to fail against the old code. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
1975a7c03f |
feat(mesh): give boot a grace period for a slow teapot, and fail for an absent one
A teapot that is thirty seconds behind and a teapot that does not exist look identical for the first thirty seconds, and only one of them should stop a deploy. bootTimeoutMs is that grace: retries with backoff until it passes. It still fails after that, deliberately. A provider the graph depends on is not optional, and booting without it would only move the failure to the first request, where it is a caller's 503 rather than the deploy's error. The full battery caught what the first cut got wrong: a bad secret was being retried. That is not a transient failure — it is the teapot's decision, and it will be the same decision in thirty seconds, so retrying only spends the deploy's patience to arrive at the identical error. Refusals now fail at once. Telling them apart without threading close codes through the neutral socket contract of four runtimes: a peer that accepted the connection and then hung up before answering rejected us on purpose; one that never accepted it may simply not be listening yet. That is exactly the distinction needed here. Retries are logged and emitted as mesh:boot:retry, kept separate from mesh:disconnect — that one is a link that was up and went away, this one never came up, and a deploy watching for trouble wants to tell those apart. 437 vitest / 12 Deno / 7 Bun / edge / JSR dry run. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
f2cb411eac |
feat(mesh): carry the caller's identity across the wire, and bound what an unauthenticated peer can do
The observability release gave every request an id and lost it at the process boundary — in the one place a distributed trace is the entire point. The RPC envelope now carries requestId, traceId and url, and the teapot adopts them instead of opening its own investigation. Both fields are optional on the wire, so the protocol version does not move. That decision needed a rule rather than a judgement call, so the rule is now written beside the constant: bump when an old peer would misparse or misbehave silently, not when work happened. Bumping per change would make the number mean the opposite of what it is for. Three things found while in here: - mesh:rpc:error emitted the per-link counter where every other emitter puts a name, so the two sides of one failure could not be matched up. - The teapot had no handshake deadline, so an unauthenticated peer could hold a socket by saying nothing, and no frame size cap, so it could make the process JSON.parse up to whatever the socket layer allowed — 100 MiB with the ws defaults, before authenticating. - The remote-route envelope was cast from the internal request object, putting ip and protocol on the wire as fields the protocol never declared. The cleartext warning is a warning and not a refusal on purpose: a private network already doing mutual TLS is legitimate, and green-tea cannot tell it apart from an exposed one. 4 of the 8 new tests verified to fail against the old code; the rest are the negative cases, which should pass both before and after. The Deno test drives the teapot's frame loop with a raw client, because server-side close codes are where these runtimes have already differed once. 431 vitest / 12 Deno / 7 Bun / edge / JSR dry run. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
6ffbad9825 |
fix(mesh): reconnect to a teapot that came back, refusing a manifest that no longer fits
A dropped link stayed dead for the life of the process. Every RPC answered 503 until the teacup restarted, so deploying a teapot forced a restart of every teacup depending on it and boot order became load-bearing — a worse operational property than any gap the docs actually listed. The Link now outlives any single socket, because the graph captured its rpc closure at boot and a reconnect that produced a new Link would leave the graph pointing at the dead one. Backoff doubles from 500ms to 30s with full jitter, so teacups that went down together do not return in lockstep. A returning teapot whose manifest no longer exports what the graph was validated against is refused, not adopted: that graph is already serving, and a token cannot be validated away after the fact. The link keeps retrying, since a partial deploy may still restore it, and logs once per distinct manifest rather than once per attempt. Refusal ships as a named policy (onManifestChange: 'refuse') so hot reconciliation can arrive later as an addition rather than as a change of what the default means — these are separate processes on separate deploy cadences. close() is terminal. closeLinks runs on shutdown, and a link that reconnected after the application hung up would leave a process that cannot exit. Also closes the documented gap where an app-scope export outlived its teapot with a stale value: a successful reconnect re-registers those bindings, so the next resolve re-runs the RPC. That invalidation is a named function rather than inline, because it is the seam a future 'reconcile' reuses. Tested on all three runtimes rather than on Node alone — Node's ws package, Deno's global WebSocket and Bun's server-level socket handler are three implementations, and swapping a socket under a live graph is where they stop agreeing. 7 of the 9 new Node tests were verified to fail against the old code; the 2 that pass are the ones that should, since the old code never reconnected at all. Mesh stays alpha. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
41c1f4308b |
chore(release): cut 26.8.0-beta.1
package.json and deno.json both still said 26.8.0-beta.0, which npm already has. Publishing would have been rejected there and — the expensive half — JSR versions are immutable, so a wrong one can never be replaced. The changelog section is closed at today rather than left under Unreleased, because what it now contains is the whole of this release: the observability contract, shutdown teardown, the dot-segment behaviour change, and the two fixes on the fetch and shutdown paths. The documentation repository is tagged 26.8.0-beta.1 alongside, and that number means the same thing there: not a version of the site, but the core release its pages describe. Cutting the two together is what makes the version a claim that the release is documented rather than only shipped. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
bb75cabeea |
docs(changelog): record the release's largest feature, which was missing entirely
Unreleased carried two entries for the 81 commits since v26.8.0-beta.0, and the observability contract was not one of them — the feature four independent reviews named as the project's biggest gap, and the reason issue #10 existed, had no changelog presence in any version. Someone deciding whether to upgrade would have read the release as a shutdown fix. Also added, in the order a reader needs them rather than the order they landed: Changed: `.` and `..` in a request path now resolve instead of 404ing. This is a behaviour change and belongs under Changed rather than buried in Fixed — it is Node-only, it ends a divergence where the same bytes reached different routes per runtime, and it is worth telling anyone whose proxy matches on the literal path that the proxy and the application no longer agree. Fixed: the BodyInit narrowing on the app.fetch path, which is the path Deno, Bun and the edge all use, and the shutdown timer ordering that left a ReferenceError waiting for whoever touched it next. Found by diffing the public surface at the tag against HEAD rather than rereading the file. `createApp` gained five options and the package eleven exports since the beta; the entries above are what had no home. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
24feca481c |
feat: shutdown teardown for plugins, providers and applications
Closing a connection meant writing process.on('SIGTERM') by hand: closeApp
drained the server and mesh links and knew nothing about the graph, and the
Bus had no shutdown event at all, so a plugin could not even observe that the
app was going away.
Implements docs/plans/2026-08-17-shutdown-teardown-design.md, D1-D8.
Three doors into one registry, with one order and one failure policy — a
@Provider may declare dispose(), a plugin may call api.onShutdown(fn), and an
application that wants neither passes createApp({ hooks: [{ onShutdown }] }).
Shipping only the plugin half would have frozen the public API around the less
common case: the thing that holds a database connection is a provider.
Callbacks take no arguments. Whatever needs closing is already in the closure
that registered it, so nothing crosses a scope and the registry needs no
container, app reference or transport. That is what keeps this a registry
rather than a second event bus — Bus.on is synchronous and emit swallows
failures on purpose, and a teardown needs the opposite of both.
Provider dispose() is registered as the provider boots rather than as it is
collected, so reverse-registration is reverse-topological order for free: a
cache that needs db closes before the db it is holding, with no second sort to
keep in step. It registers inside the try, so a provider that failed to boot is
never disposed — nothing it might close was ever opened.
Teardown runs after the drain, because an in-flight request may still be using
what a teardown is about to close, and inside the same timeoutMs, because that
number is a promise about when close() returns. teardownTimeoutMs reserves a
slice of that budget rather than extending it, and is rejected at boot rather
than clamped.
Node, Deno and Bun reach it through the close() each runtime actually uses.
app.close() returns at its no-server guard everywhere but Node, so the Deno and
Bun adapters chain it after their own drain — and app.close() now runs teardown
on that path too, since an app served through app.fetch still booted providers
that opened things. The registry drains once, so both entry points are safe.
Edge gets a doc comment and nothing else. workerd has no shutdown to intercept;
a best-effort call on an event that does not exist would be worse than saying so.
Recorded in mountPlugin's comment while widening it: "isolation is structural"
is a guarantee about the registration surface, not about the request context. A
plugin's step already receives the live context and can overwrite keys in it.
Pre-existing, unrelated, and now written where the next reader will look.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|
||
|
|
8c781c1258 |
fix: treat non-positive connection limits as unlimited
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in> |
||
|
|
9e5e5cffe9 |
feat: add concurrent connection limits
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in> |
||
|
|
270480b2d6 |
docs: fix changelog compare links to point at the public mirror
CI / build (pull_request) Failing after 13s
CHANGELOG.md ships inside the npm package, and its link references pointed at the internal Gitea host — unreachable for anyone reading the changelog on npmjs. Point them at the GitHub mirror, and compare Unreleased against `main`, since `develop` is not mirrored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
1db4e01e40 |
fix(deno): snapshot metadata before websocket upgrade
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
74f09d2e0b |
docs: document router completeness for beta
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
0541464093 |
docs(readme): tell the truth about runtimes, transport, and where the docs live
The README claimed green-tea was Node-only with Deno/Bun/edge "on the roadmap, not built" — all four have shipped. It also taught that a plain return of an AsyncIterable streams by Accept, which the explicit-transport change turned into a 500 TransportMismatchError: the one thing a README must never do is document behavior that now throws. docs/ had been frozen since the Starlight site replaced it; nothing but the README referenced those two files, so they were a second copy to keep in sync and had already drifted. Point at the site instead. Also adds what shipped unmentioned (@Html/views/static, the four runtimes, matcha) and fixes the CHANGELOG's YY.MM.PATCH, which contradicted the README's correct explanation of why the month is not zero-padded. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
dba40b0c8b |
feat(mesh): heartbeat the link, and tell the truth when a teapot is gone
Three bugs, found by writing the tests for the status codes. A teapot with a live control channel could never shut down. Control connections were never registered with the stream registry, so server.close() sat waiting on a connected teacup that had no reason to hang up, and app.close() never resolved. Every other long-lived socket was already tracked; the control channel was the one that skipped it. A downed teapot answered 500 — after 30 seconds. sendRpc queued the frame on a closed socket and waited out the full timeout for a verdict already known. It now rejects immediately with 503: a dead upstream is not "this service broke", and the status is what tells a caller it may retry and an operator where to look. An RPC that times out on a *live* link is 504 — a slow teapot and a gone one are different stories. Heartbeat: each teacup pings its teapots (`mesh.heartbeatMs`, default 15s) and closes a link after two unanswered rounds. This is what catches a half-open connection, where the socket looks open with nobody home — otherwise a teacup only learns on the next request. Ping/pong are mesh frames rather than WebSocket protocol pings because Deno's and Bun's platform WebSocket does not expose ws.ping(), so a protocol-level heartbeat could not work everywhere mesh runs. Added to v1 while the wire still has no deployed peers; later it would be a version bump that refuses every old peer. The heartbeat's first close code was 1011, which silently did nothing: a *client* may only send 1000 or 3000-4999, so it threw `invalid code` — and our neutral close swallows throws, so the link stayed open while looking closed. 4011 mirrors 1011's meaning inside the application range. Reconnect (and reconciling app-scope values, which survive their teapot from cache) stays out — it is a post-beta spec of its own. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com> |
||
|
|
9886e53747 |
feat(app): add app.ready() so introspection works on any app
inspect()/graph()/explain() are synchronous, but a mesh graph is not knowable
until its teapots have been asked, so on a mesh app they threw and the caller had
no way to fix it. Code holding an `App` could not tell which kind it had — the
Liskov complaint from the audit, and the last of it: fetch/upgrade stopped
throwing when the boot moved into the gate.
app.ready() resolves the graph and returns. On a mesh app it connects the
teapots; on every other app it is a no-op. So one shape works for both:
await app.ready();
app.graph();
which is what actually restores substitutability — a uniform protocol, not a type
that describes the asymmetry.
Deliberately not a full boot: it does not run provider factories. Resolving the
graph and being ready to serve are different things, and a devtool drawing a
diagram should not open your database connections. Serving boots them too and
shares the same memoized step, so ready() then fetch() resolves the graph once.
The guards stay — sync code cannot await network I/O — but the message names the
fix instead of describing the trap.
createApp hit 26 on the complexity gate with ready() added. Both boot stages had
their own copy of the same memoisation, so it collapses into one `once` helper
used by both, which is a smaller createApp than before this change.
Refs .specs/2026-07-15-green-tea-solid-audit (App/Mesh LSP)
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
|