feat(api): per-field verification for POST /machine/settings - #793
Closed
ChampionDesigns wants to merge 2 commits into
Closed
ChampionDesigns wants to merge 2 commits into
ChampionDesigns wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/v1/machine/settingsanswered a bare202, so a client could not tell whether themachine 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
MachineSettingWriteStatusisappliedwhen the read-back matches within half of one writequantization step,
adjustedwhen the machine took something else, andunverifiedwhen theread-back itself failed. A read-back timeout is reported as
unverified, never mistaken for asuccessful write.
MockDe1.setFanThreshholdnow clamps toMMRItem.fanThreshold's own min/max, as the firmwaredoes. Without that the mock could hold a value the machine never could, and a read-back
verification cannot tell
appliedfromadjusted.That correction exposed a pre-existing defect:
de1handler_settings_reset_testexpected a fanthreshold 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.machine, and has been exercised in normal use rather than only under test.
Impact
POST /api/v1/machine/settingsnow returns{"results": {...}}in the 202 body whereit returned a bare ack.
assets/api/rest_v1.ymlgainsDe1SettingsWriteReportandDe1SettingWriteResult;doc/Api.mddocuments them.not change.
MockDe1is stricter — it clamps where it did not. Tests that relied on the mockholding an out-of-range value will now see the clamped value, which is what the machine does.
Contributor Responsibility
AI-assisted development is allowed. The submitter remains responsible for the submitted work.