Commit Graph
175 Commits
Author SHA1 Message Date
chrnx 502b2c6b72 Merge branch 'feature/mesh-link-health' into develop
CI / build (push) Successful in 1m2s
Link health for mesh: say what is actually wrong, and notice it without waiting
for a user to find out.

Writing the tests for the status codes turned up three bugs. A teapot with a live
control channel could never shut down — control connections were the one kind of
long-lived socket nobody registered for force-close, so server.close() waited on
a teacup that had no reason to hang up. A downed teapot answered 500 after a full
30s timeout, having queued the frame on a closed socket to wait out a verdict
already known; it now answers 503 at once, and a live-but-slow teapot answers 504.
And the heartbeat's first close code, 1011, silently did nothing: a client may
only send 1000 or 3000-4999, so it threw `invalid code` into a catch that swallows
throws, leaving the link open while looking closed.

Ping/pong are mesh frames, not WebSocket protocol pings, because Deno's and Bun's
platform WebSocket does not expose ws.ping(). They land in v1 while the wire has
no deployed peers to break.

Reconnect, and reconciling app-scope values that outlive their teapot from cache,
stay out — post-beta, on their own spec.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 23:54:21 -05:00
chrnx 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>
2026-07-15 23:32:45 -05:00
chrnx 5e7d952f45 Merge branch 'refactor/solid-cleanup' into develop
A SOLID audit that turned into making mesh work off Node.

The audit found the repo already sound on DIP/ISP, and most candidate findings
did not survive verification. Five real ones did, and fixing the observability
gap exposed the rest: steps were run by three hand-rolled loops, only one of
which emitted request:step:enter/leave, so a logging plugin silently saw nothing
on @Ws routes.

Pulling that thread reached mesh, which was Node-only by construction rather
than by decision: only listen() finalized a mesh graph, and listen() builds a
Node http.Server, so app.fetch — the entry Deno/Bun/edge use — threw forever and
told operators to call something they could not call. Mesh now runs on Node, Deno
and Bun, teapot and teacup, in any combination, proven by cross-process interop
tests rather than reasoned about.

Wire protocol is versioned before it has peers to break; duplicate exported
routes fail the boot rather than silently shadowing, since there is no load
balancing to fall back on; local-over-remote precedence now warns instead of
being an accident of merge order; app.ready() resolves the graph without booting
providers, so one protocol works against mesh and non-mesh apps alike.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 23:14:26 -05:00
chrnx 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>
2026-07-15 23:00:14 -05:00
chrnx 34dbb32b2c docs(mesh): warn on shadowed remote routes, and tell the truth about mesh
Local routes are merged ahead of remote ones, so a local twin wins. That
precedence is worth keeping — your own code beating an imported one is how you
override a teapot — but it was an accident of [...local, ...remote] ordering with
nothing said, so a shadowed export looked like a broken teapot from the outside.
Warn, name the teapot, and leave the call to the developer.

The docs had gone stale in the way that started all of this. runtimes.md claimed
four times that mesh is Node-only; the mesh guide said finalization is deferred to
listen(); the changelog said "WebSocket and mesh remain Node-only". All false now.

The mesh guide gains what was enforced but never written down — which is how the
listen() trap got made in the first place, when the previous plan's "document it"
never landed:
- runs on Node/Deno/Bun, teapot and teacup, any combination; not on edge, and why
- no listen() required: the graph boots on first use
- buffered routes only, and why streams cannot cross an RPC hop
- one teapot per route, local-over-remote precedence, and the protocol version

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 9

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 16:20:55 -05:00
chrnx 033af2d1fc fix(mesh): fail the boot when two teapots export the same route
Duplicate scope tokens already threw in setRunner, but duplicate routes did not:
both were pushed into remoteRoutes, and matchRoute keeps the first of two
identical patterns (moreSpecific returns 0, not > 0). The second teapot's route
was silently dead. Same collision, two behaviours — one loud, one mute.

Fail the boot instead, naming the route and both teapots, since which pair
clashed is the thing an operator needs. The message says load balancing is not
implemented *yet*: it is a not-yet, not an impossibility.

Throwing now also keeps the door open. "First teapot wins" is a semantic callers
could come to rely on, so shipping it would make balancing a breaking change
later. An error cannot be relied on — turning it into a strategy stays additive.

Scopes keep failing rather than balancing, and should: an app-scope provider is
memoised, so "balancing" a cached value means nothing.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 16:04:57 -05:00
chrnx a74417494f test(mesh): prove mesh across Node, Deno and Bun
Every mesh test ran on Node and drove listen(); nothing off Node was covered, so
the cross-runtime work was implemented but not demonstrated. vitest excludes
test/{deno,bun,edge}, so `npm test` would not have noticed either way.

Adds, in the real runtimes:
- Deno and Bun, teapot and teacup, served through serveDeno/serveBun. Bun is not a
  duplicate of Deno: its socket events land on a server-level handler, so the
  control channel reaches app.upgrade by a different path.
- The interop matrix, in separate processes: a Deno teacup consuming a Node teapot
  and a Node teacup consuming a Deno teapot. Each asserts the `runtime` field the
  *other* process produces, so a peer answering from the wrong side fails the test.
  Node serves and connects with the `ws` package; Deno uses its global WebSocket —
  same-runtime tests could never have exercised that pairing.
- A hand-rolled v999 peer, refused across the boundary with both versions named.

Verified these tests fail for the right reason: breaking the control-channel
routing in app.upgrade fails the Node-teacup-consumes-Deno-teapot case and only
that case.

test:deno needs --allow-run/--allow-env to spawn the Node peer. The peer lives in
test/interop rather than test/deno because tsconfig excludes test/deno, so tsx
would not apply experimentalDecorators there; vitest ignores it as a non-.test.ts.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 8

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 15:30:43 -05:00
chrnx 0c68cba532 feat(mesh): mount the control channel on app.upgrade, and close links without a server
Two halves of the same "mesh off Node" gap; they touch the same file and landed
together.

Control channel (Task 6): meshControl existed only inside listen(), passed to
createHttpServer, so a teapot could only export its scopes from Node. app.upgrade
— the path serveDeno/serveBun drive — had never heard of it, which would have left
"mesh on three runtimes" meaning consume-only. It is now built in the boot gate
(it captures the finalized ordered nodes, so it cannot exist before finalize) and
the reserved path is routed from app.upgrade. Task 3 already made handle() take a
neutral WsSocket and upgrade holds one, so this is a direct call, not a second
implementation. handle() returns the connection's lifetime like runWsConnection,
so upgrade awaits it instead of returning while the peer is still talking. An app
with nothing exported refuses the reserved path explicitly rather than falling
through to "no matching ws route".

Link lifecycle (Task 7): links were reaped by server.on('close'), reachable only
through listen(), so a mesh app booted through app.fetch had links and no server
and leaked every teapot connection at `if (!server) return`. close() now closes
them first either way; that aborts each socket, which rejects its in-flight RPCs.

Also fixes a race the new tests exposed: upgrade awaited the boot *before* handing
the socket to a consumer, but `channel` is fan-out, so frames arriving during the
boot were dropped with no subscriber attached. For the control channel that is
`hello` itself — against a teapot with slow providers the handshake would hang
until timeout. Inbound is now subscribed synchronously on entry and the buffered
iterator handed down, closing the same gap for regular @Ws routes.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Tasks 6, 7

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 15:13:20 -05:00
chrnx db9a7712af feat(mesh): boot the mesh graph from the app boot gate, not listen()
Only listen() spliced remote scopes and finalized the graph, and listen() builds
a Node http.Server. Deno/Bun/edge serve through app.fetch and can never call it,
so mesh was Node-only by construction: fetch() threw "unavailable before
listen()" forever on those runtimes, telling operators to call something they
had no way to call. buildAppFetch also hardcoded remoteRoutes to [], so even past
the guard it would not have served a remote route.

Move splice+finalize into the memoized boot gate that fetch, upgrade and listen
already share, ahead of the providers — remote nodes must join before the topo
sort. Await it before building the route table rather than after, since for a
mesh app the table is not knowable until the splice has run. listen() keeps
working by awaiting the same gate; the memoization means a fetch followed by a
listen boots once, and concurrent first requests splice once.

The fetch/upgrade guards are gone rather than reworded: they are now unreachable.

inspect()/graph()/explain() keep theirs — they are synchronous and cannot await
network I/O — but their message no longer claims listen() is the only way in.

test/fetch.test.ts asserted the old contract (fetch throws until listen), i.e.
the trap itself; it now pins that a mesh app serves without listen() and that
listen() afterwards does not re-run provider factories.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 5

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 15:04:49 -05:00
chrnx 0ea4db3fef feat(mesh): connect the teacup over a runtime-neutral WebSocket client
connectLink constructed `require('ws')` directly and drove its EventEmitter API,
which is why a teacup could only run on Node. It now goes through the neutral
WsSocket like every other consumer, over whichever client the runtime provides:
the platform global (Deno, Bun, Node >= 22) or the `ws` peer for Node 18-21,
which has no global. `ws` stays optional and is only reached for when the global
is absent.

One bridge covers both because `ws` also implements the browser-compatible event
API and delivers text frames as `event.data` strings — probed against the real
package rather than taken on faith.

Both implementations are exercised in one run: `ws` is always in the matrix, so
the Node 18-21 path cannot rot unseen on CI that only runs a modern Node, which
is how a fallback quietly stops working. connectLink takes an optional Ctor to
make that possible; it doubles as a bring-your-own-WebSocket hook for runtimes
we do not ship an adapter for.

Verified the edge bundle is unaffected: `require('ws')` tree-shakes out of the
workerd build entirely.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 4

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 15:00:04 -05:00
chrnx 71b59e7c25 refactor(mesh): serve the control channel over the neutral WsSocket
The mesh control channel was the last consumer speaking the `ws` EventEmitter
API directly: http/ws.ts handed meshControl.handle a raw socket, while every
@Ws route already went through nodeSocket() to get a neutral WsSocket. Mesh did
not lack an abstraction — it skipped the one the codebase already had.

handle() now takes a WsSocket and consumes `inbound`, so both feeds work: Node
via the existing nodeSocket, and Deno/Bun via app.upgrade, where the socket is
already neutral. That is what unblocks mounting the control channel off Node.

RPCs are still dispatched without awaiting. The old `ws.on('message')` listener
overlapped them, and the peer's id-keyed pending map exists for exactly that —
awaiting inside the receive loop would have silently serialized every mesh call.
A test now pins the overlap.

The unused `http` import in http/types.ts fell out with MeshControl's req
parameter: nothing in that module is Node-shaped any more.

Node behaviour is unchanged — the teapot↔teacup integration tests pass
untouched. teapot.test.ts drives handle() directly, so its fake moved from a raw
EventEmitter to a fake WsSocket.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 3

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:53:09 -05:00
chrnx 87772868ab refactor(mesh): import node:crypto explicitly in the teapot
safeEqual guards the mesh shared secret and reached for Buffer + timingSafeEqual
through a bare 'crypto' specifier, leaving resolution to Deno/Bun node-compat
heuristics. Name the builtin explicitly — the authentication path should not
depend on which compat layer happens to answer.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 2

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:53:07 -05:00
chrnx dd0ea91a1b feat(mesh): version the wire protocol and validate frame shapes
Cross-runtime mesh means peers are separate processes on separate deploy
cadences, so the frame union is a contract between green-tea versions rather
than an internal detail. There was no version field, and decode validated only
that `type` was a known tag before casting `parsed as Frame` — every other
field was trusted, so a skewed or malformed peer failed somewhere downstream
instead of at the boundary.

Add MESH_PROTOCOL_VERSION to the hello/manifest frames. Both ends refuse a
mismatch: the teapot checks the version *before* the secret, since a skewed
peer is not an auth failure and "wrong secret" would send its operator hunting
the wrong bug.

Validate fields per frame type via a Record keyed on the type tag, so a new
frame type must add a row. The lookup uses an own-property check: `type` is
peer-controlled and a bare lookup would resolve SHAPE['constructor'] up the
prototype chain to a truthy non-check.

This is a breaking wire change, done now because it is free exactly once —
mesh is alpha behind experimental:true and has no deployed peers. Adding a
version later would break every peer already in the field.

Refs .specs/2026-07-15-green-tea-mesh-cross-runtime-plan.md Task 1

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:47:35 -05:00
chrnx d56eeafcd8 refactor: close type holes on the transport and error axes
- OpenApiRoute.transport was typed `string`, so the compiler could not check the
  transport branching at all. Type it Transport and key the documented 200 off a
  Record, so a new transport fails the build instead of silently going undocumented.
- pickEncoder fell through to ndjson for unknown transports; make the mapping
  exhaustive so a new transport cannot inherit the wrong wire format by accident.
- HttpError carries optional headers, removing the instanceof Redirect special case
  that coupled the error renderer to one subclass. Custom errors needing headers
  (retry-after, etag) no longer require touching transformers.
- Drop the module-global connSeq in mesh/link: `pending` is already per-connection,
  so a per-link counter suffices and connection ids stop depending on test order.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:37:03 -05:00
chrnx 9421b102d9 refactor(adapters): share ws plumbing across bun/deno/edge
toWsRequest, the neutral-socket wrapper and the upgrade error guard were
copy-pasted across all three runtime adapters, comments included. A change to
the upgrade close code meant remembering to touch three files.

Extract the shared parts to http/ws-adapter (kept separate from ws-core: that
module runs a connection, this one builds one from a host runtime's socket).
Bun keeps its own socket wrapper — its events land on a server-level handler
rather than the socket, so the lifecycle genuinely differs.

Verified against real runtimes: deno test, bun test, workerd via miniflare.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:37:03 -05:00
chrnx 922700674c fix(bus): emit step events for ws and mesh routes
Steps were executed by three separate hand-rolled loops: runPipeline (HTTP),
buildWsRoutes (ws) and resolveScope (mesh). Only the HTTP one emitted
request:step:enter/leave, so a logging plugin silently observed nothing on ws
routes — a gap in a documented public API, not just redundancy.

Route every transport through a single runSteps() so observability is uniform
by construction rather than by remembering to copy the emit calls.

Also fixes the plugins guide, which documented a request:step:exit event that
has never existed (the bus emits request:step:leave).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-15 14:37:03 -05:00
chrnx 44cf547f1b Merge branch 'feature/explicit-transport' into develop
CI / build (push) Has been cancelled
feat(pipeline): transport is declared, not inferred (BREAKING)

A route's declared transport is now the ground truth for what its handler
may return — the old implicit "any handler returning an AsyncIterable
streams" behavior (spec #2) is removed.

- @Get/@Post/@Put/@Patch/@Delete (buffer) MUST return a value; returning an
  AsyncIterable -> 500 TransportMismatchError.
- @Sse/@Ws MUST return an AsyncIterable; returning a value -> 500.
- @Stream (negotiate) still tolerates both (client negotiates via Accept).
- Extensible TRANSPORT_RETURN map (Record<Transport, ReturnContract>);
  runPipeline gains a required `transport` arg, wired at both call sites.
- @Html (buffer) is covered by the general rule; its return contract
  (bare->string, template->object, file->void) is documented.

BREAKING (pre-1.0): a return value no longer changes a route's wire
contract. Declare @Sse/@Stream/@Ws to stream. 0 examples affected.

269 tests, tsc/lint/complexity green. Per-task + final opus review.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 16:22:57 -05:00
chrnx 76267b74ec docs(transport): reword homepage hero — declare @Sse to stream
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 16:07:01 -05:00
chrnx 2b646eaec6 docs(transport): reword stale implicit-streaming passages
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 16:06:02 -05:00
chrnx 535392baba docs(transport): declared-transport contract + @Html return contract
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 16:02:36 -05:00
chrnx 4d1ff33f74 test(transport): end-to-end enforcement via app.fetch
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 15:59:52 -05:00
chrnx f613a6427b feat(pipeline): enforce return contract by declared transport
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 15:55:22 -05:00
chrnx 35861f0fc1 Merge branch 'feature/html-views' into develop
CI / build (push) Has been cancelled
feat(views): HTML serving — @Html decorator, template engine, static

- @Html method decorator: string / file / template modes, buffered GET/POST
  only (boot-validated; SSE/WS/other and @Html+@Transformer throw).
- Zero-dep built-in template engine (render): {{ }} HTML-escaped, {{{ }}} raw,
  nested keys; + createApp({ viewEngine }) bring-your-own hook.
- Zero-config static serving: createApp({ static: true }) -> ./public (or a
  path); content-type by extension, / -> index.html, GET/HEAD, path-traversal
  safe, declared routes win. Node/Deno/Bun (fs); edge throws at boot.
- createApp({ views }) base dir for @Html file paths (default cwd).
- Runtime-agnostic invariant preserved: fs/path lazy-required, barrel still
  loads on workerd; string-mode @Html + render are fs-free.
- Docs: guides/html + runtimes fs-note + reference pages + CHANGELOG.

261 tests, tsc/lint/complexity green. Reviewed per-task + final opus pass.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 15:13:48 -05:00
chrnx 2d6306b318 docs(views): reference pages, guide footgun note, drop unused test import
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:58:56 -05:00
chrnx 289ca5f8ff docs(views): @Html, templating, and static serving guide
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:50:06 -05:00
chrnx ad3a06f057 feat(views): zero-config static directory serving
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:42:20 -05:00
chrnx b8ebb9d04b feat(views): @Html string/file/template modes with boot validation
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:36:40 -05:00
chrnx e1a2c3253b feat(views): @Html decorator and metadata
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:31:12 -05:00
chrnx da5cc936a3 feat(views): built-in template engine + content-type map
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:26:57 -05:00
chrnx e54de8c1db Merge branch 'fix/dev-routes-on-fetch' into develop
CI / build (push) Has been cancelled
Serve /__graph__ + /__openapi__ over app.fetch so the dev tools (graph viewer,
OpenAPI) work on Deno/Bun/edge, not just the Node listen() path.
2026-07-10 00:10:56 -05:00
chrnx df13a62d93 fix(app): serve /__graph__ and /__openapi__ over app.fetch (dev tools on all runtimes)
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 00:10:54 -05:00
chrnx 6833293ccf Merge branch 'feature/runtime-edge-ws' into develop
CI / build (push) Has been cancelled
Step 4 runtime-agnostic: Edge / Cloudflare Workers + WebSocket.
- @green-tea/core/edge edgeHandler (HTTP+SSE+WS on workerd), real Miniflare test
- reuses the neutral WsSocket capability + app.upgrade (edge-only supplies a socket)
- lazy-load http/https so createApp is edge/workerd-safe (Node path identical)
- runtime-agnostic saga complete: Node + Deno + Bun + edge
2026-07-09 23:52:30 -05:00
chrnx cb4ecd6801 docs: edgeHandler — WebSocket on Cloudflare Workers / edge
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:45:27 -05:00
chrnx 70925035d7 fix(http): lazy-load http/https so createApp is edge/workerd-safe; drop test shim
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:40:28 -05:00
chrnx a4c9df9a74 test(edge): edgeHandler HTTP + WebSocket on real workerd via Miniflare
Boots the actual workerd engine locally (miniflare devDep, no CF account
needed) and round-trips HTTP (app.fetch) + WebSocket (WebSocketPair +
app.upgrade) through edgeHandler's real request path, mirroring the Deno/Bun
adapter tests' assertion shape.

workerd's nodejs_compat genuinely does not implement node:http/node:https
(confirmed in isolation against the real runtime; node:crypto, node:stream,
node:net, node:tls, node:events, node:util, node:buffer all load fine under
the same flags). The barrel statically imports them for the Node listen()
path even though edgeHandler never touches it, so the bundler stubs those
two modules at test-bundle time (inert createServer that throws if ever
called) purely to let the worker load — edgeHandler itself is untouched.
See project-docs/.superpowers/sdd/task-2-report.md for the full writeup and
the suggested core follow-up (lazy-defer those imports behind listen()).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:34:19 -05:00
chrnx 9344cc7d43 feat(edge): edgeHandler adapter — HTTP+SSE+WS on Cloudflare Workers via /edge subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:22:28 -05:00
chrnx 86c206d2c9 Merge branch 'feature/runtime-bun-ws' into develop
CI / build (push) Has been cancelled
Step 3 runtime-agnostic: Bun adapter + WebSocket.
- @green-tea/core/bun serveBun (HTTP+SSE+WS on Bun), real bun test
- reuses the neutral WsSocket capability + app.upgrade (zero core changes)
- open-deferred WsSocket build via ws.data; binary parity + ws error handler
2026-07-09 22:08:58 -05:00
chrnx 82824e5f6d fix(bun): add ws error handler for Node/Deno parity; hoist TextDecoder
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 22:00:23 -05:00
chrnx 3d21117a07 docs: serveBun — WebSocket on Bun
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:54:34 -05:00
chrnx 4351b41038 test(bun): serveBun HTTP + WebSocket integration
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:51:33 -05:00
chrnx fd6446f514 feat(bun): serveBun adapter — HTTP+SSE+WS on Bun via /bun subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:44:46 -05:00
chrnx 8d3a4ca420 Merge branch 'feature/runtime-deno-ws' into develop
CI / build (push) Has been cancelled
Step 2 runtime-agnostic: Deno adapter + WebSocket capability.
- Neutral WS core (ws-core.ts) behind a WsSocket capability
- Node adapter rebuilt over it (behaviour byte-identical)
- app.upgrade(request, socket) neutral primitive
- @green-tea/core/deno serveDeno (HTTP+SSE+WS on Deno), real deno test
- docs + CHANGELOG
2026-07-09 17:39:55 -05:00
chrnx 4a6ef784ec fix(deno): decode binary ws frames to match Node; changelog ctx.req note
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:38:23 -05:00
chrnx 47b7bf5f24 docs: serveDeno + app.upgrade — WebSocket on Deno
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:27:26 -05:00
chrnx f85b39c2c3 test(deno): serveDeno HTTP + WebSocket integration
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:23:24 -05:00
chrnx e9357efb5c fix(deno): guard fire-and-forget app.upgrade against fatal unhandled rejection
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:17:20 -05:00
chrnx 12eccd941c feat(deno): serveDeno adapter — HTTP+SSE+WS on Deno via /deno subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:11:00 -05:00
chrnx d72452d9b6 feat(app): app.upgrade — neutral WebSocket entry over the graph
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:04:38 -05:00
chrnx 7a8be39d57 refactor(ws): Node adapter builds WsSocket over the neutral core
Also fixes buildWsRoutes (app/index.ts) to read the pre-derived
protocol/ip off the neutral WsRequest instead of req.socket, which no
longer exists now that WsOpenCtx.req is WsRequest — without this every
real @Ws route throws on open() and the connection hangs.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 16:56:17 -05:00
chrnx 5e68d2de65 fix(ws): runtime-neutral close reason + registry removal on transport close
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 16:51:42 -05:00