8000 fix(cbio): drop the unverified mg/dL claim from the raw record by shroominic · Pull Request #168 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

fix(cbio): drop the unverified mg/dL claim from the raw record - #168

Closed
shroominic wants to merge 1 commit into
feature/cbio-gs1-glucose-livefrom
fix/cbio-archive-unit-claim
Closed

shroominic wants to merge 1 commit into
feature/cbio-gs1-glucose-livefrom
fix/cbio-archive-unit-claim

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Closes #145.

The defect

CbioRawGlucoseRecord divided the raw 08 field by ten, multiplied by
18.0182, and exposed the result as derivedMilligramsPerDecilitre. The test
pinned it as a fact (expect(first.derivedMilligramsPerDecilitre, 141)), and
that number is what the app rendered as a glucose value.

Nothing in this repository establishes that /10 is mmol/L, and no reference
measurement exists for this sensor. The accessor asserted a unit the protocol
does not carry, and #145 records where the rendered 101 mg/dL came from: raw
56 on the shared /10 scale, multiplied and labelled.

The fix

  • derivedMillimolesPerLitre and derivedMilligramsPerDecilitre are removed.
  • rawCurrentScaled replaces them: rawCurrent / 10, documented as an
    unverified engineering value with no unit, and explicitly not mmol/L, not
    mg/dL, and not renderable with a unit suffix.
  • isUnitVerified stays false, and the class doc says no accessor carries a
    unit in its name.
  • A new test asserts the scaled value is the raw field over ten and that both
    removed accessor names throw NoSuchMethodError, so a unit-bearing getter
    cannot quietly come back.

Verification

  • packages/cgm_cbio: flutter test 61 passed; dart format --set-exit-if-changed lib test clean.

Note on scope

The downstream half of #145 - the app rendering sensor raw / 10 with no unit
suffix - lives in the live-session branch (#142). This PR removes the source of
the claim so nothing downstream can render it from the archive.

The archive divided the raw 08 field by ten and then multiplied by 18.0182 to
produce an mg/dL number, and the test asserted that number as a fact. Nothing in
this repository establishes that /10 is mmol/L, and no reference measurement
exists for this sensor, so the accessor asserted a unit the protocol does not
carry. The app rendered that number as a glucose value.

Expose the raw field and its scaled value and nothing else: rawCurrentScaled is
documented as an unverified engineering value with no unit, the unit-bearing
accessors are gone, and a regression test fails if either name comes back.

Refs #145
shroominic added a commit that referenced this pull request Sep 18, 2026
…andidate

Reverts the merge of fix/cbio-archive-unit-claim (#168).

#168 removes CbioRawGlucoseRecord.derivedMilligramsPerDecilitre and
.derivedMillimolesPerLitre and leaves only an explicitly unitless
rawCurrentScaled. The app-live surface still fills CgmReading.valueMgdl from the
removed mg/dL accessor, so the merge leaves six analyzer errors in cgm_cbio and,
fixing them, would change the number the live surface renders.

That is a unit-reference decision on the product surface, not a mechanical
merge, and it is the owner's to make. The lane needs an adoption change (as
#192 was for #166) before this can land. Recorded as excluded in the PR body.
@shroominic
Copy link
Copy Markdown
Owner Author

Release assembly note (0.4.0 candidate 92a1de2, PR #163): this change is excluded from the candidate, deliberately and not because it is wrong.

Merging it here leaves six analyzer errors in packages/cgm_cbio, all on the app-live surface:

error - lib/src/cbio_glucose_session.dart:821:27 - The getter 'derivedMilligramsPerDecilitre' isn't defined for the type 'CbioRawGlucoseRecord'
error - test/cbio_glucose_session_test.dart:1018:25 - The getter 'derivedMillimolesPerLitre' isn't defined ...  (5 more, same removal)

openhealth's live surface still fills CgmReading.valueMgdl from the removed accessor, so repairing this means choosing what number the GS1 surface renders for an unverified scale — a unit-reference decision, not an assembly merge. The candidate therefore still ships derivedMilligramsPerDecilitre/derivedMillimolesPerLitre; the unit stays UNVERIFIED behind the provisional marker either way.

What unblocks it is the same shape as #192 was for #166: an adoption commit on feature/cbio-gs1-app-live that moves the session off the removed getters (and says in one line what the app scale is). Once that lane tip carries it, this PR can be absorbed and re-verified.

shroominic added a commit that referenced this pull request Sep 18, 2026
Adopt the archive fix from `fix/cbio-archive-unit-claim` (#168, e81e335) into
the app-live lane. The record used to expose the raw `08` field three ways:
`rawCurrent`, a derived mmol/L accessor (`rawCurrent / 10`) and a derived mg/dL
accessor (`rawCurrent / 10 * 18.0182`). Nothing in this repository establishes
that either unit belongs to the field, so the record now exposes `rawCurrent`
and `rawCurrentScaled` and no unit-bearing accessor at all.

The six `cgm_cbio` analyzer errors that blocked the adoption were the session
and its tests still reading the removed accessors:

- `_historyReadingsFor` published the mg/dL derivation into
  `CgmReading.valueMgdl`; it now publishes `rawCurrentScaled`, the same
  unit-free `/10` scale the hero already renders.
- the session tests asserted the removed accessors; they now pin the scale
  itself and the number the session publishes (`raw 97 -> 9.7`).

This changes the number a cbio record carries, so it changes what the dashboard
chart plots (`raw 53`: `95` before, `5.3` now). The hero is unchanged - it
already rendered `rawValue / 10` with no unit - and provisional readings stay
excluded from Apple Health, so no surface claims the number as mg/dL.
Documented in `docs/testing/cbio-gs1-app-live.md`.

Refs #168, #145
@shroominic
Copy link
Copy Markdown
Owner Author

Adopted into the app-live lane as c19f68a (commit message mirrors this PR's own reasoning verbatim for the archive half). Why it could not merge here as-is: this PR's base is the old feature/cbio-gs1-glucose-live, and its six cgm_cbio analyzer errors are the session and its tests still reading the removed accessors. The repair chosen was the unit-free one: _historyReadingsFor now publishes rawCurrentScaled into CgmReading.valueMgdl instead of the * 18.0182 mg/dL derivation, so the record and the hero agree on the /10 scale and no surface claims a unit.

RED: archive/session tests referencing rawCurrentScaled -> 5 undefined_getter errors. GREEN: archive accessors replaced, session publishes rawCurrentScaled, six analyzer errors gone -> cgm_cbio 96 passed / 2 skipped, openhealth 498 passed, analyze clean both.

Render change, documented in docs/testing/cbio-gs1-app-live.md: the hero is unchanged (it already rendered rawValue / 10 with no unit), but the dashboard chart plots valueMgdl, so raw 53 plots 5.3 where it plotted 95. The docs commit 4702025 on this branch (a pointer in another lane's docs/testing/cbio-gs1-glucose-live.md) was deliberately not adopted.

Closing as superseded by the lane tip; reopening would only re-add the six errors.

@shroominic
Copy link
Copy Markdown
Owner Author

Superseded by the app-live lane tip (adoption commit c19f68a).

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.

1 participant

0