Part of [Architecture](https://docs.mapcairn.com/architecture.md), which is built from [ARCHITECTURE.md](https://github.com/MapCairn/mapcairn/blob/main/ARCHITECTURE.md) in the repository, where it is edited.

Unit tests wrap components in `ServicesProvider` with fakes. In non-production builds, `createServices()` accepts overrides from `window.__MAPCAIRN_TEST_SERVICES__`, set with Playwright `addInitScript`, so end-to-end tests script geolocation, search, clipboard, storage and the system theme, and the selection store the site builds none of (`scriptSelection` in `e2e/support/services.ts`: plain references in, a store out that the test reads with `selectedRefs` and changes with `addToSelection` or `replaceSelectionExternally`, and `selectionSubscribers` shows that the host subscribed to it). The scripted store is written out inside the page, because a function cannot cross from the test, so `src/e2eSelectionSeam.test.ts` runs the `FeatureSelection` contract suite against it. It scripts no query yet. A runtime catalogue is scripted with plain data instead, because its methods cannot cross from a test into the page: a spec sets `window.__MAPCAIRN_TEST_CATALOGUE__` to `{ steps, delayMs }`, where each step is what one load answers (a list of definitions, any of them bad, `"fail"` for a rejected request or `"invalid"` for an answer that is not a list) and the last step answers again once they run out, each after `delayMs`. The seam builds the real `createRuntimeLayerCatalogue` from it with the host's decoders and formatters, so the validation and the states are the real ones, and puts it on `window.__mapcairnCatalogue` so a spec can call `refresh()` as a host does (`scriptCatalogue` and `refreshCatalogue` in `e2e/support/services.ts`). A catalogue a spec supplies as the `layers` service wins over the script. The seam is compiled out of production builds, and a test searches the build output to prove it, searching for the marker and for the two window properties the seam reads (the services and the scripted catalogue).
