3 Commits
Author SHA1 Message Date
chrnx f494fc283d docs(changelog): say how to migrate off the two new boot failures (CARD-22)
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 19s
CI / build (pull_request) Successful in 29s
CI / runtimes (edge) (pull_request) Successful in 18s
CI / runtimes (deno) (pull_request) Successful in 32s
Two Breaking entries in [Unreleased] described a new boot failure
without the step that fixes it. Found in the second pre-freeze review.

- #127, constrained route params that tie: make the constraints
  disjoint, keep one route and branch in the handler, or give one its
  own static segment. A plain param reported unreachable never served a
  request, so delete it or narrow the constraint that shadows it. For a
  WebSocket pair, declare the constrained route first.
- #126, reserved `/__mesh__/control`: move the route to another path.
  Nothing replaces the reserved one, which never reached a route on
  Deno, Bun or the edge.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-24 14:50:05 -05:00
chrnx 9de0027ddc Merge pull request 'feat: name every type the public signatures use, before the freeze (CARD-22, D19)' (#158) from feat/d19-public-surface into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 21s
CI / build (push) Successful in 29s
CI / runtimes (edge) (push) Successful in 19s
Promote → GitHub / push-github (push) Successful in 5s
CI / runtimes (deno) (push) Successful in 33s
2026-10-24 19:50:01 +00:00
chrnx 92d54dcc45 feat: name every type the public signatures use, before the freeze (CARD-22, D19)
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 20s
CI / build (pull_request) Successful in 29s
CI / runtimes (edge) (pull_request) Successful in 19s
CI / runtimes (deno) (pull_request) Successful in 32s
D19 as amended 2026-10-24: nothing that shipped in 26.9.0-beta.2 is
removed. Every symbol D19 had listed for removal or review is in that
release, so this change only adds exports and marks scope.

- Export `AppOptions`, `ExplainNode`, `WsRequest` and `WsSocket`. Each
  appears in a public signature (`createApp`, `Explain.chain`,
  `app.upgrade`) but could not be imported. `AppOptions` is the former
  inline options type of `createApp`, moved verbatim into an interface.
- Add `RequestHeaders`. `Headers` shadows the Fetch global wherever it
  is imported, so it stays only as a `@deprecated` alias of the same type.
- Mark the mesh exports and `MeshConfig` `@experimental`. They stay
  exported and unchanged, but sit outside the freeze, like the
  `experimental: true` flag the mesh already needs.
- The seven review candidates (`withConsoleFallback`, `UNMATCHED_ROUTE`,
  `HTTP_ERROR`, `VALIDATION_ERROR`, `TransportMismatchError`,
  `isAsyncIterable`, `buildOpenApi`) stay as they are.

CHANGELOG: `### Added` for the types, `### Changed` for the mesh tag, and
a new `### Deprecated` for `Headers`. No `### Breaking`.

test/types/public-surface.test.ts fails to compile if any of the new
names stops being exported. `deno publish --dry-run` passes.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-24 14:48:26 -05:00
10 changed files with 122 additions and 16 deletions

No files matched your search

+27
View File
@@ -59,6 +59,13 @@ npm treats versions as semver and semver forbids leading zeros.
against each other. A local route against a remote one keeps the deliberate local override and against each other. A local route against a remote one keeps the deliberate local override and
its warning. its warning.
To fix a pair that now fails, make the router's choice explicit. Make the two constraints
disjoint (`\d{1,3}` and `\d{4,}`), keep one route and branch inside its handler, or move one
under a static segment of its own (`/u/:id(\d+)` and `/u/short/:n(\d{1,3})`). A plain param
reported as unreachable never answered a request: delete it, or narrow the constraint that
shadows it so some segments are left over. For a WebSocket pair, declare the constrained route
first.
The check is exact. The safe subset makes every constraint a sequence of (character set, min, The check is exact. The safe subset makes every constraint a sequence of (character set, min,
max) blocks, and the check walks the product of two such sequences. It costs max) blocks, and the check walks the product of two such sequences. It costs
O(|A|·|B|·(|A|+|B|)·K) per pair, with K ≤ 2048. Measured at under 0.1 ms for `\d{0,2048}` O(|A|·|B|·(|A|+|B|)·K) per pair, with K ≤ 2048. Measured at under 0.1 ms for `\d{0,2048}`
@@ -92,6 +99,8 @@ npm treats versions as semver and semver forbids leading zeros.
always refused it, so the same route worked on one runtime and not the others. A pattern whose always refused it, so the same route worked on one runtime and not the others. A pattern whose
first segment is not the literal `__mesh__` (`/:org/:repo`, `/:rest*`) still boots; the reserved first segment is not the literal `__mesh__` (`/:org/:repo`, `/:rest*`) still boots; the reserved
path is answered ahead of the route table on every runtime, so such a route never sees it. path is answered ahead of the route table on every runtime, so such a route never sees it.
To migrate, move the route to another path, for example `/mesh/control`. Nothing replaces
`/__mesh__/control` itself: it never reached the route on Deno, Bun or the edge.
An upgrade to `/__mesh__/control` on an app with no control channel is now refused identically An upgrade to `/__mesh__/control` on an app with no control channel is now refused identically
everywhere: the Node listener accepts it and closes `1008` with everywhere: the Node listener accepts it and closes `1008` with
@@ -182,8 +191,20 @@ npm treats versions as semver and semver forbids leading zeros.
high-water mark, or the socket has closed, and at once when it already is. The built-in adapters high-water mark, or the socket has closed, and at once when it already is. The built-in adapters
all provide it. A socket built without it is never waited on, as before. all provide it. A socket built without it is never waited on, as before.
- **Types you could see but not name are now exported** (D19): `AppOptions` (the options object of
`createApp`, until now an inline type, so `const opts: AppOptions = …` works), `ExplainNode`
(one entry of `Explain.chain`), and `WsRequest` / `WsSocket` (the arguments of `app.upgrade`).
- **`RequestHeaders`** (D19): the type of the incoming request headers, under a name that does not
shadow the Fetch `Headers` global. `Headers` remains as a deprecated alias.
### Changed ### Changed
- **The mesh's exports are marked `@experimental`** (D19): `connectLink`, `buildRemote`,
`envelopeFrom`, `buildManifest`, `createMeshControl`, `MESH_CONTROL_PATH`, `Manifest`,
`RequestEnvelope`, `Frame` and `MeshConfig`. They stay exported, unchanged. The mesh already needs
`createApp({ experimental: true })`; the tag says the same thing in the types: these are outside
the API freeze and may change in a minor release.
- **Every `304` is bodiless** (#114). A `304` has no body and no `content-*` headers on any adapter, - **Every `304` is bodiless** (#114). A `304` has no body and no `content-*` headers on any adapter,
including one from `throw new NotModified()`, which used to go out with the default JSON including one from `throw new NotModified()`, which used to go out with the default JSON
envelope's `content-type`. envelope's `content-type`.
@@ -231,6 +252,12 @@ npm treats versions as semver and semver forbids leading zeros.
introspection routes (`devGraph`, `devOpenapi`) now sit before remote routes in that table, so 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. in the one case where a teapot exports the same path at the same specificity, the dev route wins.
### Deprecated
- **The `Headers` type** (D19). Import `RequestHeaders` instead: same type, a name that does not
shadow the Fetch `Headers` global in the files that import it. `Headers` stays as an alias, so
nothing breaks.
### Fixed ### Fixed
- **`listen()` rejects when the port is taken** (#138). A bind failure such as `EADDRINUSE` or - **`listen()` rejects when the port is taken** (#138). A bind failure such as `EADDRINUSE` or
+10 -7
View File
@@ -114,12 +114,8 @@ interface PipelineDeps {
logger: Logger; logger: Logger;
} }
/** /** Options for {@link createApp}. */
* Build an {@link App} from the given modules and options. export interface AppOptions {
* Wires providers, steps, controllers and plugins into a dependency graph; for non-mesh apps
* the graph is finalized eagerly, otherwise finalization is deferred to {@link App.listen}.
*/
export function createApp(opts: {
modules: Ctor[]; modules: Ctor[];
plugins?: Plugin[]; plugins?: Plugin[];
/** /**
@@ -278,7 +274,14 @@ export function createApp(opts: {
* 20+ steps on one route usually means a step is doing too much. * 20+ steps on one route usually means a step is doing too much.
*/ */
warnGraphDepth?: number | false; warnGraphDepth?: number | false;
}): App { }
/**
* Build an {@link App} from the given modules and options.
* Wires providers, steps, controllers and plugins into a dependency graph; for non-mesh apps
* the graph is finalized eagerly, otherwise finalization is deferred to {@link App.listen}.
*/
export function createApp(opts: AppOptions): App {
// mesh is alpha: its API and wire protocol may change. Require an explicit opt-in. // mesh is alpha: its API and wire protocol may change. Require an explicit opt-in.
if (opts.mesh && !opts.experimental) { if (opts.mesh && !opts.experimental) {
throw new Error( throw new Error(
+6 -1
View File
@@ -125,7 +125,12 @@ export interface RoutePlan {
args: ArgSpec[]; args: ArgSpec[];
} }
/** Mesh networking options: a secret to gate this node's exports and/or remote teapots to connect to. */ /**
* Mesh networking options: a secret to gate this node's exports and/or remote teapots to connect to.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/
export interface MeshConfig { export interface MeshConfig {
secret?: string; secret?: string;
teapots?: Array<{ url: string; secret: string }>; teapots?: Array<{ url: string; secret: string }>;
+4 -3
View File
@@ -18,7 +18,7 @@ export const VERSION = '26.9.0-beta.2';
// Application // Application
export { createApp } from './app'; export { createApp } from './app';
export type { App, InspectLine, Explain, MeshConfig } from './app'; export type { App, AppOptions, InspectLine, Explain, ExplainNode, MeshConfig } from './app';
// Graph visualization // Graph visualization
export { toMermaid, toDOT } from './graph-viz'; export { toMermaid, toDOT } from './graph-viz';
@@ -79,7 +79,7 @@ export type { StepFn, CompiledFlow } from './flow';
// Parameter decorators // Parameter decorators
export { needs, ctx, param, query, body, headers, header, cookies, cookie, inbound, abort } from './params'; export { needs, ctx, param, query, body, headers, header, cookies, cookie, inbound, abort } from './params';
export type { Query, Headers, Context, ArgSpec, ArgDecorator } from './params'; export type { Query, RequestHeaders, Headers, Context, ArgSpec, ArgDecorator } from './params';
// Cookies // Cookies
export { setCookie, parseCookies } from './cookies'; export { setCookie, parseCookies } from './cookies';
@@ -98,13 +98,14 @@ export type { StreamEncoder, SseEvent, SseFields } from './encoders';
// HTTP, security & validation // HTTP, security & validation
export type { RequestLimits } from './http'; export type { RequestLimits } from './http';
export type { WsRequest, WsSocket } from './http/ws-core';
export type { CompressionOptions } from './http/compression'; export type { CompressionOptions } from './http/compression';
export { UNMATCHED_ROUTE } from './http/core'; export { UNMATCHED_ROUTE } from './http/core';
export type { TlsOptions, CorsOptions, SecurityOptions } from './security'; export type { TlsOptions, CorsOptions, SecurityOptions } from './security';
export type { UploadedFile, MultipartBody } from './multipart'; export type { UploadedFile, MultipartBody } from './multipart';
export type { StandardSchemaV1 } from './standard-schema'; export type { StandardSchemaV1 } from './standard-schema';
// Mesh // Mesh — experimental (`createApp({ experimental: true })`): outside the API freeze, may change in a minor.
export { connectLink } from './mesh/link'; export { connectLink } from './mesh/link';
export { buildRemote, envelopeFrom } from './mesh/teacup'; export { buildRemote, envelopeFrom } from './mesh/teacup';
export { buildManifest, createMeshControl, MESH_CONTROL_PATH } from './mesh/teapot'; export { buildManifest, createMeshControl, MESH_CONTROL_PATH } from './mesh/teapot';
+3
View File
@@ -459,6 +459,9 @@ function backoffBounds(
* identity — the graph captured `rpc` at boot — and reconnects underneath it. * identity — the graph captured `rpc` at boot — and reconnects underneath it.
* *
* `Ctor` is injectable to exercise both client implementations on a single runtime. * `Ctor` is injectable to exercise both client implementations on a single runtime.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export function connectLink(args: { export function connectLink(args: {
url: string; url: string;
+9
View File
@@ -34,6 +34,9 @@ export const MESH_PROTOCOL_VERSION = 1;
* *
* `correlation` and `url` are optional by protocol, not by intent: a teapot running an older * `correlation` and `url` are optional by protocol, not by intent: a teapot running an older
* green-tea simply ignores them, which costs the correlation of that hop and nothing else. * green-tea simply ignores them, which costs the correlation of that hop and nothing else.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export interface RequestEnvelope { export interface RequestEnvelope {
method: string; method: string;
@@ -63,6 +66,9 @@ export interface RouteEntry {
* Steps only: a provider's value is the object it builds, which cannot cross a JSON wire, so * Steps only: a provider's value is the object it builds, which cannot cross a JSON wire, so
* exporting one is refused at boot (`collectProviders`). Every entry here is request-scope and * exporting one is refused at boot (`collectProviders`). Every entry here is request-scope and
* lazy — the token exists in the teacup's graph, and running it is an RPC. * lazy — the token exists in the teacup's graph, and running it is an RPC.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export interface Manifest { export interface Manifest {
steps: string[]; steps: string[];
@@ -75,6 +81,9 @@ export interface Manifest {
* `ping`/`pong` are application frames rather than WebSocket protocol pings on purpose: the `ws` * `ping`/`pong` are application frames rather than WebSocket protocol pings on purpose: the `ws`
* package exposes `ws.ping()`, but the platform `WebSocket` that Deno and Bun provide does not, * package exposes `ws.ping()`, but the platform `WebSocket` that Deno and Bun provide does not,
* so a protocol-level heartbeat could not work on every runtime mesh claims to support. * so a protocol-level heartbeat could not work on every runtime mesh claims to support.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export type Frame = export type Frame =
| { type: 'hello'; v: number; secret: string } | { type: 'hello'; v: number; secret: string }
+9 -1
View File
@@ -20,6 +20,9 @@ export interface RemoteRoute {
* `url` and `correlation` are read off `ctx.req`, the handler argument the pipeline seeds the * `url` and `correlation` are read off `ctx.req`, the handler argument the pipeline seeds the
* context with — so a request that crosses to a teapot arrives carrying the id it already had, * context with — so a request that crosses to a teapot arrives carrying the id it already had,
* and its events on the far side join the same trace instead of starting a new one. * and its events on the far side join the same trace instead of starting a new one.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export function envelopeFrom(ctx: any): RequestEnvelope { export function envelopeFrom(ctx: any): RequestEnvelope {
const req = ctx?.req; const req = ctx?.req;
@@ -37,7 +40,12 @@ export function envelopeFrom(ctx: any): RequestEnvelope {
}; };
} }
/** Turn a link's manifest into local proxy nodes: lazy request-scope steps, and routes. */ /**
* Turn a link's manifest into local proxy nodes: lazy request-scope steps, and routes.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/
export function buildRemote(link: Link): { steps: RemoteScopeNode[]; routes: RemoteRoute[] } { export function buildRemote(link: Link): { steps: RemoteScopeNode[]; routes: RemoteRoute[] } {
const steps: RemoteScopeNode[] = link.manifest.steps.map((token) => ({ const steps: RemoteScopeNode[] = link.manifest.steps.map((token) => ({
name: token, name: token,
+15 -2
View File
@@ -22,6 +22,9 @@ import {
* *
* Reserved in every app, mesh or not (D17): `createApp` refuses a route that claims it, and an upgrade * Reserved in every app, mesh or not (D17): `createApp` refuses a route that claims it, and an upgrade
* to it on an app without a control channel closes `1008` on every adapter. * to it on an app without a control channel closes `1008` on every adapter.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/ */
export const MESH_CONTROL_PATH = '/__mesh__/control'; export const MESH_CONTROL_PATH = '/__mesh__/control';
@@ -70,7 +73,12 @@ export function controlFrameLimit(maxBodyBytes = DEFAULT_MAX_BODY_BYTES): number
return WORST_ESCAPE * maxBodyBytes + ENVELOPE_HEADROOM; return WORST_ESCAPE * maxBodyBytes + ENVELOPE_HEADROOM;
} }
/** Assemble a {@link Manifest} from exported step tokens and buffered routes. */ /**
* Assemble a {@link Manifest} from exported step tokens and buffered routes.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/
export function buildManifest(args: { steps: string[]; routes: RouteEntry[] }): Manifest { export function buildManifest(args: { steps: string[]; routes: RouteEntry[] }): Manifest {
return { steps: [...args.steps], routes: args.routes }; return { steps: [...args.steps], routes: args.routes };
} }
@@ -275,7 +283,12 @@ async function serveFrames(
} }
} }
/** Build a control handler that authenticates peers and serves scope/route RPCs from the manifest. */ /**
* Build a control handler that authenticates peers and serves scope/route RPCs from the manifest.
*
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
* API freeze, so it may change in a minor release.
*/
export function createMeshControl(deps: MeshControlDeps): { export function createMeshControl(deps: MeshControlDeps): {
path: string; path: string;
maxFrameBytes: number; maxFrameBytes: number;
+7 -2
View File
@@ -7,7 +7,12 @@ import { parseCookies } from './cookies';
/** Parsed URL query string as flat key/value pairs. */ /** Parsed URL query string as flat key/value pairs. */
export type Query = Record<string, string>; export type Query = Record<string, string>;
/** Incoming request headers; a header may repeat, hence the array variant. */ /** Incoming request headers; a header may repeat, hence the array variant. */
export type Headers = Record<string, string | string[] | undefined>; export type RequestHeaders = Record<string, string | string[] | undefined>;
/**
* @deprecated Use {@link RequestHeaders}. This name shadows the Fetch `Headers` global in any file
* that imports it; it stays as an alias so existing imports keep compiling.
*/
export type Headers = RequestHeaders;
/** Per-request bag that accumulates values produced by steps and providers. */ /** Per-request bag that accumulates values produced by steps and providers. */
export type Context = Record<string, unknown>; export type Context = Record<string, unknown>;
@@ -160,7 +165,7 @@ function resolveOne(spec: ArgSpec, context: Context): unknown {
*/ */
function cookiesOf(context: Context): unknown { function cookiesOf(context: Context): unknown {
if (context.cookies === undefined) { if (context.cookies === undefined) {
const headers = context.headers as Headers | undefined; const headers = context.headers as RequestHeaders | undefined;
context.cookies = parseCookies(headers?.cookie); context.cookies = parseCookies(headers?.cookie);
} }
+32
View File
@@ -0,0 +1,32 @@
// The types D19 added to the barrel (CARD-22): each one appears in a public signature, so a user
// must be able to name it. This file's job is to fail to compile if one stops being exported.
import { test, expect } from 'vitest';
import {
createApp,
type App,
type AppOptions,
type ExplainNode,
type RequestHeaders,
type Headers,
type WsRequest,
type WsSocket,
} from '../../src';
// Options built apart from the call, the thing an inline type made impossible to annotate.
const options: AppOptions = { modules: [] };
// `app.upgrade(req, socket)`, wrapped by an adapter that has to declare what it passes.
const upgrade = (app: App, req: WsRequest, socket: WsSocket) => app.upgrade(req, socket);
const firstNeeds = (node: ExplainNode): string[] => node.needs;
// The deprecated alias is the same type, so existing imports keep compiling.
const headers: RequestHeaders = { 'x-a': 'b' };
const legacy: Headers = headers;
test('the D19 additions are typeable from the package barrel', () => {
expect(typeof createApp(options).fetch).toBe('function');
expect(typeof upgrade).toBe('function');
expect(firstNeeds({ name: 'n', kind: 'step', origin: 'o', needs: ['a'], provides: [] })).toEqual(['a']);
expect(legacy).toBe(headers);
});