Slice 1: the ingest edge

bcd6ae2 · gmorell · 2026-12-01 21:54

62 files +2242 -19
Message
{commit_body(@commit)}

Files changed

modified .gitignore
+4 −0
@@ -35,3 +35,7 @@ vigil-*.tar
35 35 npm-debug.log
36 36 /assets/node_modules/
37 37
38 +
39 +# Rust NIF build output (native/*/target) and the built libraries.
40 +/native/*/target/
41 +/priv/native/
modified ROADMAP.md
+5 −1
@@ -216,7 +216,7 @@ libraries to the images.
216 216 - A first SSO login that matches no rule follows the usual invite-only path.
217 217 - **Exit:** a user can create an org and project, copy a DSN, and mint a token. A NEIAM login in group `neiam-admins` lands as admin of org `neiam`.
218 218
219 −### 1. Ingest edge · large
219 +### 1. Ingest edge · large · **done**
220 220 - `Vigil.Ingest.Plug` covering everything under **Wire contract**: auth with a negative cache, decoders with caps, envelope framing, CORS, rate limits with outcome headers, the buffer and the Drain job.
221 221 - `/store/`, `/security/` and `/minidump/` route into the same pipeline. `/minidump/` stores the attachment for slice 12.
222 222 - Items for later slices are kept in `ingest_items` with a `deferred` state, not discarded, so those slices can process the backlog when they land.
@@ -227,6 +227,10 @@ libraries to the images.
227 227 - Tests on the status code, the body and the headers.
228 228 - An optional CI job runs the real sentry-python and sentry-elixir against a test server.
229 229 - **Exit:** both SDKs report success, and nothing is retried or lost.
230 +- **As built:**
231 + - Real sentry-python 3.x and sentry-elixir 14.x run against a live test server (`VigilWeb.SdkConformanceTest`). sentry-elixir gets back its event ids with `result: :sync`.
232 + - **DSNs carry `projects.dsn_id`, an integer.** sentry-python (`int(path.pop())`) and sentry-elixir (`Integer.parse/1`) refuse anything else in that position, so this is the one id that isn't a UUIDv7; the primary key still is.
233 + - The drain claims a batch in one statement, then processes each item in its own transaction, so one bad item can't roll back the rest.
230 234
231 235 ### 2. Events into issues · large
232 236 - **Normalisation:**
modified lib/vigil/accounts.ex
+2 −2
@@ -175,7 +175,7 @@ defmodule Vigil.Accounts do
175 175 def list_invites(%User{id: id}) do
176 176 from(i in Invite,
177 177 where: i.created_by_id == ^id,
178 − order_by: [desc: i.inserted_at],
178 + order_by: [desc: i.id],
179 179 preload: [:consumed_by]
180 180 )
181 181 |> Repo.all()
@@ -284,7 +284,7 @@ defmodule Vigil.Accounts do
284 284 def rotate_invite_for_email(email) when is_binary(email) do
285 285 from(i in Invite,
286 286 where: i.email == ^(email |> String.trim() |> String.downcase()) and is_nil(i.consumed_at),
287 − order_by: [desc: i.inserted_at]
287 + order_by: [desc: i.id]
288 288 )
289 289 |> Repo.all()
290 290 |> Enum.find(&Invite.active?/1)
modified lib/vigil/api_tokens.ex
+1 −1
@@ -14,7 +14,7 @@ defmodule Vigil.ApiTokens do
14 14 @touch_after_seconds 300
15 15
16 16 def list_tokens(%User{id: user_id}) do
17 − Repo.all(from t in ApiToken, where: t.user_id == ^user_id, order_by: [desc: t.inserted_at])
17 + Repo.all(from t in ApiToken, where: t.user_id == ^user_id, order_by: [desc: t.id])
18 18 end
19 19
20 20 def change_token(attrs \\ %{}), do: ApiToken.create_changeset(%ApiToken{}, attrs)
modified lib/vigil/application.ex
+3 −0
@@ -21,6 +21,9 @@ defmodule Vigil.Application do
21 21 Supervisor.child_spec({Task, &declare_group_rules/0}, id: :declare_group_rules),
22 22 {DNSCluster, query: Application.get_env(:vigil, :dns_cluster_query) || :ignore},
23 23 {Phoenix.PubSub, name: Vigil.PubSub},
24 + # The ingest edge's key cache and rate-limit counters (subscribes to
25 + # PubSub for flushes, so after it).
26 + Vigil.Ingest.Keys,
24 27 # Start a worker by calling: Vigil.Worker.start_link(arg)
25 28 # {Vigil.Worker, arg},
26 29 # Start to serve requests, typically the last entry
added lib/vigil/ingest.ex
+99 −0

Click to load diff…

added lib/vigil/ingest/auth.ex
+98 −0

Click to load diff…

added lib/vigil/ingest/buffered_item.ex
+32 −0

Click to load diff…

added lib/vigil/ingest/codec.ex
+94 −0

Click to load diff…

added lib/vigil/ingest/codec/native.ex
+17 −0

Click to load diff…

added lib/vigil/ingest/drain.ex
+118 −0

Click to load diff…

added lib/vigil/ingest/envelope.ex
+129 −0

Click to load diff…

added lib/vigil/ingest/keys.ex
+115 −0

Click to load diff…

added lib/vigil/ingest/outcome.ex
+19 −0

Click to load diff…

added lib/vigil/ingest/outcomes.ex
+60 −0

Click to load diff…

added lib/vigil/ingest/processor.ex
+22 −0

Click to load diff…

added lib/vigil/ingest/processors/client_report.ex
+49 −0

Click to load diff…

added lib/vigil/ingest/rate_limit.ex
+36 −0

Click to load diff…

added lib/vigil/ingest/target.ex
+15 −0

Click to load diff…

modified lib/vigil/organizations.ex
+6 −2

Click to load diff…

modified lib/vigil/projects.ex
+19 −8

Click to load diff…

modified lib/vigil/projects/project.ex
+6 −2

Click to load diff…

modified lib/vigil_web/api/v0/organization_controller.ex
+2 −1

Click to load diff…

modified lib/vigil_web/endpoint.ex
+4 −0

Click to load diff…

added lib/vigil_web/ingest_plug.ex
+260 −0

Click to load diff…

modified lib/vigil_web/live/org_settings_live/members.ex
+3 −1

Click to load diff…

modified mix.exs
+3 −0

Click to load diff…

modified mix.lock
+1 −0

Click to load diff…

added native/vigil_codec/Cargo.lock
+152 −0

Click to load diff…

added native/vigil_codec/Cargo.toml
+24 −0

Click to load diff…

added native/vigil_codec/src/lib.rs
+43 −0

Click to load diff…

added priv/repo/migrations/20261201214610_add_dsn_id_to_projects.exs
+18 −0

Click to load diff…

added priv/repo/migrations/20261201214741_create_ingest_items_and_outcomes.exs
+54 −0

Click to load diff…

added test/support/sdk/sentry_elixir_send.exs
+36 −0

Click to load diff…

added test/vigil/ingest/codec_test.exs
+65 −0

Click to load diff…

added test/vigil/ingest/envelope_test.exs
+73 −0

Click to load diff…

modified test/vigil/projects_test.exs
+2 −1

Click to load diff…

added test/vigil_web/ingest_plug_test.exs
+423 −0

Click to load diff…

added test/vigil_web/sdk_conformance_test.exs
+130 −0

Click to load diff…

Parents: 7bff5e7