fix(settings): final-review fixes -- revision, resulting limits, logical writes
From the whole-branch review of phase 5: - The preview's revision now covers the changes asked for, so a live change must be exactly what was previewed (any API caller, not only the page). It covers what the preview showed -- the settings block (and a Micromate's setup name) -- not the blocks a write only echoes, which are re-read at send and sent as read (a MiniMate's trigger block byte 5 differs by session, #46). - The units' limits hold on the block that would result: a range, rate or mode change alone can no longer leave a held trigger, alarm or record time over them. - Every MiniMate block read is logical, so push_config_raw no longer unescapes again (a job number of 4098, 10 02, was refused at Send); the preview runs the write's own block check, so a block it would refuse is shown as blocked. - A MiniMate's monitoring refusal says a stop makes it call in (spec). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
385716d8e1
commit
08d0a6c0d4
9 files changed
+209
-43
No files matched your search
@@ -23,7 +23,8 @@ from micromate.protocol import ProtocolError as _MMProtocolError
|
||||
from micromate.schedule import parse_schedule, schedule_conflicts
|
||||
from micromate.setup_block import decode_setup
|
||||
from micromate.setup_fields import (
|
||||
SettingsValueError, check_changes, editable_fields, encode_setup, field_rows, settings_state,
|
||||
SettingsValueError, changes_bytes, check_changes, editable_fields, encode_setup, field_rows,
|
||||
settings_state,
|
||||
)
|
||||
from micromate.setup_fields import revision as settings_revision
|
||||
from micromate.writes import (
|
||||
@@ -503,10 +504,12 @@ def s4_change_settings(client: Any, serial: str, *, changes: dict, revision: Opt
|
||||
normal = check_changes(setup, 4, changes)
|
||||
except SettingsValueError as exc:
|
||||
raise BadRequest(f"{exc} -- nothing sent") from exc
|
||||
rev = settings_revision([name.encode("ascii", "replace"), prefs, trigger, setup])
|
||||
# What the preview showed: the target name, the setup block, the changes. The
|
||||
# preferences and trigger blocks are re-read here and sent back as read.
|
||||
rev = settings_revision([name.encode("ascii", "replace"), setup, changes_bytes(normal)])
|
||||
if not dry_run and revision != rev:
|
||||
raise SettingsChanged(f"{serial}'s settings changed since the preview -- preview "
|
||||
"again; nothing sent")
|
||||
raise SettingsChanged(f"{serial}'s settings, or the changes asked for, are not the ones "
|
||||
"previewed -- preview again; nothing sent")
|
||||
image = encode_setup(setup, 4, normal)
|
||||
blocked: list = []
|
||||
warnings = [_EDIT_BUFFER_WARNING]
|
||||
|
||||
Reference in new issue
Block a user