Skip to content

Runtime

The Runtime is the kernel every move passes through: one gate that identifies, decides, prices, guards, commits and acts outside. Verbs run there as Functions and Workflows, started by calls, Triggers and time; every change leaves as an Event.

Capability families

Every product runs on the same kernel, and it is the only writer of the record. A fact, its Event, its meter line and its audit entry commit together, or none of them do.

FamilyWhat it gives every product
The gateOne path for every call, run and inbound Event: identify, decide, price, guard, commit, then effects. The first step that fails answers, and the call costs nothing
Verbs and the ActionEvery Verb answers one Action: done, Pending with its reason, or refused with a cure. Idempotency keys, cancel, Prefer: wait and batches work the same on all of them
Function kindsCode, generative, agentic and human, each a Function behind one Verb and one price. A step escalates to the next kind when its check fails, and the caller sees the same Action
The model routerEvery generative and agentic call goes through one router: model routing, fallbacks, a Customer's own model keys, token metering and the Max-Cost ceiling
WorkflowsDurable code and state machines: steps that run once, waits of weeks, child Actions, compensation, each run pinned to the Version it started on
TriggersWhat starts work with no call: an Event, a schedule, or a Thing entering a state. An inbound webhook and a crossed threshold each write an Event, so they start work the same way
TimeClocks as data: durations, schedules in each Customer's timezone, business calendars, deadlines that lapse, and test clocks in the Test twin
EffectsEvery outside act as a durable intent: recorded in the commit, sent once by its idempotency key, acknowledged, retried, compensated on failure, then reconciled
EventsThe change feed in order, Watches and signed webhooks out, verified webhooks in, live subscriptions, and signals sent into a waiting run

The gate's six steps are one order for every Interface. The call contract's twelve checks are the same path, rendered for HTTP. Decide and price give the caller one answer: the decision reads the price, and the price step reserves it.

StepIt answersWhen it fails
IdentifyWhich principal, for which Customer, under which Key or mandate401, before anything else is read
DecideThe one policy decision: allowed, pending, or refused with a cure403, or a Pending Action that waits for a person
PriceReserves the price the decision read, against the plan, the credits and the call's Max-Cost402, with the offers that lift it
GuardThe lifecycle state, uniqueness, rate limits, brakes and input types409, 429 or 400
CommitThe fact, its Event, its meter line, its audit entry and its intents, as oneNothing is written, and nothing is billed
EffectsEach recorded intent, sent outside onceThe intent retries, then compensates; the fact stands

Lifecycles and states

ThingStatesWhat moves it
An Actionpending, then done, failed or cancelled; refused never startsIts steps, a cancel, or a check at the gate
A waitRunning, AwaitingWorker, AwaitingInput, AwaitingTime, AwaitingSource, AwaitingAction, AwaitingApproval, RetryingThe step the run is on; the reason names who holds the ball
A run across deploysPinned to its Version until it endsNothing: a deploy moves new calls at once, and old Versions run until their work closes
An effectrecorded, sent, acknowledged, reconciled; or retrying, failed, compensatedThe outside party's answer, then what the outside later reports
A webhook deliveryqueued, delivered; or retrying for 3 days, parked, replayedThe receiver's answer, then a replay from the developer portal or the API
A clockrunning, then fired or lapsed; paused on a business calendar's closed hoursTime, or a test clock advanced in the Test twin
A live subscriptionopen, behind, closedThe client; a client that falls behind resumes from its last seq

What you declare, what the platform does

You declareThe platform does
A Verb, its Function kind and its returnsServes it on every Interface, types its output everywhere, and meters it once
A workflow() or a machine()Keeps every step's result, survives restarts, waits for weeks, and pins each run to its Version
An on line: an Event, a schedule, or a stateStarts the Verb once per Event, or once per Customer in that Customer's timezone
A duration, a deadline or a business calendarRuns the clock, fires after, lapses a window, and offers test clocks in the Test twin
A prompt and its returnsRoutes the model, falls back on a failure, uses a Customer's own model key when one is set, and counts tokens
A Watch, or a Source that deliversSigns, retries and replays deliveries out; verifies deliveries in, and writes each as an Event before anything runs
Nothing elseThe gate's order, idempotency, the commit invariant, effects, reconciliation, cutover and the evidence of every decision

Example

A won Deal starts the kickoff. The run drafts a plan, waits up to seven days for the Customer's CRM to confirm the company, then commits once.

kickoff: a week on the clock, resumed by an Event
16 lines
export default define({
  …
  sources: { crm: { system: 'crm', scope: 'customer' } },
  Deal: {
    …
    kickoff: workflow(async ($, deal) => {
      const { plan } = await $.generative('Draft the kickoff plan for {company.name}', deal,
        { returns: { plan: 'string' } })
      await $.wait({ event: 'Company.updated', where: { id: deal.company }, within: '7d' })
      const at = await $.step('stamp it', () => new Date().toISOString())
      return { plan, at }
    }),
  },
  on: { 'Deal.won': 'Deal.kickoff' },           // Trigger: what reacts to a change
  …
})
GET /actions/act_8, while it waits
HTTP/1.1 200 OK
X-Cost: price=0, currency="USD"

{
  "id": "act_8",
  "verb": "Deal.kickoff",
  "status": "pending",
  "reason": "AwaitingSource",
  "until": "2026-11-02T15:00:00Z",
  "poll": "/actions/act_8"
}

When the CRM's change arrives as Company.updated, Observed, the run resumes and stamps its time once. If the seven days pass first, the wait lapses and the run takes its next step.

Contracts with the other subsystems

Every other subsystem proposes; the Runtime commits.

SubsystemWhat the Runtime takes from itWhat the Runtime gives it
Definition and compileA compiled Version: routes, machines, prices, Triggers, staffingEvery output stamped with that Version's Digest; every run pinned to it
Identity, access and policyOne answer per move, at the decide stepThe principal and the mandate on every Action and Event
Model and recordsNouns, lifecycles and the rules on historyThe only writes to the record; every projection rebuilds from its Events
Data and SourcesSource reads and the Mappings that fill fieldsReads as steps, refreshes on schedule, write-backs as effects, outside changes as Observed Events
WorkTasks, reviews and sign-offs, as steps$.human raises a task, and the run waits AwaitingWorker until it is done
CommerceThe price, the Entitlement and the meter rulesThe meter line in the commit; charges and refunds on Stripe as effects; charged on the Event an outcome bills at
Interfaces and distributionOne Action and one Problem to renderThe same reply on HTTP, MCP, the SDK, the CLI and webhooks, and live subscriptions
Trust and operationsThe Test twin, brakes and rate limitsA trace per Action, the evidence of every decision, and replay

What Customers and their agents meet

  • One Action, everywhere. A fast Verb answers done. A slow one answers 202 with poll, and Prefer: wait=30 holds the call open.
  • A refusal before any work. A refused call costs nothing and names what lifts it: a payment, the clock, or a person.
  • A ceiling they set. Max-Cost refuses a priced call above it before it runs, and stops a metered run at it.
  • Retries that are safe. A write sent again with the same Idempotency-Key runs once and is billed once.
  • Who holds the ball. A waiting run names its reason and its deadline, and POST /actions/{id}/cancel stops it at no charge.
  • No polling. An agent subscribes to its Action or to the change feed and resumes on the Event. A Watch delivers the same Events, signed and in order.
  • A stable run. A run that starts on one Version finishes on it, whatever deploys meanwhile.

One gate, one commit and one Action, so every Interface tells the same story about every move.