8000 [Feature] AI evidence, safety, and provider contract hardening · Issue #92 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

[Feature] AI evidence, safety, and provider contract hardening #92

Open

Description

@shroominic

Outcome

Turn the existing AI foundation into a production-suitable, evidence-bound contract before exposing AI output in the main product.

Current gaps

  • Persisted insights contain free text and a broad time window but no evidence references.
  • Model output is stored without structured validation.
  • The Settings “Test with aggregates” action sends real health aggregates and persists an insight.
  • The provider is described as Anthropic-compatible, but requests always use an OpenAI-style /chat/completions endpoint/body. Only Anthropic headers and response parsing exist.
  • There is no provider-strategy ADR, adversarial safety evaluation, data receipt, output retention, or insight deletion UI contract.

Scope

  • Define versioned MetabolicContextSnapshot, EvidenceRef, and typed ObservationDraft contracts.
  • Require every numeric/factual statement to reference deterministic evidence generated by the analytics layer.
  • Add provider capability metadata: local/remote, structured output, availability reason, context size, locale, model/version, and resource limits.
  • Separate a synthetic no-health-data connection test from explicit real generation.
  • Show endpoint hostname and exact outgoing data categories before remote generation.
  • Implement output/refusal validation and reject unsupported evidence IDs or inconsistent numbers.
  • Rename cloud support to OpenAI-compatible or add a distinct Anthropic Messages serializer, endpoint, and contract tests.
  • Record an AI provider/safety ADR.
  • Define deletion, export, invalidation, prompt/model versioning, feedback, and retention behavior.
  • Add medical/dosing/treatment/emergency/prompt-injection evaluation fixtures.

Provider strategy

  1. Deterministic local observations always work without AI.
  2. Apple on-device model when available.
  3. Curated, capability-qualified local GGUF/llama.cpp runtime.
  4. Explicit BYO cloud under Advanced.
  5. Never silently fall back from local to remote.

Parallelization

Ready now. This owns AI contracts, provider adapters, safety validation, ADR, and tests. It can run in parallel with #89, the design-system issue, and deterministic analytics, but should consume—not redefine—the evidence contract from the analytics lane.

Acceptance criteria

  • Unsupported evidence or numeric claims are rejected before persistence/display.
  • Sparse data never generates an observation.
  • AI disabled means zero network activity.
  • Synthetic connection testing sends no health data.
  • Real remote generation shows recipient and data preview and requires explicit consent.
  • Native Anthropic either works end-to-end with contract tests or is not claimed.
  • All AI artifacts and keys have verified delete/export behavior.
  • Prompt/model/OS versions are recorded for reproducibility.
  • Representative unsafe prompts and journal prompt-injection fixtures fail closed.
  • ADR, threat model, rollback plan, and R2 independent review are complete.

Out of scope

  • Final Today insight card.
  • Open-ended chat.
  • Model download UI.
  • Autonomous actions or alerts.

Repository-owner recreation of the legacy issue at #39. The original discussion remains available there.

Activity

  1. added this to the 0.4 Evidence AI milestone on Sep 1, 2026
  2. added
    enhancementNew feature or request
    area:aiAI providers, safety, grounding, and insight surfaces
    risk:R2Health data, persistence, integration, AI, accessibility, or native risk
    priority:P1Next product-value delivery
    parallel:readyCan begin independently in the current wave
    on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aiAI providers, safety, grounding, and insight surfacesenhancementNew feature or requestparallel:readyCan begin independently in the current wavepriority:P1Next product-value deliveryrisk:R2Health data, persistence, integration, AI, accessibility, or native risk

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0