feat(sfm): POST /device/settings/change; retire the legacy config write

DeviceAccess.change_settings refuses before any I/O a request with no
changes, a live change without its preview's revision, or no audit log,
then dispatches the series' change (never retried).  The route returns
the preview (fields old -> new, warnings, blocked, revision) or the
result (fields old/new/now), statuses as the other changes, and marks
the cached by-host config dirty after a live change.

/device/config and /device/config/project now answer 410 with a pointer.
Deleted with them: MiniMateClient.apply_config / set_project_info and
the raw-offset _encode_compliance_config (#46 found it wrong), the
lab script poc_set_project.py and experiments.py's EXP6, both of which
wrote a live unit through it.  Git keeps them.

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-03 21:51:20 -05:00
1 parent 66bb29b9d4
commit e8eabee4a2
10 files changed
+316 -749

No files matched your search

+4 -9
View File
@@ -23,7 +23,7 @@ from fastapi import HTTPException # noqa: E402
import sfm.server as srv # noqa: E402
WRITES = {"delete_all_events", "apply_config", "set_call_home_config", "stop_monitoring"}
WRITES = {"delete_all_events", "set_call_home_config", "stop_monitoring"}
ADDR = dict(port=None, baud=38400, host="10.0.0.9", tcp_port=9034)
@@ -56,9 +56,6 @@ class Unit:
def delete_all_events(self):
self._rec("delete_all_events")
def apply_config(self, **kw):
self._rec("apply_config")
def set_call_home_config(self, **kw):
self._rec("set_call_home_config")
@@ -72,8 +69,6 @@ class Cache:
def _call(route, serial):
if route == "config":
return srv.device_config(body=srv.DeviceConfigBody(), serial=serial, **ADDR)
if route == "erase":
return srv.device_events_erase(serial=serial, **ADDR)
if route == "rescue":
@@ -98,7 +93,7 @@ def unit(monkeypatch):
return make
ROUTES = ["config", "erase", "rescue", "call_home"]
ROUTES = ["erase", "rescue", "call_home"] # /device/config is retired (410)
@pytest.mark.parametrize("route", ROUTES)
@@ -131,8 +126,8 @@ def test_guarded_route_proceeds_for_the_named_series3_unit(unit, route):
def test_the_identity_check_reuses_connects_serial_where_there_is_one(unit):
# speed: config and erase already read the serial in connect(); no extra read
for route in ("config", "erase"):
# speed: erase already reads the serial in connect(); no extra read
for route in ("erase",):
u = unit("BE9441")
_call(route, None)
assert "read_serial" not in u.calls