Skip to content

Feat/core offline hardening - #41

Merged
NBlancs merged 4 commits into
mainfrom
feat/core-offline-hardening
Oct 1, 2026
Merged

NBlancs merged 4 commits into
mainfrom
feat/core-offline-hardening

Conversation

@CyberSphinxxx

Copy link
Copy Markdown
Contributor

Summary

This PR delivers core offline hardening across storage, scheduler, voice AI, and cloud synchronization layers. It addresses concurrency locks, connection leakages, watchdog timeouts, and cloud pull foreign-key constraints, while expanding the automated test suite to 805 passing tests.


Key Changes

1. Local Storage & SQLite Resilience (src/storage/)

  • Connection & Timeout Handling: Added resilient busy-handler retries and timeout protection to prevent SQLite database locks under high concurrent read/write loads.
  • Session & Note Stores: Hardened user session handling, note tags/image URI persistence, and cleanup logic against null/undefined edge cases.
  • Calendar & RRULE Helpers: Added validation guards for RFC 5545 ICS parsing and recurring event calculations to ensure corrupt calendar data degrades gracefully without crashing.

2. Scheduler & Proactive Reminders (src/scheduler/)

  • Call Dispatcher Hardening: Resolved race conditions during background call dispatches; added fallback state machines when alarms trigger while the device is sleeping or transitioning between states.
  • Recovery Daemon: Added automatic recovery for missed reminders after device reboots or app restarts.

3. Offline AI Pipeline & Watchdogs (src/ai/)

  • Audio & Pipeline Watchdogs: Introduced timeouts on speech capture and Whisper/Kokoro inference bridges so the voice reminder flow never hangs indefinitely if native audio drops.
  • TTS Cache Hygiene: Implemented cache sweeping to periodically purge stale generated voice audio files, preserving student device storage.
  • NLU Parser Guards: Hardened JSON parser for SmolLM2 model outputs to validate expected schema fields and gracefully reject malformed payloads.

4. Cloud Sync & Data Integrity (src/sync/)

  • Pull Integrity & Foreign Key Resolution: Fixed a critical bug where cloud pull assigned incoming records to a placeholder 'cloud' user ID, triggering foreign key constraint failures. Now binds the authenticated active user token to incoming upserts.
  • Last-Write-Wins (LWW): Enforced timestamp-based conflict resolution so offline edits sync smoothly without clobbering newer server state.

5. Android Build & Runtime

  • Gradle Optimization: Configured Gradle JVM args (-Xmx4096m) and disabled legacy Jetifier to ensure clean AAR compilation on modern React Native 0.86.
  • Native Verification: Successfully compiled and validated on Android emulator (assembleDebug & installDebug).

Verification & Test Suite

All three mandatory checks pass with zero errors:

  • TypeScript (npx tsc --noEmit): Clean (0 errors)
  • Jest Unit & Integration Tests (npm test): 97 passed suites, 805 / 805 passed tests (460 new tests added)
  • ESLint (npx eslint src/): Clean (0 errors)

Copilot AI balanced review requested due to automatic review settings October 1, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CyberSphinxxx
CyberSphinxxx requested a balanced review from Copilot October 1, 2026 04:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@NBlancs

NBlancs commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

LGTM

@NBlancs NBlancs closed this Oct 1, 2026
@NBlancs NBlancs reopened this Oct 1, 2026
@NBlancs
NBlancs merged commit f7e70ae into main Oct 1, 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.

3 participants