Fail open vs fail closed
Sometimes your code asks for a decision and Ordainer can’t answer: the call times out, the network fails, or our server has an error. You decide in advance what happens then:
| Fail open | Fail closed | |
|---|---|---|
| When Ordainer can’t answer | Run the tool. | Don’t run the tool. |
| Your customers see | Nothing; the tool works. | An error, for as long as the problem lasts. |
| The risk | Calls run unmetered while it lasts. | Our outage becomes your outage. |
| Good for | Most tools: availability matters more than a few unmetered calls. | Tools where an unmetered call is expensive or unsafe. |
This is a client-side setting. The server can’t fail open for you, because when it can’t be reached, it isn’t there to answer. Nothing is written to the audit log for calls made while there was no decision. One exception: if your client times out after we have already decided, that decision is counted and in the audit log, even though your code treated the call as failed open (see Decide → limits).
What fail mode covers
Section titled “What fail mode covers”- A timeout (your client’s timeout; the Node SDK’s default is 300 ms).
- A network error: DNS, connection refused, TLS.
- A server error (
5xx, including500 internal_error). - A 200 whose body isn’t a decision.
What fail mode doesn’t cover
Section titled “What fail mode doesn’t cover”A deny is a decision. quota_exceeded, tool_not_in_plan and test_limit_reached are 200 answers, and fail mode doesn’t apply to them. What to do with a deny is the plan’s mode (see Shadow vs enforce), test_limit_reached included: it blocks in enforce and runs in shadow.
An error answer isn’t an outage. When the API answers with a 4xx, it did answer: the key is wrong or revoked, a live key has no subscription (not possible on test keys), the request is malformed, the idempotency key conflicts, or a rate limit was hit (unknown_key, revoked_key, subscription_required, invalid_request, invalid_json, invalid_idempotency_key, idempotency_conflict, rate_limited, …). Failing open on these would let a broken setup run with no cap at all, so the Node SDK blocks them in every failMode. Retrying doesn’t help (except after Retry-After on rate_limited); fix the cause. There are two exceptions. Your own lapsed subscription (subscription_inactive) follows the separate billing-lapse setting, not failMode (below). And 429 safety_limit_reached (shadow calls past the safety ceiling) is a safety limit, not a deny: SDK 1.2.0 runs the call in every failMode.
In the Node SDK
Section titled “In the Node SDK”failMode: 'open'is the default. When Ordainer can’t answer, the call runs (except during a sticky deny, below), a warning is logged, andresult.failOpenistrue. Warnings are throttled: each kind (fail open, fail closed or rejected, per error code) at most once a minute, with “(N more since the last warning)”. Set the gap withwarningIntervalMs(default 60000). Count failures inonDecision, which sees every call.failMode: 'closed'blocks when Ordainer can’t answer (timeout, network error, 5xx such as503 db_timeout, unreadable answer). The middleware answers your caller503 ordainer_unavailablewithRetry-After: 5(“This call wasn’t run. The service couldn’t finish a safety check it does before each call, so it stopped instead of going ahead without it. Nothing is wrong on your side. Please try again in a minute. (ordainer_unavailable)”), andresult.failClosedistrue. That’s the only time the SDK answers 503.- Set it on the constructor, or per call on
middleware(),wrap()ordecide(). retries(0 to 5, default 1) retries a timeout, a network error or a503(such asdecide_timeout,db_timeoutordb_unavailable) with the same idempotency key, after a short random pause (25 to 75 ms the first time), before falling back tofailMode, so a check that reached us is replayed, not counted twice. Other 5xx and all 4xx are never retried. All attempts shareretryBudgetMs(default 650).- Any 4xx, or no agent key or tool configured, is blocked in every
failMode: your caller getsplan_check_rejectedwith noRetry-After,403for billing (subscription_required) and500for everything else (forunknown_key: “This call wasn’t run. This is a setup issue on the service’s side: one of its keys isn’t recognized. It isn’t something you did, and retrying won’t help until the service fixes the key. (For the service’s team: unknown_key.)”; other setup 500s use their own similar “setup issue on the service’s side” wording), or429 rate_limitedwith the server’sRetry-Afterfor the per-key rate limit. The fix is on your side: check the agent key and your setup; retrying won’t help.result.rejectedistrue(failClosedstaysfalse; at most one offailOpen,failClosedandrejectedistrue), and a[ordainer] rejected (call blocked in any failMode): <code>: …warning is logged. A 4xx is never retried. 403 subscription_inactiveand403 subscription_requiredapply only to live keys, which aren’t available during the beta, so test keys never get them. When they apply,subscription_inactivefollows the billing-lapse settingbillingLapse, notfailMode(Terms 10.3(b)): with'open'(the default, whateverfailModeis) the call runs, unchecked and uncounted; with'closed'(opt-in) it’s blocked with403 plan_check_rejected, noRetry-Afterand a neutral message for your users (result.rejected). Its own warning says “Calls are being let through, unchecked, because billingLapse is ‘open’ (the default)” or “Calls are being blocked (403 plan_check_rejected) because billingLapse is ‘closed’”.403 subscription_required(never paid) is blocked under every setting. Both get theonBillingInactivehook on every such call.429 rate_limited(About 100 requests a second, each server counts separately.result.error.limitScopeis'per_key') is blocked with429 rate_limitedandRetry-After. It gets its own “rate limit, not an outage” warning (at most once a minute),result.rateLimited/result.retryAfterSec, and theonRateLimitedhook.429 concurrency_limited(when the key’s waiting line is full: the key already has 4 requests in flight at once on that server by default on our hosted service;result.error.limitScope: 'per_key_concurrency') is handled the same way: blocked with429 rate_limitedandRetry-After: 1, never a fail-open,result.rateLimitedtrue,result.reason'concurrency_limited',onRateLimitedruns, and the warning says “concurrency limited … Send fewer calls in parallel”. A call that waited and ran out of time is a503 decide_timeout(retried once, then failMode). Agents making parallel tool calls on one key can hit it.429 too_many_failed_auth(your address sent more than 30 missing, malformed or unknown keys in a minute, and this call’s key is missing or unknown too;result.error.limitScope: 'per_address') is a bad key, not a rate limit: rejected like other 4xx (500 plan_check_rejected), with its own warning to check the agent key. Calls with a valid key aren’t refused by it (one rare exception).401 old_key_format(ansk_agent key from before the rename) is rejected like any other 401 (500 plan_check_rejected). Create a neword_key.test_limit_reacheddoesn’t depend onfailMode: in enforce it’s blocked (429 test_limit_reached); in shadow (SDK 1.2.0) the call runs as a would-deny.429 safety_limit_reached(SDK 1.2.0; shadow calls past 10 times your monthly test limit) runs the call in everyfailMode,'closed'included:result.allowedandresult.safetyLimitedaretrue,result.failOpenisfalse, a warning is logged at most once perwarningIntervalMs, andonSafetyLimit(result)runs on every such call.- If the
baseUrlhost doesn’t resolve (ENOTFOUND/EAI_AGAIN, e.g. a typo inORDAINER_BASE_URL), SDK 1.2.0 logs one error-level line the first time, naming the host and saying to setORDAINER_BASE_URL, not held back by the warning throttle. Otherwise it’s a network error and followsfailMode.
Sticky deny
Section titled “Sticky deny”Sticky deny. Once Ordainer has denied an agent key and tool with quota_exceeded, a call for that same pair that would fail open in the next 60 seconds (a timeout, network error, 5xx or unreadable answer) is blocked instead, as a plan-limit deny: your caller gets 429 plan_limit_reached (or your denyStatus) with Retry-After, and result.stickyDeny is true (result.error still says what failed). This stops a customer who is already at its limit from running uncounted calls while Ordainer is slow or unreachable. The window ends early at the plan’s reset or when an allow arrives for the pair; set it with stickyDenyMs (default 60000, max 300000, 0 = off). In shadow mode the call still runs and is reported (stickyDeny, wouldDeny). failMode: 'closed' is unchanged.
Sticky deny lives in memory, per Ordainer instance. A fresh process, a new replica or a cold serverless start that hasn’t received the deny itself still fails open, even for a customer already over its cap. If your caps must hold during an outage and you run on serverless or many short-lived instances, use failMode: 'closed' for those routes. Sticky deny narrows the fail-open gap; it doesn’t close it.
With plain HTTP (any other language)
Section titled “With plain HTTP (any other language)”There’s no setting; it’s the branch you write for “error or timeout”. The Your first deny examples print the error and exit 1, leaving the choice to you. Whatever you pick:
- Set a client timeout that fits your request path. Don’t rely on your HTTP library’s default, which can be minutes.
- Expect the first call from a new process to be slower: make one warm-up request at startup, and on a timeout retry once with the same idempotency key. More in Introduction → When we can’t answer.
- Treat a
4xxas “don’t run”, like the SDK does. Only a timeout, network error or5xxis a real “Ordainer can’t answer”. - Log
error.codeand theX-Request-Idheader, and alert on a rising error rate. Support can trace a4xxfrom its request ID. - If you retry, reuse the same idempotency key so the call can’t be counted twice (a key replays for 24 hours). On
429 rate_limited, waitRetry-Afterseconds first.
Latency and status
Section titled “Latency and status”We don’t publish a speed target or an SLA. Our API and console run on Render in Ohio, in the US East region. Our database is Neon Postgres in AWS US East 2, also in Ohio. Each decide response includes a Server-Timing header showing how long the check took on our side. There’s no status page yet either. Size your timeout from your own measurements.
Choosing a timeout
Section titled “Choosing a timeout”- Start from the defaults. Our SDKs wait 300 ms per attempt, retry once (about 650 ms in all), then follow
failMode. Our server gives each decide a 250 ms deadline to start deciding. A decision that’s already being saved isn’t cut short, so, rarely, your client can fail open on a call we counted. See the timeline in Decide → limits. - Measure from where you run. The farther your servers are from ours (see the latency note above), the more of your time is network. Time a few calls from your own servers and set your timeout from what you see, not from our defaults.
- Read
Server-Timingto split the time.decideis our total time on the server,dbis time holding a database connection, andwaitis time waiting for one. Your end-to-end time minusdecideis network and TLS. Ifdecideis small and your total is large, the time is on the network path, not in our check.tripsmay also appear. It’s an internal marker (2 or 4), not a time. - Reuse one client per process. The first call from a new process (cron jobs, serverless functions, command-line tools) also opens the connection (DNS, TCP and TLS), so it can be slower than the calls after it. Keep one client for the life of the process, or make one warm-up request at startup (
GET /livez, see Decide). - Count fail-opens yourself. The console cannot count calls the server never saw (timeouts and network failures that failed open). The SDKs already tell your code when that happens:
onDecision(Node) oron_decision(Python, Ruby) receives a failed-open result (failOpenin Node,fail_openin Python and Ruby). Count those in the callback; do not expect them in the console.