8000 fix(cbio): give the device harnesses a real verdict (#155) by shroominic · Pull Request #185 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

fix(cbio): give the device harnesses a real verdict (#155) - #185

Closed
shroominic wants to merge 1 commit into
feature/cbio-gs1-glucose-livefrom
fix/cbio-device-harness-assertions
Closed

shroominic wants to merge 1 commit into
feature/cbio-gs1-glucose-livefrom
fix/cbio-device-harness-assertions

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Closes #155.

The two device-backed harnesses on this lane recorded evidence and asserted
nothing, so a regression in the authenticated read path could only be caught by
re-reading stdout. Both now produce a verdict.

What actually asserts

packages/cgm_cbio/lib/src/cbio_session_evidence.dart is a pure, host-tested
record: outcome, per-kind write counts, record counts and index ranges, raw
value range, bounded timing, closed error taxonomy, and app/harness identity.
invariantViolations() is the verdict.

Query harness (cbio_glucose_query_test.dart):

  • every frame is classified before it is transmitted and must be inside
    {device_information_read, glucose_read}; an unlisted frame fails before it
    is sent;
  • the invariant list must be empty;
  • outcome must be completed;
  • at least one notification and at least one decoded 0A glucose batch;
  • the harness's own decode is cross-checked against parseCbioGlucoseBatch
    from the production package, and a raw-value disagreement fails the run.

Authenticated harness (cbio_glucose_authenticated_test.dart):

  • every frame is classified before it is transmitted and must be inside
    {authentication, clock_set, glucose_read, raw_history_read};
  • the invariant list must be empty;
  • outcome must be completed (no target, missing characteristics and a failed
    authentication all produce a named non-completed outcome and a failure);
  • at least one notification and at least one decoded glucose or raw record.

Both harnesses emit CBIO-EVIDENCE <json> before the assertions run, so a
failed session still leaves a machine-readable record behind. #156 consumes
that line into a durable artifact.

Deferral

make test-e2e now says the device lane was deferred, that nothing ran, and
names every skipped harness:

DEVICE END-TO-END LANE DEFERRED: nothing was executed by this command.
Skipped device-backed harnesses:
  openhealth/integration_test/cbio_glucose_authenticated_test.dart
  openhealth/integration_test/cbio_glucose_query_test.dart
  openhealth/integration_test/cbio_live_capture_test.dart

Verification

  • packages/cgm_cbio: dart analyze --fatal-infos clean, 66/66 tests pass
    (six new evidence tests).
  • openhealth: flutter analyze --no-pub --fatal-infos clean.
  • dart format --output=none --set-exit-if-changed integration_test clean
    (this also clears the chore(cbio): format the lane integration harness #152 formatting drift in these two files).
  • make test-e2e prints the deferral above.

Notes:

The two device-backed GS1 harnesses printed evidence lines and asserted
nothing, so a regression in the authenticated read path could only be caught by
re-reading stdout. Both now build a CbioSessionEvidence record per run, assert
its invariants, and fail loudly when the session does not reach its verdict.

- New pure, host-tested model in packages/cgm_cbio: outcome, write-kind
  classification, closed error taxonomy, record counts/ranges, timing, and
  app/harness identity. It cannot carry an address, credential bytes, vendor
  material, or a physical unit.
- Writes are classified before they are transmitted and must be inside each
  harness's allow-list, so an unlisted command cannot be sent unnoticed.
- The query harness cross-checks its own 0A decode against the production
  parser and fails on a raw glucose disagreement.
- `make test-e2e` now reports the deferral loudly and names every skipped
  device-backed harness instead of reporting a generic deferral.
@shroominic
shroominic force-pushed the fix/cbio-device-harness-assertions branch from 395232e to 6ec7ff2 Compare September 18, 2026 05:09
shroominic added a commit that referenced this pull request Sep 18, 2026
…lane

Merges fix/cbio-device-harness-assertions (#185). The branch forked at 4702025,
before the app-live lane's injected-credential adoption, so its harness files
call the pre-redaction API.

Resolutions:
- packages/cgm_cbio/lib/cgm_cbio.dart: union of both exports.
- scripts/flutter-workspace.sh: union. device_integration_files() keeps the
  aggregate's device lane; device_backed_harnesses() feeds the new test-e2e
  deferral report.
- openhealth/integration_test/cbio_glucose_query_test.dart: take the branch's
  file. It is a strict superset of the aggregate's (formatting only).
- openhealth/integration_test/cbio_glucose_authenticated_test.dart: take the
  branch's instrumented file and re-apply the aggregate's injected-credential
  boundary: _credentials from the environment/defines, a noted
  vendor_material_missing abort, and key:/material: arguments on every builder
  and unmask call.
@shroominic
Copy link
Copy Markdown
Owner Author

Merge-order note for this stack, from the evidence lane (2026-09-18).

#185 should land first, then #166 rebases onto it. Neither order is conflict-free — git merge-tree --write-tree conflicts on openhealth/integration_test/cbio_glucose_authenticated_test.dart either way — so the decision is which rebase is smaller and safer, and that is not symmetric:

Landing #185 first leaves #166 a mechanical re-application — add the guarded credential block, then thread the required key: through the call sites. Landing #166 first makes #185 re-derive its entire rewrite on top of the credential plumbing. Both end with the same tree; only the cost and the review burden differ.

One ordering constraint that does not depend on this: #166 removes a default parameter from unmaskCbioFrame, so it must not land on a branch where any caller still uses the old signature. Whichever PR goes second has to update the call sites in the same commit.

If the security fix has to land sooner than #185 can be reviewed, #166 can go first — that is a deliberate trade of a larger rebase in #185 for earlier removal of the committed vendor material, not a correctness problem.

@shroominic
Copy link
Copy Markdown
Owner Author

Carried by the GS1 consolidation in PR #209 (branch feature/cbio-gs1, head 3eca4f4).

This PR is contained in the consolidated line; the merge that carries it is c85f827.

Closing as subsumed by the consolidation - not as won't fix. The per-defect evidence stays in this thread, and the carrying commit above is where the change now lives.

@shroominic shroominic closed this Sep 18, 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.

1 participant

0