Repository navigation
fix(cbio): give every closed failure its own code and its own sentence - #186
Conversation
Merges fix/cbio-failure-taxonomy (#186). Conflicts were both additive: - session_presentation.dart: union. The aggregate's closed-phase progress copy and the new per-code failure sentences are independent additions. - cbio_glucose_session.dart: take the aggregate's keyed builder call and keep the branch's write verdict. One auto-merged line returned bool from a CbioFrameWrite method; corrected to CbioFrameWrite.unavailable.
Three cases added by #186 constructed a session with the default credential source, which now fails closed with cbio.auth.material before the code under test can run. They take the suite's synthetic source like their neighbours, so they reach cbio.auth.rejected, cbio.auth.timeout, and cbio.write.failed again.
|
Rebase reminder (comment only, no edits to this branch). The lane head is now
Rebase onto |
d86bba7 to
375055b
Compare
375055b to
ced53af
Compare
|
Rebased onto the lane and merged as |
Closes #184.
The defect
cbio.connect.failedcbio.topology.failedcbio.auth.materialcbio.auth.timeoutcbio.auth.rejectedcbio.write.failedcbio.disconnected_sendMaskedlogged a refused write and returnedfalse; every caller returnedquietly, so the session stayed in
connectingwith no terminal state. AndprimaryErrorTextForSnapshotreturnedsnapshot.lastErrorverbatim for anydriver that is not Libre 2, so the failure card showed
cbio.connect.failed.RED
Both runs are against
17db5b4, the base this branch forks.GREEN
Same two commands on this branch:
exit 0,+1: All tests passed!each.The fix
_sendMaskedstops returning a barebool. It returnsCbioFrameWrite-sent,failed,unavailable,blocked,budgetExhausted- because thosefive outcomes are not interchangeable. A blocked frame never left the app, an
exhausted read budget is a normal end to polling, and a failed write means the
sensor never received the frame.
_requireWritten(outcome)fails closed withcbio.write.failedwhen theoutcome is
failed. It is used by the three frames the vendor sequence cannotproceed without: authentication, the one-time clock, and the first packed
query. The clock and query previously ignored their result entirely.
CgmSyncStage.error+CbioSessionPhase.failed+cbio.write.failedinstead of parking._readFrom(the live poll) keeps its old behaviour for the non-writeoutcomes: only a genuinely spent budget publishes the budget state. A refused
poll write no longer 8000 publishes "Read budget reached", which it never was.
userMessageForCbioFailure(code)gives each code its own sentence, andprimaryErrorTextForSnapshotuses it for CBio snapshots, exactly where Libre 2already does. Samples:
cbio.auth.rejected- "The sensor refused the link credential this builduses. Choose another sensor or update the app."
cbio.topology.failed- "This sensor does not present the link OpenGlucosesupports yet. Choose another sensor."
cbio.auth.timeout- "The sensor did not answer the link setup. Keep it closeand try again."
What this deliberately does not change
The per-code
statusTextin_failis still the same string. It is not theuser-visible surface for a failure:
sensor_connection_screen.dartrouteserroranddisconnectedstages to_ConnectionFailure, whose message comesfrom
primaryErrorTextForSnapshot. ChangingstatusTextwould have added asecond, competing layer of copy that nothing on the failure path reads. The
sentence layer is the one that was missing.
_failureCodeForkeepsCbioProtocolException->topology: it is thecatch-all for an unexpected error, and every deliberate protocol rejection is
already thrown with its own code at the throw site. Splitting
topologybycharacteristic would be a new taxonomy decision rather than a fix, so it is left
alone here.
Tests added
a write the radio refuses fails the setup with its own code- stage, codeand phase.
an unusable credential is never reported as a refused one- the linkresolves its credential before it asks the sensor, so those two codes cannot
swap.
a closed CBio failure reaches the user as a sentence- loops all sevencodes and fails if any reaches the card as
cbio.*.Verification
cd packages/cgm_cbio && flutter test- exit 0,+77: All tests passed!cd openhealth && flutter test- exit 0,+481: All tests passed!flutter analyze-No issues found!in both packagesdart formaton every line this branch adds - no changeFormatter note:
packages/cgm_cbio/test/cbio_glucose_session_test.dartalreadycarried unrelated formatter drift at
17db5b4(verified against a clean archiveof the base commit), so only the added lines are kept format-stable here.