docs(spec): one user experience for both series -- the guiding principle, applied

Brian's principle: talking to a Series 3 or a Series 4 unit is identical for
the user; only the serial prefix and each model's settings differ, and the
adapters absorb the rest.

Five places the draft broke it, now fixed: units are named the same way
(serial + address, no-serial kept only as a legacy Series-3 path); one set
of series-neutral response models with series-only fields under `detail`;
one opaque event_id for both; a uniform 501 "not supported for Series N
yet" instead of missing routes; and the webapp brought into scope with the
same screens for both.  Adds an adapter table, contract tests that keep the
two adapters honest, and notes that existing Series-3 response shapes move
to the shared models (the webapp updates with them; Terra-View does not
call /device/*).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-20 18:33:48 -04:00
1 parent 1c6aa04687
commit 3215c17e37
1 file changed
+75 -16
@@ -19,6 +19,12 @@ only speak Series 3. This design does three things:
the serial, and keeps the connection open for later commands instead of
reconnecting each time.
**The guiding principle (Brian): talking to a Series 3 unit and talking to a
Series 4 unit is the same for the user.** It is the same screens, the same
endpoints, the same way of naming a unit, and the same shape of answer. The
only visible difference is the serial (`UM…` vs `BE…`) and the settings each
model has. The differences live underneath, in one adapter per series.
It does **not** cover the emergency tools (runaway-unit stops, rescue, erase),
the call-home receiver, or anything async. Those come later, as features
shared by both series.
@@ -34,6 +40,7 @@ Series-4 SFM is for the bench and for units THOR is not holding.
| decision | why | who |
|---|---|---|
| **One user experience for both series** | the user's method is identical; only the serial prefix and each model's settings differ; adapters absorb the rest | Brian |
| Match **jobs**, not endpoints | some Series-3 endpoints only exist to work around Series-3 quirks | agreed |
| **No Series-4 emergency tools** yet (runaway stop, rescue, erase) | Micromates rarely need them | Brian |
| The series comes from the **serial prefix**: `UM` = Micromate, `BE` = MiniMate Plus, `BA` = Blastmate | the prefixes are definitive, so there is no probing | Brian |
@@ -55,8 +62,8 @@ of scope by decision.
| 1 | Identify a unit | `/device/info` (walks the whole chain, slow) | implemented: `connect()` | dispatch to the Micromate client |
| 2 | Quick status (monitoring, battery, memory, clock) | `monitor/status`, `storage_range`, `events/index` | implemented: `get_state()`; the `0x06` event count is decoded only in the bench tool | same endpoints; move the count decode into the client |
| 3 | Read settings | compliance in `/device/info`; `GET /device/call_home` | `get_setup()` implemented and verified on hardware; call-home: enable + dial string observed, rest unmapped | setup in full; call-home returns enable + dial string + raw |
| 4 | List events | `/device/events` (downloads every event to list them) | implemented, and cheap: the chain walk returns sizes | dispatch |
| 5 | Download an event | `/event/{i}`, `/waveform`, `/blastware_file` | implemented: streams the `.IDFW`/`.IDFH` itself, with a decode self-check | save through the existing `/db/import/idf_file` path |
| 4 | List events | `/device/events` (downloads every event to list them) | implemented, and cheap: the chain walk returns sizes | the same event-list shape as Series 3, each event carrying an `event_id` |
| 5 | Download an event | `/event/{i}`, `/waveform`, `/blastware_file` | implemented: streams the `.IDFW`/`.IDFH` itself, with a decode self-check | the same download and save-to-DB actions as Series 3. Underneath, Series 4 saves through `/db/import/idf_file` |
| 6 | Monitor log | only via `ach_server` (broken, see the fix list) | `0x0A` read exists; no wrapper or decoder | client wrapper + partial decode |
| 7 | Start / stop monitoring | `monitor/start`, `monitor/stop` | mapped, identical to Series 3 (`0x96`/`0x97`, acks `0x69`/`0x68`); never sent | **first write.** Verify with `0x49` state |
| 9 | Change call-home settings | `POST /device/call_home` | write mapped (`0x2C` → `0x7E`/`0x7F`, same as Series 3); field map mostly unknown | enable/disable only; the rest waits for the THOR round |
@@ -84,18 +91,61 @@ device_access ── series from serial prefix ── session / per-unit lock
read-back verification (changes only)
```
- **Series selection.** `serial` picks the library: `UM` → `micromate`; `BE`
or `BA` → `minimateplus`; any other prefix → 422. With no `serial`, the
request is Series 3, so existing Series-3 callers are unchanged.
**Series-4 requests must include `serial`.**
- **Endpoints.** The same `/device/*` paths, plus a `serial` query parameter.
Responses gain `"series": 3 | 4`. Where the two series genuinely differ (the
setup fields, the event identity), the body is series-specific under a
documented shape rather than forced into Series 3's.
- **Naming a unit is the same for both: `serial` + address.** The prefix picks
the adapter: `UM` → Series 4 (`micromate`); `BE` or `BA` → Series 3
(`minimateplus`); any other prefix → 422. A request with no `serial` is
treated as Series 3. That is a **legacy path** kept only so existing scripts
keep working; the webapp and every new caller always send `serial`.
- **One contract.** Same `/device/*` paths, same request parameters, and
**the same response models for both series**:
- `UnitInfo`, `UnitStatus`, `UnitSettings`, `EventRef`, `ChangeResult`
- Anything only one series has goes under a `detail` object inside the same
model, never as a different top-level shape. `"series": 3 | 4` is
informational.
- **Events have one identity.** An opaque `event_id` string from the event
list, passed back to download it. Underneath it is Series 3's position or
Series 4's device key, plus the serial; the user never handles either.
- **Not-yet-supported is uniform.** If one series can't do something yet,
the endpoint still exists and answers **501 "not supported for Series N
yet"**. It is never a missing route or a different call.
- **Work separate from HTTP.** Each operation is a plain function taking the
session. The handler is a thin wrapper, so making an operation an async job
later means changing the wrapper, not the operation.
### Adapters
Each series implements the same operation set behind `device_access`:
| operation | Series 3 adapter | Series 4 adapter |
|---|---|---|
| `identify` | STARTUP + serial + config | `connect()` |
| `status` | `0x1C` (+ `0x06`) | `get_state()` + `0x06` count |
| `read_settings` | `0x1A` compliance decode | `get_setup()` |
| `list_events` | today's walk | chain walk (cheap) |
| `download_event` | 5A → Blastware file | 5A → `.IDFW`/`.IDFH` |
| `monitor_log` | 501 for now (`ach_server` path is broken) | `0x0A` wrapper |
| `start` / `stop` | `0x96` / `0x97` (exists) | `0x96` / `0x97` (new) |
| `read_call_home` / `set_call_home_enabled` | exists | `0x2C` / `0x7E`+`0x7F` |
| `push_settings` | `/device/config` path (exists) | setup push (new) |
| `call_up` / `hang_up` | connect-per-request underneath, until the bench test | held session |
Each adapter maps its native data into the shared models. `UnitSettings` keeps
the fields both series have under the same names and units: record mode,
sample rate, record time, histogram interval, trigger levels, the notes as
label → value. Model-specific fields go under `detail`.
**Existing Series-3 response shapes change to the shared models.** The webapp
is updated in the same phase; Terra-View does not call `/device/*`. The
emergency endpoints (`stop_monitoring_*`, `rescue`, `events/erase`) are not
touched and stay Series-3 only; a `UM` serial gets 501.
### The webapp
The same screens for both series. You name a unit by serial + address (today
it takes host/port only), and the series shows as a badge, nothing more. Read
panels for both series land in phase 1; each write button appears for Series 4
in the phase that adds that write.
### The safety layer
**Tiers.** Every operation declares one:
@@ -161,7 +211,7 @@ One row per change attempt:
Reads are not audited.
### Sessions (Series 4)
### Sessions
1. **Call up.** Connect, `connect()` (POLL / SERIAL / STATE), identity check
against the requested serial.
@@ -176,8 +226,9 @@ Reads are not audited.
retry should reach THOR. 🔶 *Inferred:* the unit retries; its `0x2C`
retries field reads 3.
Series 3 keeps today's connect-per-request behaviour until the bench test
under *Testing*.
**Call up and hang up are the same for both series.** Underneath, the
Series-3 adapter keeps today's connect-per-request behaviour until the bench
test under *Testing*; the user sees the same actions either way.
### Series-4 write path
@@ -243,6 +294,11 @@ reviewed this way first.
- RADIO RING → session ends
- **Endpoints** through FastAPI's `TestClient` against the scripted transport
already used in `tests/test_micromate_client.py`.
- **Contract tests.** The same test, run against both adapters with fakes,
asserts that each job returns the same model with the same field names and
units. A field present for one series and absent for the other is a test
failure unless it lives under `detail`. This is the test that keeps the
guiding principle true as the code grows.
**Bench (UM20147, with Brian):** each write's first live send follows the same
protocol:
@@ -267,9 +323,12 @@ session open to a MiniMate that is monitoring, for several minutes. Record:
Each safety piece arrives with its first real use, so nothing sits untested.
1. **Series-4 reads in SFM.** `device_access.py`, series selection, the
per-unit lock (Series 3 too), the error mapping, and Series-4 sessions with
ring safety. Rows 1–6. **No writes.**
1. **One contract, reads only.** `device_access.py`, the two adapters, the
shared models, series selection, the per-unit lock, the error mapping, and
sessions with ring safety. Rows 1–6 for **both** series through the same
endpoints. **No writes.**
- 1b. **The webapp:** serial + address, and the same read panels for both
series.
2. **Encoder + opcode guard + dry run + frame-reproduction tests.** Still
nothing sent.
3. **Start/stop monitoring** (row 7): the first live write, at the bench.