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 }.
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 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>
This commit is contained in:
13 files changed
+1086
-177
No files matched your search
@@ -81,6 +81,31 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
param hit −88%, method miss −94%, path miss −96%; at 10 routes, every cell is within noise or
|
||||
faster (late param hit +3.4%, 95% CI −5.0…+12.6%).
|
||||
|
||||
- **Mesh (alpha): a teacup's remote routes follow which teapots are connected** (#124, D15). The
|
||||
route table used to be built once at boot: a teapot that started late was never served, and a
|
||||
teapot that was gone for good stayed advertised. Now:
|
||||
|
||||
- A teapot that missed `bootTimeoutMs` is retried in the background with the `reconnect` backoff.
|
||||
When it connects, its routes are served, with no restart. Its steps are not added, because the
|
||||
graph was validated at boot without them. With `reconnect: false` it is not retried.
|
||||
- While a link is reconnecting, its routes stay and answer `503`, now with `retry-after` (the
|
||||
seconds until the next attempt). `Allow` keeps them.
|
||||
- A link that gives up for good has its routes removed: they answer `404` and leave `Allow`. That
|
||||
is a link dropped with `reconnect: false`, or one refused permanently (a wrong secret, a protocol
|
||||
mismatch) while reconnecting. A refused reconnect used to retry forever. It now stops.
|
||||
- A returning teapot's routes replace its old ones: a route it added is served, one it dropped
|
||||
answers `404`. A returning manifest is still refused for a missing **step**
|
||||
(`onManifestChange: 'refuse'`), but no longer for a missing route.
|
||||
- A late route that conflicts with another teapot's (same shape, or a CARD-13 sibling conflict)
|
||||
is refused and logged, and the rest keep serving. At boot the same conflict still fails boot.
|
||||
- Every change emits `mesh:routes` with `{ url, added, removed }` (new `EventPayload` fields).
|
||||
|
||||
Membership changes publish a new table. A request in flight routes against the old one or the
|
||||
new one, never a mix. Only the remote route trees are rebuilt. `listen()` now reads the same
|
||||
table as `app.fetch`, and `createHttpServer` accepts a getter as well as an array. Dev
|
||||
introspection routes (`devGraph`, `devOpenapi`) now sit before remote routes in that table, so
|
||||
in the one case where a teapot exports the same path at the same specificity, the dev route wins.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Mesh (alpha): `HEAD` on a remote `GET` route now works** (#125). The teacup resolved `HEAD` to
|
||||
|
||||
Reference in new issue
Block a user