Skip to main content

How evaluation works

Flag evaluation never hits the management API database on the hot path. Instead:
  1. SDK initialisation — the SDK fetches the full flag bundle for your environment from the Delivery API. The bundle is a JSON snapshot of all flag configs, served from an edge cache and held in-process for 30 seconds.
  2. evaluate() call — the rule engine runs entirely in your process against the cached bundle. No network I/O.
  3. Telemetry flush — evaluation events are buffered in memory and flushed to the Management API asynchronously. Your application never waits for telemetry.

Evaluation reasons

Every evaluation returns a reason alongside the resolved value: The engine never throws. Any unhandled error results in { reason: "ERROR", value: defaultValue }.

Evaluation context

Pass any attributes you want to target on:
Attributes are matched against rule conditions. Unknown attributes are ignored.

Bundle format

The cache key for an environment’s flag bundle is:
The bundle is a JSON object mapping flag keys to their latest FlagConfig. The Delivery API reads this key on cold start, then serves from an in-process cache for subsequent requests within the same worker lifetime.

Cold start path

On a cold start, the Delivery API performs at most 2 cache reads:
  1. sdk:{keyHash} — resolve the API key to orgId + environmentId
  2. env:{environmentId}:flags — fetch the flag bundle
Subsequent evaluations in the same worker instance use the in-memory cache.