diff --git a/docs/accounts.md b/docs/accounts.md index 86ec79c..eec9235 100644 --- a/docs/accounts.md +++ b/docs/accounts.md @@ -48,7 +48,7 @@ In the Docker stacks that is the `.env` of the host that runs the server. Then r | Key | Default | What it does | |---|---|---| -| `mode` | `off` | `off` or `local` (`portal` is for the project's own instance, see [Configuration](configuration.md#user-accounts)). Anything else stops startup. The rest of the block is not checked while this is `off`. | +| `mode` | `off` | `off`, `local` or `portal` (see [Portal sign-in](#portal-sign-in)). Anything else stops startup. The rest of the block is not checked while this is `off`. | | `registration` | `open` | `open` or `closed`. When closed, `POST /auth/register` answers `403 registration_closed` and `features.registration` is `false`. People who already have an account keep signing in. | | `mail.host` | none | Required. | | `mail.port` | `587` | 1 to 65535. | @@ -57,7 +57,7 @@ In the Docker stacks that is the `.env` of the host that runs the server. Then r | `mail.starttls` | `true` | When true the send fails if the server does not offer STARTTLS; Beacon never falls back to plain text. Set `false` only for a trusted local relay. | | `mail.tls_skip_verify` | `false` | `true` accepts a mail server certificate that cannot be verified (self-signed, private CA, wrong name). The connection is still encrypted, but the server is not checked, so use it only for a mail server you run yourself on a network you trust. Applies to account mail and alert mail. Startup logs a warning while it is on. No effect with `starttls: false`. | -`BEACON_SMTP_PASSWORD` is the only account secret that comes from the environment. A mistake in the +`BEACON_SMTP_PASSWORD` is the only secret `local` accounts read from the environment. A mistake in the block stops startup with an error naming the key. An `smtp` block left under `accounts` stops startup too, with a message saying it moved to `mail`. Port 465 (implicit TLS) is not supported; use a submission port that offers STARTTLS. @@ -273,6 +273,69 @@ An hourly task (`users_cleanup`) deletes, once they are more than a week past th A live session or token is never touched by it. +## Portal sign-in + +`accounts.mode: portal` is designed to work only with the project's own MeshMapper instance, +which signs its users in through the MeshMapper portal. Users sign in at the portal and Beacon +trusts its answer. The portal is not part of Beacon and its side is not documented here. It is +not supported for other deployments: use `local`. + +```yaml +accounts: + mode: portal + portal: + url: https://portal.example.org + client_id: beacon-example +``` + +``` +BEACON_PORTAL_SECRET=... +``` + +| Setting | What it does | +|---|---| +| `accounts.portal.url` | The portal's base address. Must be an `https` URL with no credentials, query or fragment. | +| `accounts.portal.client_id` | The id the portal knows this server by. Required. | +| `BEACON_PORTAL_SECRET` | This server's client secret at the portal. Environment only, never in the file. Required. | + +A missing or malformed value stops startup with an error naming it. `DOMAIN` (or `WEB_DOMAIN`) +is needed as for `local`. The `mail` block is not read, and nothing is mailed. + +How a sign-in goes: + +1. The web app sends the browser to `GET /api/v1/auth/portal/start?return=`. The server + stores a one-time state and a PKCE verifier for 10 minutes, sets the `beacon_portal` cookie, + and redirects to `/portal.php` with `client_id`, `state`, an S256 + `code_challenge` and `redirect_uri`. `return` must be a path on the same site; anything else + becomes `/`. +2. The portal signs the user in and sends the browser back to + `/api/v1/auth/portal/callback` with `code` and `state`. That is the + redirect address to register at the portal. +3. The server checks `state` against the cookie (each state works once), then posts the code, + the verifier, `client_id` and the secret to `/portal_beacon_api.php?action=token`. + It waits at most 10 seconds and accepts the answer only if it is `200` with a JSON `user` + object of `id`, `username` and `display_name`. +4. `id` is the account key: the first sign-in with a new `id` creates the user, later ones + find it and refresh its username and display name. A username someone else holds gets a + numeric suffix; a blank one becomes `member`. +5. The browser lands on `` with the session cookie set. Any failure, + a cancel at the portal included, lands on `/?view=signin&error=portal`, + and the server logs `portal sign-in failed` with the reason at `WARN`. + +What differs from `local`: + +- `/api/v1/info` reports `features.accounts: "portal"` and `features.portalUrl`, and + `features.registration` is always `false`. `accounts.registration` changes nothing. +- A portal user has no password and no email address in Beacon. The sign-up, verify, sign-in + and reset routes, and `POST /me/password` and `POST /me/email`, answer `404 portal_managed`. +- Deleting the account is confirmed with the username instead of the password. +- Email alerts are not available: `alerts.email.enabled: true` stops startup. Push alerts work. +- On a read-only server both portal routes answer `503 read_only`. +- A user disabled in Beacon cannot sign in, whatever the portal says. + +Each portal route is limited to 20 requests a minute per client. The routes are in the +[API contract](api-contract.md#user-accounts). + ## Disabling accounts again Set `accounts.mode: off` and restart. The routes answer `404 accounts_disabled` and clients hide diff --git a/docs/api-contract.md b/docs/api-contract.md index 50de3ba..59c4c74 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -155,8 +155,8 @@ on `/packets` and `v1::` on `/nodes` and `/observers`. | `/channels` | Can't be combined with a positive `cursor` (`400`). | When `hasMore` | - `nextCursor` stays on every page with `hasMore` (except a sorted `/nodes` list, which has - none) and keeps its meaning: rows strictly older than that millisecond. Paging by `cursor` - alone gives the same pages as before and still skips rows tied on the boundary millisecond. + none) and means rows strictly older than that millisecond. Paging by `cursor` alone skips + rows tied on the boundary millisecond. - On `/packets`, `/nodes` and `/observers`, send both: `cursor` set to `nextCursor` and `pageCursor` set to `nextPageCursor` when the page has both, `cursor` alone otherwise. A server older than 2.1.0 ignores `pageCursor` and still moves forward by `cursor`. Treat @@ -197,11 +197,10 @@ Comma-separated list params (`iatas`, `scopes`, `payloadTypes`, `routeTypes`) ta `/packets` params: `payloadType` or `payloadTypes` (comma-separated integers), `payloadTypeName` (`advert`, `group_text`, `trace`, ...; used when no number is given), `routeType` or `routeTypes`, the location filters, `scope` or `scopes` (comma-separated), `since`, `until`, `hashPrefix` (4 to 16 hex characters of the packet hash), `cursor`, `pageCursor`, `limit`. Filters OR within themselves and AND across each other. The cursor is epoch ms: global `lastHeardAt` order without an IATA filter, and the time heard at the requested sites when one is set, so a filtered list stays bounded to those IATAs. With `hashPrefix` the order and cursor use global `lastHeardAt` even when an IATA filter is set. -With an IATA or region filter and no `hashPrefix` (a region page), the list is ordered by the time the packet was last heard at the requested sites, newest first. While the server trusts its site read model (see [Operations](operations.md#read-models-packets-by-site)), `pageCursor` applies and those pages are the same as before with three differences: +With an IATA or region filter and no `hashPrefix` (a region page), the list is ordered by the time the packet was last heard at the requested sites, newest first. While the server trusts its site read model (see [Operations](operations.md#read-models-packets-by-site)), `pageCursor` applies to those pages: - Packets heard at the same site time are ordered by `packetHash`, descending. - A `pageCursor` page returns the rows in the cursor's millisecond that a millisecond `cursor` skips, as on `/packets` without a region (see [Exact page cursors](#exact-page-cursors)). -- Where many observers heard a site's packets, the previous statement could end a page short, end a walk early or move `nextCursor` past rows it never returned; the new page returns those rows. While it does not, region pages answer `503` with `Retry-After: 30`; see [Pages that wait for server data](#pages-that-wait-for-server-data). @@ -764,13 +763,12 @@ edges spanning more than 180 degrees are rejected. | `GET /observers/{observerId}/adverts` | Page of adverts the observer heard. Cursor is the observation ID. | An observer's `brokers` are the brokers it was seen on in the last 30 days, and the `broker` filter -of `/observers` and `/observers/directory` matches only within those 30 days (both from 2.3.1; before, -neither had a time limit). Take the filter's values from `GET /brokers/sources`. +of `/observers` and `/observers/directory` matches only within those 30 days (both from 2.3.1; an older +server applies no time limit). Take the filter's values from `GET /brokers/sources`. -`/observers` pages by each observer's last-seen time, which the summary does not include. Since -2.1.0 `nextCursor` is that time for the last row and is present whenever `hasMore` is true. -Before, it came from the last status message and was missing when the last row had none, so a -walk by `cursor` skipped most observers. Paging by `cursor` alone can still skip observers that +`/observers` pages by each observer's last-seen time, which the summary does not include. +`nextCursor` is that time for the last row and is present whenever `hasMore` is true (a server +before 2.1.0 can leave it out). Paging by `cursor` alone can skip observers that share a millisecond (presence updates often stamp many at once); `pageCursor` reaches all of them. The `points` of the telemetry response are ordered by time. `interval=1h` returns the stored snapshots as they @@ -934,7 +932,7 @@ To page `/routes`, send the last item's `lastSeen` as `cursor` and its `id` as ` The single `iata` is matched exactly as sent, so lowercase matches nothing. An `iata` that ends in a blank (`YYZ` followed by a space) matches no region and returns `200 []`. -`iatas` is new in 2.1.0: older servers, and 2.1.0 development builds from before it, ignore it and answer with every IATA's routes. A client that asks for a region checks each route's `iata`; when one is outside the list, it pages without `iatas` and filters, as before. +`iatas` is read from 2.1.0. An older server ignores it and answers with every IATA's routes, so a client that asks for a region checks each route's `iata`; when one is outside the list, it pages without `iatas` and filters the rows itself. `/routes` and `/routes/search` return a plain array of routes: @@ -1130,7 +1128,7 @@ Swagger shows. Servers older than this endpoint return `404`. See | Flag | Meaning | |---|---| | `polling` | True when [repeater polling](repeater-polling.md) is enabled on this server. Clients show the reading charts only when it is true. | -| `accounts` | A string: `"off"`, `"local"` or `"portal"`. `"local"` and `"portal"` mean [user accounts](#user-accounts) are on; `"portal"` is sign-in through the MeshMapper portal. | +| `accounts` | A string: `"off"`, `"local"` or `"portal"`. `"local"` and `"portal"` mean [user accounts](#user-accounts) are on; `"portal"` is sign-in through the MeshMapper portal ([Portal sign-in](accounts.md#portal-sign-in)). | | `registration` | True when new sign-ups are open. Only meaningful when `accounts` is `"local"`; always `false` for `"portal"`. | | `portalUrl` | The portal's base address. Present only when `accounts` is `"portal"`. | | `telemetryRequests` | True when [telemetry requests](#telemetry-requests) are on: polling and accounts are on, `BEACON_SECRET_KEY` is set and `polling.requests_per_user` is not 0. | @@ -1301,7 +1299,7 @@ Backup details are in [Backup and export](backup-export.md). ### User accounts -Off unless `accounts.mode` is `local` ([User accounts](accounts.md)) or `portal` (the project's own MeshMapper instance only, see [Configuration](configuration.md#user-accounts)). With it off every route below, +Off unless `accounts.mode` is `local` ([User accounts](accounts.md)) or `portal` (the project's own MeshMapper instance only, see [Portal sign-in](accounts.md#portal-sign-in)). With it off every route below, under `/api/v1/auth` and `/api/v1/me`, answers `404` with code `accounts_disabled`, and no cookie is set. These are separate from the operator records at `/admin/accounts`. @@ -1548,7 +1546,7 @@ Oldest first. `poller` and `latestReadingAt` are `null` when there is none; `lat newest trusted reading. `statusReasonDays` (integer) is present only with the `offline` code. A password is never returned, only `hasPassword`. `updatedAt` is when the request last changed: an edit by the user, or a change of `status` or `statusReasonCode` made by the server (from 2.3.1; -before, a status change that followed an election or a claim left it unchanged). +an older server leaves it unchanged when the status change follows an election or a claim). `poller.state` is what the poller's own latest live claim says about this repeater, so a user can see why a poll is not working even while `status` is `active`. `poller.stateAt` is epoch ms when that claim @@ -1993,7 +1991,7 @@ corescope-claim/v1|||||||||| From 2.3.1 Beacon checks it: -- A message with no `sig` is unsigned. It is handled as before. +- A message with no `sig` is unsigned. It is processed without a signature check. - A message with `sig` that does not verify is dropped and logged as a warning. So is one with more or fewer than one reading, a `sig` that is `null` or not 128 hex characters, a time in another form, a missing or negative `reply_hops`, a `node_id` that is not 64 hex characters, a diff --git a/docs/configuration.md b/docs/configuration.md index 4c03485..42639ae 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -31,6 +31,7 @@ to open). | `BEACON_SECRET_KEY` | unset | 32 random bytes in base64. Seals the guest passwords of [telemetry requests](telemetry-requests.md). See [BEACON_SECRET_KEY](#beacon_secret_key). | | `BEACON_PUSH_SECRET` | unset | The Push secret from registering the server with the push server. Required when `alerts.push.enabled` is true; has no YAML key. See [Alerts](alerts.md#push). | | `BEACON_SMTP_PASSWORD` | unset | Password for `mail.username`. Read only when `accounts.mode` is `local`; it has no YAML key. See [User accounts](#user-accounts). | +| `BEACON_PORTAL_SECRET` | unset | This server's client secret at the sign-in portal. Required when `accounts.mode` is `portal`, where a missing one stops startup; it has no YAML key. See [User accounts](#user-accounts). | | `LOG_LEVEL` | `info` | `debug`, `info`, `warn` or `error`. Overrides `log.level`. Anything else stops startup. | | `LOG_FORMAT` | `text` | `text` or `json`. Overrides `log.format`. Anything else stops startup. | | `BEACON_CPU_PROFILE_DIR`, `BEACON_CPU_PROFILE_UNTIL` | unset | Enable a bounded CPU capture in production. See [Profiling](profiling.md). | @@ -178,11 +179,7 @@ layout sets the sizes. - **`single`** is the rollback: one API pool (`api_legacy`) on the server's own settings, and every guard family only observes, whatever `guards.enforce` says. -`database.slow_pool_size` is no longer read. It sized the `api_slow` pool of the 2.1 development -builds, which ran region and message statements that could read whole site histories; those -pages now seek from their window (see -[Deep region and message pages](operations.md#deep-region-and-message-pages)) and run on the -pools above. A config that still sets the key loads as before, and the server logs +`database.slow_pool_size` is not read. A config that sets it still loads, and the server logs `config: database.slow_pool_size is no longer used and is ignored; remove it` at `WARN` at startup. Remove the key. @@ -424,17 +421,31 @@ except a leftover `smtp` block, which always stops startup (it moved to the top- | Key | Default | What it does | |---|---|---| -| `mode` | `off` | `off` or `local`. | -| `registration` | `open` | `open` or `closed`. | +| `mode` | `off` | `off`, `local` or `portal`. | +| `registration` | `open` | `open` or `closed`. Sign-up is always closed in `portal` mode, whatever this says. | +| `portal.url` | none | Required with `portal`. The portal's base address: an `https` URL with no credentials, query or fragment. | +| `portal.client_id` | none | Required with `portal`. The id the portal knows this server by. | Accounts need the server's public address, for the links in mail and the cookie's `Secure` flag. It is `https://` followed by `WEB_DOMAIN` from the environment, or `DOMAIN` when `WEB_DOMAIN` is not set (plain `http` for `localhost` and `127.0.0.1`). The Docker stacks already set `DOMAIN`. With -neither set, `mode: local` stops startup with an error naming `DOMAIN`. The old `accounts.public_url` -key is no longer read; a leftover one is ignored with a warning at startup. +neither set, `mode: local` or `mode: portal` stops startup with an error naming `DOMAIN`. The old +`accounts.public_url` key is no longer read; a leftover one is ignored with a warning at startup. -A third mode, `portal`, exists for the project's own MeshMapper instance. It is not supported for -other deployments. +`portal` is designed to work only with the project's own MeshMapper instance: users sign in at +the MeshMapper portal and Beacon keeps no password or email address. The portal is not part of +Beacon and is not documented here. It is not supported for other deployments: use `local`. The client secret is `BEACON_PORTAL_SECRET` in +the environment, never in the file. `portal` does not read the `mail` block, and +`alerts.email.enabled: true` stops startup with it. See +[Portal sign-in](accounts.md#portal-sign-in). + +```yaml +accounts: + mode: portal + portal: + url: https://portal.example.org + client_id: beacon-example +``` `local` sends its mail through the top-level `mail` block, which email alerts share. It is checked only when `accounts.mode` is `local`. diff --git a/docs/mobile/privacy.md b/docs/mobile/privacy.md index 91fc8cd..8e15f16 100644 --- a/docs/mobile/privacy.md +++ b/docs/mobile/privacy.md @@ -1,6 +1,6 @@ # BEACON Mobile Privacy Policy -_Last updated: November 18, 2026_ +_Last updated: November 30, 2026_ BEACON Mobile ("the app") is an open-source iOS and Android client for Beacon, a real-time analyzer for MeshCore radio mesh networks. This policy explains what @@ -27,7 +27,9 @@ token for that server. address, reset a password, tell you when a new app signs in or your password or email address changes, and deliver any email alerts you turn on. - **What the app stores:** the sign-in token, kept in the platform's secure storage (the iOS Keychain or - Android Keystore) and removed when you sign out. The app does not keep your password. + Android Keystore) and removed when you sign out. While you are signed in, the app also keeps your + display name with its settings, so it can show which account each server uses. The app does not keep + your password. - **Ending it:** you can sign out of any device and delete your account in the app's profile screen or on the web. Deleting removes your user record, sessions and everything attached to the account from that server. A sign-in lasts at most a year, and you can end it earlier from the devices list. @@ -53,9 +55,10 @@ that server, and deleting your account removes it. back to you, stops being used when that app sign-in ends, and the server deletes it with your account. Each alert is encrypted with your device's key, so the push server cannot read it. To catch abuse it records which server sent a notification to which handle, when, its size and a - hash of the encrypted message. An alert names a radio - and what happened to it. You choose in your profile whether alerts reach you by push, by email to - your account's address, or both. + hash of the encrypted message. The app keeps the handle and the key in the platform's secure storage. + When you sign out or remove the server from the app, it asks the push server to delete the handle and + removes its own copy. An alert names a radio and what happened to it. You choose in your profile + whether alerts reach you by push, by email to your account's address, or both. - **Sign-in through a portal.** Some servers sign you in through the MeshMapper portal. The server then stores only the username and display name the portal gives it, and no password or email address. @@ -64,8 +67,10 @@ that server, and deleting your account removes it. The app stores its settings locally, using the platform's standard app storage: the Beacon servers you have added, your selected region, theme, language and map -preferences. This data never leaves your device unless you back up your device -through Apple or Google. Deleting the app deletes it. +preferences, and your Atlas for each server. This data never leaves your device +unless you back up your device through Apple or Google, with one exception: on a +server with synced Atlas, signing in stores your Atlas on that server (see Synced +Atlas above). Deleting the app deletes it. ## Network connections the app makes diff --git a/docs/operations.md b/docs/operations.md index 659c048..4ddff9a 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -385,9 +385,7 @@ Each is one `CREATE INDEX CONCURRENTLY`: Upgrading from 2.0.x, `054` to `056` and `059` build on tables the same startup created and filled nothing into yet, so they are instant, and `057` reads `channel_messages` (about 200,000 -rows on a large deployment) in well under a second. On a server that already runs a 2.1 -development build, the tables are full: on a production-size copy `054` took 2.0 s, `055` 0.5 s, -`056` 0.3 s, `057` 0.2 s and `059` 1.9 s. No pre-build is needed. To pre-build them anyway, run +rows on a large deployment) in well under a second. No pre-build is needed. To pre-build them anyway, run the pre-deploy check above, then each statement on its own in autocommit mode, exactly as written (`054`, `055` and `059` only where `packet_sites` exists, `056` only where `channel_message_iatas` exists): @@ -912,9 +910,12 @@ TRUNCATE channel_message_iatas; Then restart the server. It backfills and verifies again as on the first install. -A later release will drop `idx_channel_messages_channel` and `idx_channel_messages_sent_brin`. -Run a release with this read model (2.1.0 or later) for at least a week before upgrading to -that one. +The two older `channel_messages` indexes from the baseline schema are still present in 2.3.4; +no migration drops them. `idx_channel_messages_channel` (`channel_id, sent_at DESC`) is still +read: `/channels/{id}/messages` with `since` uses it when `since` leaves few of the channel's +messages. `idx_channel_messages_sent_brin` is not read by any statement in the server's plan +checks; `idx_channel_messages_sent` covers the same column. It only costs write time and a +little disk. Leave both in place. ## Read models: packets by site @@ -1215,10 +1216,7 @@ old `since` is effectively the whole message history. On a production-size copy messages) that took 2,907 buffers and 148 ms. These pages run on the pool their plan class picks (`api_custom`, 35 s; `api_legacy` under the -`single` layout), like every other page. The 2.1 development builds ran the sparse ones (a -narrow window, an `until` well in the past, rare payload types over busy sites, and `/messages` -with `iatas` and `since` or `scope`) on a separate `api_slow` pool with a 120 s statement -limit. That pool and its `database.slow_pool_size` key are gone. +`single` layout), like every other page. **A window.** A region page with a window seeks from it. Its rows are first heard in `[since, until]`, so almost all of them were heard at a site within 30 minutes of that: each @@ -1264,45 +1262,12 @@ and message statement a request runs, page by page): | Three sites and a scope, `until` 24 hours back, 3 pages | 1,294,780, 3.7 s | 6,766, 52 ms | | The 13 busiest IATAs, the last 75 minutes, limit 200, 2 pages | 65,485, 826 ms | 14,361, 119 ms | -On production the busiest-site `until` page took 48-51 s with a cold cache before this change -(about 181,000 blocks read per call). Message pages are in +Message pages are in [Read models: channel messages by site](#read-models-channel-messages-by-site). A server whose `config.yaml` still sets `database.slow_pool_size` starts as before and logs `config: database.slow_pool_size is no longer used and is ignored; remove it` at `WARN`. -### Reverting to the read-model fallbacks - -If the read-model pages must be served while a model is not trusted, as in earlier releases, -revert two server commits on `dev` rather than rolling back the image, newest first: the one -that removed the `api_slow` pool (it adds migrations `054` to `057`), then the one that removed -the fallbacks (region, scope and advert pages answer `503` until their read model is ready). -Find them with `git log --oneline -- db/pools.go`: - -```bash -git revert --no-edit -``` - -Then build, deploy and restart; no configuration change is needed, because the reverts also -restore the pool and its default of 8 connections (an explicit `slow_pool_size` in `config.yaml` -still wins). Migrations `054` to `057` stay applied; the restored statements don't read their -indexes. What to expect: - -- Untrusted region `/packets` pages, channel message pages and observer advert pages are served - by the previous statements again, with no `503` from a read model. -- All four previous statements (region, per-channel and all-channel messages, adverts) run on - `api_slow`: 8 connections, like the old `api_legacy`, ungated, with the 5 s connection wait and - a 120 s statement limit (the old pool had no limit). The total connection count grows by 8. -- If migration `046` (the drops release) has run, rebuild `idx_observations_observer_id` first, - because the restored adverts statement reads it: - - ```sql - CREATE INDEX CONCURRENTLY idx_observations_observer_id ON packet_observations USING btree (observer_id, id); - SELECT indisvalid AND indisready FROM pg_index WHERE indexrelid = 'idx_observations_observer_id'::regclass; - ``` - - The second statement must print `t` before you deploy. - ## Postgres settings The stacks in this repo run stock `postgres:16-alpine` with no tuning. The settings below suit @@ -1751,12 +1716,40 @@ The response's `config.guards.enforce` shows the new list. Add the same list to enforcing, `PUT` the list without that family (`[]` for none). `beacon_guard_refused_total` then counts real refusals. -`other` and `routes` are the families to start with. The rest are not ready in this release: -`channel_messages` statements are not guarded yet, and the packet and stats families still -run statements that later releases make cheaper. Their release notes will say when each is -ready, roughly `channel_messages` first, then `packets_global`, then `packets_region` and -`packets_window`, then `stats` and `packet_detail`. `packets_window` may stay observed for -good. +While a family is enforced, each of its requests that reaches the database (cache hits don't) +is held to three limits: + +- **Per client.** One client IP has at most 4 such requests in the database at once. A fifth + waits up to 5 s for a slot, then gets `429` `rate_limited` with `Retry-After: 1`. +- **Connection.** A statement waits at most 5 s for a pooled connection, then the request gets + `503` `service_unavailable` with `Retry-After: 2`. +- **Database time.** The request's statements are cancelled once 5 s (entity), 10 s (list) or + 30 s (aggregation) have passed since its first statement began, and the request gets `503` + `deadline_exceeded` with `Retry-After: 5`. + +A family that is not enforced runs every request to the end and only counts, in +`beacon_guard_would_refuse_total`, the ones that would have been refused. The per-client +database time budget never refuses, enforced or not. + +There are eight families, and each public `/api/v1` request belongs to exactly one: + +| Family | Requests | +|---|---| +| `routes` | `/routes`, `/routes/cross`, `/routes/search`, a route's observations | +| `channel_messages` | `/messages`, `/messages/backfill`, `/channels/{id}/messages` | +| `packets_global` | `/packets` with no region and no `since` or `until`; `/packets/backfill` with no region | +| `packets_region` | `/packets` with a region (`iatas`, `iata`, `region` or `regionId`) and no `since` or `until`; `/packets/backfill` with a region | +| `packets_window` | `/packets` with `since` or `until`, with or without a region | +| `packet_detail` | `/packets/{hash}` | +| `stats` | `/stats/*` | +| `other` | everything else | + +The class of each request is in the [API contract](api-contract.md#cost-guards). Every family +can be enforced: the server accepts any of the eight names, and every statement of a guarded +request goes through the guards, the channel message pages included. None is enforced by +default, and the server does not mark any family as unsafe to enforce. The three checks above +are what decide it for your deployment, family by family. Under +`database.api_plan_layout: single` nothing is enforced, whatever the list says. ## Index health @@ -1827,9 +1820,8 @@ reported by position with `cycle="true"`, and the example rules leave it out; Be none. On a large deployment `channels_id_seq` read about 0.02 and every `bigint` sequence about 0. -`channels_id_seq` used to burn about 2,000 values a minute through upsert conflicts (fixed by -the channel write-through); the `BeaconSequenceRunsOutIn90Days` rule in -[Example alert rules](#example-alert-rules) would have caught that. An `integer` sequence +The `BeaconSequenceRunsOutIn90Days` rule in [Example alert rules](#example-alert-rules) warns +when one is being used up fast. An `integer` sequence nearing 1 needs its column changed to `bigint`, a table rewrite to plan off-peak. After deploying, check that `channels_id_seq` stays flat over an hour: diff --git a/docs/releases.md b/docs/releases.md index 6e2f456..8f3766b 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -3,7 +3,8 @@ ## Version numbers From 2.0.0, beacon-server and beacon-web share the same major and minor version. Patch numbers -move on their own: server 2.3.3 shipped with web 2.3.2. Keep both on the same `X.Y`. +move on their own: server 2.3.3 shipped with web 2.3.2. Keep both on the same `X.Y`. BEACON +Mobile follows the same rule; see [BEACON Mobile](#beacon-mobile). A server release can raise the oldest Beacon Web and BEACON Mobile versions it accepts, as 2.3.4 does. Its entry in [Upgrading](upgrading.md) says so; upgrade the web container with the server @@ -34,7 +35,7 @@ see [Troubleshooting](troubleshooting.md#docker-compose-up-fails-with-403-forbid ## Cutting a release Maintainers only. Releases are cut by hand, not from the GitHub UI, and release commits are -signed. The flow is the same in both repos; only the version bump differs. +signed. The flow is the same in beacon-server and beacon-web; only the version bump differs. 1. Make sure `dev` is green in CI. 2. Bump the version on `dev`: @@ -57,8 +58,54 @@ beacon-docs follows the same branches without a version: open a PR from `dev` in In every repo a check rejects a PR into `main` that does not come from that repo's `dev` branch. +## BEACON Mobile + +The app lives in [beacon-flutter-app](https://github.com/MeshCore-Beacon/beacon-flutter-app). +Its branches and release PR are the same as above: work lands on `dev`, a release is a PR from +`dev` into `main` merged as a merge commit, and the merge commit is tagged `vX.Y.Z`. What +differs is that nothing is built from the tag. A maintainer builds the app locally and sends it +to the stores. + +**Version.** `version` in `pubspec.yaml` is `X.Y.Z+N`. `X.Y` is the server and web release line, +and the patch number moves on its own. The `+N` in the file is not used: every build takes the +Unix time it was built at as its build number, the same one for the Android APK, the Android +App Bundle and the iOS build, so a later build always has a higher number. + +**Dev and production builds.** `./Build.sh` makes all three files in one run, as a dev build or +a production build: + +| | Dev | Production | +|---|---|---| +| Goes to | testers (TestFlight, Google Play testing tracks) | the App Store, Google Play and the GitHub release | +| Version the app reports to itself | the build number | `X.Y.Z` | +| File names | the build number | `X.Y.Z` | + +Both carry `X.Y.Z` as the version the stores show. A dev build is never held back by a server's +minimum app version, because it does not report an `X.Y.Z` to compare. Each store reviews a +production build before it reaches users. + +**Store text.** The listing text is in the repo under `store/`: `store/apple/` for the App +Store (name, subtitle, description, keywords, What's New, review notes) and `store/google/` for +Google Play (title, descriptions, release notes). Change it there with the release, and the +maintainer pushes it to the stores with the build. + +**Cutting an app release.** + +1. Bump `version` in `pubspec.yaml` on `dev` and update the What's New text under `store/`. +2. Open the `Release vX.Y.Z` PR from `dev` into `main`, merge it as a merge commit, tag the + merge commit and fast-forward `dev`, as in [Cutting a release](#cutting-a-release). +3. Build the production build, upload it to both stores and submit it for review. +4. Publish the GitHub release for the tag with the release notes and the APK attached. An app + installed from that APK sends its user back to the GitHub releases page for updates. + +**The server's minimum app version.** A server refuses apps older than `minAppVersion` and shows +them an update screen. A server release that raises it should not go out until that app version +is live in both stores, or users are locked out with no update to install. Raise it only for a +change that breaks older apps. + ## Where to find release notes Each repo's GitHub Releases page: -[beacon-server](https://github.com/MeshCore-Beacon/beacon-server/releases) and -[beacon-web](https://github.com/MeshCore-Beacon/beacon-web/releases). +[beacon-server](https://github.com/MeshCore-Beacon/beacon-server/releases), +[beacon-web](https://github.com/MeshCore-Beacon/beacon-web/releases) and +[beacon-flutter-app](https://github.com/MeshCore-Beacon/beacon-flutter-app/releases). diff --git a/docs/upgrading.md b/docs/upgrading.md index a3832e0..93e601f 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -549,9 +549,10 @@ before going back to 2.0.x, the extra step in [Rolling back from 2.1](#rolling-b Region `/packets` pages, channel message pages filtered by `iatas` (or by `scope` without `since`), and observer advert pages are served only from their read model or backfilled data. While that is not ready they answer `503` with `Retry-After: 30`; there is no fallback to the -previous statements. The kill switches above turn those pages off instead of serving them from -the previous statements. To get the fallbacks back, revert their two server commits; see -[Reverting to the read-model fallbacks](operations.md#reverting-to-the-read-model-fallbacks). +previous statements, and no setting brings one back. The kill switches +(`readmodels.cmi.enabled` and `readmodels.packet_sites.enabled`) turn those pages off instead of +serving them from the previous statements. The only way to serve them without the read models +is the 2.0.7 image; see [Rolling back from 2.1](#rolling-back-from-21). #### Packet sites fill counts observations