diff --git a/apps/mobile/App.tsx b/apps/mobile/App.tsx
index 0387610..1377e87 100644
--- a/apps/mobile/App.tsx
+++ b/apps/mobile/App.tsx
@@ -4,10 +4,19 @@ import { StyleSheet, View } from "react-native"
import { getConvexClientUrl } from "./src/lib/convex"
import { MonthHistoryScreen } from "./src/month/MonthHistoryScreen"
+import { VoicePhotoProof } from "./src/proof/VoicePhotoProof"
+
+const QA_PROOF_ENABLED = process.env.EXPO_PUBLIC_QA_PROOF === "1"
export default function App() {
const client = useMemo(() => new ConvexReactClient(getConvexClientUrl()), [])
+ // QA branch: EXPO_PUBLIC_QA_PROOF=1 swaps the home surface for the PR #8
+ // device-proof checklist screen (see apps/mobile/src/proof/).
+ if (QA_PROOF_ENABLED) {
+ return
+ }
+
return (
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index 361b0bb..fd6d42c 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -5,6 +5,26 @@
"version": "0.1.0",
"scheme": "sharedchildjournal",
"platforms": ["ios", "android"],
- "newArchEnabled": true
+ "ios": {
+ "bundleIdentifier": "com.obvhackaton.sharedchildjournal",
+ "infoPlist": {
+ "NSSpeechRecognitionUsageDescription": "Transcribes your spoken journal updates on-device so care notes become text without sending audio off the device."
+ }
+ },
+ "newArchEnabled": true,
+ "plugins": [
+ [
+ "expo-audio",
+ {
+ "microphonePermission": "Allows recording short voice notes for your family's journal entries."
+ }
+ ],
+ [
+ "expo-image-picker",
+ {
+ "photosPermission": "Allows attaching photos of documents, drawings, and moments to journal entries."
+ }
+ ]
+ ]
}
}
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index cc6f060..8ad9d57 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -12,9 +12,13 @@
"dependencies": {
"@journal/month-history": "workspace:*",
"@journal/ui": "workspace:*",
+ "@react-native-ai/apple": "0.12.0",
"convex": "^1.46.0",
"effect": "4.0.0-rc.115",
"expo": "~57.0.23",
+ "expo-audio": "57.0.5",
+ "expo-file-system": "57.0.7",
+ "expo-image-picker": "57.0.18",
"react": "19.2.3",
"react-native": "0.86.3"
},
diff --git a/apps/mobile/src/proof/VoicePhotoProof.tsx b/apps/mobile/src/proof/VoicePhotoProof.tsx
new file mode 100644
index 0000000..b6af550
--- /dev/null
+++ b/apps/mobile/src/proof/VoicePhotoProof.tsx
@@ -0,0 +1,214 @@
+/**
+ * QA proof surface for the PR #8 device-proof checklist (spikes/voice-photo
+ * README). Rendered only when EXPO_PUBLIC_QA_PROOF=1 — the default app surface
+ * is unchanged. Each probe maps to checklist items and appends timestamped
+ * evidence lines meant to be read from simctl screenshots/recordings (see
+ * scripts/qa-ios-sim-proof.sh).
+ *
+ * Evidence taxonomy: what runs here on the iOS simulator is SIMULATOR evidence
+ * (items 2-8 partially); the deterministic fake adapter evidence is the spike's
+ * 38 unit tests; hardware-only items (real-device chip floor, live streaming)
+ * are labeled hardware-only in QA-DEVICE-PROOF.md.
+ */
+import { AudioModule, RecordingPresets, useAudioRecorder, type AudioRecorder } from "expo-audio"
+import { File } from "expo-file-system"
+import * as ImagePicker from "expo-image-picker"
+import { useCallback, useState } from "react"
+import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
+
+import { getLocalVoiceTranscriber } from "../../../../spikes/voice-photo/src/transcription/native"
+import {
+ TranscriptionError,
+ transcribeToText,
+} from "../../../../spikes/voice-photo/src/transcription/types"
+import { storePhotoCaptureViaConvex } from "./convexTransport"
+
+type Line = { readonly at: string; readonly text: string }
+
+const PROOF_LOCALES = ["en-US", "en-GB", "es-ES", "fr-FR", "de-DE", "ja-JP"] as const
+
+function now(): string {
+ return new Date().toISOString()
+}
+
+/** TurboModule registration probe (checklist item 2). */
+function probeTurboModule(add: (text: string) => void): void {
+ const transcriber = getLocalVoiceTranscriber()
+ add(`[2] factory getLocalVoiceTranscriber() -> ${transcriber === null ? "null (dev client missing pod or Expo Go)" : transcriber.name}`)
+ if (transcriber !== null) {
+ // The package's TurboModule registers a global on the JS runtime.
+ const globalKey = "__apple__llm__transcribe__"
+ const present = typeof (globalThis as Record)[globalKey] !== "undefined"
+ add(`[2] globalThis.${globalKey} present -> ${present}`)
+ }
+}
+
+/** Locale availability matrix (checklist item 7). */
+function probeLocales(add: (text: string) => void): void {
+ const transcriber = getLocalVoiceTranscriber()
+ if (transcriber === null) {
+ add("[7] skipped: no transcriber")
+ return
+ }
+ for (const locale of PROOF_LOCALES) {
+ add(`[7] isAvailable(${locale}) -> ${transcriber.isAvailable(locale)}`)
+ }
+}
+
+/** Model asset preparation (checklist item 6). */
+async function probePrepare(add: (text: string) => void): Promise {
+ const transcriber = getLocalVoiceTranscriber()
+ if (transcriber === null) {
+ add("[6] skipped: no transcriber")
+ return
+ }
+ try {
+ await transcriber.prepare("en-US")
+ add("[6] prepare(en-US) resolved (assets verified/downloaded)")
+ } catch (error) {
+ const code = error instanceof TranscriptionError ? error.code : "UNKNOWN"
+ add(`[6] prepare(en-US) threw code=${code} message=${String(error)}`)
+ }
+}
+
+/** Record-then-transcribe over the real hardware path (checklist items 3, 8, 1-partial). */
+async function probeRecordAndTranscribe(recorder: AudioRecorder, add: (text: string) => void): Promise {
+ const transcriber = getLocalVoiceTranscriber()
+ if (transcriber === null) {
+ add("[8] skipped: no transcriber")
+ return
+ }
+ const permission = await AudioModule.requestRecordingPermissionsAsync()
+ add(`[3] requestRecordingPermissionsAsync -> ${JSON.stringify(permission)}`)
+ if (!permission.granted) {
+ add("[3] mic permission not granted — prompt behavior observable on screen/recording")
+ return
+ }
+ await recorder.prepareToRecordAsync()
+ recorder.record()
+ add("[8] recording 4s (HIGH_QUALITY preset)...")
+ await new Promise((resolve) => setTimeout(resolve, 4000))
+ recorder.stop()
+ const uri = recorder.uri
+ add(`[8] recording stopped, uri=${uri ?? "null"}`)
+ if (uri === null || uri === undefined) {
+ add("[8] FAIL: recorder produced no uri")
+ return
+ }
+ const file = new File(uri)
+ const bytes = new Uint8Array(await file.arrayBuffer())
+ add(`[8] read ${bytes.byteLength} bytes from recording`)
+ try {
+ const text = await transcribeToText(transcriber, { bytes, mimeType: "audio/mp4" }, "en-US")
+ add(`[1/8] transcribe -> segments joined: "${text}"`)
+ } catch (error) {
+ const code = error instanceof TranscriptionError ? error.code : "UNKNOWN"
+ add(`[1/8] transcribe threw code=${code} message=${String(error)}`)
+ }
+}
+
+/** Photo pick + 3-request Convex upload (checklist items 4, 9). */
+async function probePhotoToConvex(add: (text: string) => void): Promise {
+ const convexUrl = process.env.EXPO_PUBLIC_CONVEX_URL
+ const permission = await ImagePicker.requestMediaLibraryPermissionsAsync()
+ add(`[4] requestMediaLibraryPermissionsAsync -> ${JSON.stringify(permission)}`)
+ if (!permission.granted) {
+ add("[4] photo permission not granted — prompt behavior observable on screen/recording")
+ return
+ }
+ const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ["images"], quality: 1 })
+ const asset = result.assets?.[0]
+ if (result.canceled || asset === undefined) {
+ add("[4] picker canceled")
+ return
+ }
+ add(`[4] picked ${asset.fileName ?? "asset"} uri=${asset.uri}`)
+ if (convexUrl === undefined || convexUrl.trim() === "") {
+ add("[9] EXPO_PUBLIC_CONVEX_URL not set — flow stopped after pick (set apps/mobile/.env)")
+ return
+ }
+ const bytes = new Uint8Array(await new File(asset.uri).arrayBuffer())
+ add(`[9] read ${bytes.byteLength} bytes; running 3-request flow against ${convexUrl}`)
+ try {
+ const stored = await storePhotoCaptureViaConvex(convexUrl, {
+ bytes,
+ mimeType: asset.mimeType ?? "image/jpeg",
+ sizeBytes: bytes.byteLength,
+ assetUri: asset.uri,
+ assetName: asset.fileName ?? undefined,
+ })
+ add(`[9] flow complete: storageId=${stored.storageId} entryId=${stored.entryId === "" ? "none (photo-only)" : stored.entryId}`)
+ } catch (error) {
+ add(`[9] flow failed: ${String(error)}`)
+ }
+}
+
+export function VoicePhotoProof(): React.JSX.Element {
+ const recorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY)
+ const [lines, setLines] = useState([])
+ const [busy, setBusy] = useState(false)
+ const add = useCallback((text: string) => {
+ setLines((prev) => [...prev, { at: now(), text }])
+ }, [])
+
+ const run = useCallback(
+ async (label: string, fn: (add: (t: string) => void) => void | Promise) => {
+ setBusy(true)
+ add(`=== ${label} start ===`)
+ try {
+ await fn(add)
+ } finally {
+ add(`=== ${label} end ===`)
+ setBusy(false)
+ }
+ },
+ [add],
+ )
+
+ return (
+
+ QA voice/photo proof (checklist item surface)
+
+ run("turboModule+locales", (a) => { probeTurboModule(a); probeLocales(a) })}
+ >
+ Probe module + locales
+
+ run("prepare", probePrepare)}>
+ Prepare en-US
+
+
+
+ run("record+transcribe", (a) => probeRecordAndTranscribe(recorder, a))}
+ >
+ Record 4s + transcribe
+
+ run("photo->convex", probePhotoToConvex)}>
+ {"Pick photo -> Convex"}
+
+
+
+ {lines.map((line, index) => (
+
+ {line.at} {line.text}
+
+ ))}
+
+
+ )
+}
+
+const styles = StyleSheet.create({
+ button: { backgroundColor: "#2563eb", borderRadius: 8, padding: 10 },
+ buttonRow: { flexDirection: "row", gap: 8, justifyContent: "space-evenly", paddingVertical: 6 },
+ buttonText: { color: "#fff", fontWeight: "600" },
+ container: { flex: 1, paddingHorizontal: 12, paddingTop: 60 },
+ line: { color: "#1f2937", fontFamily: "Menlo", fontSize: 11, paddingVertical: 1 },
+ log: { backgroundColor: "#f3f4f6", borderRadius: 8, flex: 1, marginTop: 10, padding: 8 },
+ title: { fontSize: 16, fontWeight: "700", marginBottom: 8 },
+})
diff --git a/apps/mobile/src/proof/convexTransport.ts b/apps/mobile/src/proof/convexTransport.ts
new file mode 100644
index 0000000..4beab4c
--- /dev/null
+++ b/apps/mobile/src/proof/convexTransport.ts
@@ -0,0 +1,85 @@
+import { storePhotoCapture, type PhotoCaptureResult, type PhotoStorageTransport } from "../../../../spikes/voice-photo/src/photo/photoStorage"
+import type { PickedPhoto } from "../../../../spikes/voice-photo/src/photo/types"
+
+/**
+ * Real Convex HTTP transport for the 3-request photo capture flow, used by the
+ * QA proof surface against a real Convex deployment (local-real dev backend or
+ * a dev deployment). Wire shapes are the raw /api/mutation protocol, not the
+ * convex/react client, so each request is individually observable in evidence.
+ *
+ * Function paths assume the QA module set in `spikes/voice-photo/qa-convex/`
+ * is deployed on the target backend.
+ */
+
+/** Raw Convex /api/mutation call; throws on transport, wire, or execution errors. */
+async function callMutation(deploymentUrl: string, path: string, args: Record): Promise {
+ const response = await fetch(`${deploymentUrl}/api/mutation`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ path, args, format: "json" }),
+ })
+ if (!response.ok) {
+ throw new Error(`POST /api/mutation ${path} -> HTTP ${response.status}: ${await response.text()}`)
+ }
+ const body = (await response.json()) as { status?: string; errorMessage?: string; value?: unknown }
+ if (body.errorMessage !== undefined) {
+ throw new Error(`mutation ${path} failed on the backend: ${body.errorMessage}`)
+ }
+ return body.value
+}
+
+/**
+ * The picked asset beyond the port's bytes: RN's fetch uploads files by URI
+ * (FormData file descriptor), not raw bytes, so the transport needs the asset
+ * identity alongside the PickedPhoto the port carries.
+ */
+export type PickedPhotoWithAsset = PickedPhoto & {
+ readonly assetUri: string
+ readonly assetName?: string
+}
+
+export function storePhotoCaptureViaConvex(deploymentUrl: string, photo: PickedPhotoWithAsset): Promise {
+ const transport: PhotoStorageTransport = {
+ async requestUploadUrl() {
+ const value = await callMutation(deploymentUrl, "photoStorage:generatePhotoUploadUrl", {})
+ if (typeof value !== "string") {
+ throw new Error(`generatePhotoUploadUrl returned ${JSON.stringify(value)}, expected an upload URL string`)
+ }
+ return value
+ },
+ async uploadPhoto(uploadUrl: string) {
+ // RN fetch cannot take a raw Uint8Array body; the documented multipart
+ // shape (docs.convex.dev/file-storage/upload-files) works on RN.
+ const form = new FormData()
+ form.append("file", {
+ uri: photo.assetUri,
+ name: photo.assetName ?? "photo.jpg",
+ type: photo.mimeType,
+ } as unknown as Blob)
+ const response = await fetch(uploadUrl, { method: "POST", body: form })
+ if (!response.ok) {
+ throw new Error(`photo POST -> HTTP ${response.status}: ${await response.text()}`)
+ }
+ const body = (await response.json()) as { storageId?: unknown }
+ if (typeof body.storageId !== "string") {
+ throw new Error(`photo POST returned ${JSON.stringify(body)}, expected { storageId }`)
+ }
+ return { storageId: body.storageId }
+ },
+ async commitPhoto(commit) {
+ const value = await callMutation(deploymentUrl, "photoStorage:commitPhotoCapture", {
+ storageId: commit.storageId,
+ mimeType: commit.mimeType,
+ sizeBytes: commit.sizeBytes,
+ ...(commit.entry === undefined ? {} : { entry: commit.entry }),
+ })
+ const entryId = (value as { entryId?: unknown } | null)?.entryId
+ return { entryId: typeof entryId === "string" ? entryId : "" }
+ },
+ }
+ return storePhotoCapture(transport, {
+ photo,
+ // Synthetic QA author — synthetic family data only; no real identities.
+ authorId: "qa-synthetic-author",
+ })
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 421fcf7..f3fbb26 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -23,6 +23,9 @@ importers:
'@journal/ui':
specifier: workspace:*
version: link:../../packages/ui
+ '@react-native-ai/apple':
+ specifier: 0.12.0
+ version: 0.12.0(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))
convex:
specifier: ^1.46.0
version: 1.46.0(react@19.2.3)
@@ -32,6 +35,15 @@ importers:
expo:
specifier: ~57.0.23
version: 57.0.23(@babel/core@7.29.7)(@expo/dom-webview@57.0.1)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
+ expo-audio:
+ specifier: 57.0.5
+ version: 57.0.5(expo-asset@57.0.17(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3))(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)
+ expo-file-system:
+ specifier: 57.0.7
+ version: 57.0.7(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))
+ expo-image-picker:
+ specifier: 57.0.18
+ version: 57.0.18(expo@57.0.23)
react:
specifier: 19.2.3
version: 19.2.3
@@ -162,6 +174,16 @@ importers:
packages:
+ '@ai-sdk/provider-utils@4.0.51':
+ resolution: {integrity: sha512-ukLTs9x1Xm6lxSIwbJIxYQxbZHmVeIczNntARZrBcOa6pjdBhqeZnATNnJMHa7M9dZ8Ji5NJbpKpvz7o5XyBtg==}
+ engines: {node: '>=18.17'}
+ peerDependencies:
+ zod: ^3.25.76 || ^4.1.8
+
+ '@ai-sdk/provider@3.0.16':
+ resolution: {integrity: sha512-9Av6kg0t/IN/dcYAAmEJ4B9OPhcEJqwSR+GfHEA8olRkindXpUHadc3p3cyvgFUQFTVm1G5thtsmgZ9yVb2w3A==}
+ engines: {node: '>=18'}
+
'@babel/code-frame@7.29.7':
resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==}
engines: {node: '>=6.9.0'}
@@ -854,6 +876,11 @@ packages:
'@jridgewell/trace-mapping@0.3.31':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
+ '@react-native-ai/apple@0.12.0':
+ resolution: {integrity: sha512-BC/kEDbCZprv1xcQCWsgapXm/WEsj5lieBDvU1vJXStrN+BG+hWM01zoqDGTD/j71zvt9DEfHcMvEqbrGY2uAA==}
+ peerDependencies:
+ react-native: '>=0.76.0'
+
'@react-native/assets-registry@0.86.3':
resolution: {integrity: sha512-TDhgCZA4wjJg84d5A9swiOQYPIWSKEEVdg9IwMFZDupQzW/F3QoLUrfAJOcalgqTDA9/buTB8awhE3Whwg6u9Q==}
engines: {node: ^20.19.4 || ^22.13.0 || ^24.3.0 || >= 25.0.0}
@@ -917,6 +944,9 @@ packages:
'@sinclair/typebox@0.27.12':
resolution: {integrity: sha512-hhyNJ+nbR6ZR7pToHvllEFun9TL0sbL+tk/ON75lo+Xas054uez98qRbsuNt7MBCyZKK4+8Yli/OAGZhmfBZ/g==}
+ '@standard-schema/spec@1.1.0':
+ resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
+
'@turbo/darwin-64@2.10.13':
resolution: {integrity: sha512-m5DBcpkxmcKpEJHHFUfqf9GLUjSmw3cDnBJM9nghPW3kjCNb5OyNKmzG7/yT5x5AwzOO+HMwKN+UI4iVKL87YA==}
cpu: [x64]
@@ -1363,6 +1393,10 @@ packages:
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
engines: {node: '>=6'}
+ eventsource-parser@3.1.1:
+ resolution: {integrity: sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==}
+ engines: {node: '>=18.0.0'}
+
expo-asset@57.0.17:
resolution: {integrity: sha512-qSdWZBSfEg06o3GJMwcj36tw0vXkB6eYjqkQistWmyJkHxhUOKnsKJnev6OraXxLdoI+KOd1+qgp/ENx8gcqYA==}
peerDependencies:
@@ -1370,6 +1404,14 @@ packages:
react: '*'
react-native: '*'
+ expo-audio@57.0.5:
+ resolution: {integrity: sha512-39fX5JC5zDvELB4/eDJPj2XAYRN0W9+K2DfDWm5N3aC5WZ7HRrhupWtT6hbH09NlfYpsRSqYOwEZnocFM42ynQ==}
+ peerDependencies:
+ expo: '*'
+ expo-asset: '*'
+ react: '*'
+ react-native: '*'
+
expo-constants@57.0.18:
resolution: {integrity: sha512-cLDwDOniPfuCZPHNY++cAY2ZkK97u5aobbBvilPK2LLmaWxR4ZpD31LWUIzUDLrwMPxLjmh1uURnbeYEf0Mivw==}
peerDependencies:
@@ -1389,6 +1431,16 @@ packages:
react: '*'
react-native: '*'
+ expo-image-loader@57.0.1:
+ resolution: {integrity: sha512-uhrZKLT/cTl2mXyR28kPpVkS5O+PK9N1QA/07IFM4f5T4g0lTW1JHT3NEWwEEsGFldPmVX4j7LwUVVZxE+woug==}
+ peerDependencies:
+ expo: '*'
+
+ expo-image-picker@57.0.18:
+ resolution: {integrity: sha512-3uhAHBbHntwarySehZipSQEoPo6nNpyP41t0ZjznkRHN+vDq36GvecT+nIF5C0jgOFN0srbXr7EfjgI0kYsguA==}
+ peerDependencies:
+ expo: '*'
+
expo-keep-awake@57.0.2:
resolution: {integrity: sha512-GqgH746wtJImmsbyHmCQoi7cOslKuWQBbJHXr53S35Bpf5UvxCAztvnitUEd7D0QvFN2rvkOhylbZpgZZfBLlQ==}
peerDependencies:
@@ -1617,6 +1669,9 @@ packages:
engines: {node: '>=6'}
hasBin: true
+ json-schema@0.4.0:
+ resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==}
+
json5@2.2.3:
resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==}
engines: {node: '>=6'}
@@ -2303,6 +2358,10 @@ packages:
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
+ undici@6.28.1:
+ resolution: {integrity: sha512-zWpdTVD54H48CIybL0rWQ3ukpb9d23wM7eH5RtfdmeP70cWHNjtfo7P4vZX+5CoDcO53J4Pu5uXp7lNfjc6DRA==}
+ engines: {node: '>=18.17'}
+
unicode-canonical-property-names-ecmascript@2.0.1:
resolution: {integrity: sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==}
engines: {node: '>=4'}
@@ -2445,8 +2504,23 @@ packages:
zod@3.25.76:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
+ zod@4.6.5:
+ resolution: {integrity: sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==}
+
snapshots:
+ '@ai-sdk/provider-utils@4.0.51(zod@4.6.5)':
+ dependencies:
+ '@ai-sdk/provider': 3.0.16
+ '@standard-schema/spec': 1.1.0
+ eventsource-parser: 3.1.1
+ undici: 6.28.1
+ zod: 4.6.5
+
+ '@ai-sdk/provider@3.0.16':
+ dependencies:
+ json-schema: 0.4.0
+
'@babel/code-frame@7.29.7':
dependencies:
'@babel/helper-validator-identifier': 7.29.7
@@ -3365,6 +3439,13 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.6.0
+ '@react-native-ai/apple@0.12.0(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))':
+ dependencies:
+ '@ai-sdk/provider': 3.0.16
+ '@ai-sdk/provider-utils': 4.0.51(zod@4.6.5)
+ react-native: 0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3)
+ zod: 4.6.5
+
'@react-native/assets-registry@0.86.3': {}
'@react-native/babel-plugin-codegen@0.86.3(@babel/core@7.29.7)':
@@ -3445,6 +3526,8 @@ snapshots:
'@sinclair/typebox@0.27.12': {}
+ '@standard-schema/spec@1.1.0': {}
+
'@turbo/darwin-64@2.10.13':
optional: true
@@ -3895,6 +3978,8 @@ snapshots:
event-target-shim@5.0.1: {}
+ eventsource-parser@3.1.1: {}
+
expo-asset@57.0.17(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3):
dependencies:
'@expo/image-utils': 0.11.5(typescript@6.0.3)
@@ -3906,6 +3991,13 @@ snapshots:
- supports-color
- typescript
+ expo-audio@57.0.5(expo-asset@57.0.17(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3))(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3):
+ dependencies:
+ expo: 57.0.23(@babel/core@7.29.7)(@expo/dom-webview@57.0.1)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
+ expo-asset: 57.0.17(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
+ react: 19.2.3
+ react-native: 0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3)
+
expo-constants@57.0.18(expo@57.0.23)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3)):
dependencies:
'@expo/env': 2.4.3
@@ -3926,6 +4018,15 @@ snapshots:
react: 19.2.3
react-native: 0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3)
+ expo-image-loader@57.0.1(expo@57.0.23):
+ dependencies:
+ expo: 57.0.23(@babel/core@7.29.7)(@expo/dom-webview@57.0.1)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
+
+ expo-image-picker@57.0.18(expo@57.0.23):
+ dependencies:
+ expo: 57.0.23(@babel/core@7.29.7)(@expo/dom-webview@57.0.1)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
+ expo-image-loader: 57.0.1(expo@57.0.23)
+
expo-keep-awake@57.0.2(expo@57.0.23)(react@19.2.3):
dependencies:
expo: 57.0.23(@babel/core@7.29.7)(@expo/dom-webview@57.0.1)(react-native@0.86.3(@babel/core@7.29.7)(@types/react@19.2.18)(react@19.2.3))(react@19.2.3)(typescript@6.0.3)
@@ -4156,6 +4257,8 @@ snapshots:
jsesc@3.1.0: {}
+ json-schema@0.4.0: {}
+
json5@2.2.3: {}
kleur@3.0.3: {}
@@ -5017,6 +5120,8 @@ snapshots:
undici-types@6.21.0: {}
+ undici@6.28.1: {}
+
unicode-canonical-property-names-ecmascript@2.0.1: {}
unicode-match-property-ecmascript@2.0.0:
@@ -5107,3 +5212,5 @@ snapshots:
yargs-parser: 21.1.1
zod@3.25.76: {}
+
+ zod@4.6.5: {}
diff --git a/scripts/qa-ios-sim-proof.sh b/scripts/qa-ios-sim-proof.sh
new file mode 100644
index 0000000..5bc5a33
--- /dev/null
+++ b/scripts/qa-ios-sim-proof.sh
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+#
+# qa-ios-sim-proof.sh — repeatable macOS runbook for the PR #8 device-proof
+# checklist (spikes/voice-photo README), executed on an Apple/MacOS machine.
+#
+# Provisions nothing: it verifies the toolchain, builds the custom dev client,
+# boots an iOS simulator, installs/launches the QA proof surface, and captures
+# evidence (screenshots + screen recording). Re-runnable; use --fresh to reset
+# app permissions so the permission prompts (checklist items 3-5) replay.
+#
+# Requirements (verified in step 0, all fail loudly if missing):
+# - macOS with Xcode 26 (iOS 26 SDK) — SpeechAnalyzer APIs are iOS 26
+# - CocoaPods (`pod` on PATH) — brew install cocoapods
+# - Node >= 20 + corepack (pnpm 10)
+#
+# Usage:
+# ./scripts/qa-ios-sim-proof.sh # build, boot, install, launch, record
+# ./scripts/qa-ios-sim-proof.sh --fresh # additionally reset app permissions first
+#
+# Environment overrides: SIM_NAME, SIM_RUNTIME, EVIDENCE_DIR
+set -euo pipefail
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+APP_DIR="${REPO_ROOT}/apps/mobile"
+EVIDENCE_DIR="${EVIDENCE_DIR:-${REPO_ROOT}/spikes/voice-photo/qa-evidence/$(date -u +%Y%m%dT%H%M%SZ)}"
+SIM_NAME="${SIM_NAME:-iPhone 17 Pro}"
+BUNDLE_ID="com.obvhackaton.sharedchildjournal"
+SCHEME="SharedChildJournal"
+FRESH_PERMISSIONS=false
+[[ "${1:-}" == "--fresh" ]] && FRESH_PERMISSIONS=true
+
+mkdir -p "${EVIDENCE_DIR}"
+
+section() { printf '\n===== %s =====\n' "$1"; }
+
+section "0. Toolchain + environment versions (goes into the evidence record)"
+sw_vers
+xcodebuild -version
+xcrun simctl list runtimes | grep -i ios || true
+xcrun simctl list devices available | grep -A2 "iOS" || true
+node --version
+corepack --version 2>/dev/null || true
+pod --version
+
+section "1. Install workspace (frozen lockfile — CI parity)"
+cd "${REPO_ROOT}"
+corepack enable
+pnpm install --frozen-lockfile
+
+section "2. Convex backend for the photo flow (item 9)"
+# Local-real Convex backend in a tmux session; the app/driver point at it.
+if ! tmux has-session -t qa-convex 2>/dev/null; then
+ tmux new-session -d -s qa-convex "cd '${REPO_ROOT}' && npx convex dev --dir='${REPO_ROOT}/spikes/voice-photo/qa-convex' 2>&1 | tee '${EVIDENCE_DIR}/convex-dev.log'"
+ sleep 20
+fi
+CONVEX_URL="$(grep -rhoE 'https?://127\.0\.0\.1:[0-9]+' "${REPO_ROOT}/.env.local" "${REPO_ROOT}/spikes/voice-photo/qa-convex/.env.local" 2>/dev/null | head -1 || true)"
+if [[ -z "${CONVEX_URL}" ]]; then
+ echo "WARNING: could not auto-detect local Convex URL — read it from the tmux session (tmux attach -t qa-convex) and export CONVEX_URL."
+fi
+printf 'EXPO_PUBLIC_CONVEX_URL=%s\nEXPO_PUBLIC_QA_PROOF=1\n' "${CONVEX_URL}" > "${APP_DIR}/.env"
+echo "apps/mobile/.env -> ${CONVEX_URL}"
+
+section "3. Real-backend flow evidence from the CLI (item 9, driver)"
+if [[ -n "${CONVEX_URL}" ]]; then
+ bun spikes/voice-photo/qa/evidence-3request-flow.ts "${CONVEX_URL}" | tee "${EVIDENCE_DIR}/flow-driver.log"
+else
+ echo "SKIPPED: no CONVEX_URL"
+fi
+
+section "4. Native project generation + pod install (dev-client build, item 2)"
+cd "${APP_DIR}"
+npx expo prebuild --platform ios --no-install 2>&1 | tee "${EVIDENCE_DIR}/prebuild.log"
+cd ios
+pod install 2>&1 | tee "${EVIDENCE_DIR}/pod-install.log"
+
+section "5. Boot simulator + build + install dev client"
+xcrun simctl boot "${SIM_NAME}" 2>/dev/null || true
+open -a Simulator
+xcodebuild -workspace "${APP_DIR}/ios/${SCHEME}.xcworkspace" \
+ -scheme "${SCHEME}" -configuration Debug \
+ -destination "platform=iOS Simulator,name=${SIM_NAME}" \
+ -derivedDataPath "${APP_DIR}/.qa-build/DerivedData" \
+ build 2>&1 | tee "${EVIDENCE_DIR}/xcodebuild.log" | tail -20
+APP_PATH="${APP_DIR}/.qa-build/DerivedData/Build/Products/Debug-iphonesimulator/${SCHEME}.app"
+xcrun simctl install booted "${APP_PATH}"
+
+if ${FRESH_PERMISSIONS}; then
+ section "5b. Reset permissions so prompts replay (items 3-5)"
+ xcrun simctl privacy booted reset all "${BUNDLE_ID}"
+fi
+
+section "6. Launch + record evidence"
+xcrun simctl io booted recordVideo --codec h264 --force "${EVIDENCE_DIR}/sim-run.mp4" &
+RECORD_PID=$!
+sleep 2
+xcrun simctl launch booted "${BUNDLE_ID}" | tee "${EVIDENCE_DIR}/launch.txt"
+sleep 5
+xcrun simctl io booted screenshot "${EVIDENCE_DIR}/01-launch-proof-screen.png"
+echo "NOW DRIVE THE PROOF SCREEN: tap each button; between taps the log fills."
+echo " [2]+[7]: Probe module + locales [6]: Prepare en-US"
+echo " [3]+[8]+[1]: Record 4s + transcribe (grant the mic prompt)"
+echo " [4]+[9]: Pick photo -> Convex (grant the photo prompt)"
+sleep 10
+xcrun simctl io booted screenshot "${EVIDENCE_DIR}/02-after-probes.png"
+kill -INT "${RECORD_PID}" 2>/dev/null || true
+sleep 1
+
+section "7. Evidence inventory"
+ls -la "${EVIDENCE_DIR}"
+echo
+echo "Fill spikes/voice-photo/QA-DEVICE-PROOF.md with the observed results and"
+echo "the exact versions printed in step 0. Label every artifact SIMULATOR"
+echo "evidence; hardware-only items stay hardware-only."
diff --git a/spikes/voice-photo/QA-DEVICE-PROOF.md b/spikes/voice-photo/QA-DEVICE-PROOF.md
new file mode 100644
index 0000000..b360b86
--- /dev/null
+++ b/spikes/voice-photo/QA-DEVICE-PROOF.md
@@ -0,0 +1,67 @@
+# QA device-proof status — PR #8 checklist reproduction
+
+Status of the 10-item device-proof checklist from this README, with the
+evidence taxonomy the QA brief requires. Updated by the Apple-native QA lane
+(thread `th_Kd5oUXW3`, 2026-09-17). Evidence classes: **FAKE-ADAPTER** (the
+38 deterministic unit tests), **SIMULATOR** (iOS simulator via the runbook),
+**LOCAL-REAL-BACKEND** (real Convex server, local-real deployment, CLI-driven),
+**HARDWARE-ONLY** (requires a physical Apple Intelligence-capable device),
+**BLOCKED** (no Apple machine reachable at all).
+
+## Blocker (access, concrete)
+
+The Obvious workspace cannot provision an Apple sandbox:
+`computers provisionSandbox --platform=macos` returns `FORBIDDEN — macos
+sandboxes are not enabled for this workspace` (feature gate), and no Apple
+device is paired (`computers listDevices` is empty). Until the gate is lifted
+or a Mac is registered over SSH, every SIMULATOR item below is prepared and
+replayable but not executed. The runbook (`scripts/qa-ios-sim-proof.sh`) is the
+exact reproduction script for the moment an Apple machine exists.
+
+## Verified on Linux against master `32d1f00` (this QA lane)
+
+- **Baseline gates**: `npm ci` (520 packages) clean, `tsc --noEmit` strict
+ clean, `vitest run` 38/38 pass — FAKE-ADAPTER evidence still green on the
+ current integrated code.
+- **Integration gap fixed**: the spike was NOT wired into `apps/mobile` — no
+ plugin config, no native deps, no proof surface. This lane adds the wiring
+ (isolated branch `qa/ios-sim-proof`): pinned native deps in the app,
+ `app.json` plugins + `NSSpeechRecognitionUsageDescription`, the proof screen
+ (`apps/mobile/src/proof/`), the QA Convex module set
+ (`spikes/voice-photo/qa-convex/`), the real-backend driver
+ (`spikes/voice-photo/qa/evidence-3request-flow.ts`), and the macOS runbook.
+- **Metro graph validation**: `npx expo export --platform ios` bundles the iOS
+ JS graph off-Mac — proves the spike imports resolve through Metro's platform
+ extensions and the native deps are wired (the JS half of the dev client).
+
+## Checklist status
+
+| # | Item | Class | Status |
+|---|---|---|---|
+| 1 | iOS 26 runtime SpeechAnalyzer behavior | HARDWARE-ONLY (chip floor unstated by Apple; simulator run informative but not conclusive) | not executed — blocked |
+| 2 | Custom dev-client build + TurboModule global | SIMULATOR (build) — prepared in runbook steps 4-6; JS graph validated on Linux | prepared, not executed — blocked |
+| 3 | Microphone permission prompt | SIMULATOR — runbook step 6 with `--fresh` | prepared, not executed — blocked |
+| 4 | Photo permission prompt | SIMULATOR — runbook step 6 with `--fresh` | prepared, not executed — blocked |
+| 5 | Speech-recognition authorization prompt | SIMULATOR (whether SpeechAnalyzer even triggers it stays doc-vs-ship) | prepared, not executed — blocked |
+| 6 | `prepare(locale)` model assets + failure mapping | SIMULATOR | prepared, not executed — blocked |
+| 7 | Locale availability matrix | SIMULATOR | prepared, not executed — blocked |
+| 8 | Recording hardware path (preset, bytes) | SIMULATOR (byte stream to bridge) | prepared, not executed — blocked |
+| 9 | Live Convex 3-request upload flow | **LOCAL-REAL-BACKEND — EXECUTED 2026-09-17, EVIDENCE GREEN 7/7** against an anonymous local-real backend (anonymous-qa-convex): upload URL issued → photo POST accepted (storageId) → commit persisted (photoId), using the spike's real `storePhotoCapture` flow code; read-back SHA-256 matched (`49779094…`), byte integrity through file storage proven | executed — see below |
+| 10 | Live streaming transcription | out of spike scope (batch-only MVP) | unchanged — hardware-only |
+
+Item 9 evidence runs from the CLI against a local-real Convex backend
+(`npx convex dev --dir=spikes/voice-photo/qa-convex`), synthetic 1×1 PNG,
+photo-only commit (the v0.1 contract has no Entry↔photo linkage), read-back
+SHA-256 must match. The driver also probes the entry-carrying commit path as
+the F1 negative control (PR #5 finding: Convex rejects `_`-prefixed stored
+fields) and records the observed behavior either way.
+
+## Honest limits of this lane
+
+- Nothing here claims device or simulator execution of items 1-8 until the
+ Apple gate is lifted — the runbook exists precisely so the first Mac (or
+ enabled macOS sandbox) reproduces everything with one command.
+- The `mediaTypes: ["images"]` picker option, `AudioModule` exports, and the
+ `File` API are pinned-package surfaces; the Linux typecheck run against the
+ installed `.d.ts` files validates them, but runtime confirmation happens in
+ the simulator run.
diff --git a/spikes/voice-photo/qa-convex/.gitignore b/spikes/voice-photo/qa-convex/.gitignore
new file mode 100644
index 0000000..f154cf5
--- /dev/null
+++ b/spikes/voice-photo/qa-convex/.gitignore
@@ -0,0 +1 @@
+_generated/
diff --git a/spikes/voice-photo/qa-convex/convex.json b/spikes/voice-photo/qa-convex/convex.json
new file mode 100644
index 0000000..41cea9d
--- /dev/null
+++ b/spikes/voice-photo/qa-convex/convex.json
@@ -0,0 +1,3 @@
+{
+ "functions": "convex"
+}
diff --git a/spikes/voice-photo/qa-convex/convex/photoStorage.ts b/spikes/voice-photo/qa-convex/convex/photoStorage.ts
new file mode 100644
index 0000000..8f26c1d
--- /dev/null
+++ b/spikes/voice-photo/qa-convex/convex/photoStorage.ts
@@ -0,0 +1,64 @@
+import { mutationGeneric, queryGeneric } from "convex/server"
+import { v } from "convex/values"
+
+/**
+ * QA deployment of the spike's REFERENCE module (spikes/voice-photo/convex/
+ * photoStorage.ts) plus a read-back query for byte verification. Same flow,
+ * same validators, deployed only to the throwaway local-real QA backend (see
+ * qa-convex/schema.ts). Synthetic data only.
+ */
+
+/** Step 1 of the upload flow: hand out a short-lived upload URL (expires in 1h). */
+export const generatePhotoUploadUrl = mutationGeneric({
+ args: {},
+ handler: async (ctx) => {
+ return await ctx.storage.generateUploadUrl()
+ },
+})
+
+/** Step 3 of the upload flow: persist the capture record after the POST succeeded. */
+export const commitPhotoCapture = mutationGeneric({
+ args: {
+ storageId: v.id("_storage"),
+ mimeType: v.string(),
+ sizeBytes: v.number(),
+ entry: v.optional(
+ v.object({
+ _tag: v.literal("Entry"),
+ transcript: v.string(),
+ authorId: v.string(),
+ createdAt: v.number(),
+ status: v.union(v.literal("draft"), v.literal("published")),
+ events: v.array(v.any()),
+ }),
+ ),
+ },
+ handler: async (ctx, args) => {
+ const entryId =
+ args.entry === undefined ? undefined : await ctx.db.insert("entries", { ...args.entry, _tag: undefined as never })
+ const photoId = await ctx.db.insert("photoCaptures", {
+ storageId: args.storageId,
+ mimeType: args.mimeType,
+ sizeBytes: args.sizeBytes,
+ entryId,
+ createdAt: Date.now(),
+ })
+ return { photoId, entryId: entryId ?? null }
+ },
+})
+
+/** Read-back for byte verification: a URL that serves the stored file. */
+export const getPhotoUrl = queryGeneric({
+ args: { storageId: v.id("_storage") },
+ handler: async (ctx, args) => {
+ return await ctx.storage.getUrl(args.storageId)
+ },
+})
+
+/** Count of photoCaptures (synthetic-data hygiene check). */
+export const countPhotoCaptures = queryGeneric({
+ args: {},
+ handler: async (ctx) => {
+ return (await ctx.db.query("photoCaptures").collect()).length
+ },
+})
diff --git a/spikes/voice-photo/qa-convex/convex/schema.ts b/spikes/voice-photo/qa-convex/convex/schema.ts
new file mode 100644
index 0000000..94604f3
--- /dev/null
+++ b/spikes/voice-photo/qa-convex/convex/schema.ts
@@ -0,0 +1,33 @@
+import { defineSchema, defineTable } from "convex/server"
+import { v } from "convex/values"
+
+/**
+ * THROWAWAY QA schema for the PR #8 device-proof / 3-request-flow evidence
+ * runs (checklist item 9). Deliberately NOT part of the canonical backend
+ * schema in backend/convex — the v0.1 domain contract has no photo-capture
+ * table (that extension belongs to the contract thread), and this schema only
+ * exists so the reference module's flow can run against a real Convex server
+ * (local-real dev backend) without touching shared deployments or contracts.
+ *
+ * Synthetic data only.
+ */
+
+export default defineSchema({
+ photoCaptures: defineTable({
+ storageId: v.string(),
+ mimeType: v.string(),
+ sizeBytes: v.number(),
+ entryId: v.optional(v.union(v.id("entries"), v.null())),
+ createdAt: v.number(),
+ }),
+ // Minimal entries shape for the optional Entry-commit path. The events
+ // field mirrors the reference validator so the F1 probe isolates the
+ // `_tag` question instead of failing on missing columns.
+ entries: defineTable({
+ transcript: v.string(),
+ authorId: v.string(),
+ createdAt: v.number(),
+ status: v.union(v.literal("draft"), v.literal("published")),
+ events: v.optional(v.array(v.any())),
+ }),
+})
diff --git a/spikes/voice-photo/qa-convex/package.json b/spikes/voice-photo/qa-convex/package.json
new file mode 100644
index 0000000..aba1bf2
--- /dev/null
+++ b/spikes/voice-photo/qa-convex/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "voice-photo-qa-backend",
+ "private": true,
+ "type": "module",
+ "dependencies": {
+ "convex": "^1.46.0"
+ }
+}
diff --git a/spikes/voice-photo/qa/evidence-3request-flow.ts b/spikes/voice-photo/qa/evidence-3request-flow.ts
new file mode 100644
index 0000000..d3c8925
--- /dev/null
+++ b/spikes/voice-photo/qa/evidence-3request-flow.ts
@@ -0,0 +1,129 @@
+/**
+ * PR #8 checklist item 9 — 3-request Convex photo upload flow, REAL backend
+ * evidence driver.
+ *
+ * Runs the spike's REAL client flow (`src/photo/photoStorage.ts`) with a real
+ * fetch transport against a real Convex server (local-real dev backend started
+ * with `npx convex dev --dir=.../qa-convex`, or any dev deployment URL handed
+ * in as argv[2]). Verifies byte-integrity by reading the file back through
+ * `getPhotoUrl` and comparing SHA-256. Probes the entry-carrying commit path
+ * as a negative control (PR #5 finding F1: Convex rejects _-prefixed stored
+ * fields). Synthetic data only.
+ *
+ * Usage: bun spikes/voice-photo/qa/evidence-3request-flow.ts
+ */
+import { createHash } from "node:crypto"
+
+import { storePhotoCapture, type PhotoStorageTransport } from "../src/photo/photoStorage"
+
+const deploymentUrl = process.argv[2] ?? process.env.CONVEX_URL
+if (deploymentUrl === undefined || deploymentUrl === "") {
+ console.error("usage: bun evidence-3request-flow.ts ")
+ process.exit(2)
+}
+
+interface Step {
+ step: string
+ detail: string
+ ok: boolean
+}
+
+const steps: Step[] = []
+function record(step: string, detail: string, ok: boolean): void {
+ steps.push({ step, detail, ok })
+ console.log(`[${ok ? "ok" : "FAIL"}] ${step}: ${detail}`)
+}
+
+async function callConvex(fnPath: string, args: Record, endpoint: "mutation" | "query" = "mutation"): Promise {
+ const response = await fetch(`${deploymentUrl}/api/${endpoint}`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ path: fnPath, args, format: "json" }),
+ })
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`)
+ const body = (await response.json()) as { status?: string; errorMessage?: string; value?: unknown }
+ if (body.errorMessage !== undefined) throw new Error(`backend error: ${body.errorMessage}`)
+ return body.value
+}
+
+// A real (tiny) PNG — 1x1 transparent pixel, base64-decoded. Synthetic data.
+const PNG_1X1_BASE64 =
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
+const photoBytes = new Uint8Array(Buffer.from(PNG_1X1_BASE64, "base64"))
+const expectedSha256 = createHash("sha256").update(photoBytes).digest("hex")
+record("fixture", `synthetic 1x1 PNG, ${photoBytes.byteLength} bytes, sha256=${expectedSha256}`, true)
+
+const transport: PhotoStorageTransport = {
+ async requestUploadUrl() {
+ const value = await callConvex("photoStorage:generatePhotoUploadUrl", {})
+ if (typeof value !== "string") throw new Error(`expected URL string, got ${JSON.stringify(value)}`)
+ record("1-requestUploadUrl", `upload URL issued: ${value.slice(0, 72)}...`, true)
+ return value
+ },
+ async uploadPhoto(uploadUrl) {
+ const blob = new Blob([photoBytes], { type: "image/png" })
+ const response = await fetch(uploadUrl, { method: "POST", headers: { "Content-Type": "image/png" }, body: blob })
+ if (!response.ok) throw new Error(`photo POST -> HTTP ${response.status}: ${await response.text()}`)
+ const body = (await response.json()) as { storageId?: unknown }
+ if (typeof body.storageId !== "string") throw new Error(`expected { storageId }, got ${JSON.stringify(body)}`)
+ record("2-uploadPhoto", `POST ok, storageId=${body.storageId}`, true)
+ return { storageId: body.storageId }
+ },
+ async commitPhoto(commit) {
+ const value = (await callConvex("photoStorage:commitPhotoCapture", {
+ storageId: commit.storageId,
+ mimeType: commit.mimeType,
+ sizeBytes: commit.sizeBytes,
+ })) as { photoId?: unknown; entryId?: unknown }
+ record("3-commitPhoto", `committed photoId=${String(value?.photoId)} entryId=${String(value?.entryId)} (photo-only path)`, true)
+ return { entryId: typeof value?.entryId === "string" ? value.entryId : "" }
+ },
+}
+
+try {
+ const result = await storePhotoCapture(transport, {
+ photo: { bytes: photoBytes, mimeType: "image/png", sizeBytes: photoBytes.byteLength },
+ authorId: "qa-synthetic-author",
+ })
+ record("flow", `storePhotoCapture completed: storageId=${result.storageId}`, true)
+
+ // Byte-integrity read-back.
+ const photoUrl = (await callConvex("photoStorage:getPhotoUrl", { storageId: result.storageId }, "query")) as unknown
+ if (typeof photoUrl !== "string") throw new Error(`getPhotoUrl returned ${JSON.stringify(photoUrl)}`)
+ const readBack = new Uint8Array(await (await fetch(photoUrl)).arrayBuffer())
+ const readBackSha256 = createHash("sha256").update(readBack).digest("hex")
+ record(
+ "readback",
+ `fetched ${readBack.byteLength} bytes back; sha256 match=${readBackSha256 === expectedSha256} (${readBackSha256})`,
+ readBackSha256 === expectedSha256,
+ )
+
+ // Negative control: the entry-carrying commit path (F1 probe). Outcome is
+ // recorded neutrally — the interesting question is whether `_tag` or any
+ // other field causes rejection at the raw /api protocol layer.
+ try {
+ const entryResult = (await callConvex("photoStorage:commitPhotoCapture", {
+ storageId: result.storageId,
+ mimeType: "image/png",
+ sizeBytes: photoBytes.byteLength,
+ entry: {
+ _tag: "Entry",
+ transcript: "qa synthetic entry",
+ authorId: "qa-synthetic-author",
+ createdAt: Date.now(),
+ status: "draft",
+ events: [],
+ },
+ })) as unknown
+ record("f1-probe-entry-commit", `entry commit SUCCEEDED: ${JSON.stringify(entryResult)} — raw protocol accepts the entry (check stored doc for _tag handling)`, true)
+ } catch (error) {
+ record("f1-probe-entry-commit", `entry commit REJECTED: ${String(error)}`, true)
+ }
+} catch (error) {
+ record("flow", String(error), false)
+ process.exitCode = 1
+}
+
+const allOk = steps.every((s) => s.ok)
+console.log(`\nSUMMARY: ${steps.filter((s) => s.ok).length}/${steps.length} steps ok -> ${allOk ? "EVIDENCE GREEN" : "EVIDENCE FAILED"}`)
+if (!allOk) process.exitCode = 1
diff --git a/spikes/voice-photo/src/transcription/types.ts b/spikes/voice-photo/src/transcription/types.ts
index 42f16da..a017398 100644
--- a/spikes/voice-photo/src/transcription/types.ts
+++ b/spikes/voice-photo/src/transcription/types.ts
@@ -101,7 +101,9 @@ export function withAbort(promise: Promise, signal?: AbortSignal): Promise
}
function cancelledError(signal: AbortSignal): TranscriptionError {
- return new TranscriptionError('cancelled', 'Transcription was cancelled', { cause: signal.reason })
+ // `reason` is ES2022 DOM lib; cast keeps the spike typecheck-clean under
+ // older lib configs (the app's compile graph pulls this file in).
+ return new TranscriptionError('cancelled', 'Transcription was cancelled', { cause: (signal as AbortSignal & { reason?: unknown }).reason })
}
/** Record-then-transcribe convenience: transcribe and join to composer text. */