8000 fix(cbio): disclose the positions the stored history never received by shroominic · Pull Request #188 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

fix(cbio): disclose the positions the stored history never received - #188

Merged
shroominic merged 1 commit into
feature/cbio-gs1-app-livefrom
fix/cbio-history-holes
Sep 18, 2026
Merged

shroominic merged 1 commit into
feature/cbio-gs1-app-livefrom
fix/cbio-history-holes

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Closes #187.

The defect

cbioStoredRangeText reported count + first–last, which is an envelope, not
what the app stored. The protocol's index counter advances one per stored
minute, so a span can contain positions that never arrived. Five records at
1, 2, 3, 6, 7 were captioned "sensor minutes 1–7".

RED

cd openhealth && flutter test test/cbio_app_surface_test.dart --plain-name 'names a hole'
exit 1
Expected: '5 readings stored · sensor minutes 1–7 · 2 positions not received'
  Actual: '5 readings stored · sensor minutes 1–7'
cd openhealth && flutter test test/cbio_app_surface_test.dart --plain-name 'names a hole in the stored history'
exit 1
(the dashboard renders the same envelope for a history holed at 13 and 14)

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

  • cbioMissingPositions(readings) answers the question the caption was missing:
    distinct sensor positions, their span, and the difference. It works from the
    readings the surface already has, so no new snapshot field or archive
    plumbing is needed - the same arithmetic CbioHistoryArchive.hasGap performs
    at ingest time.
  • cbioStoredRangeText appends the count when it is non-zero:
    5 readings stored · sensor minutes 1–7 · 2 positions not received.
  • A full span is byte-for-byte unchanged, so the existing dashboard test and
    every contiguous history keep the caption they had.

Tests added

  • the stored range names a hole instead of printing an envelope - a full span,
    a holed span, and a single record.
  • the dashboard names a hole in the stored history - the real widget, found by
    its ValueKey('cbioStoredRange'), asserts the rendered text.

Observed, not fixed here

A hole also pins historySync.inProgress to true forever, because
CbioGlucoseSession._atLiveEdge returns false when CbioHistoryArchive.hasGap.
The history section therefore shows "Fetching sensor history: 5 of 16 records"
for a fetch that is finished but holed. That is a different defect in the sync
contract - it is inProgress conflating "still fetching" with "not at the live
edge" - and it changes when the session persists history and when
ensureFreshData catches up, so it is deliberately left out of this caption
fix. The card now names the hole in the meantime.

Verification

  • cd openhealth && flutter test - exit 0, +482: All tests passed!
  • flutter analyze - No issues found!
  • dart format on every line this branch adds - no change

shroominic added a commit that referenced this pull request Sep 18, 2026
Merges fix/cbio-history-holes (#188). The one conflict was additive: the
aggregate's closed-failure sentence test and the branch's hole-caption tests
both insert at the same point, so both are kept.

No credential, address, or vendor material is added by this merge.
@shroominic
Copy link
Copy Markdown
Owner Author

Rebase reminder (comment only, no edits to this branch).

The lane head is now 05785b0 (#192 merged). This PR is still based on 17db5b4; the merge-base is fine, but expect a conflict in
packages/cgm_cbio/lib/src/cbio_glucose_session.dart around credential resolution. Resolve it by keeping the injected path:

  • the session resolves CbioCredentials once per session into _resolved, before the transport is touched, and every mask/unmask/builder call receives _streamKey/the material explicitly;
  • CbioCompiledAuthMaterialProvider and the compiled constants are gone; a build without material fails closed with cbio.auth.material;
  • the lane also reads _clockReferenceEpochSeconds (set in _writeClock) when it derives the record-index anchor, so keep that field and the _historyReadingsFor(anchor) / metadata spread when you resolve.

Rebase onto feature/cbio-gs1-app-live before review so CI runs against the lane head.

@shroominic
shroominic force-pushed the fix/cbio-history-holes branch from 8e44316 to b0dc99f Compare September 18, 2026 09:43
@shroominic
shroominic merged commit 77795f9 into feature/cbio-gs1-app-live Sep 18, 2026
3 checks passed
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