Reeve Docs

Docs / Architecture

Client applications

Reeve has two clients. The web application (frontend/: React, TypeScript, Vite, MUI, TanStack Query, Zustand, SignalR and Zod) is the full control surface for residents, operators and administrators. The Android companion (mobile/, .NET MAUI) monitors the house and sends simple commands. Both authenticate with the same server-side session behind an opaque cookie (authentication). Neither holds a bearer token.

This page describes the client model and the rules contributors must keep. Build and test instructions are in development/frontend.md and development/mobile.md. What a user sees is in reference/mobile.md and reference/custom-widgets.md. Cross-cutting client rules are in constraints.md and mobile.

Basic and Advanced

One web application serves two audiences through a basic | advanced view mode. Basic is the default. It trims navigation to household destinations and replaces the technical inventory with a room-grouped Start screen and a per-device drawer. Advanced is the full operator surface. The phone reads the same mode from the user's preferences.

Every surface declares its audience

A new surface states whether it serves Basic or Advanced. Basic never renders a device id, source id, plugin or protocol name, freshness token, raw or unmapped properties or metadata editing, including in attributes such as an accessible name, title or id. A Basic surface may decide from a signal it keeps off screen but must not print it.

The Advanced toggle is derived from navigation

The toggle renders only when the user's permission-filtered navigation holds an Advanced-only destination whose required permissions the user holds, or when the user holds an in-page Advanced capability with no destination (dashboards.edit, dashboards.manage). Everyone else is anchored to Basic and sees no control. Add an Advanced destination to the navigation configuration and the toggle follows. Do not add permissions to a gating list by hand.

Hiding a navigation item never hides its route

A destination missing from Basic navigation stays routable, so bookmarks and deep links work. Only a mode switch made while standing on a destination the new mode hides redirects, with history replacement. Mode is presentation only: the server still refuses a user who forces Advanced.

One formatter, one verdict

State text, units, rounding, locale grouping, capability ordering, cover wording, the unavailability verdict and the on/off words live in shared modules that Basic and Advanced both import. The phone mirrors them in CanonicalValueFormatter and DeviceReachability. Do not copy a rule into a second module (one rule, one module). No client converts units: the unit travels with the value.

Basic tiers capabilities by their catalogue role

Basic shows Control and Reading capabilities, folds Setting behind one "Settings" entry and hides Diagnostic. Advanced shows all. The role is declared once on the canonical model and copied into the descriptor and the TypeScript catalogue.

  • A key with no declared role is a Control when the instance can be commanded and a Reading otherwise. A raw driver property has no role and appears only in Advanced.
  • The analytics numeric-property response carries the resolved role, so a chart can drop a series without knowing its name.
  • A role says whether a row is shown, not whether its history is worth drawing. camera.pan and camera.tilt stay controls and are left out of Basic charts by key, as are unit-less series.
  • A device's mains voltage is a Reading. A sensor's voltage is Diagnostic.

A control with configuration beyond what a resident acts on wraps those rows in DrawerSettings. The Basic drawer shows the primary controls and one collapsed "Settings · N", and a page renders the same children in place. The control knows which rows are configuration. The drawer keeps no list of device types or capability keys. An optional enum select with no value uses the shared NotSetSelect and reads "Not set", never a synthetic "None" item.

A device page shows Overview and History in Basic

The logical device page has Overview, History, Sources, Settings and, in Advanced, Diagnostics. Settings holds the Basic tile editor and the linked helpers, opened from the header's Edit tile button. Panels stay mounted, so a half-edited tile survives a tab change. In Basic the logical page shows only Overview and History. The physical page shows Overview in Basic and adds Diagnostics in Advanced.

A Basic history opens on the device's main reading with the others behind "More readings". It never states a count of withheld readings. Only the operator surface keeps its ten-series caption. See history charts.

Shared presentation rules

Every user-visible string is English

Both clients are single-language English, whatever the browser or phone locale, and a localised surface is a defect. Numbers use the viewer's locale separators. The phone uses no native Picker, because its Android dialog uses the system locale.

Colour schemes are product-owned

The web application builds both palettes from one brand-token module, defaults to light and has an explicit toggle. Pass an explicit default mode, because the component library's default follows the operating system. With CSS variables enabled the theme's palette object holds the light values only, so read the variable form for anything that must switch scheme.

The phone reads a persisted preference (System, Light or Dark) before any page exists and defaults to Dark. Every colour resolves through a semantic light/dark token pair copied from the web's brand tokens. Do not hard-code a colour.

A displayed instant reads in the viewer's time zone

One formatter turns an instant into English text in the zone the viewer's browser reports. It is relative under 24 hours ("5 min ago") and otherwise reads "Oct 26, 18:02", with the year when it is not the current one.

  • A value that lies ahead (an expiry, a renewal) and a time inside a sentence ("since …") read absolute. An instant whose exact value matters carries the precise form, with seconds and year, as its tooltip.
  • The household zone (home.timeZoneId) applies to what the household schedules, such as an automation at 06:00, never to when something happened. There is no per-user time-zone setting.
  • The formatter never waits for home settings. The phone formats through its injected time provider.
  • The Start greeting and date follow the household zone from GET /api/home (the browser's while unread), in bands from 05:00, 12:00, 18:00 and 22:00. This is the one place an instant follows the household's clock.

The onboarding wizard proposes the browser's time zone. The server derives no zone from the language and suggests Etc/UTC when the client sends none. The currency suggestion comes from the language-to-currency table and falls back to USD with locale en-US. The person confirms both.

Silence counts only for a device that reports on a cadence

A client never ages a reading itself and never reads the freshness label to decide reachability. Basic reads two server signals:

  • availability: Offline or Orphaned is unreachable. Online and Unknown are reachable.
  • The additive silent flag on the typed device summary. It is true only for a sensor or presence reporter whose last report is older than Automations:Freshness:SilentAfterSeconds (24 h by default).

A light, switch, outlet, camera or cover reports on change, so a quiet one is healthy. A silent device is greyed, left out of the summary and its averages, and makes no open or closed claim. The phone applies the same verdict through DeviceReachability. Basic surfaces that judge availability from the typed-device list (Start, the Basic energy overview, the drawer) re-read it every five minutes while mounted, because no push frame carries the transition. Server-side freshness is in device model. Never hide a device because it has no quick action or reads unavailable.

A capability's command nature comes from the catalogue

[CanonicalCommand] on a canonical member marks a capability whose write issues a command instead of setting a state the device keeps (cover.state, cover.moving, valve.state, vacuum.command, mediaplayer.command). RestingTokens names values that are also a state to restore (a cover's open and close). SupersededBy names a sibling that states the rest more precisely (a cover's position). The generator copies both into the descriptor and the TypeScript catalogue and refuses a resting token the member does not allow or a sibling that does not exist.

Capturing a scene keeps a command capability only at a resting token, and drops it when the capture also holds the capability that supersedes it, so replaying a captured blind never sends stop after its position. A scene author can still add any command by hand.

Web application

The hub connection recovers by itself and refetches

withAutomaticReconnect gives up after five delays, so the SPA wraps it in its own restart loop and never calls start() twice on one connection. After any reconnect every subscriber refetches, because frames sent while the socket was down are not replayed. The phone raises the same "frames may have been missed" signal. A request for one replica's logs names the replica, because the connection may land on any replica.

Session state is torn down on every principal change

tearDownSessionState advances the session generation and clears the query cache, the view-mode cache and store, the dashboard draft, the workflow editor canvas and the hidden presence-device set. It runs on sign-out, on any session-ending 401, on a failed bootstrap and on an identity swap through a federated callback. Drop the view-mode cache before the store re-seeds from it. Optimistic writers snapshot the session generation and must not touch the cache once it is stale.

Cache policy is set in one place, and the service worker is stamped per build

The frontend nginx sets Cache-Control once, by one map $uri and one server-level add_header:

Content Cache-Control
App shell, sw.js, manifest, unhashed public files no-cache
Content-hashed /assets/ public, max-age=31536000, immutable
Proxied API and hub responses The backend's headers

Each security header is one server-level add_header over a map $uri that is empty for /api/, /hubs/ and /ws/, so nginx adds none to proxied responses (a second content security policy there would refuse the widget runtime's iframe). A location block must declare no add_header of its own, because nginx then drops every inherited server-level header.

The service worker's cache name is a hash of the emitted file names, substituted for __BUILD_ID__ by a Vite plugin. It caches only hashed /assets/ and the app shell and never intercepts /.well-known/. A lazy chunk that fails to load from a tab older than the deploy reloads the page once. System status shows the Version box as Attention while live replicas run different versions.

A dashboard is a recursive container

A dashboard is a recursive structure of rows, columns and leaf widgets, stored as configuration and edited through a draft. Dashboards are personal, administrator-published shared, or pinned subscriptions to a shared one. Editing is an operator capability, so dashboards.edit alone can enable the mode toggle.

A widget's data binding matches by capability key, widened only by unit from the canonical catalogue (an outlet publishes power under a different key than a standalone meter). A key the catalogue does not declare, or declares without a unit, matches exactly.

Every dashboard response, read or write, carries the references it names that no longer resolve (a deleted device or helper), so a client cache never loses them on save. A widget that names one shows a warning strip with a Remove widget action, and a banner above the dashboard counts what it lost. See removed devices.

A user with no dashboard sees an explanation and one action. Nothing is written until the click, so a deleted dashboard does not come back.

  • Advanced, with dashboards.edit and at least one room: "Create a dashboard from my rooms" creates a personal dashboard "My home" with one room panel per room, in room order, in one flow: "grid" leaf.
  • Basic: "Open Start" links to /app, because Basic dashboards are read-only. Advanced has no Start (/app redirects to the dashboard).
  • Without dashboards.edit, or with no rooms, only the explanation shows.

A leaf container may carry flow: "grid" (part of the dashboard definition contract and the SPA schema, stored as opaque JSON). Viewing flows its widgets into CSS columns, one per 460 px of width. Editing shows a single stack, because drag-and-drop sorting assumes one column.

Custom widgets are contained by the browser

A custom widget is a static bundle in an iframe with sandbox="allow-scripts" and no same-origin. A strict content security policy permits no inline script. The widget talks to the host only by message passing. The sandbox is the whole trust boundary. A widget is not a plugin and carries no signing, certification or trust badge.

  • A widget never receives the user's credential.
  • It may touch only devices bound to it in the dashboard configuration. The host bridge checks every action and subscription.
  • Every action key is a real canonical controllable capability key. A write to a critical capability waits for the resident's confirmation in the host.
  • The configuration form is generated from the widget's JSON Schema. A repository's trust level only selects the install warning.

Preview mounts the production runtime with identical sandbox attributes and policy. The bridge intercepts every SDK call, blocks state mutation and returns placeholder data. Preview sessions live in Redis, because one request creates a preview and another, possibly on a different replica, reads its files. Nothing reaches the database. A per-user cap evicts the oldest session.

A widget repository is an OCI artifact (integrity anchored by the layer digest) or a hosted-Git release (anchored by the asset checksum) whose host is on the allowlist. Raw files from a Git tree are not accepted. A stored credential for a private source is attached only when the request host belongs to the repository's provider. Sync runs on one replica, and the database row is what makes a widget installed, so record it only after the files are written. Details are in reference/custom-widgets.md.

Web maps are Leaflet

Geofences, location pickers, presence and location history render over Leaflet with raster tiles and fixed overlay colours in both schemes, sharing one overlay vocabulary. Do not add a second web mapping library. Map and video libraries are mocked in the web unit suite, so test real tiles or playback in a browser test.

History charts

A device's history is one small chart per unit on one shared time axis with linked hover, ordered as the tiles are, with round y ticks fitted to the data. A chart whose series each hold one reading is shown as a sentence. The dashboard chart widget keeps every series of one unit on one chart, because its author grouped them.

The y axis fits the data with a little headroom and always contains every reading. For a unit with natural limits (percent, relative humidity) the rounding stops padding at the limit, so a humidity chart does not end at 105 %. A reading a little past the limit (a 0-254 level shown as 100.4 %) counts as on it.

The server owns what a series means, and the client draws what the chart response says:

  • A step series (a controllable reading) is drawn as steps, with its carried-in value as the first point.
  • A series with heldUntilUtc is drawn flat to that instant.
  • A cumulative counter (any Wh or kWh series) is drawn as the use between readings that the server computed, with no gap however long a step is.
  • The carried-in value has no time of its own, so nothing that states a reading or its time uses it.

The device drawer, the logical page and the dashboard widget therefore draw alike. The server side is in data.

Decimal input reads a point and a comma alike

Every decimal input is a text field read by one parser: an optional sign, digits and one . or , (or the browser locale's separator) as the decimal mark.

  • Grouping separators and exponents show an error and block saving. The ambiguous shape of one to three digits, the locale's grouping separator and exactly three digits ("1,500" in English) is refused with an error naming both readings.
  • The field writes numbers with the locale's decimal mark and no grouping. The host receives a number, null when empty and NaN when unreadable.
  • Do not use type="number" for decimals: in a decimal-comma locale it silently drops a typed point. Whole-number fields keep it.

Room icons resolve in the SPA

A room's icon is a free string of at most 64 characters that the SPA resolves through one explicit map. Saving writes a picker key, or null for the default icon. Emoji values (a trailing U+FE0F is ignored) and the demo content's tokens resolve as read-side aliases. Any other value renders the default icon.

Start and its tiles

Start shows a device by its Basic tile preference. shown and hidden decide. auto, the default, leaves out Coordinator, Presence and Unknown devices.

What a switch or an outlet drives is the household's choice

BasicTilePreferences.presentsAs is auto, light or outlet, set per logical device in the Basic tile editor. A stored row without the field reads as auto, as does a value a build does not recognise. A Switch may be presented as a light or an outlet, and an Outlet as a light. The backend refuses a choice the device type does not allow.

The SPA reads the choice through presentedCategory, which drives the Start light count, the tile icon and tone, and the room widget. The phone applies the same rule. A presented light is on when any of its gangs is on. How the choice reaches the Matter bridge is in integrations.

A thermostat is worded from its running state

The Basic tile and the drawer's state line say what the unit is doing only when it reports a running state: "Heating to 21 °C", "Cooling to 24 °C" or "Idle · 26 °C". A system that is off reads "Off". With no running state the line names the mode, the setpoint for that mode and the room temperature, and claims no work ("Heat · set to 21 °C · room 19 °C"). The tile's tone follows the same decision. A heating or cooling action works to its own setpoint when the device declares one. Never derive heating or cooling from room versus target.

A multi-gang tile has one switch for all its gangs

With an automatic quick action, a device with two or more controllable power gangs shows one switch that commands every such gang to one value. It reads on while any gang is on, so a tap on a mixed device turns everything off. A household none, or a chosen gang the device lost, shows no switch. The drawer still controls each gang. Settings toggles (backlight, child lock) are not power gangs. A device is never split into several tiles.

A tile's quick action is an unambiguous power toggle or a ranged number

Offer an inline quick action only for an unambiguous power toggle or a ranged number, never "the first controllable toggle". Descriptors declare test mode, mute, away mode, child lock and strobe as controllable. A controllable number with no declared minimum and maximum gets no inline control.

Tile wording

  • A number on a Start tile carries the capability's label in sentence case ("Soil moisture 100 %") unless it is the category's primary reading: the first of its headline readings, and temperature for a Sensor. Toggles and enums are not labelled. A Diagnostic capability is not a headline reading.
  • The typed device summary carries lastEvent (time and button) for scene controllers, read from persisted device events bounded to 90 days. The tile says "Button 1 pressed · 5 min ago" or "No recent presses" and takes a live press from the realtime device event.
  • isUnlabelledChannel treats a blank label, a bare generic word (state, channel, gang, ch) or state with a gang token (State L2, state_l1) as unlabelled. Such a channel reads "Channel N" by its 1-based position, in the lists, device pages, Basic drawer and Recent activity. A name a person plausibly types ("Switch 3") must never match. The host keeps no per-protocol driver strings.
  • vacuum.fanSpeed is labelled "Cleaning mode" when its declared options carry cleaning-method semantics (vacuum, mop, vacuum_then_mop, deep_clean). A label the plugin chose wins. Otherwise "Fan speed" stays.

Android companion

The phone is a read-oriented companion

The phone monitors the house and sends simple commands. Dashboards are display-only and authoring is web-only. What the phone may change is a closed list:

  • a device's name, its room and favourites
  • scene activation
  • per-capability actuation
  • pairing a device
  • for the baby monitor: starting and stopping a session, acknowledging an episode and requesting a test alarm

Scenes run and are never undone. No affordance gates on a role name. The server filters what the phone may see and run.

Core decides; the Android head draws and maps

Reeve.Mobile.Core and Reeve.Mobile.Tests target plain net11.0. The head, Reeve.Mobile, targets net11.0-android (minimum API 26, Android only) and no test can reference it. Platform files for other operating systems exist in the template layout and do not build.

  • Put every user-visible string, visibility or enabled condition and decision in a Core type. Markup reaches copy by x:Static.
  • The head (pages, controls, Platforms/Android) only binds, forwards lifecycle moments and maps Core results onto platform calls. Android surfaces (widget providers, controls provider, tile service, shortcut publisher, notifier) are mappers: what to publish, labels, who may act and whether a tap needs confirmation come from unit-tested Core types.
  • Platform capabilities reach Core through narrow interfaces. Register them so that a missing registration in a service-only process is a logged no-op.
  • Chart drawables render precomputed series with resolved colours and compute no statistics.

The navigation host is hand-built

The app roots on a custom ShellHostPage with four bottom tabs over an overlay layer, not on the framework's shell, because bottom sheets cannot be drawn over the framework's tab bar.

  • The host reparents each tab's content, so page lifecycle callbacks never fire. Each tab view-model drives its first load from an explicit initialise hook, recorded as initialised only when a load actually ran.
  • The host owns the back button and the modal stack. Dialogs, navigation and sheets resolve it through ShellHostPage.Current, never the first application window, which can linger after Android re-creates the activity. A null host throws on purpose.
  • Pushed routes pass one auth gate that refuses to stack a modal over the sign-in screen. The two-factor challenge route is exempt, because its caller holds a challenge and no session. Deep-link context (a gang index) is parked inside the push after the gate, so a redirect to sign-in cannot carry it to the next user.
  • Switching host state and cold-start state application first drain modals and sheets. Session restore releases its gate in a finally, so a throwing restore falls back to sign-in.
  • Only a biometric prompt the user actually failed signs them out. A prompt that could not be shown, or a dismissal, keeps the session.
  • MainActivity is single-top and has an explicit Java name. A standard launch mode drops deep links, and a generated name disables pinned shortcuts after an update.
  • Recognise intent extras by key presence through DeviceDeepLinkKeys.
  • An activity re-created by a configuration change or process death, or launched from Recents, hands back the intent that first created it. That delivery opens nothing.
  • A link that cannot be honoured in time lands on Home.

The phone caches for offline and scrubs everything on sign-out

The last dashboard and per-device snapshots are cached on disk, so the house still renders with the server unreachable.

  • Offline, the app shows cached state with its as-of time in one banner and a dashed texture per tile. A truncated or corrupt cache file reads as "no cache".
  • Background location reports queue in memory. After a gap the newest fix is sent first and the backlog after it, each stamped with its send time. The server dates a fix by its age, applies where the phone is now and keeps older fixes as history. Queued reports survive transient failures but not process termination.
  • Session material is stored only through the platform secure-storage abstraction.
  • Signing out clears the cache and every external surface, because the cached dashboard lists every accessible device. A new surface that can name a device or a person joins the scrub.

The phone hides infrastructure in both modes

DeviceVisibility.IsShown hides Coordinator devices (hub, gateway, router) and Unknown devices (a type the build does not recognise) in Basic and Advanced. It hides Presence in Basic only. A Basic tile preference of shown still shows such a device, and hidden is honoured in Basic only. The Devices list and its search, Home, favourites, the widget and room counts all use this one rule. The app has no per-device hide toggle, and network diagnostics belong to the web.

Critical capabilities are confirmed per capability, set on the server

An administrator marks individual capabilities of a device as critical in the web application. The flag is data, never a name heuristic, and is off by default. A critical capability needs two taps everywhere it can be actuated: web, widget and phone.

  • Every sheet shows a visible confirmation affordance (on the phone one ConfirmPillView for every sheet kind).
  • The armed question holds the capability key and the exact value. The second tap dispatches that stored value. A different value asks afresh, and the question lapses after a few seconds.
  • A device whose flags cannot be read is treated as critical throughout. How stale the flag may be before it is re-read is a security deadline, never derived from a battery-tuning interval.
  • Only a discrete action (a chip, a button, a stepper press, a released slider or dial) arms the gate. A continuous or debounced input (a slider in flight, the PTZ pad, a debounced stepper) never drives a critical capability.

On the phone's climate sheet a critical part is shown with its reported value and cannot be changed there. "Full controls" switches the sheet body to the generic Control sheet of the same device, where the confirmation sends the change, and "Back to climate" returns.

Device sheets commit once and show what the device reports

  • Continuous controls (slider, vessel, dial) commit on drag completed, never per tick. Abandoning a drag dispatches nothing. A number with no usable domain gets no slider.
  • Toggles, chips and buttons route through the press gate and never flip locally. A refused command restores what the device reports.
  • A non-controllable capability is a labelled value, not a greyed control.
  • Pan and tilt are one pad with one commit path, because two commands land mid-motion and firmware queues or drops the second. The canonical contract has no stop verb.
  • A multi-channel sheet keeps the row's gang ids ({guid}:ch{N}). An id naming no gang is refused, never defaulted to gang 0.
  • A vacuum's chosen areas are sent before start, and a refused selection stops the clean.

A camera admits only a few viewers and hiding a WebView does not stop its stream, so dismissing a camera sheet releases the viewer slot and inactive baby-monitor tiles load about:blank. Auto-preview is off by default, because a preview wakes a battery or cloud camera. Camera surfaces carry an explicit dark background, because a WebView paints white until its first paint. Media flows through the backend as described in camera media.

Android system surfaces are product surfaces

The phone ships a device-controls provider for the power menu and lock screen, three Quick Settings scene tiles, launcher shortcuts and home-screen widgets for favourites and presence.

  • Each runs in a cold process with no activity. It rehydrates the session before deciding whether the user is signed in, and latches only on an authoritative outcome, never on a cancelled wait or an offline failure.
  • Only the controls panel may dispatch a device command and only the scene tile may activate a scene. Widgets and shortcuts navigate and display.
  • A wrong permission string or manifest attribute compiles while the surface never appears, so component names, keep rules and bind permissions must be exact.

Device Controls panel. The service is bound with android.permission.BIND_CONTROLS.

  • With no session the feed returns a placeholder, decided before any API call. One control that cannot be built is skipped.
  • Confirmation is capability-keyed and decided in Core. The allowlist that may skip authentication fails closed: only light, switch, outlet, fan and cover. Locks and security devices always require authentication. Choosing per control is an Android 13 API, so on Android 11 and 12 every control requires authentication.
  • Only an explicit success or challenge maps to a success response. Never latch a tile to a state the device did not reach.

Quick Settings tiles. There are exactly three scene slots, one tile per manifest component, because slots cannot be generated at runtime.

  • Tap one arms ("Confirm?") and tap two runs. The unlock-and-run layer is the lock-screen gate, not the confirmation.
  • A stale label stands until the next listening window, because tiles are passive.
  • The add-tile prompt is offered once and skipped while the preference is off. Every slot carries a manifest label, because the tile picker reads it without binding the service.

Settings. A Settings view-model that has not finished initialising holds placeholder defaults and must not write them (an unguarded geofence save would put a home at (0, 0)). Seed under a loading flag so setters do not re-persist loaded values. Each section loads independently, so one failure never suppresses the others and raises at most one alert. The server version reads "Unavailable" on failure.

Home-screen widgets. Widgets refresh through AppWidgetManager from the realtime device stream while the process lives, with a WorkManager periodic chain as the floor. updatePeriodMillis is 0 in both widget info files and stays 0. The 15-minute refresh interval lives once in Core, and every staleness horizon derives from it. The chain has one stable unique work name, and the worker has an explicit Java name that is a persisted identity. Structural failures return Retry, so the chain survives until the next sign-in.

RemoteViews inflate in the launcher process, so use only the framework's @RemoteView classes. Anything else (Space, ImageButton, ConstraintLayout, Material views) fails as "Problem loading widget" with no build error.

  • Only the item root carries a click, and the click template is mutable. Item ids are positions, with HasStableIds false.
  • Signed-out or empty frames push a layout with no adapter view. Widget services are not exported.
  • Only chrome may use Android dynamic colour. State tokens, text tiers and the tone ladder are never re-declared against system colours.
  • A failed tick keeps the last good value per person and marks only the derived word stale.

One foreground service carries every background job

Location sharing, "Notify me when the app is closed" and a live baby-monitor session are jobs of one foreground service with one ongoing notification. BackgroundServiceCoordinator in Core decides the set of jobs. The head starts the service with only the types the current jobs justify: location while the user is signed in and sharing is consented and granted, and specialUse for delivery and the baby monitor. The manifest declares specialUse and its subtype property, not dataSync (Android caps dataSync at six hours a day). Below API 34 a delivery-only service runs with no type.

  • Add a job only from the foreground. Every later change or stop is a plain start queued behind the foreground one. Never call StopService. The service is not sticky.
  • A new background job is a new flag on this service with its own type and consent, never a second service.
  • While the app is backgrounded the kept hub connection leaves its device group. It carries alerts and not every state change, so every screen, widget and the controls panel reloads when the stream resumes.

A "share my location" switch decides whether position reporting runs. When it is on, the service's location job keeps the process alive so the location loop survives backgrounding, so do not stop the loop when the app is minimised. A user who declines gets no presence and no geofence automations. Request background location separately from, and after, foreground location. An absent speed on a fix is not "standing still": treating it so pins the loop at its slowest cadence.

"Who is home" is a roster-first list with position markers over a self-hosted raster tile, falling back to a plain grid. Do not add a commercial map SDK or the framework's map control, because both bring a cloud dependency and an API key. The presence widget is list-first too.

Pairing is a rendering wizard over a Core state machine

The four-step pairing wizard only renders. Transitions, outcomes, the count-up and navigation order live in OnboardingViewModel.

  • Stop is offered only at step 2 and only while the backend's cancel endpoint would accept it (no terminal outcome, hand-off not latched, session status absent or Pending).
  • An integration that could not answer is shown dimmed with its reason. The server's raw failure reason classifies and is never shown.
  • A screen-scoped cancellation never aborts work that already changed the world outside the phone. After the device joined a network, no outcome offers a retry.
  • The screen that shows a live pairing credential excludes itself from the recent-apps snapshot. The server never runs Bluetooth.

The QR plate is the one literal-colour surface: dark-on-light in both themes, with the four-module quiet zone supplied by the matrix. Only the canvas is a fixed square, because a font-scaled code is stretched and does not decode. On an encoding failure the canvas is hidden. It is drawn over QrMatrix with no imaging package.

Phone-driven Matter onboarding uses the Google Home Mobile SDK through Reeve.MatterAndroid.Bindings, which depends on the Xamarin.GooglePlayServices.Home NuGet binding. The version is pinned centrally in the root package props. A compile-time contract file lists the SDK types the flow uses, so a binding update that renames or drops one breaks the build. Where the platform services are absent, the pairing offer is not shown. The server side is in integrations.

Phone design invariants

  • Amber "Live" means exactly on, flowing, now. Never use it for identity, selection, links, focus, emphasis, warnings or done. A warning is the Warn token plus a word, never colour alone.
  • Use colour tokens only, as consumer-side light/dark pairs. A bare reference to a pair throws at runtime.
  • Do not express staleness or disabled state as wrapper opacity. Stale tiles carry a dashed texture and the offline banner is full strength.
  • Text scales to 200 %. Rows use a minimum height, never a fixed one. Tap targets are at least 48 dp (primary rows 56 dp).
  • No shadows, idle or looping animation or blocking spinner (in-flight is a sentence and the action stops being tappable). State is a glyph tint, never a glyph swap.
  • Selectors are row sheets in the host's overlay, never a native Picker. Switches are the app's own. Text on a surface clears 4.5:1.
  • Copy names no protocol outside the pairing and ecosystems screens. Progress is the four-segment spine, never a percentage.