No description
  • TypeScript 86.3%
  • JavaScript 13.5%
  • Nix 0.1%
  • Shell 0.1%
Find a file
2026-11-13 11:45:41 +01:00
.agent-memory FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
.codex/skills chore: openspec init 2026-04-28 11:27:16 +02:00
.maestro FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
.pi FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
.plans FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
__tests__ FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
assets chore: add a test icon for iOS 2026-04-02 19:02:22 +02:00
config FLA-95: Add Clerk sign-in and isolated session caching 2026-11-03 13:36:46 +07:00
docs FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
patches FLA-87: Upgrade to Expo SDK 58 and the iOS 27 build stack 2026-10-25 17:20:16 +07:00
scripts FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
src FLA-95: Verify device-only persistence and backup recovery 2026-11-10 20:27:11 +07:00
workers/sync FLA-95: Verify local Clerk sessions and fix native startup 2026-11-08 17:00:57 +07:00
.dir-locals.el nix flake init 2026-02-18 15:25:05 +01:00
.envrc FLA-000: tidy up workspace 2026-08-17 15:40:11 +07:00
.gitignore refactor(cards): isolate update card planning 2026-04-28 15:50:10 +02:00
.prettierignore FLA-80: Enforce feature package boundaries 2026-08-17 15:04:57 +07:00
.prettierrc.json Install prettier 2026-02-19 10:44:16 +01:00
AGENTS.md FLA-84: Require review before commits 2026-08-23 15:39:44 +07:00
app.config.js FLA-95: Verify local Clerk sessions and fix native startup 2026-11-08 17:00:57 +07:00
app.json FLA-87: Upgrade to Expo SDK 58 and the iOS 27 build stack 2026-10-25 17:20:16 +07:00
babel.config.js Install unistyles 2026-02-19 11:58:34 +01:00
bun.lock FLA-95: Add Clerk sign-in and isolated session caching 2026-11-03 13:36:46 +07:00
bunfig.toml FLA-87: Upgrade to Expo SDK 58 and the iOS 27 build stack 2026-10-25 17:20:16 +07:00
eas.json FLA-86: Add guarded Apple protocol canary and readiness checks 2026-10-30 16:42:53 +07:00
eslint.config.js FLA-94: Add authenticated Cloudflare sync for TinyBase 2026-11-02 22:38:45 +07:00
flake.lock nix flake init 2026-02-18 15:25:05 +01:00
flake.nix FLA-28: Add initial Maestro create-and-review test 2026-08-05 16:36:38 +07:00
index.ts FLA-95: Verify local Clerk sessions and fix native startup 2026-11-08 17:00:57 +07:00
metro.config.js Setup Sentry 2026-07-10 15:18:54 +02:00
package.json FLA-95: Replace legacy Maestro tests with Clerk flows 2026-11-09 15:59:51 +07:00
README.md FLA-95: Extend Maestro coverage with one disposable simulator 2026-11-13 11:45:41 +01:00
skills-lock.json chore: install instantdb skill 2026-04-08 15:03:44 +02:00
tsconfig.json FLA-94: Add authenticated Cloudflare sync for TinyBase 2026-11-02 22:38:45 +07:00

Flashcards

Clerk authentication and local libraries

The iOS app account entrypoint uses Clerk-provided native sign-in UI with isolated dev/test public instance pins. Device-only use remains account-free and preserves its existing storage namespace. Live synchronization and account-management/deletion controls are not enabled yet. See Clerk setup and safe verification before installing an authentication-cutover build; retain an external card export first.

The Apple protocol/Instant material below is retained historical tooling, not the active account entrypoint. The old Instant Maestro login/reset flows have been removed; remote test users, credentials and preservation tooling have not been deleted.

Maestro — six flat iOS flows

bun run maestro:test
# Focus only on the four new native UI cases (still a fresh build/install):
bun run maestro:test --native-ui-only

This CLI-only command builds one isolated Flashcards Test Release with embedded JavaScript and creates one new, disposable iPhone Duo / iOS 27.1 simulator. A full run uses seven clean installation generations, fully erasing that simulator between completed groups (six resets): account flows together, device-only/backup source together, empty restore, then four EN/DE × light/dark cases. The focused command uses the same one-simulator strategy for four UI generations (three resets). After every erase it boots, reapplies locale/theme/standard Large text and reinstalls the same binary. Core/backup cases remain English/light. The runtime must be installed and support iPhone Duo. Maestro executes on simulators, not Tobfon.

Only the exact simulator created in the current process can be erased; its UDID/name/runtime/type/canonical data path and completed generation are revalidated before reset. Existing/owner-used simulators are never adopted or reset. Failures stop without retry or erase/cleanup. The main generated ios/, Clerk settings, deployments and synchronization remain untouched.

There are six flat files / nine cases, without suite grouping:

  • .maestro/card_persistence.yaml — create/edit, then retain the saved card after a cold restart.

  • .maestro/sign_out.yaml — private UI disappears, cold startup remains signed out, and same-account sign-in restores the card.

  • .maestro/account_isolation.yaml — A → B → A → B keeps each library separate and retained, including an A cold restart.

  • .maestro/device_only.yaml — choose device-only use, create/edit a card, then cold-restart without signing in.

  • .maestro/backup_recovery.yaml — save a real source backup through Save to Files, import those retained bytes through the native picker into a fresh device-only profile, cold-restart and compare a new normal app export. The comparison preserves IDs, HTML, tags, timestamps, visibility/locales, directions and complete FSRS fields; only export-generation time and collection order are ignored.

  • .maestro/native_ui.yaml — runs four EN/DE × light/dark cases. Checks localized app/Clerk controls, empty-identifier validation, keyboard entry, cancellation/reopening before and during a code challenge, successful retry, tabs, draft confirmation/keep-editing/save, editor return, sign-out and signed-out cold startup. Each case retains seven named screenshots; the runner verifies simulator locale/appearance, not pixel-perfect visual output.

The provided Clerk native UI signs in/up only the reusable synthetic accounts flashcards-1+clerk_test@example.com and flashcards-2+clerk_test@example.com. Clerk's documented public test code is 424242; no inbox, secret key, real OTP or app-side bypass is needed. The runner first verifies that Test mode is already enabled on the pinned test Development instance and never changes it. These publicly accessible test identities must contain only disposable fixture data. Normal account verification is unchanged.

Use the guarded runner rather than targeting flow files at a personal installation. Account flows check the full synthetic account label; device flows check On this device and never sign in. A full erase clears all data, including SDK state/keychains, only on this run's disposable simulator—not an owner installation. There is no app-level bulk card deletion, selective keychain editing or remote account deletion. Before erasing the source, the runner syncs and reads back its verified Save to Files JSON into the private run directory outside the simulator, then rechecks that archive before reset. Recovery reopens those external bytes after erase and transfers only the verified JSON into a proven-empty, UI-saved incoming file in the new device-only profile. It never stages private database/profile/auth files. The final comparison reads a new attempt-specific app export, not the unchanged incoming file, and does not claim a second native Files save.

All other Maestro CLI/MCP sessions and surviving drivers must be stopped throughout UI execution. Check with node scripts/run-maestro-ios.mjs --check-exclusive; the runner refuses known competitors without terminating them. A UDID alone previously failed to prevent a cross-target response. The preflight is not a sandbox or an atomic lock against clients started later. Pi can start a new Maestro MCP process after reboot, so rebooting alone does not establish exclusivity.

The native picker points are qualified only for the pinned iPhone Duo / iOS 27.1 / English / standard Large layout. Runner byte checks prove source retention outside app cache; merely opening/dismissing a share sheet never does. Run IDs keep fixture names distinct. Private build/test artifacts, screenshots and source/re-export JSON remain outside the simulator across resets. Earlier completed installation generations are intentionally erased; only the final or failed generation's live device state remains. Success shuts down that one simulator without deleting it. Failure preserves its current state with no further reset/cleanup. Accessibility/VoiceOver are deferred, not passed. Physical offline behavior, real owner-backup recovery, full-session expiry, injected network/backend errors and untested layouts remain separate checks; recovery after erasing the same virtual device is not a separate-device migration, account conversion or live synchronization.

Legacy Instant authentication/tooling configuration

APP_VARIANT is the only build selector:

Variant Bundle ID EAS environment Services
dev de.totap.flashcards.dev preview Environment-local INSTANT_APP_ID
test de.totap.flashcards.test development Environment-local INSTANT_APP_ID
production de.totap.flashcards production Unavailable until FLA-27 provisions isolated production services

A missing APP_VARIANT defaults to dev for local work. Unknown variants, missing values, swapped values, and production builds fail during Expo config evaluation. The selected variant checks the environment-local INSTANT_APP_ID against a checked-in fingerprint before exposing it through validated Expo extra. The Instant app ID is public; INSTANT_APP_ADMIN_TOKEN remains server-only.

Both flashcards-dev and flashcards-test continue using the Instant auth-client name apple-ios for normal native Apple sign-in. The native App IDs are separate Sign in with Apple primary identifiers. The retained protocol diagnostics use separate development and test server keys. The Apple Services ID is de.totap.flashcards.auth; the native Expo flow has no web domains or return URLs.

Account-deletion revocation remains gated on Instant's supported capability/current-account binding and recent-authentication/native-session contracts. Canary hash/email checks are restricted protocol evidence, not a general ownership proof; leave the canary disabled until its separate activation and live-test requirements are met. Never persist per-user Apple authorization codes or identity/access/refresh tokens, even encrypted. Current server code does not read APPLE_TOKEN_ENCRYPTION_KEY; do not delete existing remote values without approval because older immutable deployments may still depend on them. Normal Apple/email login and persisted Instant sessions remain unchanged.

Architecture

The application uses top-level packages with an enforced dependency direction:

src/
├── app/             # Expo Router entry points and cross-package composition
├── auth/            # Sign-in and profile workflows
├── cards/           # Reusable card domain, persistence, queries, audio, and backup
├── editor/          # New/edit card workflows
├── library/         # Card library workflow
├── review-prep/     # Review selection and customization
├── review-session/  # Active review workflow
├── settings/        # Settings and backup orchestration
└── shared/          # Domain-neutral infrastructure and reusable UI

Files under src/app define the stable navigation tree required by Expo Router. Route groups such as (tabs) and (modals) organize navigation without adding URL segments, _layout.tsx configures navigators and providers, [id].tsx represents a dynamic parameter, and +api.ts defines a server endpoint. App entry points also own cross-package handoffs such as editor seeds, review-session seeds, and injected auth operations. Screen packages do not import one another or app modules.

Each package keeps only the directories it needs. Routes adapt navigation-independent inputs to screens, screens compose complete workflows, components contain package-owned UI, hooks orchestrate package state, model contains pure types and rules, and lib contains package-specific utilities. Cards additionally owns data, queries, audio, and backup. Shared remains domain-neutral.

The dependency direction is:

app and root i18n composition
  → auth/editor/library/review-prep/review-session/settings
  → cards
  → shared

Cross-package imports use the public cards and shared paths enforced in eslint.config.js. Native screen code cannot import cards persistence implementations, admin adapters, or server modules. Focused server paths are available only to API routes and cards server code. Use bunx expo lint to verify both ESM and CommonJS imports, including parent-relative escapes.

Tests for package-owned behavior are colocated under each package's __tests__ directory. Only multi-package composition tests belong under root __tests__/app; script tests remain under root __tests__/scripts.

For example, editing an existing card flows through:

src/app/(modals)/edit-card/[id].tsx
  → src/editor/routes/edit-card-route.tsx
  → src/editor/screens/edit-card-screen.tsx
  → editor hooks
  → the cards CardStore contract
  → the checked local TinyBase implementation

API routes and preview builds

Do not use Expo's automatic build-time server deployment (EXPO_UNSTABLE_DEPLOY_SERVER) or deploy directly to an alias. The native development and test builds use separate stable EAS Hosting aliases:

https://tobio-flashcards--preview.expo.app
https://tobio-flashcards--test.expo.app

Local development leaves EXPO_PUBLIC_API_ORIGIN unset and uses the local Expo server. Preview builds get a fixed origin from eas.json; app.config.js uses it as the Expo Router origin.

Server credentials are EAS Sensitive variables because Hosting does not support Secret visibility. They must never use an EXPO_PUBLIC_* name, enter Expo extra, or be pulled into .env.local.

Deploy immutable API routes

Export and create an immutable, unaliased deployment first:

# Development server environment
bunx eas-cli@latest env:exec preview \
  'APP_VARIANT=dev bunx expo export --platform web --no-ssg' \
  --non-interactive
bunx eas-cli@latest deploy --environment preview --json --non-interactive

# Test server environment
bunx eas-cli@latest env:exec development \
  'APP_VARIANT=test bunx expo export --platform web --no-ssg' \
  --non-interactive
bunx eas-cli@latest deploy --environment development --json --non-interactive

Before promotion, verify the exact deployment origin, expected environment fingerprint, readiness response, and disabled canary:

bun scripts/verify-apple-server-deployment.ts dev <deployment-origin> disabled <deployment-id>
bun scripts/verify-apple-server-deployment.ts test <deployment-origin> disabled <deployment-id>

Record the deployment ID currently assigned to the target alias in the EAS dashboard. Promote only the exact verified, canary-disabled deployment ID:

bunx eas-cli@latest deploy:alias --alias preview --id <verified-dev-deployment-id>
bunx eas-cli@latest deploy:alias --alias test --id <verified-test-deployment-id>

Verify the alias with the same script. Rollback reassigns the recorded prior deployment ID. Verify the rollback target before re-promoting, and retain a known-good canary-disabled deployment as the baseline.

A canary-enabled deployment must be immutable, unaliased, and expire in code within 90 minutes. The server requires exact SHA-256 fingerprints for one disposable Instant user and its matching Apple subject, plus a forbidden fingerprint for the permanent Maestro user. It also requires the verified Instant and Apple emails to match exactly.

Use a probe build pinned to an immutable deployment. Set the temporary public EXPO_PUBLIC_APPLE_PROTOCOL_CANARY_ORIGIN and its matching EXPO_PUBLIC_APPLE_PROTOCOL_CANARY_DEPLOYMENT_ID in preview or development, then build the matching apple-canary-dev or apple-canary-test EAS profile. App config rejects stable aliases and origins that do not contain the recorded deployment ID. The hidden Settings control can identify the Apple subject fingerprint locally without sending the discarded authorization code to the server. Configure that fingerprint server-side, create a new expiring canary deployment, update both probe values, and rebuild before running the protocol test.

Verify the enabled deployment with the script's enabled state, run only the allowlisted disposable account, then create and promote a separate disabled deployment. Delete the temporary canary deployment and confirm its origin no longer responds:

bunx eas-cli@latest deploy:delete <canary-deployment-id>

Never retry an Apple authorization code after an ambiguous exchange. Report revocation as confirmed only when Apple returned HTTP 200. Production deployment remains blocked until FLA-27 provides isolated credentials and backends.

Local iPhone preview build

Connect, unlock, and trust the iPhone. Generate a clean project with only the public native configuration; do not pull the Hosting environment because it also contains server credentials:

APP_VARIANT=dev \
INSTANT_APP_ID=<flashcards-dev-app-id> \
bunx expo prebuild --clean --platform ios

EXPO_SKIP_SERVER_EXPORT=1 bunx expo run:ios --device --configuration Release

Use APP_VARIANT=test with the test app ID for the test bundle. Apple protocol probe builds additionally require an authorized immutable deployment origin and EXPO_PUBLIC_APPLE_PROTOCOL_CANARY_ENABLED=true. That public flag only exposes the native control; server enablement, expiration, bearer authentication, and disposable-account allowlists remain authoritative.

EXPO_SKIP_SERVER_EXPORT=1 makes app.config.js use static web output so the native Release build does not try to export API routes. The command prompts for the target device when necessary.