# A reference implementation on AWS, service by service

> Every AWS service the engine uses, what it does, which part of the engine runs in it and whether that part is Rust or a managed service; a request traced through the real services; the template; and the cost model with its arithmetic, down to what one free project costs.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service). Status: at launch.  
Source: https://docs.sypnia.com/architecture/reference-implementation-aws/

For agents: Read this for the concrete AWS deployment of the Sypnia engine: CloudFront, three Lambda functions running the same Rust binary (sypnia-ingest, sypnia-api, sypnia-worker), one SQS intake queue with its dead-letter queue, EventBridge Scheduler, S3, RDS for PostgreSQL, Secrets Manager, CloudWatch alarms; where the Rust code and the engine's logic run; limits per service; a template excerpt; unit costs (per 1,000 batches, per million events, per GB-month, per 1,000 replays, per analysis), the idle cost, worked examples, and the cost of a Free-plan project on Sypnia Cloud with the proposed limits.

[Deployment shapes](https://docs.sypnia.com/architecture/deployment-shapes) says the engine can run as functions on AWS. This page is that deployment with the names on: which AWS service does what, where the Rust code runs, where the engine's logic lives, what each service is limited to, and what it costs. It is the deployment the template `sypnia-aws.yaml` creates, and the one Sypnia Cloud runs **\[Cloud]**.

> **In plain words**
>
> On AWS, Amazon's services carry the data and keep it: an address, a queue, a bucket, a database, a clock. They decide nothing. Every decision, what to accept, what is a problem, what to count, when to alert, is made by one program written in Rust, which runs in three small functions. If you can read that program, you have read all of the engine's logic.

> **Note: About the numbers**
>
> Limits of AWS services are the published ones. Times are the design's budgets, not measurements of the Rust engine, which is not released yet. Prices are the public on-demand list prices for `us-east-1` as assumed on **2026-11-15**; they change, so redo the sums with the linked price lists before you rely on a total. Figures «measured on the system this engine comes from» say so.

## The services

Nine AWS services. One of them, Lambda, runs the engine's code, as three functions. The last column is the answer to «is this Rust, or is this Amazon?».

| AWS service                                                | What it does here                                                                                                                                                   | Which part of the engine                                                                                                               | Rust code, or managed                                                                              |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| **Amazon CloudFront**                                      | The one HTTPS address. Sends `/v1/ingest/*`, `/v1/otlp/*` and `/v1/sdk.js` to the ingest function and everything else to the API function. Caches only `/v1/sdk.js` | None. It forwards                                                                                                                      | Managed. Configuration: two path rules                                                             |
| **AWS Lambda**, function `sypnia-ingest`                   | Receives what SDKs send                                                                                                                                             | **Ingest**: the seven gates, then the batch goes to the queue; replay chunks and snapshots go to the Bucket                            | **Rust**: the `sypnia` binary with `SYPNIA_ROLE=ingest`                                            |
| **AWS Lambda**, function `sypnia-worker`                   | Does all the work that is not a request                                                                                                                             | **The worker**: writing segments, the Fast path, the Roll-up, the agent's jobs, Alerts and webhooks, uptime checks, retention, Parquet | **Rust**: the same binary with `SYPNIA_ROLE=worker`                                                |
| **AWS Lambda**, function `sypnia-api`                      | Answers people and coding agents                                                                                                                                    | **The API, the MCP server and the Console**                                                                                            | **Rust**: the same binary with `SYPNIA_ROLE=api`                                                   |
| **Amazon SQS**, the intake queue and its dead-letter queue | Holds validated batches until the worker has written them; parks the ones that failed five times                                                                    | None. It is the buffer a function cannot keep in memory                                                                                | Managed. Configuration: retention, visibility timeout, `maxReceiveCount`                           |
| **Amazon EventBridge Scheduler**                           | Wakes the worker every minute                                                                                                                                       | None. The worker decides what is due                                                                                                   | Managed. Configuration: `rate(1 minute)`                                                           |
| **Amazon S3**                                              | The Bucket: segments, per-session files, replay chunks, snapshots, source maps, Parquet                                                                             | None. Keys are built by the engine; retention is the engine's daily job                                                                | Managed. Configuration: private, encrypted, one rule for unfinished uploads, CORS for replay links |
| **Amazon RDS for PostgreSQL**                              | Postgres: the ledger, problems, numbers, the session index, alerts, jobs                                                                                            | None. No stored procedure, no trigger, no extension                                                                                    | Managed. Or any Postgres 15 or later of yours                                                      |
| **AWS Secrets Manager**                                    | Holds the generated password of the database the template creates                                                                                                   | None                                                                                                                                   | Managed                                                                                            |
| **Amazon CloudWatch**                                      | A log group per function, kept 30 days; three alarms                                                                                                                | None. The alarms watch the engine from outside                                                                                         | Managed. Configuration: three thresholds                                                           |
| **AWS IAM**                                                | One role per function, each with the least it needs                                                                                                                 | None                                                                                                                                   | Managed                                                                                            |

Not used, on purpose: no load balancer, no API gateway, no container cluster, no NAT gateway, no stream, no cache, no search service, no workflow service, no second database.

|                                            | Sypnia engine (open source, self-hosted)                                                        | Sypnia Cloud (paid service, with a free tier)                                                                                             |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| E-mail                                     | None. Alerts are recorded and sent to your webhook; the guides show how to send e-mail from it. | **Amazon SES**: alert e-mails and the daily summary.                                                                                      |
| AI provider                                | Yours, off until you set a key. The worker calls it over HTTPS.                                 | **OpenRouter**, with settings that forbid providers from keeping or training on the data.                                                 |
| Accounts, billing, the app, the GitHub App | Not in the engine.                                                                              | The private app. It is a client of the engine's public API, like your own tools; it has its own database and adds no logic to the engine. |

## Where the Rust is, and where the logic is

**Figure (diagram not drawn yet)**: The reference implementation. The three lit boxes are the engine: one Rust binary, three roles. Everything else is a managed service that moves or holds bytes.

It will show: ARCHITECTURE DIAGRAM with AWS service names, inside one frame «AWS account · us-east-1 · stack: sypnia». The three Lambda functions are the LIT elements (accent fill) and carry a small «Rust» tag each; every other node is drawn in the neutral tone with a small «managed» tag. LEFT, outside the frame: «Your app (SDK)» and below it «You · your coding agent · your CI». INSIDE, left to right: node «Amazon CloudFront · the address» (two outgoing arrows labelled «/v1/ingest/\* · /v1/otlp/\* · /v1/sdk.js» and «everything else»); LIT box «AWS Lambda · sypnia-ingest» with the sub-label «Ingest: the seven gates» and the tag «256 MB · 10 s · 40 copies»; queue symbol «Amazon SQS · intake queue» with a smaller one under it «dead-letter queue · 14 days»; LIT box «AWS Lambda · sypnia-worker» with FIVE small inner tiles stacked: «write segments», «Fast path», «Roll-up», «The agent», «Alerts · uptime · retention» and the tag «1,024 MB · 15 min · 2 copies»; above the worker a clock «Amazon EventBridge Scheduler · every minute»; a curved arrow from the worker to itself labelled «agent jobs»; to the right two stores stacked: «Amazon S3 · the Bucket» and «Amazon RDS for PostgreSQL · Postgres»; bottom row a LIT box «AWS Lambda · sypnia-api» with the sub-label «API · MCP server · Console» and the tag «512 MB · 30 s · 20 copies». Small nodes in a corner strip labelled «around it»: «AWS Secrets Manager · database password», «Amazon CloudWatch · logs + 3 alarms», «AWS IAM · one role per function». ARROWS: Your app → CloudFront → sypnia-ingest; sypnia-ingest → intake queue «SendMessage»; sypnia-ingest → S3 «replay chunks, snapshots»; intake queue → sypnia-worker «up to 10 s of messages»; intake queue ⇢ dead-letter queue (dashed) «after 5 deliveries»; sypnia-worker → S3 «segments, session files, Parquet»; sypnia-worker → RDS «ledger, problems, numbers, jobs»; You → CloudFront → sypnia-api; sypnia-api → RDS «reads»; sypnia-api → S3 «signed links». OUTSIDE the frame on the right, dashed: «AI provider (yours · Sypnia Cloud: OpenRouter)» and «Your webhook», each with an arrow from sypnia-worker; and a dashed cloud-only box «Sypnia Cloud only: Amazon SES · the private app» with a cloud badge. A legend with two swatches: accent «the engine: Rust, all the logic» and neutral «AWS managed services: they move and hold bytes». Numbered callouts (1) CloudFront, (2) sypnia-ingest, (3) the queues, (4) sypnia-worker, (5) the scheduler, (6) S3, (7) RDS, (8) sypnia-api.

Three statements, each of which you can check in the template and in the code:

1. **Everything inside the three functions is the engine, and the engine is Rust.** The functions run the same file, `sypnia`, built for arm64 and started by Lambda as its `bootstrap`. There is no Node, Python or Java runtime in the deployment, and no second program.
2. **AWS services move and hold bytes.** CloudFront forwards a request. SQS keeps a message. S3 keeps an object. Postgres keeps rows. The scheduler sends one fixed JSON document a minute. None of them inspects an event.
3. **No logic lives in a service's configuration.** What the template configures is numbers and names: two path rules, a retention, a visibility timeout, the `5` of the dead-letter rule, a rate, three alarm thresholds, the roles. There is no request-mapping template, no rule with a filter, no code at the edge, no bucket notification, no stored procedure, no trigger, no workflow definition. Retention is not even a bucket lifecycle rule: it is the engine's daily job, so it is the same on any S3-compatible store.

That third statement is what makes the engine portable. Replace SQS by memory and Lambda by a process, and you have the [one-process shape](https://docs.sypnia.com/architecture/deployment-shapes#as-one-long-running-process), with the same code deciding the same things.

### From crates to functions to services

**Figure (diagram not drawn yet)**: Which crate runs in which function, and which service each function may touch. The left column holds all the logic.

It will show: THREE-COLUMN MAPPING DIAGRAM with connecting lines. LEFT COLUMN titled «Crates (Rust)»: eleven small nodes stacked in the layers of the codebase diagram, exact labels: «sypnia (binary): main, lambda, Engine», «sypnia-ingest», «sypnia-pipeline», «sypnia-agent», «sypnia-alerts», «sypnia-api», «sypnia-store», «sypnia-db», «sypnia-fingerprint», «sypnia-core». MIDDLE COLUMN titled «Functions (the same binary, by role)», three larger LIT boxes: «sypnia-ingest · SYPNIA_ROLE=ingest», «sypnia-worker · SYPNIA_ROLE=worker», «sypnia-api · SYPNIA_ROLE=api». RIGHT COLUMN titled «AWS services», nodes: «Amazon CloudFront», «Amazon SQS», «Amazon EventBridge Scheduler», «Amazon S3», «Amazon RDS for PostgreSQL», and dashed «AI provider», «Your webhook». LINES left → middle (which crate's code runs in which function): sypnia-ingest → sypnia-ingest function (label «gates, send») and → sypnia-worker function (label «the queue's other end: write segments»); sypnia-pipeline → sypnia-worker; sypnia-agent → sypnia-worker (label «jobs») and → sypnia-api (label «the prompt»); sypnia-alerts → sypnia-worker; sypnia-api → sypnia-api function; a bracket around sypnia-store, sypnia-db, sypnia-fingerprint, sypnia-core labelled «linked into all three»; the binary crate → all three with the label «main → lambda::run(role)». LINES middle → right (what each function is allowed to touch, with the permission as the label): sypnia-ingest function → SQS «send»; → S3 «put only»; ← CloudFront «invoked by». sypnia-worker function ← SQS «receives, deletes, delays»; ← Scheduler «every minute»; → S3 «read and write»; → RDS «read and write»; → AI provider; → Your webhook. sypnia-api function ← CloudFront; → RDS «read, and the writes of the API»; → S3 «read + sign». Under the diagram one line: «the left column is all the logic; the right column has none». Numbered callouts (1) left column, (2) middle, (3) right.

| Crate                                             | Runs in                                                                                                | Reaches                                                     |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| `sypnia` (the binary): `main`, `lambda`, `Engine` | All three functions                                                                                    | The Lambda runtime                                          |
| `sypnia-ingest`                                   | `sypnia-ingest`: the gates and the send. `sypnia-worker`: the queue's other end, which writes segments | SQS, S3                                                     |
| `sypnia-pipeline`                                 | `sypnia-worker`                                                                                        | S3, Postgres                                                |
| `sypnia-agent`                                    | `sypnia-worker`: the jobs. `sypnia-api`: the prompt                                                    | S3, Postgres, the AI provider                               |
| `sypnia-alerts`                                   | `sypnia-worker`                                                                                        | Postgres, your webhook, the addresses of your uptime checks |
| `sypnia-api`                                      | `sypnia-api`                                                                                           | Postgres, S3 (read, and signing links)                      |
| `sypnia-store`, `sypnia-db`                       | All three                                                                                              | S3; Postgres                                                |
| `sypnia-fingerprint`, `sypnia-core`               | All three                                                                                              | Nothing: no I/O                                             |

The functions share one entry point. It is the `main` of [Deployment shapes](https://docs.sypnia.com/architecture/deployment-shapes#one-engine-two-ways-to-wake-it); these are the lines that matter here. Notice that the role is the only thing that differs between the three functions, and that it is read from the environment the template sets.

`crates/sypnia/src/main.rs`

```rust
    // Bucket, Postgres, the AI provider (or none), the alert sinks. Built once, shared by everything.
    let engine = match Engine::connect(config.clone()).await {
        Ok(engine) => Arc::new(engine),
        Err(error) => return fail(4, &error),
    };

    // Inside AWS Lambda the runtime sets this variable and there is no command line.
    if std::env::var_os("AWS_LAMBDA_RUNTIME_API").is_some() {
        return exit(lambda::run(engine, config.role).await); // SYPNIA_ROLE: ingest | worker | api
    }
```

## One request through the real services

The failed payment of the [overview](https://docs.sypnia.com/architecture#a-requests-life-in-9-steps), with the service that carries each step, its time budget, its limit and what happens when that service fails. The failure column is a summary; [What happens when something fails](https://docs.sypnia.com/architecture/reliability) has every case.

| #  | Step                                                                                           | Service                                                 | Budget                                 | The limit that applies                                                                                                  | If it fails                                                                    |
| -- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| 1  | The browser sends `POST /v1/ingest/events`                                                     | CloudFront → Lambda `sypnia-ingest`                     | 50 ms warm; 300 ms for a cold function | Body: 2 MiB after decompression (the engine's), 6 MB (Lambda's). 10 s. 40 copies; beyond them the address answers `429` | The SDK keeps the batch and retries with the same `batch_id`                   |
| 2  | Ingest sends the validated batch                                                               | SQS `SendMessage`                                       | 20 ms                                  | 256 KiB a message; a batch over 192 KiB compressed goes to S3 and the message names it                                  | `503`; the SDK retries                                                         |
| 3  | Ingest answers `200`                                                                           | Lambda → CloudFront                                     | —                                      | —                                                                                                                       | —                                                                              |
| 4  | The queue hands the batch to the worker                                                        | SQS → Lambda `sypnia-worker`                            | Up to 10 s                             | 500 messages or 6 MB a delivery. 2 copies. Visibility 15 min                                                            | Delivered again after 15 s, 1 min, 5 min, 15 min; then the dead-letter queue   |
| 5  | The worker writes the segment                                                                  | S3 `PutObject`                                          | 300 ms                                 | 4 MiB a segment, before compression                                                                                     | The message is not deleted; step 4 repeats                                     |
| 6  | The worker writes the ledger row, scans the segment, writes the problem, its alert and its job | RDS for PostgreSQL, one transaction                     | 50 ms; 5 s for the scan                | 3 connections per worker copy                                                                                           | The segment stays leased 2 minutes, then another try; 5 tries, then quarantine |
| 7  | The worker calls itself with the job                                                           | Lambda `Invoke`, asynchronous                           | 100 ms                                 | Lambda's own retries off: the job row is the retry                                                                      | The minute tick finds the row                                                  |
| 8  | The agent reads maps and the session, calls the model, writes the sentence                     | S3 `GetObject`; HTTPS to the AI provider; Postgres      | 60 s                                   | 15 min for the function; 3 tries for the job                                                                            | The alert leaves on time without the sentence; `analysis.status: failed`       |
| 9  | The alert is released to your webhook                                                          | HTTPS from the worker                                   | 10 s                                   | 7 tries over 21 hours                                                                                                   | The alert is recorded all the same                                             |
| 10 | Every minute: one pass                                                                         | EventBridge Scheduler → Lambda `sypnia-worker`          | 1 s when idle                          | 2 copies shared with steps 4, 7 and 8                                                                                   | The next tick does it                                                          |
| 11 | Your coding agent calls the MCP tool `problem`                                                 | CloudFront → Lambda `sypnia-api` → Postgres             | 300 ms                                 | Answer: 6 MB (Lambda's); 30 s; 20 copies; 2 connections per copy                                                        | `503` with `Retry-After: 2`                                                    |
| 12 | You open the replay                                                                            | `sypnia-api` signs links; the browser reads S3 directly | 300 ms for the links                   | A link lives 15 minutes; chunks never pass through a function                                                           | `503`; the list of problems still works                                        |

### Limits and settings in one place

| Where             | Setting                           | Value                                                                                                  | Why this value                                                                                                 |
| ----------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `sypnia-ingest`   | Memory, time limit, copies        | 256 MB, 10 s, 40                                                                                       | It only checks and forwards. 40 copies at 50 ms accept about 800 batches a second                              |
| `sypnia-worker`   | Memory, time limit, copies        | 1,024 MB, 15 min, 2                                                                                    | Two projects rolled at once (2 × 256 MB), the source-map cache, room. The daily job may need the 15 minutes    |
| `sypnia-api`      | Memory, time limit, copies        | 512 MB, 30 s, 20                                                                                       | A session's detail is built in memory, inside a 4 MB budget                                                    |
| All functions     | Architecture, runtime             | arm64, `provided.al2023`                                                                               | A native binary; no language runtime to start                                                                  |
| All functions     | Environment                       | Under 4 KB in all                                                                                      | Lambda's limit. The engine needs about 12 settings                                                             |
| Intake queue      | Retention, visibility, deliveries | 4 days, 15 min, 5                                                                                      | See [Reliability](https://docs.sypnia.com/architecture/reliability#on-aws-one-queue-and-its-dead-letter-queue) |
| Dead-letter queue | Retention                         | 14 days                                                                                                | The longest SQS allows                                                                                         |
| Queue → worker    | Batch, window, answer             | 500 messages or 6 MB, 10 s, failures reported per message                                              | One bad message does not send the others back                                                                  |
| Scheduler         | Rate                              | Every minute                                                                                           | One schedule; daily and weekly work is started by the pass when due                                            |
| Bucket            | Encryption, access                | At rest, private                                                                                       | Functions reach it through their roles; browsers through 15-minute signed links                                |
| Postgres          | Connections                       | At most 86: 40 × 1, 20 × 2, 2 × 3                                                                      | Fits the smallest instance, which accepts about 100                                                            |
| Alarms            | Three                             | Dead-letter queue not empty; oldest message over 120 s for 3 minutes; worker failing in 3 of 5 minutes | They work when the engine does not                                                                             |

The two copies of the worker are shared by the queue's deliveries, the minute tick and agent jobs. When all are busy, a new call waits: a message stays in the queue, an asynchronous call is held by Lambda. Nothing is lost; work is later. This is the first number to raise when `lag_seconds` grows, together with the database's connections.

## The template

The whole deployment is one file, `sypnia-aws.yaml`. This excerpt is the part this page talks about: the three functions, the queue with its dead-letter rule, the schedule and one alarm. Left out: the distribution, the bucket, the database, the other two alarms and the outputs. How to deploy it is in [Deploy on AWS](https://docs.sypnia.com/self-hosting/deploy-aws).

`deploy/sypnia-aws.yaml (excerpt)`

```yaml
Transform: AWS::Serverless-2016-10-31

Globals:
  Function:
    Runtime: provided.al2023          # no language runtime: the package is the sypnia binary, named bootstrap
    Handler: bootstrap
    Architectures: [arm64]
    CodeUri: { Bucket: !Ref CodeBucket, Key: !Sub "sypnia/${Version}/sypnia-lambda-arm64.zip" }
    Environment:
      Variables:
        SYPNIA_ROOT_TOKEN: !Ref RootToken
        SYPNIA_STORAGE_BUCKET: !Ref Bucket
        SYPNIA_DATABASE_URL: !If [CreateDb, !Sub "postgres://sypnia:{{resolve:secretsmanager:${DatabaseSecret}:SecretString:password}}@${Database.Endpoint.Address}:5432/sypnia?sslmode=require", !Ref DatabaseUrl]
        SYPNIA_INTAKE_QUEUE_URL: !Ref IntakeQueue                       # the queue stands in for the in-memory buffer
        SYPNIA_INTAKE_DEAD_LETTER_QUEUE_URL: !Ref IntakeDeadLetterQueue # read by /v1/engine/status and sypnia doctor

Resources:
  IngestFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: sypnia-ingest
      MemorySize: 256
      Timeout: 10
      ReservedConcurrentExecutions: 40
      FunctionUrlConfig: { AuthType: NONE }   # reached through the distribution; the engine checks every key itself
      Environment: { Variables: { SYPNIA_ROLE: ingest, SYPNIA_DATABASE_MAX_CONNECTIONS: "1" } }
      Policies:
        - SQSSendMessagePolicy: { QueueName: !GetAtt IntakeQueue.QueueName }
        - Statement: [{ Effect: Allow, Action: "s3:PutObject", Resource: !Sub "${Bucket.Arn}/*" }]

  ApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: sypnia-api
      MemorySize: 512
      Timeout: 30
      ReservedConcurrentExecutions: 20
      FunctionUrlConfig: { AuthType: NONE }
      Environment: { Variables: { SYPNIA_ROLE: api, SYPNIA_DATABASE_MAX_CONNECTIONS: "2" } }
      Policies:
        - S3ReadPolicy: { BucketName: !Ref Bucket }                    # read, and sign links to read

  WorkerFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: sypnia-worker
      MemorySize: 1024
      Timeout: 900
      ReservedConcurrentExecutions: 2
      Environment: { Variables: { SYPNIA_ROLE: worker, SYPNIA_DATABASE_MAX_CONNECTIONS: "3" } }
      EventInvokeConfig: { MaximumRetryAttempts: 0 }                    # a job is a row in Postgres: the row is the retry
      Policies:
        - S3CrudPolicy: { BucketName: !Ref Bucket }
        - Statement:
            - { Effect: Allow, Action: "lambda:InvokeFunction", Resource: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:sypnia-worker" }
            - { Effect: Allow, Action: "sqs:GetQueueAttributes", Resource: !GetAtt IntakeDeadLetterQueue.Arn }
      Events:
        Intake:
          Type: SQS
          Properties:
            Queue: !GetAtt IntakeQueue.Arn
            BatchSize: 500
            MaximumBatchingWindowInSeconds: 10
            FunctionResponseTypes: [ReportBatchItemFailures]             # only the messages that failed come back
            ScalingConfig: { MaximumConcurrency: 2 }
        EveryMinute:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: rate(1 minute)
            Input: '{"job":"pass"}'

  IntakeQueue:
    Type: AWS::SQS::Queue
    Properties:
      VisibilityTimeout: 900                  # not shorter than the worker's time limit
      MessageRetentionPeriod: 345600          # 4 days
      ReceiveMessageWaitTimeSeconds: 20
      SqsManagedSseEnabled: true
      RedrivePolicy:
        deadLetterTargetArn: !GetAtt IntakeDeadLetterQueue.Arn
        maxReceiveCount: 5                    # the fifth failed delivery is the last

  IntakeDeadLetterQueue:
    Type: AWS::SQS::Queue
    Properties:
      MessageRetentionPeriod: 1209600         # 14 days
      SqsManagedSseEnabled: true

  DeadLetterNotEmpty:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Batches were set aside. Look at one, fix the cause, redrive.
      Namespace: AWS/SQS
      MetricName: ApproximateNumberOfMessagesVisible
      Dimensions: [{ Name: QueueName, Value: !GetAtt IntakeDeadLetterQueue.QueueName }]
      Statistic: Maximum
      Period: 60
      EvaluationPeriods: 1
      Threshold: 0
      ComparisonOperator: GreaterThanThreshold
      TreatMissingData: notBreaching
```

What wakes the worker is told apart by the shape of the event, in `worker_event` of [Deployment shapes](https://docs.sypnia.com/architecture/deployment-shapes#as-aws-functions): `{ "Records": […] }` is the queue, `{ "job": "pass" }` is the schedule, `{ "job": { "agent": { "problem": "prb_8f3k2m9x4q7w" } } }` is the worker calling itself.

## Postgres: which one, and why

The reference uses **Amazon RDS for PostgreSQL, one small instance in one availability zone**: `db.t4g.micro`, Postgres 16, 20 GB, encrypted, backups kept 7 days. It is what the template creates when `CreateDatabase` is `true`.

| Option                                                 | Idle cost a month                                                 | Good                                                               | The price you pay                                                                                                                  |
| ------------------------------------------------------ | ----------------------------------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| **RDS for PostgreSQL**, `db.t4g.micro` (the reference) | 11.68 + 2.30 of disk                                              | The cheapest managed Postgres on AWS; a fixed bill; plain Postgres | One zone: a failure of the instance is minutes of «receiving works, reading does not». About 100 connections                       |
| RDS, two zones (Multi-AZ)                              | Twice the instance and the disk                                   | Fails over by itself in a minute or two                            | Twice the price for a database the Bucket can mostly rebuild                                                                       |
| Aurora Serverless v2                                   | From 43.80: 0.5 capacity units × 0.12 × 730, plus storage and I/O | Grows and shrinks with load                                        | Three times the idle cost. Scaling to zero does not fit: the minute tick would wake it every minute                                |
| A Postgres outside AWS (Supabase, Neon, your own)      | 0 to 25                                                           | You may already have it                                            | Every query crosses the internet; their connection limits apply. Use a session-mode or direct connection, not a transaction pooler |

**One connection string.** The engine takes a single `SYPNIA_DATABASE_URL`, for every role. It must be a direct or session-mode connection: the engine prepares its statements and runs transactions of several statements, which a transaction-mode pooler breaks. Functions keep the total small instead: 1 connection per ingest copy, 2 per API copy, 3 per worker copy.

> **Warning: The database the template creates is reachable from the internet**
>
> The functions run outside a private network, because the worker must reach your webhook, your AI provider and your uptime checks, and inside a private network that needs a NAT gateway: about USD 33 a month before traffic, more than everything else in a small deployment together. A database that such functions can reach has a public address. The template forces TLS and generates a 32-character password, kept in Secrets Manager. The alternatives: bring a Postgres with the network rules you want, or put the functions in a private network with a NAT gateway and pay for it. The cost model below counts both ways.

**Secrets.** The generated database password lives in Secrets Manager and is resolved when the stack deploys. The root token, the AI key and the webhook secret are template parameters that are never echoed, stored as the functions' environment, which Lambda encrypts at rest. Anyone who may read a function's configuration can read them; restrict that permission as you would restrict the secrets themselves.

## The cost model

### Prices used

USD, on demand, `us-east-1`, as assumed on 2026-11-15, without any free allowance. Each name links to the official price list.

| Service                                                                     | Unit                                                                                            | Price                      |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | -------------------------- |
| [AWS Lambda](https://aws.amazon.com/lambda/pricing/), arm64                 | Per GB-second; per million requests                                                             | 0.0000133334; 0.20         |
| [Amazon SQS](https://aws.amazon.com/sqs/pricing/), standard                 | Per million requests (each 64 KB of a message is one)                                           | 0.40                       |
| [Amazon S3](https://aws.amazon.com/s3/pricing/), Standard                   | Per GB-month; per million writes or lists; per million reads                                    | 0.023; 5.00; 0.40          |
| [Amazon CloudFront](https://aws.amazon.com/cloudfront/pricing/)             | Per million HTTPS requests; per GB sent to the function; per GB sent out                        | 1.00; 0.02; 0.085          |
| Data leaving AWS from S3                                                    | Per GB                                                                                          | 0.09                       |
| [Amazon RDS for PostgreSQL](https://aws.amazon.com/rds/postgresql/pricing/) | `db.t4g.micro` per hour; `db.t4g.medium` per hour; disk per GB-month; a public address per hour | 0.016; 0.065; 0.115; 0.005 |
| [Amazon EventBridge Scheduler](https://aws.amazon.com/eventbridge/pricing/) | Per million invocations                                                                         | 1.00                       |
| [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/pricing/)             | Logs per GB; per alarm a month                                                                  | 0.50; 0.10                 |
| [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/pricing/)      | Per secret a month                                                                              | 0.40                       |
| [Amazon SES](https://aws.amazon.com/ses/pricing/) **\[Cloud]**              | Per 1,000 e-mails                                                                               | 0.10                       |
| NAT gateway (not in the reference)                                          | Per hour; per GB                                                                                | 0.045; 0.045               |

AWS gives every account a monthly allowance that covers a small deployment's functions (400,000 GB-seconds and a million requests), its queue (a million requests) and its address (10 million requests). The unit costs below ignore it, so they stay true at any size.

### An idle deployment

Nothing arrives. What still costs:

| Line                                     | Arithmetic                                                               | A month     |
| ---------------------------------------- | ------------------------------------------------------------------------ | ----------- |
| The minute tick                          | 43,200 calls × 1 s × 1 GB × 0.0000133334, plus 43,200 × 0.20 ÷ 1,000,000 | 0.59        |
| The schedule                             | 43,200 × 1.00 ÷ 1,000,000                                                | 0.04        |
| The queue's empty polls                  | About 15 a minute: 648,000 × 0.40 ÷ 1,000,000                            | 0.26        |
| Three alarms                             | 3 × 0.10                                                                 | 0.30        |
| One secret                               |                                                                          | 0.40        |
| Logs                                     | About 0.1 GB                                                             | 0.05        |
| Bucket, address, the other two functions | Nothing arrives, nothing is billed                                       | 0.00        |
| **The engine, idle**                     |                                                                          | **≈ 1.64**  |
| Postgres, if the template creates it     | 0.016 × 730 + 20 × 0.115                                                 | 13.98       |
| Its public address                       | 0.005 × 730                                                              | 3.65        |
| **Total, idle**                          |                                                                          | **≈ 19.27** |

With a Postgres you already have, an idle engine is under USD 2 a month, and with the free allowance it is cents.

### Unit costs

**Receiving, storing and processing events.** The unit that costs is not the event: it is the batch, and the segment it lands in.

| Step, per 1,000 batches                                           | Service    | Arithmetic                            | USD        |
| ----------------------------------------------------------------- | ---------- | ------------------------------------- | ---------- |
| The address receives them                                         | CloudFront | 1,000 × 1.00 ÷ 1,000,000              | 0.00100    |
| The bodies reach the function, 3 KB each                          | CloudFront | 0.003 GB × 0.02                       | 0.00006    |
| `sypnia-ingest` is called                                         | Lambda     | 1,000 × 0.20 ÷ 1,000,000              | 0.00020    |
| It runs 50 ms at 256 MB                                           | Lambda     | 12.5 GB-s × 0.0000133334              | 0.00017    |
| The batches are sent to the queue                                 | SQS        | 1,000 × 0.40 ÷ 1,000,000              | 0.00040    |
| The worker receives and deletes them, in groups                   | SQS        | About 670 requests × 0.40 ÷ 1,000,000 | 0.00027    |
| **Receiving**                                                     |            |                                       | **0.0021** |
| Segments written: at most one per batch                           | S3         | 1,000 × 5.00 ÷ 1,000,000              | 0.00500    |
| Each read once by the fast path and up to 11 times by the roll-up | S3         | 12,000 × 0.40 ÷ 1,000,000             | 0.00480    |
| The worker's time for them, 20 ms each at 1 GB                    | Lambda     | 20 GB-s × 0.0000133334                | 0.00027    |
| **Storing and processing, at most**                               |            |                                       | **0.0101** |
| **Total, at most**                                                |            |                                       | **0.0122** |

Segments are the larger half, and they are capped: a project and environment gets at most one segment per 10-second delivery, 259,200 a month, however much it sends. So the cost of a million events depends on how they arrive:

| A million events                                                                                                                                                    | Batches   | Segments                              | Arithmetic                                                        | USD         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------- | ----------------------------------------------------------------- | ----------- |
| **A busy project**: the small project of [Deployment shapes](https://docs.sypnia.com/architecture/deployment-shapes#what-it-costs-on-aws), 4 million events a month | 225,000   | 65,000 (the cap, shared by 4 million) | 225 × 0.0021 + 65 × 0.0101 + 15,000 session files × 5 ÷ 1,000,000 | **≈ 1.20**  |
| **A quiet project**: every batch alone in its 10 seconds                                                                                                            | 225,000   | 225,000                               | 225 × 0.0122 + 0.08                                               | **≈ 2.80**  |
| **The worst shape**: every event alone in a batch, two events a session                                                                                             | 1,000,000 | 1,000,000                             | 1,000 × 0.0122 + 1,000,000 session files × 5 ÷ 1,000,000          | **≈ 17.20** |

Measured on the system this engine comes from: 4.4 events a batch and 30 batches a session, which is where 225,000 comes from. The worst shape is what a ceiling must assume, and what nobody's app looks like.

**Storing.** USD 0.023 per GB-month. A GB is about 8 million events as segments (125 MB a million), or 2.7 million with their per-session files and Parquet (375 MB a million), or about 1,330 short replays.

**Replays.** A recording is one object per 10 seconds, sent through the address and `sypnia-ingest`, and read by the browser straight from S3 when someone watches it.

| Per 1,000 replays                             | A short one: 22 chunks, 0.75 MB (measured there)             | The longest: 720 chunks, 144 MB, two hours |
| --------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------ |
| Requests through the address and the function | 22,000 × (1.00 + 0.20 + 0.33) ÷ 1,000,000 = 0.034            | 1.10                                       |
| Bodies to the function                        | 0.75 GB × 0.02 = 0.015                                       | 2.88                                       |
| Objects written                               | 22,000 × 5 ÷ 1,000,000 = 0.110                               | 3.60                                       |
| **Stored**                                    | **≈ 0.16**                                                   | **≈ 7.58**                                 |
| Kept, per month of retention                  | 0.75 GB × 0.023 = 0.017                                      | 3.31                                       |
| **Watched once, each of them**                | 22,000 reads × 0.40 ÷ 1,000,000 + 0.75 GB × 0.09 = **0.076** | **≈ 13.25**                                |

A short replay costs two hundredths of a cent to store and watch. The longest costs two cents, almost 90 times more, and most of that is the data leaving AWS when it is watched.

**An AI analysis.** The engine counts tokens, not money; the price is your provider's. The formula:

```text
cost = calls × (tokens_in × price_in + tokens_out × price_out) ÷ 1,000,000
```

|                               | Tokens in                                                                                           | Tokens out                     | Calls                                                                 |
| ----------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------ | --------------------------------------------------------------------- |
| A usual analysis              | 8,000: about 24,000 characters of context at 3 to 4 characters a token, plus the fixed instructions | 700                            | 1.15: assumed, one answer in seven fails the check and is asked again |
| The largest the engine allows | 9,000                                                                                               | 2,000 (`ai.max_output_tokens`) | 3                                                                     |

| Price of the model, per million tokens in / out | A usual analysis | The largest |
| ----------------------------------------------- | ---------------- | ----------- |
| 0.15 / 0.60                                     | 0.0019           | 0.0077      |
| 0.40 / 1.60                                     | 0.0050           | 0.0204      |
| 3.00 / 15.00                                    | 0.040            | 0.171       |

So an analysis costs between a fifth of a cent and four cents, depending on the model, and up to 17 cents in the worst case with an expensive one. Measured on the system this engine comes from: USD 0.08 to 0.20 for a weekly run of 15 to 25 calls, about half a cent to a cent a call. No model is named here because none is promised.

**An uptime check.** One request a minute, made inside the pass that runs anyway: about USD 0.02 a month for its 43,200 result rows and its share of the worker's time.

### Two self-hosted examples

The two projects of [Deployment shapes](https://docs.sypnia.com/architecture/deployment-shapes#what-it-costs-on-aws), summed by service. The line-by-line arithmetic is there; the last rows add three small fixed items that table leaves out.

| USD a month                                             | Small: 4 million events, 30,000 sessions | Medium: 40 million events, 300,000 sessions |
| ------------------------------------------------------- | ---------------------------------------- | ------------------------------------------- |
| Lambda                                                  | 3.31                                     | 15.26                                       |
| SQS                                                     | 0.60                                     | 4.00                                        |
| S3: writes, reads, storage                              | 3.52                                     | 14.34                                       |
| CloudWatch logs                                         | 0.50                                     | 2.00                                        |
| CloudFront                                              | 0.00 (inside the allowance)              | 0.00                                        |
| **The engine**                                          | **≈ 8**                                  | **≈ 36**                                    |
| RDS for PostgreSQL                                      | ≈ 14 (`db.t4g.micro`)                    | 25 to 50 (2 to 4 GB of memory)              |
| **Total, as on the other pages**                        | **≈ 22**                                 | **≈ 60 to 85**                              |
| Three alarms, one secret, the database's public address | 0.30 + 0.40 + 3.65 = 4.35                | 4.35                                        |
| **Everything on the bill**                              | **≈ 26**                                 | **≈ 65 to 90**                              |
| With the functions in a private network instead         | + 32.85 for the NAT gateway, − 3.65      | The same                                    |

Not included: the model, at your provider's price (a project that makes 200 usual analyses a month at 0.40 / 1.60 pays USD 1.00), and data leaving AWS when you watch replays (0.09 per GB).

### One project on Sypnia Cloud's Free plan **\[Cloud]**

The owner's rule: **no project on the Free plan may cost Sypnia more than USD 3 a month, everything included.** A rule like that is only true if every line of the bill has a limit. So this section does three things: it prices each limit at its worst shape, it shows which lines have no limit today, and it proposes the limits that make the rule hold.

**Shared, fixed costs.** Sypnia Cloud is this same deployment, sized for many projects, and its fixed costs are shared by all of them:

| Fixed, a month                                       | Arithmetic                      | USD       |
| ---------------------------------------------------- | ------------------------------- | --------- |
| Postgres: `db.t4g.medium` in two zones, 100 GB       | 2 × 0.065 × 730 + 100 × 0.23    | 117.90    |
| A NAT gateway, so the database has no public address | 0.045 × 730                     | 32.85     |
| The minute tick, budgeted at 10 s a pass             | 43,200 × 10 GB-s × 0.0000133334 | 5.76      |
| Logs, alarms, secrets                                | 10 GB × 0.50 + 0.30 + 1.20      | 6.50      |
| **Fixed**                                            |                                 | **≈ 163** |

Assumption, stated: **500 projects share one such deployment**, so each carries USD 0.33. With 130 projects the share is USD 1.25 and the ceiling below still holds; with fewer, Sypnia pays the fixed cost whatever the plans are, and the ceiling is a statement about each further project. The private app's own hosting is not in this number.

**The model.** For the Free plan's arithmetic Sypnia Cloud's model is budgeted at no more than USD 0.40 per million tokens in and 1.60 out: a usual analysis is half a cent, the largest is two cents. If a dearer model is chosen, the row scales with it.

**A free project at 100 % of every limit, at the worst shape:**

| Limit (proposed)                                                          | At the limit                                            | Unit cost, worst shape            | USD a month |
| ------------------------------------------------------------------------- | ------------------------------------------------------- | --------------------------------- | ----------- |
| Events received: hard stop at 20,000, four times the 5,000 counted events | 20,000 batches of one event                             | 0.0122 per 1,000 batches          | 0.24        |
| …their sessions                                                           | 10,000 sessions, two files written each                 | 5.00 per million writes           | 0.10        |
| …their roll-ups                                                           | A run in every 5 minutes of the month: 8,640 × 0.3 GB-s | 0.0000133334 per GB-s             | 0.04        |
| Replays: 50 a month, 30 minutes each at most, kept 7 days                 | 50 × 180 chunks, 36 MB each; every one watched once     | 0.0021 to store + 0.0033 to watch | 0.27        |
| Uptime checks: 1                                                          | 43,200 checks                                           |                                   | 0.02        |
| Analyses: 50 a month                                                      | 50 of the largest                                       | 0.0204                            | 1.02        |
| Alert e-mails: 100 a month, plus the daily summary                        | 131 e-mails                                             | 0.10 per 1,000                    | 0.01        |
| Pull requests: none                                                       |                                                         |                                   | 0.00        |
| Share of the fixed costs                                                  | 163 ÷ 500                                               |                                   | 0.33        |
| **Total**                                                                 |                                                         |                                   | **≈ 2.03**  |

The same project at the same limits with the shape real apps have (4.4 events a batch, short replays of which one in five is watched, usual analyses) costs about **USD 0.65**, half of it the fixed share.

**Figure (diagram not drawn yet)**: What one free project costs Sypnia a month, by component. The agent's analyses are half of the worst case, which is why their limit is the one that changes most.

It will show: HORIZONTAL STACKED BAR CHART, one chart with two bars and a vertical limit line. X axis in USD from 0 to 3.25 with ticks every 0.50; a bold vertical line at 3.00 labelled «the ceiling: USD 3». BAR 1 labelled «A free project at 100 % of every limit, worst shape · USD 2.03», segments left to right with these exact labels and widths: «AI analyses · 1.02» (the lit segment, accent colour), «Events: receive, store, process · 0.38», «Share of fixed costs · 0.33», «Replays: store and watch · 0.27», «Uptime check · 0.02», «E-mail · 0.01». BAR 2 labelled «The same limits, the shape real apps have · USD 0.65», segments: «Share of fixed costs · 0.33», «AI analyses · 0.25», «Events · 0.03», «Uptime check · 0.02», «Replays · 0.01», «E-mail · 0.01». To the right of bar 1, a bracket from 2.03 to 3.00 labelled «margin: 0.97». Under the chart a third, hatched bar that runs past the right edge with a break mark, labelled «Today's proposal (20 analyses a day, 5 pull requests, no hard stop) · more than USD 15», to show it crosses the ceiling. Legend not needed: labels are on the segments. Text alternative lists the six components of each bar with their values.

**Against today's proposal.** `pricing.ts` and [Limits](https://docs.sypnia.com/agent/limits) propose for Free: 5,000 events, 50 replays, 7 days, 1 uptime check, 5 pull requests a month and 20 analyses a day. Priced the same way:

| Line          | Today's proposal                                                        | USD a month, worst shape                              | Verdict                                                                         |
| ------------- | ----------------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------- |
| Analyses      | 20 a day, 620 a month                                                   | 620 × 0.0204 = 12.65                                  | Four times the ceiling by itself. Even at the usual size it is 3.10             |
| Pull requests | 5 a month                                                               | 5 × 0.30 to 0.60 = 1.50 to 3.00                       | Half the ceiling to all of it. Already decided: not in the Free plan            |
| Events        | 5,000 counted; uncounted events and failures past the limit have no cap | No ceiling                                            | A page that fires a custom event in a loop, or an error in a loop, is unbounded |
| Replays       | 50, each up to two hours                                                | 50 × (0.0084 + 0.0133) = 1.08                         | Fits only if nothing else is at its worst                                       |
| Alert e-mails | No cap                                                                  | No ceiling                                            | An uptime check that flaps all month is 43,200 e-mails: 4.32                    |
| **Total**     |                                                                         | **More than 15, with two lines that have no ceiling** |                                                                                 |

> **Warning: Proposed limits (for the owner to confirm)**
>
> What must change for the ceiling to hold, and the same check for the paid plans. Nothing here is applied to `pricing.ts` or to the Sypnia Cloud pages yet.
>
> |                                                                                       | Free                                            | Builder, USD 10                             | Team, USD 49                                  |
> | ------------------------------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------- | --------------------------------------------- |
> | Events a month (counted)                                                              | 5,000 · unchanged                               | 50,000 · unchanged                          | 500,000 · unchanged                           |
> | **New:** hard stop on everything received, counted or not, failures included          | 20,000                                          | 200,000                                     | 2,000,000                                     |
> | Replays a month                                                                       | 50 · unchanged                                  | 500 · unchanged                             | 5,000 · unchanged                             |
> | **New:** longest recording                                                            | 30 minutes                                      | 2 hours                                     | 2 hours                                       |
> | Analyses                                                                              | **50 a month, 10 a day at most** · was 20 a day | **200 a month** · was 100 a day per project | **1,000 a month** · was 500 a day per project |
> | Pull requests a month                                                                 | **0** · was 5                                   | **5** · was 50                              | **30** · was 300                              |
> | **New:** alert e-mails a month; past it, alerts stay in the app and the daily summary | 100                                             | 1,000                                       | 5,000                                         |
> | Projects, people, uptime checks, days kept                                            | Unchanged                                       | Unchanged                                   | Unchanged                                     |
>
> Past the hard stop ingest answers `429 limit_reached` until the month ends, and the owners are told, as at any limit. Limits are per organization, as on [Plans and limits](https://docs.sypnia.com/cloud/plans-and-limits).

**The paid plans at 100 % of the proposed limits.** A paid plan is priced on the shape real apps have, with the worst shape stated as the risk. A pull request is the least certain number here, because its worker is not designed in detail: it is budgeted at USD 0.30, and 0.60 at worst, for about 120,000 tokens in and 8,000 out with a model fit for writing code.

| USD a month                                          | Builder, 3 projects   | Team, 10 projects       |
| ---------------------------------------------------- | --------------------- | ----------------------- |
| Events: twice the counted ones received, 4.4 a batch | 0.29                  | 3.12                    |
| Replays: short, one in five watched                  | 0.10                  | 1.13                    |
| Uptime checks                                        | 5 × 0.02 = 0.10       | 25 × 0.02 = 0.50        |
| Analyses, usual size                                 | 200 × 0.005 = 1.00    | 1,000 × 0.005 = 5.00    |
| Pull requests                                        | 5 × 0.30 = 1.50       | 30 × 0.30 = 9.00        |
| E-mail: summaries and alerts                         | 0.06                  | 0.51                    |
| Share of the fixed costs                             | 3 × 0.33 = 0.99       | 10 × 0.33 = 3.30        |
| Card payment: 2.9 % + 0.30                           | 0.59                  | 1.72                    |
| **Cost at 100 % of limits**                          | **≈ 4.63**            | **≈ 24.28**             |
| **Margin**                                           | **5.37, 54 %**        | **24.72, 50 %**         |
| The same limits at the worst shape                   | ≈ 24.50               | ≈ 233                   |
| With today's proposal for pull requests (50 and 300) | 18.13: a loss of 8.13 | 105.28: a loss of 56.28 |

Three things to read from it:

1. **Pull requests and analyses are the bill.** Storage, events and replays together are under a fifth of either plan's cost at real shapes. The model is more than half.
2. **The paid plans are not safe at the worst shape, and the exposure is one line:** long recordings that are all watched. 5,000 two-hour replays are 720 GB written, kept three months and downloaded: about USD 154 on a USD 49 plan. A shorter longest recording on paid plans, or counting hours of replay instead of replays, would close it. It is a question for the owner, below.
3. **Today's numbers for pull requests lose money** on both paid plans at any shape.

### Questions this model leaves open

- **The model's price tier for Sypnia Cloud.** Everything above assumes 0.40 / 1.60 per million tokens. A model at 3.00 / 15.00 makes the Free plan's 50 analyses cost up to USD 8.55; the same ceiling then allows 5.
- **The NAT gateway.** USD 33 a month so that Sypnia Cloud's database has no public address. Counted above; the self-hosted reference does without it.
- **Replays on paid plans:** a cap per recording, or hours instead of a count.
- **The cost of a pull request,** once its worker exists and can be measured.

## What changed from the system this comes from

| There                                                                                                                         | Here                                                               | Why                                                            |
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------- |
| An ingest function, an hourly one, a daily one and a weekly one, in TypeScript, with a native query engine as a 68 MB binding | Three functions by role, one Rust binary, no native dependency     | One program to read, arm64, 300 ms cold starts                 |
| A managed delivery stream between ingest and the bucket                                                                       | SQS, with a dead-letter queue and a redrive command                | Freshness; objects named by project; failures you can see      |
| The app's shared database                                                                                                     | A database of the engine's own                                     | The shared one ran out of memory once                          |
| Retention as bucket lifecycle rules and a database cron extension                                                             | The engine's daily job                                             | The same on any store and any Postgres                         |
| Cost estimated once, for one app                                                                                              | A unit cost per batch, replay and analysis, and a ceiling per plan | A service with a free plan must know what a free project costs |

## Next
