mesh: let a teapot declare that it may be absent (expects + degrade) #51

Closed
opened 2026-08-18 17:33:49 +00:00 by chrnx · 1 comment
Owner

A teapot that is unreachable at boot fails the teacup's boot, always. That is the right default — a provider the graph depends on is not optional — but it is not right for every teapot. Billing being away is a degraded checkout; authorization being away is not a degraded anything.

Strictness should be declared per teapot, not per app:

mesh: {
  teapots: [
    { url: billingUrl, secret, expects: ['billing'] },   // may be absent
    { url: authUrl, secret },                            // must be there
  ],
}

Why expects is required and cannot be inferred

A teapot that never answered never sent a manifest, so we do not know what it exported. Without that list there is nothing to put in the graph, @needs('billing') has no producer, and the boot fails anyway — degrading would fail identically, just later.

The tempting shortcut is to placeholder every unresolved token. It must not happen: assertNeedsSatisfiable currently produces

handler 'checkout' needs 'biling' but nothing (local or mesh) provides it

with a nearest-match suggestion, and placeholdering everything would replace that with a runtime 503 far from the typo.

expects also fixes a second problem for free: a developer who reads @needs('billing') and greps the codebase finds nothing today. With expects, the grep lands on the teapot entry — which host it lives on, and under what contract. That is a better answer than splitting the decorator into a remote variant, which would put the origin at every use site and require editing all of them the day the token becomes local.

Design notes

  • Placeholders are request-scope. An app-scope placeholder resolves at boot, and throwing there is the failure being avoided. A request-scope node runs per request and throws 503 naming the token and its teapot.
  • expects names tokens only, never their kind. The manifest carries the scope, so the teapot decides and the teacup obeys.
  • Routes cannot be degraded — a route needs a method and a pattern nobody told us. A request for one 404s, like any unregistered route.
  • Degraded tokens surface through app.degraded(), the API that already reports optional providers that failed to boot, rather than a parallel concept.
  • A degraded link keeps retrying in the background. Reconnection only covers links that handshook at least once; this one never did. Without its own loop, a degraded teapot stays degraded until the process restarts.
  • Open: if the placeholder was registered request-scope and the arriving manifest says the token is app-scope, adopting it changes the kind of node at runtime, not just its runner.

Plan: docs/plans/2026-08-18-mesh-degrade-plan.md.

A teapot that is unreachable at boot fails the teacup's boot, always. That is the right default — a provider the graph depends on is not optional — but it is not right for every teapot. Billing being away is a degraded checkout; authorization being away is not a degraded anything. Strictness should be declared **per teapot**, not per app: ```ts mesh: { teapots: [ { url: billingUrl, secret, expects: ['billing'] }, // may be absent { url: authUrl, secret }, // must be there ], } ``` ## Why `expects` is required and cannot be inferred A teapot that never answered never sent a manifest, so **we do not know what it exported**. Without that list there is nothing to put in the graph, `@needs('billing')` has no producer, and the boot fails anyway — degrading would fail identically, just later. The tempting shortcut is to placeholder every unresolved token. It must not happen: `assertNeedsSatisfiable` currently produces ``` handler 'checkout' needs 'biling' but nothing (local or mesh) provides it ``` with a nearest-match suggestion, and placeholdering everything would replace that with a runtime 503 far from the typo. `expects` also fixes a second problem for free: a developer who reads `@needs('billing')` and greps the codebase finds nothing today. With `expects`, the grep lands on the teapot entry — which host it lives on, and under what contract. That is a better answer than splitting the decorator into a remote variant, which would put the origin at every use site and require editing all of them the day the token becomes local. ## Design notes - **Placeholders are request-scope.** An app-scope placeholder resolves at boot, and throwing there is the failure being avoided. A request-scope node runs per request and throws 503 naming the token and its teapot. - **`expects` names tokens only, never their kind.** The manifest carries the scope, so the teapot decides and the teacup obeys. - **Routes cannot be degraded** — a route needs a method and a pattern nobody told us. A request for one 404s, like any unregistered route. - **Degraded tokens surface through `app.degraded()`**, the API that already reports optional providers that failed to boot, rather than a parallel concept. - **A degraded link keeps retrying in the background.** Reconnection only covers links that handshook at least once; this one never did. Without its own loop, a degraded teapot stays degraded until the process restarts. - **Open:** if the placeholder was registered request-scope and the arriving manifest says the token is app-scope, adopting it changes the *kind* of node at runtime, not just its runner. Plan: `docs/plans/2026-08-18-mesh-degrade-plan.md`.
Author
Owner

Moved to GitHub: https://github.com/Expressive-Tea/green-tea/issues/56. Development now happens there.

Moved to GitHub: https://github.com/Expressive-Tea/green-tea/issues/56. Development now happens there.
chrnx closed this issue 2026-11-18 03:55:54 +00:00
Sign in to join this conversation.