Skip to content

feat(api): per-field verification for POST /machine/settings - #793

Closed
ChampionDesigns wants to merge 2 commits into
decentespresso:mainfrom
ChampionDesigns:ben/machine-settings-verify
Closed

ChampionDesigns wants to merge 2 commits into
decentespresso:mainfrom
ChampionDesigns:ben/machine-settings-verify

Conversation

@ChampionDesigns

Copy link
Copy Markdown
Collaborator

Summary

POST /api/v1/machine/settings answered a bare 202, so a client could not tell whether the
machine took the value it asked for. It now reads every written field back inside the same
serialized device write
and answers with a per-field report:

{"results": {"fan": {"requested": 51, "actual": 50, "status": "adjusted"}}}

Base: main. Independent.

Design notes

MachineSettingWriteStatus is applied when the read-back matches within half of one write
quantization step
, adjusted when the machine took something else, and unverified when the
read-back itself failed. A read-back timeout is reported as unverified, never mistaken for a
successful write.

MockDe1.setFanThreshhold now clamps to MMRItem.fanThreshold's own min/max, as the firmware
does. Without that the mock could hold a value the machine never could, and a read-back
verification cannot tell applied from adjusted.

That correction exposed a pre-existing defect: de1handler_settings_reset_test expected a fan
threshold of 55, which is above the firmware's max of 50 and was never reachable. The
unclamped mock was hiding it. It now expects 50.

Linked Issue

N/A

Verification

  • flutter analyze — clean.
  • flutter test — the three settings test files 40 passed, and the full suite 3931 passed /
    1 skipped
    after the mock clamp, which touches every test that writes a fan threshold.
  • dart format — clean on every changed file.
  • Verified on hardware. This change ships in the Decaid-Canary build Ben runs on his own
    machine, and has been exercised in normal use rather than only under test.

Impact

  • API: POST /api/v1/machine/settings now returns {"results": {...}} in the 202 body where
    it returned a bare ack. assets/api/rest_v1.yml gains De1SettingsWriteReport and
    De1SettingWriteResult; doc/Api.md documents them.
  • Compatibility: additive. A client that ignores the body is unaffected; the status code does
    not change.
  • User-visible: none directly. A skin can now show whether a setting took.
  • Behaviour: MockDe1 is stricter — it clamps where it did not. Tests that relied on the mock
    holding an out-of-range value will now see the clamped value, which is what the machine does.
  • Security: none.

Contributor Responsibility

AI-assisted development is allowed. The submitter remains responsible for the submitted work.

  • I have reviewed and understand all changes in this PR and take responsibility for their correctness, security, behavior, licensing, and provenance, including any AI-assisted or AI-generated work.

ChampionDesigns and others added 2 commits September 5, 2026 11:15
The endpoint answered a bare 202, so a client could not tell whether the
machine took the value it asked for. It now reads every written field back
inside the same serialized device write and answers with a per-field report:

  {"results": {"fan": {"requested": 51, "actual": 50, "status": "adjusted"}}}

MachineSettingWriteStatus is applied when the read-back matches within half of
one write quantization step, adjusted when the machine took something else,
and unverified when the read-back itself failed — a timeout is reported as
unverified rather than being mistaken for a successful write.

MockDe1.setFanThreshhold now clamps to MMRItem.fanThreshold's own min/max, as
the firmware does. Without that the mock could hold a value the machine never
could, and a read-back verification cannot tell "applied" from "adjusted".
That corrects one existing assertion: de1handler_settings_reset_test expected
a fan threshold of 55, which is above the firmware's max of 50 and was never
reachable. It now expects 50.

The doc says the applied tolerance is HALF of one quantization step, matching
what the code compares — the correction decide/machine-settings-refusal was
written for, which had no feature to attach to until now.

Verified: flutter analyze clean, the three settings test files 40 passed, the
FULL suite 3931 passed / 1 skipped, dart format clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…s-verify

# Conflicts:
#	assets/api/rest_v1.yml
@tadelv tadelv closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants