diff --git a/CHANGELOG.md b/CHANGELOG.md index 1edf726..c65bb14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,54 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). green-tea uses calendar versioning: `YY.M.PATCH` — the month is not zero-padded, since npm treats versions as semver and semver forbids leading zeros. +## [Unreleased] + +### Changed + +- **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 + value *is* the object it builds — a pool, a client, a `db` — and an object is not what a JSON wire + carries. What did cross was whatever half of it survived serialization, and it arrived as an + app-scope binding: the teacup resolved it once at boot and then served that value for the life of + the process, out of a cache the teapot no longer stood behind. Restarting the teapot, or changing + what it built, changed nothing on the teacup until the teacup itself restarted. + + Export a `@Step` instead. It runs on the teapot, per request, and only its result comes back — + which is why the two entries below follow from this one: a remote export now holds nothing between + requests. `invalidateRemoteBindings`, the `rebind` array and the `onReconnect` callback that drove + them are gone with it. All three existed to throw away a cached app-scope value when a link came + back; there is no longer a cached value, so a reconnected link is simply usable again on the next + RPC. Internal, so nothing importable changed. + + **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): 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 + container is thirty seconds behind" and "the teapot does not exist" look identical for the first + thirty seconds; exhausting it now warns and starts without that teapot, whose steps and routes + answer `503`. Refusing to start took down the half of the teacup that never needed that teapot at + all, and moved a `503` on some requests into an outage on every one of them. + + Two conditions still fail the boot, both deliberately. A **permanent refusal** — a wrong secret, + a protocol mismatch — is the teapot's decision rather than the network's, and it will be the same + decision in thirty seconds; retrying only spends the deploy's patience to arrive at the identical + error. And a local step that **needs a token nothing provides** still fails, because that check is + what catches a typo in a token name, and a typo does not come good by waiting. That error now + names the teapots that did not connect, and says "local or connected mesh" rather than "local or + mesh" — the old wording claimed a search that had not 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 diff --git a/README.md b/README.md index 9dfcc8e..3fe23b3 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,8 @@ green-tea is **beta**, on the road to a release candidate. Express and Fastify h **mesh is alpha.** Distributed DI works, but discovery, load-balancing, and failover are not built, and its API and wire protocol may change between releases. It is gated behind an explicit opt-in — `createApp({ mesh, experimental: true })` — and `createApp` throws if you configure `mesh` without it. Don't ship mesh to production yet. +**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 makes an absent teapot survivable. A remote step holds nothing between requests, so a teacup whose teapot never answers still boots once the `bootTimeoutMs` grace runs out — it warns, starts without it, and that teapot's steps and routes answer `503` until it arrives. What still fails the boot is a local step that `@needs` a token *nothing* provides, and that is deliberate: it is the check that catches a typo in a token name, which no amount of waiting will fix. The error names the teapots that did not connect, so the two cases read differently. + **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. ## Docs & development diff --git a/docs/plans/2026-08-18-mesh-degrade-plan.md b/docs/plans/2026-08-18-mesh-degrade-plan.md index d38bc85..753d61f 100644 --- a/docs/plans/2026-08-18-mesh-degrade-plan.md +++ b/docs/plans/2026-08-18-mesh-degrade-plan.md @@ -64,6 +64,13 @@ instead of a boot manifest. (`invalidateRemoteBindings`). If that seam turns out not to fit, that is a signal the seam was wrong, not a reason to write a second one. +**Note, 2026-09-06: that seam is gone.** `invalidateRemoteBindings`, the `rebind` array and the +`onReconnect` callback were removed along with the remote app-scope binding when the mesh stopped +exporting providers — with nothing cached between requests, there is nothing left to invalidate. +This does not block D6, and it is not the "seam was wrong" case either: a degraded token swaps the +*runner* behind a step node, which is a graph mutation, not a container rebind. It never needed the +seam. Whatever the swap is written on, it is still one mechanism, decided when the work starts. + ## Tasks 1. `expects` and `onUnreachable` on the teapot entry; `createApp` throws for `'degrade'` without diff --git a/src/app/index.ts b/src/app/index.ts index b359ac2..b19fe52 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -699,7 +699,14 @@ function finalizeGraph( return { orderedProviders, orderedSteps }; } -/** Throws if any route needs a key that nothing (local or mesh) provides, suggesting the nearest match. */ +/** + * Throws if any route needs a key that nothing provides, suggesting the nearest match. + * + * `missingNote` arrives only from a mesh boot, and only when a teapot did not connect. It changes + * what the message can honestly claim: "local or connected mesh" instead of "local or mesh", since + * the exports of an absent teapot were never searched — and it appends which teapots those were, + * which is the actual cause every time it is the cause. + */ function assertNeedsSatisfiable( routePlans: RoutePlan[], providerNodes: GraphNode[], diff --git a/test/bun/mesh.test.ts b/test/bun/mesh.test.ts index a5b2234..d4410ab 100644 --- a/test/bun/mesh.test.ts +++ b/test/bun/mesh.test.ts @@ -1,4 +1,4 @@ -// Real Bun integration test for mesh: a teapot exporting its scopes and a teacup consuming +// Real Bun integration test for mesh: a teapot exporting its steps and a teacup consuming // them, both under the actual Bun runtime, driven entirely through serveBun. // // Bun's ws lifecycle differs from Deno's — its socket events land on a server-level handler diff --git a/test/deno/mesh-interop.test.ts b/test/deno/mesh-interop.test.ts index 47f94ff..423175e 100644 --- a/test/deno/mesh-interop.test.ts +++ b/test/deno/mesh-interop.test.ts @@ -112,7 +112,7 @@ Deno.test('interop: a Deno teacup consumes a Node teapot', async () => { try { const res = await teacup.fetch(new Request('http://x/api/local/who', { headers: { 'x-token': 'abc' } })); assertEquals(res.status, 200); - // the config came from the Node process: proof the scope crossed the runtime boundary + // the config came from the Node process: proof the remote step crossed the runtime boundary assertEquals(await res.json(), { config: { region: 'mx', runtime: 'node' }, auth: { token: 'abc' }, @@ -140,7 +140,7 @@ Deno.test('interop: a Node teacup consumes a Deno teapot', async () => { try { const result = await firstJsonLine(node); assertEquals(result.ok, true); - // the Node peer resolved a scope served by Deno's app.upgrade control channel + // the Node peer ran a step served by Deno's app.upgrade control channel assertEquals(result.body.config, { region: 'mx', runtime: 'deno' }); assertEquals(result.body.auth, { token: 'abc' }); } finally { diff --git a/test/deno/mesh.test.ts b/test/deno/mesh.test.ts index 172f3c8..41d71ec 100644 --- a/test/deno/mesh.test.ts +++ b/test/deno/mesh.test.ts @@ -1,4 +1,4 @@ -// Real Deno integration test for mesh: a teapot exporting its scopes and a teacup consuming +// Real Deno integration test for mesh: a teapot exporting its steps and a teacup consuming // them, both under the actual Deno runtime, driven entirely through serveDeno. // // This is the test that makes "mesh runs off Node" a fact rather than an intention. It covers,