# Problem grouping

> How failures become problems, with the exact fingerprint algorithm worked by hand, symbolication with source maps, the rule that makes one request one problem across browser and server, the states of a problem and what triggers an alert.

Applies to: the Sypnia engine (open source, self-hosted).  
Source: https://telemetry.docs.sypnia.com/architecture/problem-grouping/

A problem is a group of failures with one cause. This page is how the engine decides that two failures are the same, how it turns a minified stack into your own files and lines, and how a problem moves between its states. It is the design behind [Problems](https://telemetry.docs.sypnia.com/concepts/problems).

Grouping is done by the fast path: the reader that scans each new segment for failures every 30 seconds. [Data flow](https://telemetry.docs.sypnia.com/architecture/data-flow) shows where it sits.

> **Note: About the code and the numbers**
>
> The Rust here is an excerpt of the engine's code. The fingerprints on this page are real: they were computed with the algorithm described, and the engine's test suite checks these exact values.

## From a failure to a problem

**Figure**: A failure's path. The fingerprint decides between a new problem and one more occurrence; source maps are applied after, and never change the grouping.

1. Is it a failure? Errors, failed calls and timeouts are kept; everything else is left to the Roll-up.
2. Is it part of a request already known? Then it is evidence of that request's problem, not a new one.
3. The fingerprint is computed from the failure itself.
4. Is the fingerprint known in this project and environment? No: a new problem. Yes: the same problem gets one more occurrence.
5. Source maps go to the agent, which turns the stack into original files and lines. They never change the grouping.

Left to right. A segment holds one line: a `server_error` with the fingerprint `88a44b15205cb153`. Every 30 seconds the Fast path reads it and asks its three questions. The fingerprint decides: «New problem» or «Same problem: add 1 occurrence». Either way the result goes to Postgres, to the tables `problems`, `problem_occurrences`, `problem_hits` and `alerts`. From there The agent symbolicates the stack and then writes the sentence, and Alerts holds the alert until the sentence is ready or 100 seconds have passed. The Bucket's `sourcemaps/4f2a91c/` feeds The agent, not the Fast path.

**(1) What counts as a failure.** The fast path looks at four kinds of line and ignores every other.

| Line                | A failure when                                                                                                                | Kind                                           | Fingerprint comes from                                                                                               |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `error` (browser)   | Always                                                                                                                        | `error`                                        | The SDK: `fp`                                                                                                        |
| `server_error`      | Always                                                                                                                        | `error`, or `failed_call` when `src` is `span` | Ingest, while it maps OTLP: the `exception` event's `sypnia.error.fingerprint` when the sender set it, else computed |
| `server_request`    | `partial` is true (the span carried `sypnia.partial`) and no full record of the same trace and span arrives within 15 minutes | `timeout`                                      | Ingest, while it maps OTLP                                                                                           |
| `request` (browser) | `400`, or `500` and above; no answer (`status` 0) only once the same call has failed for 3 people in the hour                 | `failed_call`                                  | The engine: no SDK field carries it                                                                                  |

A `401`, `403`, `404`, `409` or `422` is not a failure. Neither is a rage click or a slow page. Those are counted by the roll-up and never reach this code.

**A browser call with no answer** (`status` 0: the network dropped, the tab was closed, a blocker stopped it) does not open a problem on its own: one person on a bad connection is not a bug. It is counted in the numbers (`network_errors`, `failed_requests`) and in a tally per call and UTC hour (the table `quiet_failures`, up to 200 people). It counts toward a problem from the moment the same call, by its fingerprint (`METHOD path` and status 0, whatever page made it), has failed for 3 different people in the same hour: the failure that makes it 3 opens the problem, or adds to it, and so does every later one of that hour. The first two people stay in the hour's tally, not in the problem. A call answered `400`, or `500` and above, is a problem at once, and a call inside a trace the server already failed is evidence, as before.

**A request that never finished.** The server SDKs send a partial record of a request still running after 20 seconds and the full record when it ends, usually in a later export. A partial record waits 15 minutes for its full record (the same trace and server span), the longest a function may run on AWS Lambda. When the full record arrives, the wait is over and nothing is opened; a full record in the same segment wins at once. When 15 minutes pass without it, the partial record is decided like a held browser call: evidence of the trace's problem when there is one, else a `timeout` problem. So a timeout is known up to 15 minutes late, outside the 2 minutes the other problems take. Two limits: a request that runs longer than 15 minutes and then finishes is reported as a timeout, and a full record that arrives before its own partial record (an exporter's retry) does not cancel it.

**(2), (3), (4)** are the next three sections. **(5)** is symbolication.

## The fingerprint

A fingerprint is 16 hex characters. Failures with the same fingerprint, in the same project and environment, are the same problem.

For a browser error it is computed in the browser SDK, so that the SDK can also drop a repeat of the same error within 5 seconds. Server data arrives as OTLP, from `@sypnia/telemetry/node`, `@sypnia/telemetry/next` or any OpenTelemetry exporter: a sender may set the fingerprint of an error as the attribute `sypnia.error.fingerprint` on its `exception` event, and ingest computes it for every failure that arrives without one, failed calls and timeouts included. The engine also computes it for failed browser calls. SDK and engine must give the same bytes for the same input, so the algorithm is written down here exactly, and the same test vectors run in TypeScript and in Rust.

### The algorithm

**For an error**, three parts joined with `|`:

```text
name | normalized message | function@file of the first frame of your own code
```

1. **`name`**: the error's name. `Error` when there is none.

2. **The message, normalized**, in this order:

   | Step | Replace                                                 | With      |
   | ---- | ------------------------------------------------------- | --------- |
   | 1    | URLs                                                    | `<url>`   |
   | 2    | Paths of built chunks, such as `/_next/static/chunks/…` | `<chunk>` |
   | 3    | UUIDs                                                   | `<uuid>`  |
   | 4    | Quoted strings of up to 200 characters                  | `"…"`     |
   | 5    | Runs of 12 or more hex characters                       | `<hex>`   |
   | 6    | Numbers                                                 | `#`       |
   | 7    | Runs of whitespace                                      | one space |
   | 8    | Everything after the first 300 characters               | nothing   |

3. **The top frame**: read the first 30 lines of the stack, in the V8 form (`at fn (file:line:col)`) or the Gecko form (`fn@file:line:col`). Take the first frame whose file is not noise. Noise is `node_modules`, the framework's own runtime chunks, `react-dom`, `scheduler`, `node:internal` and `<anonymous>`. If every frame is noise, take the first. Then clean the file: remove the origin, the query and the hash; remove a build hash of the form `-` followed by 8 or more hex characters; cut everything before the build folder. The part is `function@file`, or empty when there is no stack.

If the framework gave the error a digest of 6 or more digits, the fingerprint is the hash of `digest:` and the digest instead, because that id is already stable.

**For a failed call**, the call, how it failed, and the request it happened in:

```text
call | span name | status or error code | METHOD | route
```

The code is the database's for a database call (a client span with `db.system.name`, or the older `db.system`): `db.response.status_code` first, such as the SQLSTATE `23505` or PostgREST's `PGRST116`, then the HTTP status. A Supabase call that answered HTTP 400 with `23505` is grouped by `23505`. A database call also adds the pattern of the first line of its message (`sypnia.db.message`, else the span's status message) after the code, normalized with the message steps above:

```text
call | span name | code | normalized first line | METHOD | route
```

So two errors a database function raises with one code (`P0001`) are two problems, while the values in a message and in its `Detail:` and `Hint:` lines never split one: every e-mail that hits `duplicate key value violates unique constraint "users_email_key"` gives the same first line, `duplicate key value violates unique constraint "…"`. The problem's title carries the code only, «INSERT users answered 23505 in POST /api/signup», never the message, which may hold personal data.

**For a timeout**: `timeout | METHOD | route`.

**The hash**, `hash64`, is FNV-1a with 32 bits, run twice over the same string with two different seeds, the two results written as 8 hex characters each and joined.

|                         | Value                                               |
| ----------------------- | --------------------------------------------------- |
| Seed of the first half  | `0x811c9dc5`                                        |
| Seed of the second half | `0x050c5d1f`                                        |
| Prime                   | `0x01000193`                                        |
| One step                | `h = (h XOR unit) × prime`, keeping the low 32 bits |
| A unit                  | One **UTF-16 code unit** of the string              |

> **Warning: UTF-16 code units, not bytes**
>
> The original is JavaScript, where a string is a sequence of UTF-16 code units, and the SDKs still are. Rust strings are UTF-8. Hashing bytes gives the same result only for plain ASCII. For `ñ` the first half is `740b78dc` over its one code unit and `069dc2f9` over its two bytes. A port that hashes bytes would quietly split every problem whose message has an accent or an emoji. The Rust below walks `encode_utf16()`.

Notice that the function takes no project and no time: a fingerprint depends only on the failure.

`crates/sypnia-fingerprint/src/lib.rs`

```rust
const PRIME: u32 = 0x0100_0193;
const SEED_A: u32 = 0x811c_9dc5;
const SEED_B: u32 = 0x050c_5d1f;

/// FNV-1a, 32 bits, over UTF-16 code units. Must match the SDKs bit for bit.
fn fnv1a_utf16(text: &str, seed: u32) -> u32 {
    text.encode_utf16()
        .fold(seed, |hash, unit| (hash ^ u32::from(unit)).wrapping_mul(PRIME))
}

/// 16 hex characters: two 32-bit hashes of the same text with different seeds.
pub fn hash64(text: &str) -> Fingerprint {
    Fingerprint::from_halves(fnv1a_utf16(text, SEED_A), fnv1a_utf16(text, SEED_B))
}

pub fn error_fingerprint(name: Option<&str>, message: &str, stack: Option<&str>, digest: Option<&str>) -> Fingerprint {
    if let Some(digest) = digest.filter(|d| d.len() >= 6 && d.bytes().all(|b| b.is_ascii_digit())) {
        return hash64(&format!("digest:{digest}"));
    }
    let frame = stack
        .and_then(top_frame) // first frame of your own code, V8 or Gecko
        .map(|f| format!("{}@{}", f.function, normalize_frame_file(&f.file)))
        .unwrap_or_default();
    hash64(&format!(
        "{}|{}|{}",
        name.unwrap_or("Error"),
        normalize_message(message),
        frame,
    ))
}

/// For a database call, `code` is the code, `|`, and the normalized first line of its message.
pub fn call_fingerprint(span_name: &str, code: &str, method: &str, route: &str) -> Fingerprint {
    hash64(&format!("call|{span_name}|{code}|{}|{route}", method.to_ascii_uppercase()))
}

pub fn timeout_fingerprint(method: &str, route: &str) -> Fingerprint {
    hash64(&format!("timeout|{}|{route}", method.to_ascii_uppercase()))
}
```

### Worked by hand

The shop's checkout page throws this when the payment is refused:

```text
ApiError: POST /api/checkout failed with 400 (amount_required)
    at o (https://shop.example/assets/checkout-3f9c-8d21e07b.js:1:47630)
    at async c (https://shop.example/assets/checkout-3f9c-8d21e07b.js:1:48211)
    at async HTMLButtonElement.<anonymous> (https://shop.example/assets/checkout-3f9c-8d21e07b.js:1:49002)
```

**Figure**: The fingerprint of the checkout error, step by step. Change the order number or the customer and nothing here changes; change the line of code that throws and it does.

1. The name: `ApiError`.
2. The message, normalized: numbers become `#`, so `400` does not split the group.
3. The top frame: the first frame of your own code, without the origin, the line, the column or the build hash in the file name.
4. The three results joined with `|`.
5. `hash64`: FNV-1a over UTF-16 units with two seeds; the two halves side by side are the fingerprint.

Five steps, each with what goes in and what comes out. Step 1: `ApiError: POST /api/checkout failed with 400 (amount_required)` gives `ApiError`. Step 2: `POST /api/checkout failed with 400 (amount_required)` gives `POST /api/checkout failed with # (amount_required)`. Step 3: `at o (https://shop.example/assets/checkout-3f9c-8d21e07b.js:1:47630)` gives `o@/assets/checkout-3f9c.js`. Step 4: joined, `ApiError|POST /api/checkout failed with # (amount_required)|o@/assets/checkout-3f9c.js`. Step 5: seed `0x811c9dc5` gives `15228057`, seed `0x050c5d1f` gives `93228d19`, and the fingerprint is `1522805793228d19`.

| Step                                                                                                                                                                                                                                                                                                                                                           | Result                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| (1) Name                                                                                                                                                                                                                                                                                                                                                       | `ApiError`                                                                               |
| (2) Message, normalized. Rule 6 turns `400` into `#`; nothing else matches                                                                                                                                                                                                                                                                                     | `POST /api/checkout failed with # (amount_required)`                                     |
| (3) Top frame. The first frame, `o`, is your own code. Its file loses the origin, the line and the column. `-8d21e07b` is a build hash, a dash and eight hex characters, so it goes: the next build names the file differently and the fingerprint must not change with it. `-3f9c` is four characters, shorter than the eight a build hash needs, so it stays | `o@/assets/checkout-3f9c.js`                                                             |
| (4) Joined                                                                                                                                                                                                                                                                                                                                                     | ApiError\|POST /api/checkout failed with # (amount_required)\|o@/assets/checkout-3f9c.js |
| (5) `hash64`, first half, seed `0x811c9dc5`                                                                                                                                                                                                                                                                                                                    | `15228057`                                                                               |
| (5) `hash64`, second half, seed `0x050c5d1f`                                                                                                                                                                                                                                                                                                                   | `93228d19`                                                                               |
| **Fingerprint**                                                                                                                                                                                                                                                                                                                                                | **`1522805793228d19`**                                                                   |

The first two steps of the first half, to check an implementation against: the string starts with `A` (unit `0x41`) and `p` (`0x70`).

```text
h0 = 0x811c9dc5
h1 = (h0 XOR 0x41) × 0x01000193 mod 2^32 = 0x811c9d84 × 0x01000193 = 0xc40bf6cc
h2 = (h1 XOR 0x70) × 0x01000193 mod 2^32 = 0xc40bf6bc × 0x01000193 = 0x5ad569f4
…
h86 = 0x15228057
```

And the failure behind it on the server, the call that the payment service refused:

| Failure                          | Hashed string                                     | Fingerprint        |
| -------------------------------- | ------------------------------------------------- | ------------------ |
| The server's failed call         | call\|POST /v1/payments\|400\|POST\|/api/checkout | `88a44b15205cb153` |
| If that request had hung instead | timeout\|POST\|/api/checkout                      | `c405205e99c5aa6c` |

`88a44b15205cb153` is the problem of the example story. Why it is that one and not the browser's is the next section.

## One request, one problem

**(2) in the first figure.** When the customer clicks Pay, three failures are reported for the same request:

1. the server's call to the payment service answered `400` (a failed client span that `@sypnia/telemetry/node` sent as OTLP, stored by ingest as a `server_error`);
2. the page's call to `POST /api/checkout` answered `400` (`request`, from `@sypnia/telemetry/browser`);
3. the page threw `ApiError` (`error`, from `@sypnia/telemetry/browser`).

Three problems for one click would be noise. The rule: **the deepest failure in a trace is the problem; what the person saw is evidence inside it.**

**Figure**: One click, three failures, one problem. The failed call at the bottom of the trace is the problem; the two things the browser saw are attached to it.

1. The server's failed call, `POST /v1/payments`, 3,790 ms, answered `400`: the deepest failure in the trace. It is the problem.
2. The page's failed call, `POST /api/checkout`, 3,870 ms: evidence inside that problem.
3. The `ApiError` the page threw 4 ms later, in the same batch: it follows the request, so it is evidence too.

A trace drawn as a waterfall, with one trace id, `7c2e9a4b…`. The browser's `request` to `POST /api/checkout` takes 3,870 ms and is answered `400`. Inside it, the server span of shop-api, which arrived by OTLP (the engine stores it as a `server_request`), takes 3,842 ms. Inside that, `SELECT carts` takes 12 ms and is fine, and the span `POST /v1/payments` takes 3,790 ms and fails with `400`. What the engine keeps is one problem, `88a44b15205cb153`, «POST /v1/payments answered 400 in POST /api/checkout»: one more occurrence, the person `u_1042` and the session `8f3a6c1e…`, and as evidence the page's failed call and its `ApiError`. No problem is opened for the browser call, and none for `ApiError`.

How the fast path applies it:

| Failure                                                                                               | What the fast path does                                                                                                                                                                                                                                                                                                                                                                    |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| A failure from the server, with a trace id (1)                                                        | It is the problem. One row goes into `trace_failures`: «trace `7c2e9a4b…` belongs to problem `prb_8f3k2m9x4q7w`», kept 48 hours. If the same trace has two server failures, the one in the deepest span wins.                                                                                                                                                                              |
| A failed `request` from the browser, with a trace id (2)                                              | Look up the trace in `trace_failures`. **Found:** it is evidence of that problem. It adds no occurrence; it adds the person and the session if the server record did not carry them. **Not found, and the project has sent server data:** hold it for 15 seconds in `held_failures`, then look again. **Still not found, or the project has only the browser SDK:** it is its own problem. |
| A browser `error` in the same batch and session as a failed `request`, at most 2 seconds after it (3) | It follows that request: evidence if the request is evidence, part of the request's problem otherwise.                                                                                                                                                                                                                                                                                     |
| A browser `error` with no failed request before it                                                    | Its own problem. This is most browser errors: a `TypeError` in your code has no request behind it.                                                                                                                                                                                                                                                                                         |

**The deepest span.** A span's depth is the number of `parent` links between it and the root of its trace. The links come from the records of the trace: a span in a `server_request`'s `spans` with `parent` null hangs from that record's server span, any other span from the span its `parent` names, and the server span from its own `parent`, which is the browser's call (its `span`) or a span of the service that called it. The fast path follows them through every record of the trace in the segment it scans. Of two server failures of one trace, the deeper one wins, decided in this order:

1. If one failure's span is an ancestor of the other's, the descendant wins, at any depth. `trace_failures.ancestors` keeps the chain of the winner, so this holds when the two arrive in different segments and the engine has seen only part of the chain: a payment service's failure that arrived first still wins over the failed call to it that `shop-api` reports later.
2. Otherwise, the one with more known ancestors wins.
3. A tie goes to the span that started later: the code went on after the earlier failure, so the earlier one was survived, and the later one is the last thing that happened before the request failed.
4. A tie in start time goes to the smaller span id, so the choice never depends on the order of arrival.

The failure that loses is evidence of the winner's problem, like the browser's call: it adds no occurrence. When a deeper failure arrives after a shallower one already opened a problem or counted an occurrence, the deeper one takes over the trace's row in `trace_failures` from then on; what was already counted stays where it was. That happens only when a service that was called reports after the one that called it, which is rare: with the Sypnia server SDKs each service exports a request about 2 seconds after it answered, and a called service answers before its caller. With several workers, it is also the one count that depends on which commit lands first: two failures of one trace that tie in depth, in segments scanned out of order, count once or twice. Making it independent of order would mean undoing the shallower occurrence, which this rule rules out.

The hold exists because the two halves travel separately. The server's record usually arrives first, since the server sends when the request ends and the browser waits up to 10 seconds to send its batch. The 15 seconds cover the opposite order. They are part of the 2-minute budget worked out in [Data flow](https://telemetry.docs.sypnia.com/architecture/data-flow), and they are spent only by projects that send server data.

A project with only the browser SDK gets the page's failed call as the problem, exactly as [Problems](https://telemetry.docs.sypnia.com/concepts/problems) says.

## Symbolication

A browser reports the stack of the code it ran: minified, in one line, with names like `o`. Source maps turn it back into your files.

**(5) in the first figure.** Symbolication happens after the problem exists and before the agent reads it. It never changes the fingerprint: grouping uses the minified frame, so a problem does not split when maps arrive late or are missing.

|                  | Rule                                                                                                                                                                                                                                                                                                                                                                                                   |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| When             | Its own step of the worker, right after the fast path, on every pass and in `sypnia aggregate`. A problem seen in the last 7 days that has a release and a stack and is not symbolicated yet is tried at once, then every 10 minutes: that is how maps uploaded after the failure are used. The first occurrence in each new release (its `ver` is not yet in `problems.releases`) is symbolicated too |
| Which occurrence | The problem's sample, its first occurrence, with the maps of `problems.first_release`. No release, no symbolication                                                                                                                                                                                                                                                                                    |
| Finding the map  | `sourcemaps/<release>/index.json` maps each served path to its map. A frame is looked up by its served path, with the origin, the query and the hash removed. Bundlers name maps independently of chunks, so the engine never guesses `<file>.map`                                                                                                                                                     |
| Frames           | The first 30. V8 and Gecko forms. A frame with no map stays as it is, and so does a frame whose lookup lands on an earlier generated line                                                                                                                                                                                                                                                              |
| Output           | `sample.stack_original`, the stack with original `file:line:column` and function names; `sample.frames_original`, each mapped frame with 2 lines of source on each side, from the map's `sourcesContent`; and `where`: the first mapped frame not under `node_modules/` or the bundler's runtime. `where` on the problem and the frames of its context read these until the agent writes its own place |
| Limits           | A cache of 50 maps or 200 MB; a single map over 64 MB is skipped; 60 seconds for the step                                                                                                                                                                                                                                                                                                              |
| On failure       | The problem keeps its minified stack. The step never blocks a problem or an alert                                                                                                                                                                                                                                                                                                                      |

For the checkout error the result is:

```text
ApiError: POST /api/checkout failed with 400 (amount_required)
    at confirmPayment (src/checkout/checkout.tsx:142:11)
    at async onPayClick (src/checkout/PayButton.tsx:31:5)
```

One number is exposed for this step: **problems symbolicated ÷ problems that had a release and a stack**, over the last 24 hours, shown by `sypnia doctor` on its `pipeline` line as «n of m problems symbolicated in 24 h». It is information: `doctor` does not fail on it. The reason is an incident in the system this comes from: for six days no error was symbolicated, because a build option broke the map reader, and nobody noticed. A log line is not a health number.

## The states of a problem

A problem has one status, `open`, `resolved` or `ignored`, and an open problem can carry marks: **new**, **growing**, **came back**. Together they are the states below.

**Figure**: The states of a problem. The engine makes only three moves by itself: a problem is born, it grows, it comes back. Everything else is a person.

1. A problem is born: the first failure with this fingerprint. Alert `problem.new`.
2. It grows: the people affected are at least twice those at the last alert, and at least 5. Alert `problem.growing`.
3. It comes back: a resolved problem happens again (in the fix release or later, if one was named). Alert `problem.regressed`.
4. An ignored problem that happens again is counted, sends no alert and stays ignored.

Six states. «Open · new» becomes «Open» 24 hours after the first failure; «Open · new» and «Open» become «Open · growing» when the problem grows; «Open · growing» becomes «Open» 24 hours later. From any open state a person or a token resolves it («Resolved») or a person or a token with the `admin` scope ignores it («Ignored»). «Resolved» becomes «Open · came back» when it happens again, and «Open · came back» can be resolved again. «Resolved» and «Ignored» can be reopened by hand, to «Open». In every open state new occurrences are counted. Solid arrows are moves of the engine; dashed arrows are moves of a person.

The engine decides a transition with one pure function. It receives the problem as it was before this segment and as it is after, and answers what happened. Notice that it cannot write anything: the caller writes the transition, the alert and the ledger row in one transaction, so a transition can never be recorded twice.

`crates/sypnia-pipeline/src/problems/transition.rs`

```rust
#[derive(Debug, PartialEq)]
pub enum Transition {
    Born,
    CameBack,
    Growing { from: u32, to: u32 },
    Quiet, // counted, nothing to tell anyone
}

pub fn transition(
    before: Option<&ProblemState>,
    after: &ProblemState,
    seen: &Seen,          // what this segment added: releases, people
    rules: &GrowingRule,  // factor 2, min_people 5, unless the project changed them
) -> Transition {
    let Some(before) = before else {
        return Transition::Born;
    };
    match before.status {
        Status::Ignored => Transition::Quiet,
        Status::Resolved => {
            // «Old tabs»: with a fix release named, only a failure in that release or a later one reopens.
            let reopens = match &before.resolved_in_release {
                Some(fix) => seen.releases.iter().any(|r| r.is_same_or_later_than(fix)),
                None => true,
            };
            if reopens { Transition::CameBack } else { Transition::Quiet }
        }
        Status::Open => {
            let threshold = before
                .people_at_last_alert
                .saturating_mul(rules.factor)
                .max(rules.min_people);
            if after.people >= threshold && after.people > before.people_at_last_alert {
                Transition::Growing { from: before.people_at_last_alert, to: after.people }
            } else {
                Transition::Quiet
            }
        }
    }
}
```

Follow the example of [Problems](https://telemetry.docs.sypnia.com/concepts/problems) through it. The problem is born with 1 person, and `people_at_last_alert` becomes 1. At 3 people the threshold is `max(1 × 2, 5) = 5`: quiet. At 5 people: growing, and `people_at_last_alert` becomes 5. The next threshold is 10, then 20.

«Later» for a release means first seen by the engine at the same time as the fix release or after it. The engine does not compare version strings: a short git commit has no order.

### What a transition writes

All in the one transaction that also marks the segment as scanned:

| Transition | `problems`                                                                           | Alert               | The agent                                         |
| ---------- | ------------------------------------------------------------------------------------ | ------------------- | ------------------------------------------------- |
| Born       | A new row, `status = open`, `people_at_last_alert = people`                          | `problem.new`       | Symbolicate, then analyse                         |
| Came back  | `status = open`, `regressed = true`; `resolved_at` and `resolved_by` stay as history | `problem.regressed` | Symbolicate, then analyse again                   |
| Growing    | `growing_until = now + 24 h`, `people_at_last_alert = people`                        | `problem.growing`   | Analyse again, inside the daily limit per problem |
| Quiet      | Counters and `last_seen` only                                                        | None                | Nothing                                           |

## What triggers an alert

For problems, exactly the three transitions above, and only when the project's rule for that kind is on for the problem's environment. By default the three are on for `production` only.

Each alert row has a `dedupe_key` with a unique index, which is what makes «one problem is one alert» a property of the database instead of a hope:

| Alert               | `dedupe_key`                                          | So that                            |
| ------------------- | ----------------------------------------------------- | ---------------------------------- |
| `problem.new`       | `problem.new:<problem id>`                            | A problem is new once in its life  |
| `problem.regressed` | `problem.regressed:<problem id>:<resolved_at>`        | Once for each time it was resolved |
| `problem.growing`   | `problem.growing:<problem id>:<people at last alert>` | Once for each step: 5, 10, 20      |

The alert is inserted with `released_at` empty and `release_by` set to 100 seconds after the failure reached ingest. It is released when the agent has written the sentence, or at `release_by`, whichever is first. Releasing means: set `released_at`, write the title (the sentence, or the technical title), and hand it to each alert sink. [The agent's pipeline](https://telemetry.docs.sypnia.com/architecture/agent-pipeline) shows that hand-off, and [Deployment shapes](https://telemetry.docs.sypnia.com/architecture/deployment-shapes) shows the sinks.

The other alert kinds (uptime, a page that got slower, an API route failing, usage, the engine itself) are produced by the pass and the roll-up from numbers, not by this code. Their rules are in [Alerts and the daily summary](https://telemetry.docs.sypnia.com/concepts/alerts-and-daily-summary).

## A problem, as the API returns it

After three people and five failures, `GET /v1/problems/pay-button-does-nothing` answers with the row of `problems`, its analysis, and links:

`GET /v1/problems/pay-button-does-nothing`

```json
{
  "id": "prb_8f3k2m9x4q7w",
  "slug": "pay-button-does-nothing",
  "fingerprint": "88a44b15205cb153",
  "kind": "failed_call",
  "origin": "server",
  "status": "open",
  "regressed": false,
  "title": "POST /v1/payments answered 400 in POST /api/checkout",
  "environment": "production",
  "route": "/checkout",
  "where": { "file": "src/checkout/checkout.tsx", "line": 142, "function": "confirmPayment" },
  "first_seen": "2026-03-12T09:12:04Z",
  "last_seen": "2026-03-12T10:31:47Z",
  "first_release": "4f2a91c",
  "last_release": "4f2a91c",
  "occurrences": 5,
  "people": 3,
  "sessions": 3,
  "resolved_at": null,
  "resolved_by": null,
  "resolved_in_release": null,
  "note": null,
  "analysis": {
    "status": "ready",
    "sentence": "3 people tried to pay today and could not. The Pay button does nothing since yesterday's change.",
    "confidence": "high",
    "runs": 3
  },
  "pull_request": null,
  "url": "https://sypnia.example.com/console/problems/pay-button-does-nothing",
  "created_at": "2026-03-12T09:13:02Z"
}
```

The analysis is shortened here; its full shape is in the [API reference](https://telemetry.docs.sypnia.com/api/problems). `occurrences` is 5 and not 15: each click produced three failures and one occurrence.

## What changed from the system this comes from

| There                                                           | Here                                                                                | Why                                                                   |
| --------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| Error groups keyed by fingerprint and stage                     | Problems keyed by project, environment and fingerprint                              | Multi-project                                                         |
| Grouped once an hour                                            | Every 30 seconds, by the fast path                                                  | The 2-minute promise                                                  |
| Browser and server failures of one request were separate groups | One problem, by trace                                                               | Brief: one cause, one sentence                                        |
| People and sessions per day, from arrays capped at 200          | The same per hour for the timeline, plus `problem_hits` for an exact lifetime count | «3 people» is the product's sentence; it must be exact                |
| A `4xx` was never a server issue; the browser kept its code     | A failed call is no answer, `400`, or `500` and above, in the browser too           | So an app with only the browser SDK gets problems                     |
| Symbolication inside the hourly job, 200 groups an hour         | After each new or returning problem                                                 | A new problem needs its real file within the 2 minutes, for the agent |
| Chunk and digest rules of one framework inside the fingerprint  | The same rules, as one list per platform                                            | Any framework, not one                                                |
| `hash64` over UTF-16 units, in JavaScript                       | The same, bit for bit, in Rust                                                      | Existing groups keep their fingerprints                               |

## Next
