docs(plan): phase 4 -- call-home enable/disable by serial, both series

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-11-02 16:47:56 -05:00
1 parent 2389b4c4f6
commit 5b37ea22cc
1 file changed
+245
@@ -0,0 +1,245 @@
# Phase 4 — Call-home enable/disable Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Turn a unit's automatic call-home on or off from SFM, for both series, through the audited change path start/stop already uses: identity check → audit → one send → read back → audit.
**Architecture:** `run_change` (`sfm/device_access/change.py`) becomes kind-agnostic: a `ChangeKind` says what the change is called and which state means it took. Each series supplies a call-home state read (`"enabled"` / `"disabled"`, plus Series 4's `"calling_home"`) and a send built from the block it read moments before. Series 4 sends `micromate.writes.plan_call_home_enabled` (frames already equal to THOR's). Series 3 patches byte 5 of the unescaped `0x2C` image and sends it through the existing `0x7E`/`0x7F` path. A gate keeps that send refused until its frame is reproduced from a Blastware capture. New serial-keyed routes, and the page's Call Home tab by serial gets On/Off buttons.
**Tech Stack:** Python 3 / FastAPI (SFM), pytest; page JS in `sfm/static/` tested with Node.
**Spec:** `docs/superpowers/specs/2026-10-20-sfm-series4-parity-design.md` — row 9 of the job table, "The safety layer" (tiers, read-back: "call-home → re-read `0x2C` and compare the edited bytes"), the per-operation table (`call-home enable/disable | read 0x2C → 0x7E (126 B content, offset 0x007E) → 0x7F | re-read 0x2C`), build phase 4.
## Global Constraints
- Branch `feat/series4-sfm-parity`, worktree `~/seismo-relay-parity`. Never commit to `main`. Push every commit. No `CHANGELOG.md` edits (written on `dev` at merge).
- **No live write without Brian's explicit go, per send.** Dry runs and tests only, until the bench task.
- A write is never retried (`DeviceAccess._dispatch(change=True)`); never send `0xA2`; never write modem baud or modem type.
- File boundary with the decode-checker session: do not edit `minimateplus/event_file_io.py`, `histogram_codec.py`, `waveform_codec.py`, `bw_xml_report.py`, `decode_check*.py`.
- No inline JavaScript: new page logic goes in `sfm/static/device_routing.js` (DOM-free, Node-tested); `sfm/static/sfm_webapp.js` only applies it (stack-wide rule, 2026-11-02).
- Series 4: read-modify-write. Send back every byte of the block as read except bit 0 of `content[5]`. Never synthesise or zero `content[118:120]` (unit-maintained; it changes after a config write).
- Series 3: read the enable byte from the **unescaped** block (the lesson of bench finding #1). `0x00` off, `0x01` on (measured April 2026, BE11529). Any other value is `unknown(0xNN)` and nothing is sent.
- Speed is secondary to reliability: no new round trips beyond the reads the change needs.
- Test command: `/home/serversdown/seismo-relay/.venv/bin/python -m pytest -q -p no:cacheprovider`. Baseline: exactly 16 known failures (15 in `tests/test_bw_ascii_report.py`, `tests/test_event_file_io.py::test_save_imported_bw_without_report_works_unchanged`). Read the failure list before committing.
## Review Focus
1. A change requested while a Micromate is calling home (run state `0x03`) → 503, nothing sent, the line released (the existing `CallHomeInProgress` path).
2. A MiniMate whose unescaped byte 5 is neither `0x00` nor `0x01` → state `unknown(0xNN)`: a dry run still shows it, a live change sends nothing (`UnitStateUnknown`, 409).
3. A read-back where other bytes changed (Series 4 `[118:120]` always does) → verified on the edited bit alone; the changed offsets are recorded in the result and the audit row, never a mismatch.
4. Already in the requested state → skipped with no send, unless `even_if_already` (the bench's no-op write is exactly that experiment).
5. A live Series-3 call-home change before its frame has been reproduced from a Blastware capture → 501 before any connection. A dry run works.
---
### Task 1: `run_change` takes a `ChangeKind`
**Files:**
- Modify: `sfm/device_access/change.py` (signature and the three derived names at the top of `run_change`; the finish paths that build `detail` and `states`)
- Modify: `sfm/device_access/s3.py` (`change_monitoring`), `sfm/device_access/s4.py` (`s4_change_monitoring`) — call sites only
- Test: `tests/test_device_access_change_kind.py` (new)
**Interfaces:**
- Produces:
- `@dataclass(frozen=True) class ChangeKind: action: str; want: str; became: str` in `change.py`.
- `monitoring_change(start: bool) -> ChangeKind` gives exactly today's values: `("start monitoring", "monitoring", "started")` / `("stop monitoring", "idle", "stopped")`.
- `call_home_change(enabled: bool) -> ChangeKind` gives `("enable call-home", "enabled", "enabled")` / `("disable call-home", "disabled", "disabled")`.
- `run_change(*, kind: ChangeKind, serial, series, dry_run, even_if_already, audit, address, caller, sleep, verify_timeout_s, verify_interval_s, read_serial, read_state, describe_plan, send, is_refusal=_never, is_ring=_never, pre_send=None, snapshot: Optional[Callable[[], Dict[str, Any]]] = None) -> ChangeResult`. `start` is gone.
- `snapshot`: called once, after the read-back loop, on the two normal finish paths (verified `ok` or `mismatch`). Its dict goes in `detail["snapshot"]` and the audit row's `states["snapshot"]`. A snapshot that raises is recorded as `{"error": str(exc)}` and does not change the outcome.
- [ ] **Step 1: Write the failing tests** (fake callables, no device, the `Audit` fake pattern from `tests/test_device_access_change.py`):
- `test_monitoring_kinds_are_todays_names`: `monitoring_change(True) == ChangeKind("start monitoring", "monitoring", "started")`, and likewise for stop.
- `test_a_call_home_change_is_verified_by_its_own_state`: `kind=call_home_change(False)`, states `["enabled", "disabled"]` → `(outcome, verified, state_after) == ("sent", "ok", "disabled")`, and `result.action == "disable call-home"`.
- `test_a_call_home_read_back_that_did_not_change_is_a_mismatch`: states `["enabled", "enabled", "enabled", "enabled"]` with verify `(3.0, 1.0)` → `("failed", "mismatch")`.
- `test_the_snapshot_is_kept_in_the_result_and_the_audit`: `snapshot=lambda: {"after": "ab"}` → `result.detail["snapshot"] == {"after": "ab"}` and the audit row's `states["snapshot"] == {"after": "ab"}`.
- `test_a_failing_snapshot_does_not_change_the_outcome`: a snapshot raising `RuntimeError("x")` → still `("sent", "ok")`, `detail["snapshot"] == {"error": "x"}`.
- [ ] **Step 2: Run** `pytest tests/test_device_access_change_kind.py -v`. Expected: FAIL (`ImportError: cannot import name 'ChangeKind'`).
- [ ] **Step 3: Implement.** Replace `start` with `kind` in `run_change`, deriving `action`, `want` and `became` from `kind`. Add the snapshot as specified. Update the two call sites to `kind=monitoring_change(start)`, keeping their own `start` parameter.
- [ ] **Step 4: Run** the new file plus `tests/test_device_access_change.py tests/test_device_access_s3_events.py tests/test_server_device_access.py`. Expected: all pass, with the existing start/stop tests unchanged.
- [ ] **Step 5: Commit** `refactor(sfm): run_change takes a ChangeKind -- start/stop unchanged, call-home next (phase 4)`.
### Task 2: Series 4 — read call-home, change it
**Files:**
- Modify: `micromate/opcodes.py` (`ENABLEABLE_WRITES`), `micromate/client.py` (new method)
- Modify: `sfm/device_access/models.py` (new `CallHomeState`), `sfm/device_access/s4.py` (two new functions)
- Modify: `tests/device_access_fakes.py` (`FakeMicromateClient` call-home support), `tests/test_micromate_execute.py:37` (the ceiling assertion)
- Test: `tests/test_device_access_s4_call_home.py` (new)
**Interfaces:**
- Consumes: Task 1's `ChangeKind`, `call_home_change`, `run_change(snapshot=…)`.
- Produces:
- `ENABLEABLE_WRITES = frozenset({0x96, 0x97, 0x7E, 0x7F})`.
- `MicromateClient.get_call_home_content() -> bytes`: the 126-byte content, `_content(self.protocol.read_call_home_config())`.
- `@dataclass class CallHomeState: serial: str; series: int; enabled: Optional[bool]; dial_string: Optional[str]; detail: Dict[str, Any]` (`detail["byte5"]` as `"0xNN"`, `detail["block"]` as hex).
- `s4_call_home_state(client, serial) -> CallHomeState`: enabled is bit 0 of `content[5]`; the dial string is `content[6:46]` up to its first NUL, decoded as ASCII.
- `s4_change_call_home(client, serial, *, enabled, dry_run, even_if_already, audit, address, caller, sleep, verify_timeout_s, verify_interval_s) -> ChangeResult`:
- `read_state` returns `"calling_home"` when `client.read_run_state().name == "calling_home"`, else `"enabled"` / `"disabled"` from `content[5] & 1`. It keeps the last content it read.
- `describe_plan`: `plan_call_home_enabled(last_content, enabled).describe()`, so the plan is built from the read `run_change` made just before.
- `send` executes that same plan object.
- `snapshot` returns `{"before": hex, "after": hex, "changed_offsets": [...]}`, comparing the first and last content read.
- `pre_send`, `is_refusal` and `is_ring` are as in `s4_change_monitoring`.
- [ ] **Step 1: Fake support.**
- `FakeMicromateClient(call_home=<126-byte content>)`, defaulting to UM12947's enabled read from `tests/fixtures/micromate-writes` (the reads `tests/test_micromate_writes.py::_call_home_reads` uses), plus a `read_call_home_config()` on `_FakeProtocol` returning `bytes(11) + content`.
- `execute(plan)` applies a `0x7E` step's data as the new content, then replaces `[118:120]` with its bitwise complement, mimicking the unit-maintained field (the default read already holds `2e 5e`, so a fixed value would not change it).
- [ ] **Step 2: Write the failing tests:**
- `test_s4_call_home_state_reads_the_enable_bit_and_dial_string`: on the default content (UM12947, `[5] = 0x05`) → `enabled is True`, `dial_string == "RADIO RING"`, `detail["byte5"] == "0x05"`.
- `test_s4_dry_run_shows_thors_frames`: dry run `enabled=False` → `result.plan` frames equal `plan_call_home_enabled(content, False).describe()["steps"]` frames, and `fake.executed == []`.
- `test_s4_disable_sends_7e_7f_and_verifies`: live `enabled=False` → `("sent", "ok", "disabled")`; executed plan subs `[0x7E, 0x7F]`.
- `test_s4_unit_maintained_bytes_do_not_make_a_mismatch`: same run → `verified == "ok"` and `detail["snapshot"]["changed_offsets"] == [5, 118, 119]`.
- `test_s4_no_change_while_calling_home`: `run_states=[0x03]` → `CallHomeInProgress`, nothing executed.
- `test_s4_already_enabled_is_skipped`: `enabled=True` on enabled content → `outcome == "skipped"`, nothing executed. With `even_if_already=True` → executed once, and the plan carries the "changes nothing" warning.
- Update `test_micromate_execute.py:37` to the new four-SUB set.
- [ ] **Step 3: Run** the new file. Expected: FAIL (`ImportError: s4_call_home_state`).
- [ ] **Step 4: Implement** as specified in Interfaces.
- [ ] **Step 5: Run** the new file plus `tests/test_micromate_execute.py tests/test_micromate_writes.py tests/test_device_access_change.py`. Expected: pass.
- [ ] **Step 6: Commit** `feat(sfm): Series-4 call-home state and audited enable/disable (phase 4)`.
### Task 3: Series 3 — read call-home, change it (live send gated)
**Files:**
- Modify: `minimateplus/protocol.py` (two pure functions next to `write_image`), `minimateplus/client.py` (two methods)
- Modify: `sfm/device_access/s3.py` (gate constant + two adapter methods)
- Modify: `tests/device_access_fakes.py` (`FakeMiniMateClient` call-home support)
- Test: `tests/test_s3_call_home.py` (new)
**Interfaces:**
- Consumes: Task 1, and Task 2's `CallHomeState`.
- Produces:
- `call_home_enabled(raw: bytes) -> Optional[bool]` in `minimateplus/protocol.py`: `unescape_reply(raw)[5]`, `0x01` → True, `0x00` → False, else None.
- `call_home_image(raw: bytes, enabled: bool) -> bytes`: `write_image(SUB_CALL_HOME_WRITE, raw)` with byte 5 set to `0x01`/`0x00` and every other byte unchanged. Raises `ValueError` when the image's byte 5 is not `0x00`/`0x01`.
- `MiniMateClient.read_call_home_raw() -> bytes` (the protocol's `read_call_home_config()`) and `MiniMateClient.write_call_home_image(image: bytes) -> None` (the protocol's `write_call_home_config(image)`: `0x7E` then `0x7F`, each ack checked).
- `S3_CALL_HOME_FRAME_VERIFIED = False` in `sfm/device_access/s3.py`. Task 4 flips it.
- `Series3Adapter.call_home_state(address, serial) -> CallHomeState`: `wake`, then `read_call_home_raw()`. The dial string is the unescaped `[6:46]` up to its first NUL. `detail` carries `byte5`, `block` (raw hex) and `serial_verified: False`, as status does.
- `Series3Adapter.change_call_home(address, serial, *, enabled, dry_run, even_if_already, audit, caller, sleep, verify_timeout_s, verify_interval_s) -> ChangeResult`:
- When `not dry_run and not S3_CALL_HOME_FRAME_VERIFIED`, raise `NotSupported("a MiniMate call-home write waits until its frame has been reproduced from a Blastware capture -- nothing sent")` before `_run`.
- Otherwise use `run_change(kind=call_home_change(enabled), retry=False)` with:
- `read_serial` = `client.connect()`, as for start/stop;
- `read_state` = `wake` + `read_call_home_raw()`, giving `enabled` / `disabled` / `unknown(0xNN)` and keeping the last raw;
- `describe_plan` = the steps `[{"sub": "0x7E", "frame": build_bw_write_frame(0x7E, image).hex()}, {"sub": "0x7F", "frame": build_bw_write_frame(0x7F, b"").hex()}]`;
- `send` = `client.write_call_home_image(image)`, returning `{"subs": ["0x81", "0x80"]}`;
- `snapshot` as in Task 2, over unescaped images.
- [ ] **Step 1: Fake support.**
- `FakeMiniMateClient(call_home_raw=<125 B>)`. The default is built from the documented 4-20-26 layout: `00 7C DC 00 00`, `[5] = 0x01`, `[6:46] = b"RADIO RING"` NUL-padded, `[117:119] = 10 03`, zeros elsewhere to 125 bytes.
- `read_call_home_raw()` steps and returns it.
- `write_call_home_image(image)` records `self.writes.append("call_home")` and stores the image for the next read.
- [ ] **Step 2: Write the failing tests:**
- `test_s3_enable_byte_reads_from_the_unescaped_block`: on the default raw → `call_home_enabled(raw) is True`. A raw with an escape spliced in before byte 5 (`00 7C 10 03 00 00 01 …`) still reads True.
- `test_s3_image_changes_only_byte_5`: `call_home_image(raw, False)` differs from `write_image(0x7E, raw)` at index 5 only, and its length is 126 (N `0x7C` + 2).
- `test_s3_image_refuses_an_unknown_byte_5`: raw with unescaped `[5] = 0x07` → `ValueError`.
- `test_s3_call_home_state`: through `Series3Adapter` with the fake → `enabled is True`, `dial_string == "RADIO RING"`, `detail["serial_verified"] is False`; the calls include `"wake"` before `"read_call_home_raw"`.
- `test_s3_live_change_is_refused_until_the_frame_is_verified`: `dry_run=False` → `NotSupported` (501), the factory never called.
- `test_s3_dry_run_shows_both_frames`: `dry_run=True` → plan steps `0x7E`/`0x7F`, `fake.writes == []`.
- `test_s3_change_once_verified` (monkeypatch `S3_CALL_HOME_FRAME_VERIFIED = True`): live `enabled=False` → `("sent", "ok", "disabled")`, `fake.writes == ["call_home"]`, `detail["snapshot"]["changed_offsets"] == [5]`.
- `test_s3_unknown_byte_5_sends_nothing` (gate open): raw with `[5] = 0x07` → `UnitStateUnknown`, no write.
- [ ] **Step 3: Run** the new file. Expected: FAIL (`ImportError: call_home_enabled`).
- [ ] **Step 4: Implement** as specified.
- [ ] **Step 5: Run** the new file plus `tests/test_device_access_change.py tests/test_server_series3_guard.py`. Expected: pass.
- [ ] **Step 6: Commit** `feat(sfm): Series-3 call-home state and audited enable/disable, live send gated until its frame is verified (phase 4)`.
### Task 4: Reproduce Blastware's Series-3 call-home write (opens the gate)
**Precondition:** Brian has found a capture of Blastware changing call-home settings, from the BW VM (CLAUDE.md names it `4-20-26/call home settings/`, BE11529), and copied the BW-TX and S3-RX files into `tests/fixtures/s3-call-home-bw/`. **If no capture exists, skip this task.** The gate stays shut, the Series-3 half of the bench (Task 7) starts by recording one, and this task runs after it.
**Files:**
- Create: `tests/fixtures/s3-call-home-bw/` (Brian's files, added with `git add -f` if they match an ignore rule) and `tests/test_s3_call_home_bw_frames.py`
- Modify: `sfm/device_access/s3.py` (`S3_CALL_HOME_FRAME_VERIFIED = True`, with a comment naming the test)
- [ ] **Step 1: Write the test** `test_sfm_builds_blastwares_call_home_write`:
1. Parse the S3-RX file with `S3FrameParser`, taking each `0xD3` data reply (`data[11:]`) in order. Parse the BW-TX file for the `0x7E` and `0x7F` request frames, using the #46 parser in `tests/test_minimate_write_frames.py` (`_frames`, `_payload`; import or copy them).
2. For each `0x7E`, work out what Blastware asked for: the unescaped byte 5 of its image.
3. Assert `build_bw_write_frame(0x7E, call_home_image(prev_read, wanted)) == bw_7e_frame` and `build_bw_write_frame(0x7F, b"") == bw_7f_frame`.
4. If Blastware also changed fields other than byte 5 in that write, assert only on writes where byte 5 is the sole difference from the read, and record the count.
- [ ] **Step 2: Run it.** Expected: PASS, with at least one write asserted. A FAIL means SFM's frame is not Blastware's: stop, record the byte differences in the spec's phase-4 notes, and leave the gate shut.
- [ ] **Step 3: Flip the gate**, then run `tests/test_s3_call_home.py`. The "refused until verified" test now fails by design: change it to assert the gate's comment names this test, and keep the monkeypatched tests.
- [ ] **Step 4: Commit** `test(s3): SFM's call-home write equals Blastware's, frame for frame -- opens the live send`.
### Task 5: DeviceAccess and the serial routes
**Files:**
- Modify: `sfm/device_access/access.py` (two methods, two constants), `sfm/server.py` (three routes, `_SERIAL_AWARE_PATHS`)
- Test: `tests/test_device_access_call_home.py`, plus additions to `tests/test_server_device_access.py`
**Interfaces:**
- Consumes: Tasks 2 and 3.
- Produces:
- `DeviceAccess.call_home_state(address, serial) -> CallHomeState` (a read, via `_dispatch`).
- `DeviceAccess.set_call_home(address, serial, *, enabled: bool, dry_run=False, even_if_already=False, caller="api") -> ChangeResult` (`change=True`). It uses `_CALL_HOME_VERIFY_TIMEOUT_S = 3.0` and `_CALL_HOME_VERIFY_INTERVAL_S = 1.0`, at most 3 read-backs one second apart, not the monitoring window.
- Routes:
- `GET /device/call_home/state?serial=&host=&tcp_port=` → the `CallHomeState` as a dict.
- `POST /device/call_home/enable` and `/device/call_home/disable`, taking `serial` (required), `host`, `tcp_port`, `dry_run`, `even_if_already` and `caller`, through `_change_response`. The statuses are the start/stop route's, including Batch 2's `sent`/`audit_id` on an unconfirmed change.
- All three go in `_SERIAL_AWARE_PATHS`. The legacy `GET`/`POST /device/call_home` stay unchanged, and outside that set.
- [ ] **Step 1: Write the failing tests:**
- `test_set_call_home_dispatches_by_series`: a `UM` serial reaches the S4 function and a `BE` serial the S3 adapter, using the fakes from Tasks 2 and 3.
- `test_set_call_home_is_never_retried`: an S4 held line that drops → raised, executed once.
- `test_call_home_routes_need_a_serial`: no `serial` → 422.
- `test_enable_route_returns_the_change_result`: a fake access → 200 and the body's `action == "enable call-home"`.
- `test_legacy_call_home_post_still_refuses_a_micromate_serial`: `_device_guard("/device/call_home", {"serial": "UM20147"})` → 501, unchanged.
- `test_call_home_routes_are_serial_aware`: the three new paths are in `_SERIAL_AWARE_PATHS`.
- [ ] **Step 2: Run.** Expected: FAIL (`AttributeError: set_call_home`).
- [ ] **Step 3: Implement**, mirroring `start_monitoring` / `device_monitor_start`.
- [ ] **Step 4: Run** the new and modified test files plus `tests/test_server_series3_guard.py`. Expected: pass.
- [ ] **Step 5: Commit** `feat(sfm): call-home state and enable/disable by serial -- GET /device/call_home/state, POST /device/call_home/{enable,disable} (phase 4)`.
### Task 6: The page — Call Home by serial
**Files:**
- Modify: `sfm/static/device_routing.js` (routes, `controlsFor`, `serialPanes`, `changeErrorText`, new `callHomeRows`), `sfm/static/sfm_webapp.js` (glue), `sfm/sfm_webapp.html` (a state box and two buttons in the Call Home tab)
- Test: `tests/test_webapp_device_routing.py`, plus a jsdom run of `page_files_load.js` in the scratchpad (not committed)
**Interfaces:**
- Consumes: Task 5's routes and Batch 2's `serialPanes` / `changeErrorText`.
- Produces:
- `DEVICE_ROUTES`:
- `call_home_state: ['GET', '/device/call_home/state', true]`
- `call_home_on: ['POST', '/device/call_home/enable', true]`
- `call_home_off: ['POST', '/device/call_home/disable', true]`
- `controlsFor(unit).callHomeChange = serialMode && (series === 3 || series === 4)`. `callHomeWrite` (the legacy multi-field form) stays `false`, with `reasons.callHomeWrite = 'By serial: use Call-home On / Off (audited). Other call-home fields wait for the THOR round.'`
- `serialPanes(...)` gains `callHomeForm: !bySerial` and `callHomeBox: bySerial`. Batch 2's existing test gets the two keys added.
- `changeErrorText(label, status, body, unit, statusText)` takes the whole label (`"Start monitoring"`, `"Enable call-home"`) and returns `` `${label} not confirmed: …` `` / `` `${label} failed: …` ``. Update its two callers and Batch 2's test.
- `callHomeRows(state) -> [[label, value], …]` returns:
- `['Call-home', 'On' | 'Off' | 'Unknown (byte 5 = 0xNN)']`
- `['Dial string', … or '—']`
- `['Series', 3 | 4]`
- [ ] **Step 1: Write the failing Node tests:**
- `test_call_home_routes_need_a_serial`: `deviceUrl('call_home_on', BLANK)` → null; with S4 → `{method: 'POST', path: '/device/call_home/enable?serial=UM20147&host=h&tcp_port=9034'}`.
- `test_call_home_change_needs_a_confirmed_series`: typed but unconfirmed → false; confirmed 3 → true; confirmed 4 → true; legacy → false.
- `test_call_home_rows`: `{enabled: true, dial_string: 'RADIO RING', series: 4}` → `[['Call-home','On'],['Dial string','RADIO RING'],['Series',4]]`; `{enabled: null, detail: {byte5: '0x07'}, series: 3}` → first row `['Call-home','Unknown (byte 5 = 0x07)']`.
- Update the `changeErrorText` and `serialPanes` tests to the new shapes.
- [ ] **Step 2: Run** `pytest tests/test_webapp_device_routing.py`. Expected: FAIL (`callHomeRows` is not defined).
- [ ] **Step 3: Implement the routing functions**, then the glue:
- By serial, the Call Home tab hides the legacy form and shows the state box via `serialPanes`, in `applyControls`.
- `readCallHome()` uses `call_home_state` and renders `callHomeRows`.
- `changeCallHome(on)` asks `confirm()` with the serial and on/off, sends `call_home_on`/`call_home_off`, reports with `changeSummary` / `changeErrorText('Enable call-home' | 'Disable call-home', …)`, then re-reads the state.
- The buttons are enabled by `controlsFor().callHomeChange`.
- HTML: `#ch-state` (a `dev-table`), `#ch-on-btn` and `#ch-off-btn` inside a `#ch-serial` box; the existing form goes in `#ch-legacy`.
- [ ] **Step 4: Run** the Node tests (pass), then the jsdom check. Extend `page_files_load.js` with:
- S4: Call Home read → rows shown, legacy form hidden;
- Off → `POST /device/call_home/disable?serial=UM20147…` sent after confirm, status from `changeSummary`;
- legacy mode: form shown;
- no script errors.
- [ ] **Step 5: Commit** `feat(sfm): the page's Call Home tab by serial -- state and audited On / Off (phase 4)`.
### Task 7: Docs, and the bench session (Brian's go per send)
**Files:**
- Modify: the spec (a "Phase 4" entry after phase 3's under Build phases), `CLAUDE.md` ("Where things stand"), and `docs/micromate_protocol_reference.md` / `docs/instantel_protocol_reference.md` (CRLF: Edit tool or byte-safe writes) for whatever the bench measures
- [ ] **Step 1: Docs before the bench.**
- Spec: what was built, with commit IDs; the gate's state; the bench questions below.
- CLAUDE.md: one status line.
- Commit `docs: phase 4 built -- call-home enable/disable by serial; bench questions`.
- [ ] **Step 2: Bench, UM20147 on its modem, idle.** One send per go:
- (a) dry run `disable`, showing frames and warnings, including "0x00 is unobserved";
- (b) `enable` with `even_if_already` (the no-op write: does a Micromate accept it?);
- (c) `disable`: read-back, the unit's screen, and the snapshot's changed offsets;
- (d) `enable`, back to how it was.
- Record each audit id and `[118:120]` before/after.
- [ ] **Step 3: Bench, BE9441 on its modem, idle.**
- If Task 4 did not run: first record Blastware changing call-home on BE9441 through the bridge, then run Task 4.
- Then (a) to (d) as above.
- [ ] **Step 4: One unit monitoring** (Brian picks which): a dry run, then one `disable` / `enable` pair. This settles whether a unit accepts a call-home write while monitoring. Unmeasured; nothing in the code assumes either answer.
- [ ] **Step 5: Record the results** in the spec and the protocol references (measured, with audit ids), and commit `docs: phase 4 bench -- call-home on/off on both series`.