# Device Fleet Manager

**Operations for connected devices in the field.**
`device-fleet.infinity-sdg.com`. An Infinity Software Development Group product built on Kalos/ADL.

```
product → device (serial, location, firmware, last seen)
firmware (signed) → rollout: canary → ring1 → general
alert (telemetry) → RMA (return, repair, replace)
```

The product is for makers of connected lighting, IoT sensors, gateways, audio and wearables.

## What it enforces

The rules below are enforced on the server, so no screen or API call can skip them.

- **Only signed firmware is released.** A firmware image never changes after it's built.
- **Rollouts are staged.** A rollout starts only on released firmware, and a wider ring never starts before its canary has completed.
- **High failure rates are flagged.** A stage with more than 5% failures is flagged before the next ring. Halting a stage requires a written reason.
- **A return (RMA) is opened only for a device marked faulty.** Closing it requires a disposition: repair, replace, refund or scrap.
- **Silent devices are caught.** An hourly schedule flags any device that hasn't reported for 72 hours as faulty.
- **Alerts are resolved only with a written resolution.**
- **Serial numbers are permanent.**
- **Every change is audited** with the old and new values, who made it and when. Firmware releases and halted rollouts also appear in a readable history timeline.

## Resources

`product` · `location` · `device` · `firmware` · `rollout` · `alert` · `rma`

Views: **openAlerts**, **rolloutProgress**, **faultyDevices**.
Roles: `engineer`, `support`, `operator`, `admin`.

## Demo data

- **Products and devices:** 10 products, from mesh lighting controllers and occupancy sensors to gateways, a safety band and an air-quality monitor. They're spread across 10 customer locations with 32 devices.
- **Firmware:** every product has a signed release whose canary completed. Lighting-controller ring 1 completed, while occupancy-sensor ring 1 was **halted** after failures topped 10%. An older lighting image was withdrawn, and an unsigned safety-band build is qualified but can't be released.
- **Returns:** 10 devices went faulty and were returned under RMA, at various stages of closing.
- **Alerts:** 12 telemetry alerts covering offline, overheating, crash loops and tampering, from just raised to resolved.

Regenerate the seed with `python3 seeds/gen_seed.py`.

## Run it

This repo runs on a [Kalos](https://github.com/datajango/kalos) checkout, as one of its `*.infinity-sdg.com` sub-domain sites.

```bash
export KALOS_REPO=~/kalos        # defaults to ../kalos beside this repo
scripts/kalos.sh validate        # static checks (adlref + config + seed)
scripts/kalos.sh start           # certs + fresh DB + kalosd on :9209
scripts/kalos.sh verify          # boot, seed, exercise over TLS, stop
```

Sign in as `admin` / `Admin123!`, or as `engineer1`, `support1` or `operator1` / `Demo123!`.

## Reselling

The product is generic. To brand it for a customer, change `site.json`, the port in `config.json`, and the data in `seeds/gen_seed.py`.
