fix(mesh): reconnect to a teapot that came back, refusing a manifest that no longer fits #47

Merged
chrnx merged 1 commits from feat/mesh-reconnect into develop 2026-08-18 16:04:56 +00:00
Owner

Closes the gap that made mesh unusable in production: a dropped link stayed dead for the life of the process, so deploying a teapot forced a restart of every teacup and boot order became load-bearing.

  • Link outlives any single socket — the graph captured its rpc closure at boot, so a reconnect producing a new Link would leave the graph pointing at the dead one.
  • Backoff doubles 500ms → 30s with full jitter. mesh: { reconnect: false } restores the old behaviour.
  • A returning manifest that no longer exports what the graph was validated against is refused, as a named policy (onManifestChange: 'refuse') so a future 'reconcile' is additive.
  • close() is terminal, so app.close() cannot leave a process that refuses to exit.
  • Closes the documented stale-app-scope-value gap: a successful reconnect re-registers those bindings.

Mesh stays alpha. Plan: docs/plans/2026-08-18-mesh-reconnect-plan.md.

425 vitest / 11 Deno / 7 Bun / edge / JSR dry run. 7 of the 9 new Node tests verified to fail against the old code; the 2 that pass are the ones that should, since the old code never reconnected.

Closes the gap that made mesh unusable in production: a dropped link stayed dead for the life of the process, so deploying a teapot forced a restart of every teacup and boot order became load-bearing. - `Link` outlives any single socket — the graph captured its `rpc` closure at boot, so a reconnect producing a new `Link` would leave the graph pointing at the dead one. - Backoff doubles 500ms → 30s with full jitter. `mesh: { reconnect: false }` restores the old behaviour. - A returning manifest that no longer exports what the graph was validated against is **refused**, as a named policy (`onManifestChange: 'refuse'`) so a future `'reconcile'` is additive. - `close()` is terminal, so `app.close()` cannot leave a process that refuses to exit. - Closes the documented stale-app-scope-value gap: a successful reconnect re-registers those bindings. Mesh stays **alpha**. Plan: `docs/plans/2026-08-18-mesh-reconnect-plan.md`. 425 vitest / 11 Deno / 7 Bun / edge / JSR dry run. 7 of the 9 new Node tests verified to fail against the old code; the 2 that pass are the ones that should, since the old code never reconnected.
chrnx added 1 commit 2026-08-18 16:00:17 +00:00
fix(mesh): reconnect to a teapot that came back, refusing a manifest that no longer fits
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 18s
6ffbad9825
A dropped link stayed dead for the life of the process. Every RPC answered
503 until the teacup restarted, so deploying a teapot forced a restart of
every teacup depending on it and boot order became load-bearing — a worse
operational property than any gap the docs actually listed.

The Link now outlives any single socket, because the graph captured its rpc
closure at boot and a reconnect that produced a new Link would leave the graph
pointing at the dead one. Backoff doubles from 500ms to 30s with full jitter,
so teacups that went down together do not return in lockstep.

A returning teapot whose manifest no longer exports what the graph was
validated against is refused, not adopted: that graph is already serving, and
a token cannot be validated away after the fact. The link keeps retrying,
since a partial deploy may still restore it, and logs once per distinct
manifest rather than once per attempt. Refusal ships as a named policy
(onManifestChange: 'refuse') so hot reconciliation can arrive later as an
addition rather than as a change of what the default means — these are
separate processes on separate deploy cadences.

close() is terminal. closeLinks runs on shutdown, and a link that reconnected
after the application hung up would leave a process that cannot exit.

Also closes the documented gap where an app-scope export outlived its teapot
with a stale value: a successful reconnect re-registers those bindings, so the
next resolve re-runs the RPC. That invalidation is a named function rather
than inline, because it is the seam a future 'reconcile' reuses.

Tested on all three runtimes rather than on Node alone — Node's ws package,
Deno's global WebSocket and Bun's server-level socket handler are three
implementations, and swapping a socket under a live graph is where they stop
agreeing. 7 of the 9 new Node tests were verified to fail against the old
code; the 2 that pass are the ones that should, since the old code never
reconnected at all.

Mesh stays alpha.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx merged commit 1ccbf6cadf into develop 2026-08-18 16:04:56 +00:00
Sign in to join this conversation.