PVA Local Data and AI Boundary Pass
internal prototype · canonical JSON + Dreamborn Forge HTML
internal generated
local-data-ai-boundary-pass · supabase_json

PVA Local Data and AI Boundary Pass

local-data-ai-boundary-pass artifact · for Patient Visit Advocate · phase PVA-SLICE-02 · status approved

Planning Surface

Use this to decide what happens next.

Status

approved

Phase

PVA-SLICE-02

Agent Handoff
Start Here

local-data-ai-boundary-pass artifact · for Patient Visit Advocate · phase PVA-SLICE-02 · status approved

Completion Evidence

No explicit evidence field yet. Require tests, screenshots, linked PRs, or reviewed outputs before marking complete.

Artifact Shape
  • phase: id: string, name: string, status: string
  • title: PVA Local Data and AI Boundary Pass
  • product: Patient Visit Advocate
  • purpose: Convert the approved patient-data-ai-contract into implementation-ready data and model boundaries: explicit state machine, field-level entity specs, local storage recommendation, AI boundary options, hard blockers before server-side PHI, and free-to-paid transition rules. This is a focused pass artifact — no code, no migrations.
  • pass type: delta
  • created at: 2026-05-08
  • created by: vikram
  • ai boundary: output_contract: object, local_prototype_options: object, recommended_prototype_path: string, ai_agent_constraints_from_architecture: object
  • artifact type: local-data-ai-boundary-pass
  • data entities: 6 items
  • open decisions: 4 items
  • schema version: 1.0
Structured Payload

Machine-readable source fields

phase
id

PVA-SLICE-02

name

Patient Data + AI Contract

status

draft

title

PVA Local Data and AI Boundary Pass

product

Patient Visit Advocate

purpose

Convert the approved patient-data-ai-contract into implementation-ready data and model boundaries: explicit state machine, field-level entity specs, local storage recommendation, AI boundary options, hard blockers before server-side PHI, and free-to-paid transition rules. This is a focused pass artifact — no code, no migrations.

pass type

delta

created at

2026-05-08

created by

vikram

ai boundary
output contract
required outputs
  • StructuredCaptureField records with source and confidence tags
  • Visit brief stub with uncertainty markers
  • Question plan items framed as clinician discussion questions
  • Safety flags isolated in EscalationEvent, not mixed into summary text
  • model_version and generated_at provenance on any AI-generated artifact
prohibited outputs
  • Diagnosis or differential diagnosis as fact
  • Treatment instruction or medication recommendation
  • Dosage recommendation
  • Emergency triage specificity beyond approved escalation copy
  • Any field labeled 'diagnosis', 'treatment', or 'recommendation' without explicit clinician-framing
local prototype options
optionphi risktradeoffdescriptionrecommended forblocker
A — Fully Manual / StubbedNone — no model call.Lower fidelity for testing value prop, but safest for prototype. Validates the form factor.No AI call. Structured fields are entered by the user directly. VisitBrief and QuestionPlan are template-based stubs.First 5–10 user tests.
B — Browser-Local Model (e.g. WebLLM / Ollama local)Low — no server transmission. Model provenance and output quality must be verified.Feasibility depends on device capability and model size. Not guaranteed on all phones.Small model runs on device. RawCapture text is processed locally. No text leaves the device.Model selection and output quality review required before patient testing.
C — Controlled Cloud Model with Synthetic Data OnlyNone if strictly synthetic. Must enforce no-real-PHI rule at call site.Good for validating generation quality without PHI risk. Must not drift to real data.Cloud model (e.g. Claude API) called with synthetic/anonymized intake text only. No real patient text.Demo and internal quality testing before real-user prototype.
D — Cloud Model with Approved Consent PathHigh — all server PHI blockers (SPB-001 through SPB-007) must be cleared.Full product experience but blocked until legal, data contract, and retention decisions complete.Real patient text sent to cloud model. Requires full server-side PHI contract.
recommended prototype path

Option A (manual/stubbed) for initial prototype. Option C (synthetic cloud) for internal generation quality testing. Option D only after all server PHI blockers resolved.

ai agent constraints from architecture
  • intake-agent: No diagnosis, no treatment recommendations. Ask adaptive questions, extract structured fields from messy input.
  • clinical-guardrail-layer: Classify seriousness signals conservatively. Never produce diagnosis categories as facts.
  • question-generator: Questions framed for clinician discussion only. Never clinical directives.
  • translator: Uncertainty preserved. No simplification that loses important qualifiers.
  • memory-writer: User-corrected facts only. Raw chat is not primary memory.
artifact type

local-data-ai-boundary-pass

data entities
namefieldspurposestorage scopeuser controlsanalytics rule
LocalVisitDraft- local_id: name: string, type: string, notes: string, required: boolean - state: name: string, type: string, notes: string, required: boolean - visit_label: name: string, type: string, notes: string, required: boolean - created_at: name: string, type: string, notes: string, required: boolean - last_opened_at: name: string, type: string, notes: string, required: boolean - expires_at: name: string, type: string, notes: string, required: boolean - deleted_at: name: string, type: string, notes: string, required: boolean - server_visit_id: name: string, type: string, notes: string, required: booleAnonymous on-device visit prep container before any account creation or server sync.local-only- delete - export - view expiry date - extend expiry onceOnly state transitions and funnel counters may be reported. No visit_label, no health text.
RawCapture- capture_id: name: string, type: string, notes: string, required: boolean - local_draft_ref: name: string, type: string, notes: string, required: boolean - capture_type: name: string, type: string, required: boolean - text: name: string, type: string, notes: string, required: boolean - created_at: name: string, type: string, required: boolean - retention_policy: name: string, type: string, notes: string, required: boolean - local_only: name: string, type: string, notes: string, default: boolean, required: booleanOriginal typed or voice-transcribed user input, local-first with explicit retention tagging.local-only by default
StructuredCaptureField- field_id: name: string, type: string, required: boolean - local_draft_ref: name: string, type: string, required: boolean - section: name: string, type: string, required: boolean - label: name: string, type: string, notes: string, required: boolean - value: name: string, type: string, notes: string, required: boolean - source: name: string, type: string, required: boolean - model_confidence: name: string, type: string, notes: string, required: boolean - user_corrected: name: string, type: string, default: boolean, required: boolean - user_confirmed_at: name: string, type: string, notes: strinField-level extracted or user-entered structure from RawCapture, with model confidence and user correction state.local-only by default; server-syncable post account save if server PHI blockers cleared
EscalationEvent- event_id: name: string, type: string, required: boolean - local_draft_ref: name: string, type: string, required: boolean - trigger_category: name: string, type: string, notes: string, required: boolean - copy_version: name: string, type: string, notes: string, required: boolean - acknowledged_at: name: string, type: string, notes: string, required: boolean - stored_scope: name: string, type: string, notes: string, default: string, required: booleanRecord that serious-symptom safety copy was shown and acknowledged. Separates safety signal from health-text analytics.local-only; never synced to analytics or third-party systemstrigger_category counter (no text) may be reported as a funnel safety metric only after server PHI blockers cleared and only as aggregate count.
QuickVisitNote- note_id: name: string, type: string, required: boolean - local_draft_ref: name: string, type: string, required: boolean - question_ref: name: string, type: string, notes: string, required: boolean - note_text: name: string, type: string, notes: string, required: boolean - note_type: name: string, type: string, required: boolean - question_status: name: string, type: string, notes: string, required: boolean - created_at: name: string, type: string, required: boolean - local_only_until_saved: name: string, type: string, notes: string, default: boolean, required: booleanIn-visit or immediate post-visit note tied to question status or debrief. Supports in-visit quick note mode and post-visit capture.local-only until user opts into account save
ExportArtifact- export_id: name: string, type: string, required: boolean - local_draft_ref: name: string, type: string, required: boolean - format: name: string, type: string, required: boolean - sections_included: name: string, type: string, notes: string, required: boolean - created_at: name: string, type: string, required: boolean - user_confirmed_sensitive_share: name: string, type: string, notes: string, required: boolean - destination: name: string, type: string, notes: string, required: booleanMetadata record of a local export/share package. Tracks what was shared and requires explicit user acknowledgement before generation.local-only metadata; exported file is user-managedexport format and sections_included count only may be reported. No health text, no visit label.
open decisions
idownerimpactdecision
OD-001Justin / ProductDetermines whether any model infrastructure is needed for SLICE-01 testing.Which AI option (A/B/C) is used for the first prototype build?
OD-002Justin / ProductIf any free server persistence: all SPB blockers apply to free tier.Does the free app include a limited saved-visit trial (e.g. 3 visits), or is free always local-only?
OD-003Content / LegalSPB-005 blocks all patient-facing testing until resolved.What is the approved escalation copy version (ESC-V1 token and exact copy text)?
OD-004Justin / LegalSPB-003 blocker. No real PHI to cloud until resolved.Which server-side model provider and DPA are selected for Option D?
schema version

1.0

source artifacts
idroleuuid
patient-data-ai-contract/PVA-SLICE-02primary contract to expand1d0623fa-7b89-46d2-ab35-4b5223f17507
architecture/MVP-01approved AI agent boundaries and generation pipeline9783e2c4-7623-4324-8aaa-86ee7dd77733
local-pocket-prototype-spec/PVA-SLICE-01offline behavior, expiry, required screensae4aafaa-7ac7-4054-9b0a-fa443a7c8d94
trust-boundary-charter/PVA-SLICE-00hard rules TB-001 through TB-00878ca477c-cd9c-4ba8-84ed-db0944e88702
revised-decomposition-plan/PVA-AUTOPILOT-01routing and slice exit conditions17a8249c-f8f0-42e5-aef1-1c9dd7e0c784
delta from approved
summary

M-01 Visit Data Model and Architecture MVP-01 define the full server-side entity set and AI workflow. This pass does NOT modify those artifacts. It adds six local-prototype entities not present in M-01, specifies their state machine and field contracts, defines local-only storage, and draws the lines AI processing must not cross before server-side PHI is approved.

new in this pass
  • LocalVisitDraft — anonymous on-device container with explicit state machine
  • RawCapture — original user input with retention tagging
  • StructuredCaptureField — field-level extraction with confidence and correction state
  • EscalationEvent — record of serious-symptom copy acknowledgement
  • QuickVisitNote — in-visit and immediate post-visit note keyed to question status
  • ExportArtifact — local export package metadata with sensitive-share acknowledgement
m01 entities retained unchanged
  • PatientProfile
  • Visit
  • IntakeSummary
  • VisitBrief
  • QuestionPlan
  • PostVisitDebrief
  • PatientMemoryItem
  • CaregiverAccess
  • LegalAcknowledgement
architecture constraints retained
  • No diagnosis or differential diagnosis
  • No treatment or medication recommendation
  • AI-first orchestrated workflow with structured artifacts
  • Generated memory not reused in prompts until user-confirmed
  • Analytics must never include health text, names, question text, brief or debrief content
free paid transition
free local
scope

Single-visit prep loop: messy intake, editable structure review, visit brief, question plan, in-visit quick notes, post-visit debrief capture, local export, draft recovery and delete.

storage

Local device only. No server-side persistence.

retention

30 days default, 7-day grace on expiry. User can extend once.

ai permitted

Options A, B, or C only (no real PHI to server). Option D requires all SPB blockers resolved.

what is not free

Persistent saved history, cross-visit memory search, unresolved question continuity, reusable user-confirmed memory.

data entities used
  • LocalVisitDraft
  • RawCapture
  • StructuredCaptureField
  • EscalationEvent
  • QuickVisitNote
  • ExportArtifact
analytics permitted

State transition counters, funnel events, export format counts. No health text, visit labels, or question text.

paid individual
scope

Persistent PatientMemoryItem (M-01), saved Visit records, longitudinal QuestionPlan continuity, searchable history, cross-visit ExportArtifact generation.

storage

Server-side M-01 entities via approved account sync path.

memory rule

Generated memory (PatientMemoryItem) must not be reused in AI prompts until user explicitly confirms or edits. Architecture MVP-01 memory-writer agent boundary applies.

ai permitted

Option D after all SPB blockers cleared.

paywall ux rule

Do not punish free user immediately after trust is earned. Debrief capture is free. Saved/searchable longitudinal debrief memory is the paywall. Trust Boundary Charter caution rule applies.

transition trigger

User opts into account save. LocalVisitDraft.server_visit_id is populated. Local records may be migrated to server entities following approved sync path.

free account optional
scope

A limited free account tier may be offered (e.g. 3 saved visits) as a trial hook, but this is an open decision (OD-002).

blocker

If free account includes any server-side health text storage, all SPB blockers apply to the free tier.

constraint

Must be resolved before account/save flow is implemented. Default assumption for this pass: free = local-only.

paid family caregiver later
scope

Multiple PatientProfile records, CaregiverAccess grants, delegated prep and follow-up, family memory continuity.

constraint

Not in first prototype or MVP. Deferred to SLICE-04 or later per revised-decomposition-plan.

data dependency

Requires CaregiverAccess (M-01) and multi-profile PatientProfile support. No new schema defined here.

local storage recommendation
rationale
  • Structured relational storage supports the state machine, foreign key relationships between draft→capture→fields→notes, and expiry queries.
  • AsyncStorage is insufficient for relational queries across entities; use for non-relational user preferences only (e.g. onboarding flags, theme).
  • IndexedDB (Dexie) is viable for web/PWA; SQLite preferred for native mobile for better query performance and data integrity.
  • Local encryption: use Expo SecureStore or SQLCipher (SQLite) for the database file at rest. Key derived from device secure enclave or user-provided PIN. No cloud key storage in prototype.
primary choice

SQLite via Expo SQLite or React Native SQLite (native mobile) / IndexedDB with Dexie.js (web/PWA)

encryption posture
at rest

Required before any patient-facing test with real health text. Encrypt the local DB file. Key in device secure enclave.

in transit

No health text leaves device in local prototype. If network call required for AI, use TLS 1.2+ minimum.

key metadata

Store only: key_created_at, key_version, enclave_type. Never store the key itself in app storage.

expiry enforcement
mechanism

On app launch, query all LocalVisitDraft where expires_at < now() and state != draft_deleted. Transition to draft_expired, show recovery prompt.

purge order

Child records first (RawCapture, StructuredCaptureField, EscalationEvent, QuickVisitNote, ExportArtifact), then LocalVisitDraft. Never partial-delete a draft.

grace period

7 days from expires_at. After grace period, delete all child records before deleting draft.

prototype simplification

For the first local-only prototype, a single SQLite database without encryption is acceptable IF AND ONLY IF synthetic/demo data is used. Real patient text requires encryption before any testing.

next steps for build planning
  • Resolve OD-001 (AI option for prototype) before SLICE-04 UX Build Gate dispatches.
  • Resolve OD-003 (escalation copy version) before any patient-facing test regardless of AI option.
  • This artifact feeds SLICE-04 (Pocket UX Build Gate): screen inventory and state maps should reference LocalVisitDraft state machine.
  • This artifact feeds SLICE-05 (Patient-Facing MVP Build): all SPB blockers must be resolved before Option D AI and server-side PHI entity persistence.
  • Do not dispatch implementation tasks from this pass. This is a boundary and decision artifact only.
hard blockers before server phi
idblocksblockerrequired artifact
SPB-001- Option D AI - server-side M-01 entity persistence with real health textConsent version and UI must be finalized and approved before any real patient text is sent to a server model.Approved consent flow spec with exact copy text.
SPB-002- Option D AI - RawCapture local_only = falseRetention rule must be defined: how long is health text stored server-side, and what triggers deletion?Approved data retention and deletion policy.
SPB-003- Option D AIModel provider and data processing agreement (DPA) must be selected and approved.Signed or reviewed DPA with model vendor.
SPB-004- Option D AIServer-side logging policy must be defined: what is logged, for how long, and under what conditions deleted.Approved server logging spec covering model request/response fields.
SPB-005- All options for patient-facing testing - EscalationEvent.copy_version field assignmentEscalation copy version must be finalized and approved before any patient-facing intake test (prototype or MVP).Approved escalation copy with version token (ESC-V1 or equivalent). Applies to ALL AI options for patient-facing testing.
SPB-006- server-side M-01 entity persistenceServer-side encryption posture (at rest, in transit, key management) must be approved before any server-side PHI storage.Approved security posture spec, consistent with Trust Boundary Charter TB-008.
SPB-007- public beta - any production releaseDeletion and export paths must be implemented and tested before public beta. User must be able to delete all server-stored health content.Approved deletion/export implementation spec.
local visit draft state machine
entity

LocalVisitDraft

states
idlabeldescriptionallowed transitions
draft_newNewDraft created; no content yet. Created by Fast Visit Start screen.- draft_capturing - draft_deleted
draft_capturingCapturingUser is entering raw intake via text. RawCapture records attach.- draft_reviewing - draft_deleted
draft_reviewingReviewingStructuredCaptureField records generated or user-entered; user is editing. EscalationEvent may fire here if serious signals detected.- draft_briefed - draft_capturing - draft_deleted
draft_briefedBriefedVisitBrief and QuestionPlan stubs exist locally. User may proceed to visit.- draft_in_visit - draft_reviewing - draft_exported - draft_deleted
draft_in_visitIn VisitUser in appointment; QuickVisitNote records attach, question items marked answered/open.- draft_debriefing - draft_briefed - draft_exported - draft_deleted
draft_debriefingDebriefingPost-visit quick capture; QuickVisitNote or debrief text entered.- draft_complete - draft_in_visit - draft_exported - draft_deleted
draft_completeCompleteFull single-visit loop done. Local only until user opts into account/save.- draft_exported - draft_deleted
draft_exportedExportedExportArtifact record created; user acknowledged sensitive content. Can return to prior workflow states.- draft_complete - draft_deleted
draft_expiredExpiredPast retention expiry. Soft-deleted; show recovery prompt on reopen during grace period.- draft_deleted
draft_deletedDeletedUser-deleted or purged after expiry grace period. All local records wiped.
storage

device-local only (AsyncStorage / SQLite; see local_storage_recommendation)

identity

local_id — UUID generated on-device; no server assignment until account sync

expiry rule
rule

On reopen after expiry, show draft recovery prompt before starting a new visit. After grace period, purge all associated records. User can explicitly extend or delete.

source

local-pocket-prototype-spec/PVA-SLICE-01 offline_behavior.expiry + patient-data-ai-contract hard_open_questions[0]

default days

30

free app default

30

grace period days

7

prototype default

30

recovery rule

On app reopen, check for any draft not in draft_deleted state. If found, present recovery screen before offering new visit start.