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 layers
Section titled “The layers”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"]
1. The SDK’s public API
Section titled “1. The SDK’s public API”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.
2. The describe document
Section titled “2. The describe document”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.
3. ABI v1
Section titled “3. ABI v1”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.
4. The JavaScript environment today
Section titled “4. The JavaScript environment today”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.
5. Platform-facing behaviour
Section titled “5. Platform-facing behaviour”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 is404; a wrong method is405; a version still loading is503withRetry-After; a busy function is429withRetry-After: 1; a call past its deadline is504; a body over the limit is413; a failing function is500, with the detail in the log only. Calling an explicit version (@vN) needsplatform:function:version:invoke. - Webhook verification. A
webhookendpoint isPOSTonly, 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,anonymousorprincipal. A principal carriesid,type,tier,clients,clientCodes,roles,applications,allApplicationsandpermissions(the access token’sscope). Only API access tokens are accepted, and theAuthorizationheader 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.
2xxdelivered;429withRetry-Afterretried without spending an attempt;422withFlowCatalyst-Outcome: rejectfinal; 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.
6. Not promised
Section titled “6. Not promised”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.
How changes are made
Section titled “How changes are made”- Additive first. A new capability arrives as something new beside the old: a new operation number, a new describe key, a new SDK call.
- 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.
- 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.
- Rollback is an alias change. The version an alias points at is never pruned, so going back is always possible.
- Rebuilding in bulk uses the ordinary tools:
fcdev fn deploy --skip-unchangedpublishes and promotes only a function whose artifact changed, and--no-promotestages a version to check first.
Writing functions that keep working
Section titled “Writing functions that keep working”- 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,
emitneeds a deduplication id derived from what you are handling, anddispatchis not deduplicated. - In TypeScript, stay inside the provided set above, and check a library for
URL,TextEncoder,cryptoand timers before adopting it. - Treat the deadline as the budget, and never log secrets or SQL parameters.
Read next
Section titled “Read next”- Functions: the model this promise is about.
- Function describe document and ABI: every field and operation.
- Write a function and Publish, promote and use aliases.
- Function SDKs (TypeScript; Go, Rust and Java beside it).
- Decision: one contract, several engines.