bootProviders was a for...of with an await inside, so an app paid the sum of its
providers' latencies rather than its longest chain. topoLevels groups the already
topo-sorted list into dependency levels and each level runs together.
Measured on the issue's case — three providers, no edges, 200ms each: 616ms → 210ms,
which is the critical path exactly.
Teardown still runs in the exact reverse of boot: registration follows level order, not
completion order. A required provider that fails no longer prevents its independent
siblings from starting, so whatever they opened is registered for teardown before the boot
aborts. On the bus, boot:provider:start no longer strictly alternates with :ok.
sse(data, { id, event, retry }). An app that never calls it produces byte-identical
output.
Half of this already worked and it was worth checking before designing anything: the
request envelope has always carried every header, so a handler could already read @header('last-event-id') — it just always arrived empty, because nothing wrote an id.
green-tea stores nothing. No buffer, no retention, no replay. Framework-managed replay
would need a stream identity that survives a disconnect — which does not exist, every
request builds a fresh iterable — plus a retention policy no default gets right and an
in-process buffer that breaks with two instances. This is also the prerequisite for any of
that, since replay would key on these ids.
An id with a newline is rejected, not stripped: the format is line-based and an id is the
value most likely to be built from a request, so one newline lets a caller append fields to
somebody else's stream.
stream:open/:close/:error were Node-only. Every Fetch runtime emitted none of them and
broke the response with a transport error instead of writing the encoder's error frame. Both
halves silent: a consumer counting stream:error saw zero on three of four runtimes, and the
client got a truncated body indistinguishable from a clean end.
The test drives both adapters from one route table — a table describing one and then the
other is how they drifted in the first place.
#84 — those events carry the request they belong to
core.ts documented them as carrying requestId since the stream landed. They carried { name }. The split is right — an hour-long SSE connection must not share a latency
distribution with a 2ms reply — but it only works if the two can be joined.
route comes along because the contract this beta settled says label on route, never on name, and route was absent from exactly the events a stream gauge is built from.
A WebSocket upgrade correlates itself: it is an HTTP request with headers like any other, so
it adopts a gateway's x-request-id rather than opening a second identity, and carries transport: 'ws'.
Found and filed while working: #83 and #84, both fixed here. Left open by decision: #68 (needs a new package) and #50/#51 (mesh is frozen for now).
Gates on every commit: lint 0 errors, format:check, complexity, typecheck, 534 vitest on
Node 22, 533 on Node 18, 17 Deno, 7 Bun, edge PASS, build, deno publish --dry-run.
Changelog heading stays [Unreleased] — the version and the date belong to the cut.
Four issues, one branch, one commit each, plus the changelog. Every commit gated on CI.
### #71 — independent providers boot concurrently
`bootProviders` was a `for...of` with an `await` inside, so an app paid the **sum** of its
providers' latencies rather than its longest chain. `topoLevels` groups the already
topo-sorted list into dependency levels and each level runs together.
Measured on the issue's case — three providers, no edges, 200ms each: **616ms → 210ms**,
which is the critical path exactly.
Teardown still runs in the exact reverse of boot: registration follows level order, not
completion order. A required provider that fails no longer prevents its independent
siblings from starting, so whatever they opened is registered for teardown before the boot
aborts. On the bus, `boot:provider:start` no longer strictly alternates with `:ok`.
### #46 — `@Sse` emits an `id:`
`sse(data, { id, event, retry })`. An app that never calls it produces byte-identical
output.
Half of this already worked and it was worth checking before designing anything: the
request envelope has always carried every header, so a handler could already read
`@header('last-event-id')` — it just always arrived empty, because nothing wrote an id.
**green-tea stores nothing.** No buffer, no retention, no replay. Framework-managed replay
would need a stream identity that survives a disconnect — which does not exist, every
request builds a fresh iterable — plus a retention policy no default gets right and an
in-process buffer that breaks with two instances. This is also the prerequisite for any of
that, since replay would key on these ids.
An `id` with a newline is rejected, not stripped: the format is line-based and an id is the
value most likely to be built from a request, so one newline lets a caller append fields to
somebody else's stream.
### #83 — stream lifecycle on every runtime
`stream:open`/`:close`/`:error` were Node-only. Every Fetch runtime emitted none of them and
broke the response with a transport error instead of writing the encoder's error frame. Both
halves silent: a consumer counting `stream:error` saw zero on three of four runtimes, and the
client got a truncated body indistinguishable from a clean end.
The test drives both adapters from one route table — a table describing one and then the
other is how they drifted in the first place.
### #84 — those events carry the request they belong to
`core.ts` documented them as carrying `requestId` since the stream landed. They carried
`{ name }`. The split is right — an hour-long SSE connection must not share a latency
distribution with a 2ms reply — but it only works if the two can be **joined**.
`route` comes along because the contract this beta settled says label on `route`, never on
`name`, and `route` was absent from exactly the events a stream gauge is built from.
A WebSocket upgrade correlates itself: it is an HTTP request with headers like any other, so
it adopts a gateway's `x-request-id` rather than opening a second identity, and carries
`transport: 'ws'`.
---
Found and filed while working: **#83** and **#84**, both fixed here. Left open by decision:
**#68** (needs a new package) and **#50**/**#51** (mesh is frozen for now).
Gates on every commit: lint 0 errors, format:check, complexity, typecheck, **534** vitest on
Node 22, **533** on Node 18, 17 Deno, 7 Bun, edge PASS, build, `deno publish --dry-run`.
Changelog heading stays `[Unreleased]` — the version and the date belong to the cut.
`bootProviders` was a `for...of` with an `await` inside, so three providers that share
nothing took the sum of their latencies rather than the longest one. Measured on the
issue's case — three providers, no edges, 200ms each — 616ms before, 210ms after.
The graph already knew. `topoSort` proves which nodes cannot constrain each other and
then throws that away by returning a flat list; `topoLevels` groups the sorted list back
into dependency levels in one forward pass, and boot runs a level with `Promise.all`.
Nothing else about the ordering changes: level N is fully registered and warmed before
level N+1 starts, which is the same guarantee the sequential walk gave.
This is the second thing users get for declaring `needs`/`provides` instead of ordering
`app.use` calls by hand. Pruning was the first. An Express app cannot parallelize its
middleware because nothing declares what is independent — we have that declaration and
were not spending it.
Three things had to survive the change, and each has a test:
- **Teardown stays deterministic.** Registration follows level order, not completion
order, so the registry running in reverse still gives dependants teardown before their
dependencies. Following whichever provider settled first would have turned that from a
guarantee into luck.
- **A failed sibling does not strand the level.** `bootProvider` returns an outcome
instead of rejecting, and successful teardowns are registered before any failure is
raised — so a boot aborted by a required provider still leaves whatever its siblings
opened closeable. Previously they had not started at all; now they may be in flight.
- **A provider that threw gets no teardown**, unchanged: it never provided anything, and
`dispose()` on a half-constructed one is how a teardown finds a null connection.
Behaviour visible to a bus consumer: `boot:provider:start` no longer strictly alternates
with `:ok`. A level emits its starts together, then its results. That is the truth about
what is happening rather than a change in what is reported.
Verified non-vacuous: reverting `src/` fails the overlap assertion and all five
`topoLevels` cases, and puts the benchmark back at 616ms.
Closes#71
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`sseEncoder` wrote one field. With no `id:` on the wire the browser had nothing to put in
`Last-Event-ID`, so every automatic reconnect rebuilt the route's iterable from its start
and lost the gap in silence — a healthy-looking stream that had simply skipped events.
Half of this already worked and it was worth checking before designing anything: the
request envelope has always carried every header, so a handler could already read
`@header('last-event-id')`. It just always arrived empty, because we never gave the
browser an id to send.
`sse(data, { id, event, retry })` tags a stream item; `sseEncoder` writes the fields ahead
of `data:`. An app that never calls it sees byte-identical output. `event:` and `retry:`
come along because the envelope carries them for free and neither was reachable before.
**green-tea stores nothing.** No buffer, no retention window, no replay. The framework
carries the marker in both directions and the handler decides what the gap means, because
only the source knows: a paged log re-reads from an offset, a live sensor has no past
worth delivering. Framework-managed replay would need a stream identity that survives a
disconnect — which does not exist, since every request builds a fresh iterable — plus a
retention policy no default can get right and an in-process buffer that breaks the moment
there are two instances. This commit is also the prerequisite for any of that: whatever
replay might land later keys on these ids.
An id with a newline is rejected, not stripped. An id is exactly the value most likely to
be derived from a request — a cursor, a page token — and the SSE format is line-based, so
one newline lets a caller append arbitrary fields to somebody else's stream. Stripping
would resume from the wrong place invisibly, which is the failure this whole feature
exists to close, so it throws where the stream can report it.
`ndjsonEncoder` unwraps the payload and drops the fields: a `negotiate` route yields the
same items to both encoders, and NDJSON has no frame to carry them and no resumption
protocol to use them.
Verified non-vacuous: reverting just the two `encode` functions fails the six framing and
round-trip assertions and leaves the validation ones passing, which is the right split.
Closes#46
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`pipeStream` emitted `stream:open`/`:close`/`:error` and wrote the encoder's error frame.
`asReadableStream` — the path every Fetch runtime takes, so Deno, Bun, workerd and
`app.fetch()` on Node — emitted nothing and called `controller.error(err)`.
Both halves of that were silent. A consumer counting `stream:error` saw zero on three of
the four runtimes while the streams were failing normally, and the client got a truncated
body with no explanation, which from the outside is indistinguishable from a clean end of
stream. The observability guide documents these three events without qualification; on
three runtimes they did not exist.
The error path now frames rather than breaks. Enqueue `encodeError`'s frame, then close
cleanly — the Node behaviour, and the better one: an SSE consumer that received an `error`
event knows what happened, where a transport-level failure looks exactly like the
connection dropping. `controller.error` is kept for an encoder with no error frame to
offer, because then breaking the stream is the only signal left.
`stream:close` is latched. A `cancel` can land after the body already ended, and the three
exits — done, error, cancel — must not each emit their own.
The test drives both adapters from one route table rather than asserting them in separate
blocks, since a table that describes one and then the other is how the two drifted in the
first place. Verified non-vacuous: reverting `src/http/web.ts` fails all four fetch rows
and leaves the three Node ones green, which is the split that says the test is measuring
the adapter and not the framework.
The `sse()` injection test from the previous commit went back to `app.fetch`. It had been
written against `listen()` only because the fetch path swallowed the error — that was a
workaround for this bug, and it is no longer needed.
Closes#83
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`src/http/core.ts` documented the design as "`stream:open`/`stream:close` already describe
the connection, and now carry the same `requestId`". They carried `{ name }` and nothing
else, on all three emitters, and `Bus.emit` forwards a payload verbatim — so there was
nowhere else it could have been arriving from. The comment described an intent that was
never carried out.
The split it describes is right: a route returning an `AsyncIterable` is done in
milliseconds while its connection may live for hours, so ending the request span at the
handler's return keeps hour-long SSE connections out of the same latency distribution as
2ms replies. But the split only works if the two can be **joined**, and `requestId` is the
join key — it is what `EventPayload` defines itself as. Without it an exporter could not
say which request opened the connection still holding a slot, and `traceId`, carried
verbatim so an exporter can hand it to OTLP, never reached the longest-lived thing the
server does.
`route` comes along for a second reason. The contract this beta settled says label on
`route`, never on `name` — and `route` was absent from precisely the events a stream gauge
is built from, leaving a correct consumer with nothing to label. On a stream event `name`
is always the route pattern rather than the concrete path, so the two are the same value
here; both are emitted because the rule a consumer follows is written against `route`.
A WebSocket upgrade correlates itself. It is an HTTP request with headers like any other,
so `runWsConnection` derives its own correlation and adopts a gateway's `x-request-id`
rather than opening a second identity for a connection that already has one. Deriving it
in the one place a ws connection is set up is what keeps it one identity per connection
instead of one per emitter, and it also carries `transport: 'ws'`, which nothing on that
path previously distinguished.
Verified non-vacuous: reverting `src/` fails exactly the six new correlation assertions
across the three emitters and leaves the thirteen lifecycle ones green.
Closes#84
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
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>
chrnx
changed title from WIP: Tier 3 for the beta: independent providers boot concurrently to Tier 3 for the beta: what the graph earns you, and a stream stream you can build on2026-09-01 17:01:15 +00:00
chrnx
changed title from Tier 3 for the beta: what the graph earns you, and a stream stream you can build on to Tier 3 for the beta: what the graph earns you, and an event stream you can build on2026-09-01 17:01:42 +00:00
chrnx
merged commit e7b1c462e6 into develop2026-09-01 17:01:54 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Four issues, one branch, one commit each, plus the changelog. Every commit gated on CI.
#71 — independent providers boot concurrently
bootProviderswas afor...ofwith anawaitinside, so an app paid the sum of itsproviders' latencies rather than its longest chain.
topoLevelsgroups the alreadytopo-sorted list into dependency levels and each level runs together.
Measured on the issue's case — three providers, no edges, 200ms each: 616ms → 210ms,
which is the critical path exactly.
Teardown still runs in the exact reverse of boot: registration follows level order, not
completion order. A required provider that fails no longer prevents its independent
siblings from starting, so whatever they opened is registered for teardown before the boot
aborts. On the bus,
boot:provider:startno longer strictly alternates with:ok.#46 —
@Sseemits anid:sse(data, { id, event, retry }). An app that never calls it produces byte-identicaloutput.
Half of this already worked and it was worth checking before designing anything: the
request envelope has always carried every header, so a handler could already read
@header('last-event-id')— it just always arrived empty, because nothing wrote an id.green-tea stores nothing. No buffer, no retention, no replay. Framework-managed replay
would need a stream identity that survives a disconnect — which does not exist, every
request builds a fresh iterable — plus a retention policy no default gets right and an
in-process buffer that breaks with two instances. This is also the prerequisite for any of
that, since replay would key on these ids.
An
idwith a newline is rejected, not stripped: the format is line-based and an id is thevalue most likely to be built from a request, so one newline lets a caller append fields to
somebody else's stream.
#83 — stream lifecycle on every runtime
stream:open/:close/:errorwere Node-only. Every Fetch runtime emitted none of them andbroke the response with a transport error instead of writing the encoder's error frame. Both
halves silent: a consumer counting
stream:errorsaw zero on three of four runtimes, and theclient got a truncated body indistinguishable from a clean end.
The test drives both adapters from one route table — a table describing one and then the
other is how they drifted in the first place.
#84 — those events carry the request they belong to
core.tsdocumented them as carryingrequestIdsince the stream landed. They carried{ name }. The split is right — an hour-long SSE connection must not share a latencydistribution with a 2ms reply — but it only works if the two can be joined.
routecomes along because the contract this beta settled says label onroute, never onname, androutewas absent from exactly the events a stream gauge is built from.A WebSocket upgrade correlates itself: it is an HTTP request with headers like any other, so
it adopts a gateway's
x-request-idrather than opening a second identity, and carriestransport: 'ws'.Found and filed while working: #83 and #84, both fixed here. Left open by decision:
#68 (needs a new package) and #50/#51 (mesh is frozen for now).
Gates on every commit: lint 0 errors, format:check, complexity, typecheck, 534 vitest on
Node 22, 533 on Node 18, 17 Deno, 7 Bun, edge PASS, build,
deno publish --dry-run.Changelog heading stays
[Unreleased]— the version and the date belong to the cut.`sseEncoder` wrote one field. With no `id:` on the wire the browser had nothing to put in `Last-Event-ID`, so every automatic reconnect rebuilt the route's iterable from its start and lost the gap in silence — a healthy-looking stream that had simply skipped events. Half of this already worked and it was worth checking before designing anything: the request envelope has always carried every header, so a handler could already read `@header('last-event-id')`. It just always arrived empty, because we never gave the browser an id to send. `sse(data, { id, event, retry })` tags a stream item; `sseEncoder` writes the fields ahead of `data:`. An app that never calls it sees byte-identical output. `event:` and `retry:` come along because the envelope carries them for free and neither was reachable before. **green-tea stores nothing.** No buffer, no retention window, no replay. The framework carries the marker in both directions and the handler decides what the gap means, because only the source knows: a paged log re-reads from an offset, a live sensor has no past worth delivering. Framework-managed replay would need a stream identity that survives a disconnect — which does not exist, since every request builds a fresh iterable — plus a retention policy no default can get right and an in-process buffer that breaks the moment there are two instances. This commit is also the prerequisite for any of that: whatever replay might land later keys on these ids. An id with a newline is rejected, not stripped. An id is exactly the value most likely to be derived from a request — a cursor, a page token — and the SSE format is line-based, so one newline lets a caller append arbitrary fields to somebody else's stream. Stripping would resume from the wrong place invisibly, which is the failure this whole feature exists to close, so it throws where the stream can report it. `ndjsonEncoder` unwraps the payload and drops the fields: a `negotiate` route yields the same items to both encoders, and NDJSON has no frame to carry them and no resumption protocol to use them. Verified non-vacuous: reverting just the two `encode` functions fails the six framing and round-trip assertions and leaves the validation ones passing, which is the right split. Closes #46 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>`src/http/core.ts` documented the design as "`stream:open`/`stream:close` already describe the connection, and now carry the same `requestId`". They carried `{ name }` and nothing else, on all three emitters, and `Bus.emit` forwards a payload verbatim — so there was nowhere else it could have been arriving from. The comment described an intent that was never carried out. The split it describes is right: a route returning an `AsyncIterable` is done in milliseconds while its connection may live for hours, so ending the request span at the handler's return keeps hour-long SSE connections out of the same latency distribution as 2ms replies. But the split only works if the two can be **joined**, and `requestId` is the join key — it is what `EventPayload` defines itself as. Without it an exporter could not say which request opened the connection still holding a slot, and `traceId`, carried verbatim so an exporter can hand it to OTLP, never reached the longest-lived thing the server does. `route` comes along for a second reason. The contract this beta settled says label on `route`, never on `name` — and `route` was absent from precisely the events a stream gauge is built from, leaving a correct consumer with nothing to label. On a stream event `name` is always the route pattern rather than the concrete path, so the two are the same value here; both are emitted because the rule a consumer follows is written against `route`. A WebSocket upgrade correlates itself. It is an HTTP request with headers like any other, so `runWsConnection` derives its own correlation and adopts a gateway's `x-request-id` rather than opening a second identity for a connection that already has one. Deriving it in the one place a ws connection is set up is what keeps it one identity per connection instead of one per emitter, and it also carries `transport: 'ws'`, which nothing on that path previously distinguished. Verified non-vacuous: reverting `src/` fails exactly the six new correlation assertions across the three emitters and leaves the thirteen lifecycle ones green. Closes #84 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>WIP: Tier 3 for the beta: independent providers boot concurrentlyto Tier 3 for the beta: what the graph earns you, and a stream stream you can build onTier 3 for the beta: what the graph earns you, and a stream stream you can build onto Tier 3 for the beta: what the graph earns you, and an event stream you can build on