Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5258096
feat(core)!: require the instance id and seal it in the database
Medformatik Nov 24, 2026
b6067e8
feat(contributions-api): trust a relay's token for the enrollment limit
Medformatik Nov 24, 2026
1a6d33a
fix(contributions-api): take the instance id explicitly when erasing …
Medformatik Nov 24, 2026
3d0b422
feat(contrib-core)!: version every signed claim body with "v": 1
Medformatik Nov 24, 2026
2ab54ee
fix(manifests)!: apply OpenMapX's community manifest rules
Medformatik Nov 24, 2026
d875725
docs(federation): fix the compose example for an OpenMapX install
Medformatik Nov 24, 2026
2d53fe9
docs(ingest): document the routing, speed and status routes in OpenAPI
Medformatik Nov 24, 2026
09976bf
docs(release-notes): note the instance id, relay, claim version and m…
Medformatik Nov 24, 2026
a979191
test: give the test projects the required instance id
Medformatik Nov 24, 2026
09527cb
fix(ci): qualify the images with the required instance id and its seal
Medformatik Nov 24, 2026
69d8fcf
docs: list the required instance id in .env.example and the dev command
Medformatik Nov 24, 2026
84f683d
fix(federation): run federation-admin as the sealed instance id only
Medformatik Nov 24, 2026
41e058c
fix(contributions-api): warn when a relay's token does not match
Medformatik Nov 24, 2026
acffd81
refactor(ingest): read the instance id of /feeds/status once at regis…
Medformatik Nov 24, 2026
af1d9e5
fix(federation): hold actor and peer instance ids to the DNS-name gra…
Medformatik Nov 24, 2026
fa4b1dc
docs: say how to replace a wrongly sealed instance id, and pin Caddy
Medformatik Nov 24, 2026
b8a927b
build: pin the OpenMapX product contracts to 19754a18
Medformatik Nov 25, 2026
0bf0dd5
feat(manifests): mark the settings each service cannot start without …
Medformatik Nov 25, 2026
958ebbc
fix(ci): expect the sealed instance id among the qualified runtime ch…
Medformatik Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ DATABASE_URL=postgres://openconditions:openconditions@localhost:5432/openconditi
# OPENCONDITIONS_SECRETS_KEY_FILE may name a file holding it instead.
OPENCONDITIONS_SECRETS_KEY=

# Instance id (REQUIRED): a lower-case DNS name, usually the instance's public
# host name, e.g. maps.example.org. Set it once, before the first start, to the
# same value on every OpenConditions service of the instance. The first ingest
# start seals it in the database, and every service refuses another id; it is
# part of every record id, so it never changes.
OPENCONDITIONS_INSTANCE_ID=

# HTTP server (optional; defaults shown)
PORT=4100
HOST=0.0.0.0
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ Requirements:
```bash
pnpm install

# Run the ingest service against a local PostGIS (any reachable PostGIS works):
# Run the ingest service against a local PostGIS (any reachable PostGIS works),
# with a secrets key kept in a file Git ignores and a development instance id;
# the database is sealed to both on the first start:
[ -f .secrets-key ] || (umask 077 && openssl rand -hex 32 > .secrets-key)
DATABASE_URL=postgres://postgres:postgres@localhost:5432/openconditions \
OPENCONDITIONS_SECRETS_KEY_FILE="$PWD/.secrets-key" \
OPENCONDITIONS_INSTANCE_ID=dev.localhost \
pnpm --filter @openconditions/ingest dev

# Work on the Python resolver:
Expand Down
4 changes: 4 additions & 0 deletions LICENSING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ default. Packages that carry a different license have their own `LICENSE` file
and a matching `license` field in their `package.json` (or `pyproject.toml`);
that per-package license takes precedence for that package.

The OpenMapX extension bundle (`extension.json`) installs only the ingest and
contributions services, so it declares their licence, AGPL-3.0-or-later, and
every service manifest declares the licence of the service it runs.

The third-party Docker images OpenConditions runs alongside (PostGIS, and — when
self-hosting OpenMapX — Valhalla, Redis, …) run as **separate containers
communicating over the network**. They are not linked into OpenConditions' code
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ pnpm build

DATABASE_URL=postgres://postgres:postgres@localhost:5432/openconditions \
OPENCONDITIONS_SECRETS_KEY_FILE="$PWD/.secrets-key" \
OPENCONDITIONS_INSTANCE_ID=dev.localhost \
pnpm --filter @openconditions/ingest dev
```

The service applies its migrations, starts polling the enabled feeds, and serves on `:4100`. Keep `.secrets-key`: a start with another key refuses to read what the first one stored (see [secrets encrypted at rest](#secrets-encrypted-at-rest)).
The service applies its migrations, starts polling the enabled feeds, and serves on `:4100`. Keep `.secrets-key`: a start with another key refuses to read what the first one stored (see [secrets encrypted at rest](#secrets-encrypted-at-rest)). Keep the instance id too: the database is sealed to it (see [the instance id](#the-instance-id)).

### Public API

Expand All @@ -143,7 +144,13 @@ also `minSeverity`, `horizonDays`, `subtype`, a time window `from`/`to` that inc
TraFF is a [complete bounded feed](docs/traff.md), with no page controls or continuation header. `canonical=1` serves the
canonical view: one feature per cluster of features several sources describe, and the fused reading of
a property several sources or the crowd report. Everything is rate-limited; `GET /openapi.json`
describes it all, and [storage](docs/storage.md#read-api) says what each route reads.
describes it all, the routing, speed and status products (`/feeds/status`, `/valhalla/exclusions.json`,
`/segments.geojson`, `/segments/speed.csv`, `/segments/profiles.json`, `/segments/conditions.json`)
included, and [storage](docs/storage.md#read-api) says what each route reads.

Paths never break. A path keeps its meaning, and its responses may gain members but never lose or
change one. A breaking change gets a new path, and the old path keeps serving its contract, so the
paths carry no version prefix.

| Endpoint | Content |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
Expand Down Expand Up @@ -199,6 +206,14 @@ charging layer, the webcam layer and the hazard overlays. A request carrying `Au
public-scope. Reads with a bbox fetch stale on-demand feeds first, waiting at most
`OPENCONDITIONS_ON_DEMAND_DEADLINE_MS` (default 3000). See [services/ingest/README.md](services/ingest/README.md).

## The instance id

Every record an instance originates is named `oc:<class>:<instanceId>:<localId>`, federation peers know the instance by that id, and crowd votes are signed over record ids. The id therefore never changes once records exist. `OPENCONDITIONS_INSTANCE_ID` is required, with no default, on every OpenConditions service: the ingest service, the heavy-feeds ingest process, the contributions API and the federation service, all with the same value. It is a lower-case DNS name, labels of letters, digits and inner dashes up to 63 characters joined by single dots, at most 253 characters, for example the instance's public host name `maps.example.org`.

After migrating, the first ingest process to start seals the id in `conditions.instance_identity`, once. Every service then refuses to start with another id, naming the sealed one, and the contributions and federation services wait at start until the row is there. A service also refuses to start without the variable or with a value that is not a DNS name.

To use another id, for example after sealing a typo on the first start, start the OpenConditions data over: the stored records, the crowd's signed votes and every peer's copies carry the sealed id. Stop every OpenConditions service, drop the schema that holds all of it with `DROP SCHEMA conditions CASCADE` (as the ingest service's role, which owns it), set the new id on every service and start the ingest service first. Under OpenMapX the database is OpenMapX's own, so drop only the `conditions` schema, never the database. Deleting the one row of `conditions.instance_identity` instead is enough only while the ingest service is stopped and no record carries the old id yet: `feature`, `offer` and `situation` have no row with that `instance_id`.

## Secrets encrypted at rest

OpenConditions keeps three kinds of secret in its tables: the OAuth grants of feeds that need an account login (the access and refresh tokens, for example EUMETSAT's), the contributions API's token-issuer private keys, and the federation service's instance private keys. They are stored encrypted with AES-256-GCM under one key, `OPENCONDITIONS_SECRETS_KEY`. The OpenConditions tables never hold that key. Each value is bound to its table, column and row, so a value copied to another row does not decrypt. A dump of the OpenConditions tables therefore holds none of these secrets in clear.
Expand Down
2 changes: 1 addition & 1 deletion atlas/cameras.json
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@
"overpass": {
"url": {
"title": "Overpass URL",
"description": "Base URL of the Overpass instance (http://overpass:80, https://overpass-api.de) or its full interpreter URL (http://overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"description": "Base URL of the Overpass instance (http://openmapx-overpass:80, https://overpass-api.de) or its full interpreter URL (http://openmapx-overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"default": "https://overpass-api.de"
}
},
Expand Down
2 changes: 1 addition & 1 deletion atlas/charging.json
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@
"overpass": {
"url": {
"title": "Overpass URL",
"description": "Base URL of the Overpass instance (http://overpass:80, https://overpass-api.de) or its full interpreter URL (http://overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"description": "Base URL of the Overpass instance (http://openmapx-overpass:80, https://overpass-api.de) or its full interpreter URL (http://openmapx-overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"default": "https://overpass-api.de"
}
},
Expand Down
2 changes: 1 addition & 1 deletion atlas/fuel.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"overpass": {
"url": {
"title": "Overpass URL",
"description": "Base URL of the Overpass instance (http://overpass:80, https://overpass-api.de) or its full interpreter URL (http://overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"description": "Base URL of the Overpass instance (http://openmapx-overpass:80, https://overpass-api.de) or its full interpreter URL (http://openmapx-overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"default": "https://overpass-api.de"
}
}
Expand Down
2 changes: 1 addition & 1 deletion atlas/parking.json
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@
"overpass": {
"url": {
"title": "Overpass URL",
"description": "Base URL of the Overpass instance (http://overpass:80, https://overpass-api.de) or its full interpreter URL (http://overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"description": "Base URL of the Overpass instance (http://openmapx-overpass:80, https://overpass-api.de) or its full interpreter URL (http://openmapx-overpass:80/api/interpreter), as OpenMapX's OVERPASS_URL accepts: queries go to the base URL plus /api/interpreter. Defaults to the public instance, which allows about 10,000 requests a day; point it at a self-hosted Overpass for heavier use. A private host also needs OPENCONDITIONS_EGRESS_ALLOWED_HOSTS.",
"default": "https://overpass-api.de"
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/container-qualification.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ There is no registry login, push, package write, OIDC or privileged artifact con

## What must execute

`scripts/qualify-container-images.py qualify` builds the selected fixed recipe into an untagged OCI archive. The image must run as a non-root user, become healthy using its actual image healthcheck, and pass runtime/native probes on a fresh internal Docker network and owned PG16 database. No host port is published, no operator database or credentials are used, and provider egress is unavailable. Test-only grant/reviewer credentials and a random secrets key (`OPENCONDITIONS_SECRETS_KEY`) are freshly generated for every image. Database readiness uses a real TCP query to the fixture database, rather than accepting the image's temporary bootstrap server.
`scripts/qualify-container-images.py qualify` builds the selected fixed recipe into an untagged OCI archive. The image must run as a non-root user, become healthy using its actual image healthcheck, and pass runtime/native probes on a fresh internal Docker network and owned PG16 database. No host port is published, no operator database or credentials are used, and provider egress is unavailable. Test-only grant/reviewer credentials and a random secrets key (`OPENCONDITIONS_SECRETS_KEY`) are freshly generated for every image, and every service runs with the fixed instance id `qualification.example.org` (`OPENCONDITIONS_INSTANCE_ID`). Database readiness uses a real TCP query to the fixture database, rather than accepting the image's temporary bootstrap server.

- Ingest applies its bundled migrations. For contributions-api and federation, which apply none and wait at boot for the schema version, the script first applies the source's migrations to the fixture database and records them as the ingest service does. For contributions-api, which also waits for the secrets key check, the script then seals that check row with the throwaway key, as the ingest service does, from a small Node script run inside the image; the service verifies the row with its own code at start, so a seal that drifted from the service's format fails qualification. Every Node service returns its status document and exercises native WebCrypto. Federation's default-disabled status is recorded; this does not prove enabled peer or public-host behavior. Independent federation interoperability remains a separate CI gate.
- Ingest applies its bundled migrations. For contributions-api and federation, which apply none and wait at boot for the schema version, the script first applies the source's migrations to the fixture database and records them as the ingest service does. For contributions-api, which also waits for the secrets key check, the script then seals that check row with the throwaway key, as the ingest service does, from a small Node script run inside the image; the service verifies the row with its own code at start, so a seal that drifted from the service's format fails qualification. Ingest seals the instance id itself after migrating. For contributions-api and federation, which wait at boot for that row and refuse another id, the script seals it first the same way, inside the image. After health, the script checks that `conditions.instance_identity` holds the fixture's id. Every Node service returns its status document and exercises native WebCrypto. Federation's default-disabled status is recorded; this does not prove enabled peer or public-host behavior. Independent federation interoperability remains a separate CI gate.
- Ingest additionally exercises its compiled osmium binary on a real OSM fixture, verifies baked feed
credentials and migration metadata, and makes an Impit native request to its own health endpoint.
Polling is explicitly excluded and the remote feed layer stays off.
Expand Down
2 changes: 1 addition & 1 deletion docs/database-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The contributions and federation services apply no migrations. At start they cal
Each OpenConditions service connects as a dedicated role, never as the PostgreSQL superuser; the heavy-feeds process and the federation service share the ingest service's (below). After every migrate, `runMigrations()` calls `conditions.grant_consumer_roles()`, a function of the custom migration that grants two roles by name exactly what they use, each only if it exists. It runs with its caller's rights and no role but its owner (the ingest service's role) may call it:

- `openmapx_tiles_owner` is OpenMapX's role for its traffic tile. OpenMapX's PostGIS service creates it at every start; it cannot log in and owns the function in OpenMapX's `tiles` schema that the tile server calls, which calls `conditions.segment_flow`. It gets `USAGE` on `conditions`, `SELECT` on `road_segment`, `segment_speed`, `source` and `public_license_policy`, and `EXECUTE` on `segment_flow`, `flow_public_licenses` and `flow_osm_credit`: what the tile reads, so credentials, crowd data and every other table stay unreadable to it.
- `openconditions_contributions` is the contributions service's login, which the operator creates as OpenMapX's community extensions guide describes. It gets `USAGE` on `conditions`, `SELECT` on `conditions.__drizzle_migrations` for the schema version and on `conditions.secrets_key_check` to verify its secrets key, and the table privileges its queries use (the identity columns it inserts into need no grant on their sequences): reporters, block list, reports, votes and evidence, the issuer's keys and tokens, the situations and latest readings reports land on, the fused readings they refresh and the feed readings they are checked against. The federation capture triggers run with its rights when it writes a situation or a latest reading, so it also reads the subscriptions and journals into the outbox. It deletes no reporter: the ingest service's sweep does, as the owner, and the reporter strip trigger runs with the deleting role's rights.
- `openconditions_contributions` is the contributions service's login, which the operator creates as OpenMapX's community extensions guide describes. It gets `USAGE` on `conditions`, `SELECT` on `conditions.__drizzle_migrations` for the schema version, on `conditions.secrets_key_check` to verify its secrets key and on `conditions.instance_identity` to verify its instance id, and the table privileges its queries use (the identity columns it inserts into need no grant on their sequences): reporters, block list, reports, votes and evidence, the issuer's keys and tokens, the situations and latest readings reports land on, the fused readings they refresh and the feed readings they are checked against. The federation capture triggers run with its rights when it writes a situation or a latest reading, so it also reads the subscriptions and journals into the outbox. It deletes no reporter: the ingest service's sweep does, as the owner, and the reporter strip trigger runs with the deleting role's rights.

The ingest service's role (`openconditions_ingest` under OpenMapX) owns `conditions` and needs no grant. The heavy-feeds process connects as the same role, since it migrates, grants and may seal the secrets key check like the primary; a role of its own would fail at `CREATE SCHEMA`, at the migration or at the grant step. The federation service connects as the same role too: at every start it creates and drops partitions of `observation`, which only the table's owner may do.

Expand Down
Loading
Loading