docs: record the plugin contract change and app.boot()
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
2 files changed
+47
-13
No files matched your search
+45
-11
@@ -8,7 +8,24 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
### Breaking
|
||||
|
||||
- **A plugin is a named object.** `Plugin` is now `{ name, mount(api) }`; it was `(api) => void`.
|
||||
The name that `plugin:mounted` reports came from `fn.name`, which is `""` for an arrow returned
|
||||
straight from a factory, `"plugin"` for a `const`, and whatever a minifier leaves behind — so the
|
||||
event that exists to report which plugins mounted reported none of them by name. The name is now
|
||||
the author's word, a failed `mount` is reported as `plugin "<name>" failed to mount: …` with the
|
||||
original error as its `cause`, and two plugins sharing a name fail `createApp`.
|
||||
|
||||
Migration is mechanical:
|
||||
|
||||
```diff
|
||||
- const jwt = (options) => ({ scope }) => { scope.add(node); };
|
||||
+ const jwt = (options) => ({
|
||||
+ name: options.provides ?? 'jwt',
|
||||
+ mount({ scope }) { scope.add(node); },
|
||||
+ });
|
||||
```
|
||||
|
||||
- **Mesh (alpha): only steps and routes can be exported.** `@Provider({ export: true })` now fails
|
||||
the boot, with an error naming the provider and the replacement. A provider is a factory whose
|
||||
@@ -28,6 +45,33 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
**A teapot that boots today can stop booting**, and the replacement is mechanical: the exported
|
||||
`@Provider` becomes a `@Step` that returns what the provider's value carried.
|
||||
|
||||
- **Mesh (alpha): the manifest carries step names.** `{ scopes: [{ token, scope }], routes }` is now
|
||||
`{ steps: string[], routes }`. Every export is request-scope after the change above, so the
|
||||
lifetime field had one possible value left and told a reader nothing. A manifest step that is not
|
||||
a string is now rejected on arrival, rather than trusted because a peer sent it.
|
||||
|
||||
`MESH_PROTOCOL_VERSION` deliberately stays at `1`. Mesh is alpha behind `experimental: true`, both
|
||||
peers ship from this repository, and there is no deployed pair of versions for a bump to protect —
|
||||
it would spend the number on nobody. A stable wire would not get that option; alpha is exactly
|
||||
what the word buys, and this is the last comfortable moment to use it.
|
||||
|
||||
### Added
|
||||
|
||||
- **`app.boot()`** runs the provider factories now instead of on the first request. `listen()`
|
||||
always did this; `app.fetch`, `serveDeno`, `serveBun` and `edgeHandler` boot lazily, and the boot
|
||||
memo keeps a rejection — so a bad key answered 500 on *every* request, from the runtime, without
|
||||
reaching `onError`. `await app.boot()` before `Deno.serve`/`Bun.serve` turns that into a startup
|
||||
failure. On workerd there is no startup outside a request, so calling it moves nothing.
|
||||
- **Errors are recognised by brand.** `HttpError` and `ValidationError` now carry
|
||||
`Symbol.for('green-tea.http-error')` and `Symbol.for('green-tea.validation-error')`, and
|
||||
`isHttpError` checks the brand instead of `instanceof`. An error thrown by code holding a
|
||||
different copy of core — a plugin package, an app that installed from npm and JSR both — now
|
||||
renders with its own status instead of a 500. The exported `HttpErrorLike` type and the
|
||||
`isValidationError` guard come with it. The string is the public protocol: code that imports only
|
||||
types writes `Symbol.for('green-tea.http-error')` itself.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Mesh (alpha): an unreachable teapot no longer stops a teacup from booting.** Blocking was never
|
||||
caution, it was arithmetic: an app-scope value has to resolve *at boot*, because there is no later
|
||||
to resolve it in. A step is nothing but later. The `bootTimeoutMs` grace still waits, since "the
|
||||
@@ -55,16 +99,6 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
connected mesh" rather than "local or mesh", the old wording having claimed a search that never
|
||||
happened.
|
||||
|
||||
- **Mesh (alpha): the manifest carries step names.** `{ scopes: [{ token, scope }], routes }` is now
|
||||
`{ steps: string[], routes }`. Every export is request-scope after the change above, so the
|
||||
lifetime field had one possible value left and told a reader nothing. A manifest step that is not
|
||||
a string is now rejected on arrival, rather than trusted because a peer sent it.
|
||||
|
||||
`MESH_PROTOCOL_VERSION` deliberately stays at `1`. Mesh is alpha behind `experimental: true`, both
|
||||
peers ship from this repository, and there is no deployed pair of versions for a bump to protect —
|
||||
it would spend the number on nobody. A stable wire would not get that option; alpha is exactly
|
||||
what the word buys, and this is the last comfortable moment to use it.
|
||||
|
||||
## [26.9.0-beta.1] - 2026-09-04
|
||||
|
||||
### Added
|
||||
|
||||
@@ -58,7 +58,7 @@ npm install busboy # multipart/form-data file uploads
|
||||
- **One primitive for real-time.** Declare the transport — SSE, ndjson, or a WebSocket duplex — and return an `AsyncIterable`; backpressure and cleanup are handled. *Why it matters:* no separate gateway, adapter, or library to bolt on.
|
||||
- **The same app runs on Node, Deno, Bun, and the edge.** One codebase, one import; you swap the entry point (`app.listen` → `serveDeno` / `serveBun` / `edgeHandler`) and nothing else. HTTP, SSE, and WebSocket — including rooms and channels — behave identically on all four. *Why it matters:* the graph model isn't a bet on one runtime's future, and no other opinionated/DI framework runs everywhere.
|
||||
- **A remote dependency looks like a local one.** `@needs('billing')` resolves the same whether `billing` lives in this process or on another node (mesh, experimental). *Why it matters:* no gRPC layer or message-pattern DSL to learn — there's the graph, and some nodes happen to live elsewhere.
|
||||
- **Plugins can't sabotage you.** A plugin gets `bus.on(...)` (observe), `scope.add(...)` (extend its own scope) and `onShutdown(...)` (release what it opened). There is no API to reorder or delete another scope's steps. *Why it matters:* installing a plugin can't break your body parser.
|
||||
- **Plugins can't sabotage you.** A plugin is `{ name, mount(api) }`. It gets `bus.on(...)` (observe), `scope.add(...)` (extend its own scope) and `onShutdown(...)` (release what it opened). There is no API to reorder or delete another scope's steps. *Why it matters:* installing a plugin can't break your body parser.
|
||||
|
||||
## Who does the work?
|
||||
|
||||
@@ -288,7 +288,7 @@ green-tea is **beta**, on the road to a release candidate. Express and Fastify h
|
||||
|
||||
**What a teapot exports: steps and routes, and nothing else.** A `@Provider` marked `export: true` fails the boot with an error that says why — a provider's value *is* the object it builds, a pool or a client or a `db`, and the mesh moves data, not objects. Export a `@Step` instead: it runs on the teapot, per request, and its result is what comes back. That is also what lets a teacup boot without its teapot: a remote step holds nothing between requests, so a teacup whose teapot never answers still starts once the `bootTimeoutMs` grace runs out — it warns and carries on. Be precise about what that means, because it is narrower than it sounds. A teapot that never connected sent no manifest, so nothing of it reached the graph: its routes **404** rather than `503`, since nothing was registered to match, and a local step that `@needs` one of its tokens **still fails the boot**, naming the teapot that did not connect. That failure is deliberate — it is the check that catches a typo in a token name, which no amount of waiting will fix. `503` is what you get from a teapot that connected and *later* died, where the link and its exports do exist. So what the change buys is the teacup that does *not* depend on that teapot starting anyway, rather than refusing over a dependency it never had. Keeping a *needed* token serving while its teapot is legitimately away is a known gap, not an oversight: the intended answer is the `expects` list in [the mesh degrade plan](./docs/plans/2026-08-18-mesh-degrade-plan.md), which is planned and not built.
|
||||
|
||||
**What is settled, and what is still moving.** Present state, not a roadmap and not the API freeze — this is spare-time work by one person, and a schedule it cannot keep would cost more than it earns. The **graph is the settled part**: `needs`/`provides`, the order derived from them, and the boot-time failure when nothing provides a key have not changed since the beta hardening on 7 July, and `@Provider`, `@Step`, `@Route` and handler shapes still mean what they meant then — the decorator *set* has grown (`@Head`, `@Options`, `@Html`), which only ever adds. **Still moving:** the plugin API, which gained `onShutdown` this week; `createApp`'s options, which gain fields most months; and the pipeline context, which in July became one object mutated in place rather than copied per step — so a step that captured it now sees later steps' writes. **Alpha:** mesh, above. Legacy decorators are a standing *external* risk rather than a green-tea one — see [Why legacy decorators](#why-legacy-decorators). The [matcha](https://github.com/Expressive-Tea/matcha) CLI ships from its own repository on its own version line, so nothing here speaks for it.
|
||||
**What is settled, and what is still moving.** Present state, not a roadmap and not the API freeze — this is spare-time work by one person, and a schedule it cannot keep would cost more than it earns. The **graph is the settled part**: `needs`/`provides`, the order derived from them, and the boot-time failure when nothing provides a key have not changed since the beta hardening on 7 July, and `@Provider`, `@Step`, `@Route` and handler shapes still mean what they meant then — the decorator *set* has grown (`@Head`, `@Options`, `@Html`), which only ever adds. **Still moving:** the plugin API, which became `{ name, mount }` and gained `onShutdown`; `createApp`'s options, which gain fields most months; and the pipeline context, which in July became one object mutated in place rather than copied per step — so a step that captured it now sees later steps' writes. **Alpha:** mesh, above. Legacy decorators are a standing *external* risk rather than a green-tea one — see [Why legacy decorators](#why-legacy-decorators). The [matcha](https://github.com/Expressive-Tea/matcha) CLI ships from its own repository on its own version line, so nothing here speaks for it.
|
||||
|
||||
## Docs & development
|
||||
|
||||
|
||||
Reference in new issue
Block a user