Skip to content

The function stability promise

An operator may end up with hundreds of functions. Two things must never force a change to their source: an ordinary release of the platform, an SDK or a runner, and a change of the engine that runs them. This page says what is promised so that both hold, and how a change is made without breaking it.

The rule that makes the promise possible: function source depends only on the SDK’s public API, and the SDK depends only on the ABI, the describe document and the JavaScript environment, which change only by addition. Everything under that line belongs to the runner and may change in any release.

flowchart TB
  src["Your function source"] --> sdk["1. SDK public API<br/>(fn-go, @flowcatalyst/fn, flowcatalyst-fn, Java function API)"]
  sdk --> desc["2. Describe document"]
  sdk --> abi["3. ABI v1 (WebAssembly)"]
  sdk --> js["4. JavaScript environment"]
  desc --> sem["5. Platform-facing behaviour<br/>auth, signing, caller, declarations, outcomes, limits"]
  abi --> sem
  js --> sem
  sem -.-> run["6. Runner-defined: not promised<br/>engine, memory accounting, scheduling, CPU"]

The public API of a function SDK is what its README and the functions guide name: the declaration calls, the handler signature, the request, caller and principal types, the response helpers, the capability calls and the error types. Anything else (internal files, generated glue, the shape of the built bundle, test seams) can change in any release. Function source must never reach for it.

The function SDKs are all pre-1.0 today, so semantic versioning does not yet carry the promise on its own; the contract does.

The describe document is what the SDK writes into the artifact: abi (always 1), endpoints, subscriptions, schedules, config, secrets, db, httpAllow, emits, dispatches, traceContexts, platformToken, and jvm for a Java function.

  • A key, once released, keeps its meaning. New keys are only ever added.
  • The platform at publish, the platform at promote and the runner at load all parse it strictly: a key they do not know is refused, never ignored.
  • Because of that, a new key reaches you in a fixed order: the platform and the runners are released first, the SDK that writes the key second. An SDK never emits a key an up-to-date platform would refuse.

ABI v1 is the binary contract between a WebAssembly module and the runner. Its exports (memory, the marker fc_abi_v1, fc_alloc, fc_handle, fc_describe, an optional _initialize), its two imports (fc.call, fc.take), its frame format and the allowed import modules (fc and wasi_snapshot_preview1) are frozen. A module built for ABI v1 loads and runs on every runner that claims the wasm runtime, byte for byte unchanged.

Host operations are numbered (log is 1, config.get 2, up to platform.token at 15). A number, its request and its result never change. A new operation takes the next number, and a runner that predates it answers UNKNOWN_OP, which the SDKs handle (the trace operations, for example, then simply report “not tracing”). Error codes (NOT_DECLARED, NOT_ALLOWED, DEADLINE, TOO_LARGE, UNAVAILABLE and the rest) are frozen strings; only UNAVAILABLE is retryable, and a capability failure is returned as an error, never a crash. Readers on both sides ignore fields they do not know in a frame, so adding a field is safe.

A module that does not satisfy the ABI is refused at load with a LOAD: code (ABI_UNKNOWN, EXPORT_MISSING, IMPORT_NOT_ALLOWED and so on), never half-run.

A TypeScript function is bundled as one script and runs in QuickJS. What it can rely on is the intersection of what any JavaScript runner provides, not what one engine happens to offer:

Facility Status
The ECMAScript language and library up to ES2020 (Map, Set, Promise, async/await, typed arrays, BigInt, JSON, Date, RegExp) Provided
console.log, info, warn, error, debug (routed to the function log) Provided
The SDK’s own calls: fn.fetch, fn.emit, fn.dispatch, fn.log, config, secrets and databases Provided
A handler that returns a promise, and await on SDK calls Provided
Intl, locale formatting, library features after ES2020 Best effort: do not rely on them
Global fetch, URL, TextEncoder, crypto, timers, Buffer, process, Node built-ins Not provided: use the SDK’s calls, and bundle pure-JavaScript libraries

A V8-based runner, when one exists, will offer more. Code that uses the extras would run there and break on QuickJS, so the promise is the smaller set.

These hold on every runner, for every runtime:

  • Addresses and calls. The address is {application}.{name} and never changes. A runner serves /fn/{address}[@alias|@vN]/{path}. No match is 404; a wrong method is 405; a version still loading is 503 with Retry-After; a busy function is 429 with Retry-After: 1; a call past its deadline is 504; a body over the limit is 413; a failing function is 500, with the detail in the log only. Calling an explicit version (@vN) needs platform:function:version:invoke.
  • Webhook verification. A webhook endpoint is POST only, and the signature and timestamp (300 seconds) are checked before the function runs. It verifies with one service account’s secret: the function’s own if set, otherwise the application’s. An inactive account refuses every delivery rather than falling back.
  • The caller. One of webhook, anonymous or principal. A principal carries id, type, tier, clients, clientCodes, roles, applications, allApplications and permissions (the access token’s scope). Only API access tokens are accepted, and the Authorization header is removed before the function sees the request.
  • Declarations. Only declared config keys, secrets, databases, hosts, event types and dispatch targets are reachable. Promotion is refused while a declared value is missing.
  • Delivery outcomes. 2xx delivered; 429 with Retry-After retried without spending an attempt; 422 with FlowCatalyst-Outcome: reject final; anything else a failed attempt.
  • Portable limits. The timeout (passed into every database, HTTP and emit call), the request body limit and the concurrency limit behave the same on every runner. An endpoint may lower the function’s timeout and body limit, never raise them.

Which engine runs the function, how memory is accounted for (the memory limit is “an upper bound you ask for”, enforced differently by different engines), CPU share, instruction counting, how instances are reused (today they are recycled after 10,000 calls, trimmed when idle and discarded after a failure) and the runner’s control protocol. Function source must not depend on any of them.

  1. Additive first. A new capability arrives as something new beside the old: a new operation number, a new describe key, a new SDK call.
  2. Platform and runners before SDKs. The SDK that uses a new key or operation is released only after the platform and the runners accept it.
  3. The same contract on every engine. A new engine is an implementation detail of a runner and must run existing artifacts unchanged. It never requires a source change.
  4. Rollback is an alias change. The version an alias points at is never pruned, so going back is always possible.
  5. Rebuilding in bulk uses the ordinary tools: fcdev fn deploy --skip-unchanged publishes and promotes only a function whose artifact changed, and --no-promote stages a version to check first.
  • Import only the SDK’s public API, and declare everything through the SDK; never write a describe document by hand.
  • Do not depend on timing, memory headroom, CPU share or instance reuse.
  • Be idempotent: deliveries are at least once, emit needs a deduplication id derived from what you are handling, and dispatch is not deduplicated.
  • In TypeScript, stay inside the provided set above, and check a library for URL, TextEncoder, crypto and timers before adopting it.
  • Treat the deadline as the budget, and never log secrets or SQL parameters.