Outcomes and events
How every outcome reaches the caller, every listener and Telemetry: the outbox in the case's own transaction, the fast path and the sweep, and what Run guarantees.
Where an outcome goes
When a case ends, its outcome goes to three places, and Run decides how it travels:
| To | How |
|---|---|
| Whoever is waiting | The answer of the request, for a case that starts in_app or external |
| Every case that listens to it | An event, through the outbox, to each listener’s own queue |
| Sypnia Telemetry, always | The span of the run, with sypnia.case and sypnia.case.outcome (Telemetry and use cases) |
In the code, every run ends with ctx.outcome: the outcome or the failure that happened, with its data (Sypnorm):
if (forecast.rainFrom) return ctx.outcome('RainExpected', { from: forecast.rainFrom });
return ctx.outcome('ClearSkies', {});The outbox: saved with the data
An outcome that someone listens to is saved in the same transaction as the data it describes. When pause-deliveries commits, the paused deliveries and the event deliveries.pause-deliveries.DeliveriesPaused.v1 are written together, or neither is. There is never an event about data that was rolled back, and never data whose event was lost.
Run knows at build time which outcomes have listeners. For those, the runtime adds one row to the table sypnia_cases.outbox inside the case’s transaction, with the direct runner and with the Data API’s all-or-nothing transaction alike. An outcome nobody listens to writes nothing.
Then the event leaves by one of two roads:
| Where Run runs | The bus | The sweeper |
|---|---|---|
| Cloud Sypnia Cloud | Amazon EventBridge, one bus per app environment, and an Amazon SQS queue per listener | a schedule of the app |
| Engine The engine in your AWS account | the same, in your account | the same |
| Engine Without AWS: Docker or your own server | Postgres: each listener’s queue is a table | a background task in each service, woken by LISTEN/NOTIFY right after the commit, sweeping every minute |
What each event carries
{
"id": "0193f6c2-7a1e-7c3b-9d2a-5e8f1b4c6a70",
"name": "weather.check-weather.RainExpected.v1",
"data": { "from": "2026-11-18T15:00:00-05:00" },
"occurred_at": "2026-11-18T13:00:04Z",
"key": null,
"traceparent": "00-7c2e9a4b1d8f4e6a9b3c5d7e1f2a4b6c-a1b2c3d4e5f60718-01",
"cause": ["check-weather"],
"depth": 1
}nameisarea.case.Outcome.v<n>. Changing an outcome’s data in a way that would break a listener needs a new version; the old one keeps being published next to it for 90 days, then stops, and the build warns every listener still on it with the days left (Versions).traceparentcarries the trace, so the listener’s run is part of the same story in Telemetry: the weather check, the paused deliveries and the message to the baker are one trace.causeanddepthsay which cases led here. They are how Run stops a loop.datais at most 256 KB. For something bigger, put it in Sypnia Files and send its path.
What Run guarantees
- At least once. An event reaches every listener at least once. Getting it twice does what getting it once does: the runtime records the event ids each listener already handled, for 7 days, and skips a repeat before your code runs.
- Each listener on its own. Every listener has its own queue and its own retries: 5 attempts with growing waits. After the last one, the event goes to that listener’s dead letters, shown on its case in the map and in the console.
run cases dlq tell-the-bakerlists them, and--replaysends them again once the cause is fixed. - Order when you ask for it. Events are handled in any order unless the start says
order_by: <field>; then the events with the same value of that field are handled one at a time, in order. - Waiting for several. An
on_allstart keeps what it has seen for each key until all of its outcomes arrived within the window, and runs once. A window that closes first runs nothing: it ends asWindowExpired, with what had arrived, on the case in the map and in Sypnia Telemetry, among the case’s outcomes and on the trace of the last event that arrived.
Loops
A chain of cases can come back on itself: «Resume deliveries» leading again to «Pause deliveries». Run checks twice:
- At build time, from the map: a chain of listeners that closes a circle stops the build, unless one case in it declares how it stops:
loop: { bounded: true, max: 3, until: "the forecast is clear" }. A case can never listen to its own outcome. - At run time, from
causeanddepth: an event whose chain already holds the case it would start, or that is more than 10 steps deep, does not run it. The run is recorded asLoopStoppedon the trace, and Telemetry raises an alert.