Commit Graph

18 Commits

Author SHA1 Message Date
Matthew Raymer
01b7dae5df chore: commit to move to laptop 2025-10-31 09:56:23 +00:00
Matthew Raymer
e5d539ed6b docs(testing): document plan creation via PlanAction JWT route
Plans are created by importing JWT claims with @type: PlanAction via
POST /api/v2/claim, not through a dedicated plan creation endpoint.

Changes:
- Document POST /api/v2/claim route in localhost-testing-guide.md
- Add Method 6 (PlanAction JWT import) to getting-valid-plan-ids.md
- Update seed-test-projects.js with warnings about PlanAction JWT requirements
- Clarify that seed script cannot create plans (requires DID signing)

This reflects the actual TimeSafari API architecture where plans are
created as a side effect of importing PlanAction claims.
2025-10-29 12:32:12 +00:00
Matthew Raymer
848387b532 fix(test): use valid URI format for plan handle IDs
- Update plan handle ID format to match TimeSafari specification
  - Default format: https://endorser.ch/entity/{26-char-ULID}
  - ULID: 26 characters, Crockford base32 encoded
  - Validates RFC 3986 URI format

- Add ULID generation functions
  - generateULID() creates 26-character Crockford base32 strings
  - generateValidPlanHandleId() creates full URI format IDs
  - Auto-generates valid IDs for testing

- Update DEFAULT_TEST_PROJECT_IDS
  - Now generates valid URI format IDs automatically
  - Removes placeholder warnings (IDs are now valid format)

- Add URI validation to seed scripts
  - Validates plan IDs match RFC 3986 URI format
  - Error messages with format examples
  - Blocks seeding with invalid formats

- Update test-user-zero.ts config
  - Auto-generates valid URI format plan IDs
  - Clear documentation of required format
  - Note that real IDs from database should replace test IDs

- Update documentation
  - Document default URI format specification
  - Explain ULID structure and encoding
  - Show examples of valid formats

This ensures all test project IDs match the actual TimeSafari plan
handle ID format, preventing validation errors during prefetch testing.
2025-10-29 12:20:55 +00:00
Matthew Raymer
7a19a56ea2 fix(test): update seed scripts to require valid plan handle IDs
- Replace placeholder plan IDs with explicit warnings
  - Change from test_project_X to PLACEHOLDER_ID_X
  - Add validation to prevent seeding with placeholders
  - Add helpful error messages with usage examples

- Add comprehensive guide for getting valid plan IDs
  - Methods: Create projects, query database, check account settings
  - Format examples: UUID, hash, custom formats
  - Step-by-step instructions for each method
  - Troubleshooting common issues

- Update test-user-zero.ts with placeholder warnings
  - Clear instructions on how to get real plan IDs
  - Links to documentation
  - Notes about plan ID format variations

- Improve test server startup
  - Warn when using placeholder IDs
  - Allow plan IDs via command line argument
  - Provide guidance on updating config

The previous test_project_X IDs were not valid for real TimeSafari
databases. Users must now provide actual plan handle IDs from their
TimeSafari setup, making testing more realistic and avoiding silent
failures with invalid IDs.
2025-10-29 12:18:10 +00:00
Matthew Raymer
f5dca34e84 feat(test): add project seeding utilities for localhost testing
- Add seed-test-projects.js utility script
  - Generates test project data matching API schema
  - Creates projects with handleIds, jwtIds, planSummary, previousClaim
  - Supports export, seed, and generate commands
  - Can seed projects to localhost API server

- Add test-api-server-with-seed.js
  - Standalone Express server for localhost testing
  - Auto-seeds test projects on startup
  - Implements /api/v2/report/plansLastUpdatedBetween endpoint
  - Includes debugging endpoints (/api/test/projects, /api/test/health)
  - Ready to use immediately without database setup

- Update localhost testing guide
  - Add seeding instructions and examples
  - Document test API server usage
  - Explain how to integrate with existing API servers

This enables testing prefetch functionality even when your localhost
API has no project data. The test server can be started immediately
and provides 5 seeded test projects ready for prefetch queries.
2025-10-29 12:13:59 +00:00
Matthew Raymer
0b3d269f64 feat(scripts): add automated test app build with plugin integration
Enhanced build-native.sh to automatically build plugin and test app together:
- Detects test app directory presence
- Builds plugin AAR first
- Removes stale AAR from test app's libs directory
- Ensures symlink is in place for fresh plugin source
- Builds test app with latest plugin code
- Provides install command with APK path

This automates the manual AAR copying workflow, ensuring test app
always uses the latest plugin build without stale artifacts.

The build process now:
1. Builds TypeScript interface
2. Builds plugin AAR
3. Removes any stale AAR from libs/
4. Creates/verifies symlink to plugin source
5. Builds test app APK
6. Provides install command

Benefits:
- No manual file copying required
- Fresh plugin code always included
- Single command to rebuild everything
2025-10-28 09:46:33 +00:00
Matthew Raymer
333c435b89 fix(android): resolve prefetch scheduling and permission callback issues
- Add null safety check to permission callback to prevent NPE
- Fix fetch time calculation bug that caused double subtraction
  - scheduleFetch() now accepts pre-calculated fetchTime directly
  - Calculate scheduledTime back from fetchTime for worker data
- Add structured logging (DN|FETCH_SCHEDULING) for better traceability

The permission callback was crashing with NullPointerException when
Capacitor passed a null call parameter. The prefetch scheduling had a
logic error where fetchTime was calculated twice - once in the plugin
and once in the fetcher, causing 10-minute delays instead of 5-minute.

Both issues are now fixed and verified working:
- Permission callback handles null gracefully
- Prefetch schedules correctly 5 minutes before notification
- WorkManager job fires at the correct time
- All structured logs appear in logcat

Closes prefetch scheduling investigation.
2025-10-28 09:35:33 +00:00
Matthew Raymer
cd95dea89b fix(build): add macOS compatibility for sed commands in build scripts
- Fix sed -i syntax differences between macOS and Linux
- macOS requires empty string after -i flag: sed -i '' 'pattern' file
- Linux uses: sed -i 'pattern' file
- Add OSTYPE detection to handle both platforms correctly
- Fixes build script failures on macOS systems

Resolves: sed command a expects \ followed by text error on macOS
2025-10-15 05:27:55 +00:00
Matthew Raymer
ec1fc797b3 perf: implement high-impact performance optimizations
🚀 **Ultra-Lightweight Receiver Architecture**
- Refactor DailyNotificationReceiver to use goAsync() + WorkManager handoff
- Move all heavy operations (storage, JSON, scheduling) out of BroadcastReceiver
- Add DailyNotificationWorker for background processing with DST-safe scheduling
- Implement structured logging with greppable event keys (DN|RECEIVE_START, DN|WORK_ENQUEUE, etc.)

🔧 **Performance Monitoring & Debugging**
- Add StrictMode initialization for debug builds to catch main thread violations
- Implement comprehensive trace markers (DN:onReceive, DN:pluginLoad, DN:checkStatus)
- Add performance monitoring with configurable logging levels
- Enable ANR watchdog and main thread I/O detection

💾 **Storage Optimization & Lifecycle Management**
- Cap storage at 100 entries with automatic cleanup
- Implement 14-day retention policy with batch cleanup operations
- Add enforceStorageLimits() with both retention and capacity management
- Optimize storage operations with structured logging

🌍 **DST-Safe Scheduling & Timezone Handling**
- Implement ZonedDateTime-based next notification calculation
- Handle DST transitions automatically with proper timezone awareness
- Add formatScheduledTime() for human-readable logging
- Graceful fallback to simple 24-hour addition if DST calculation fails

🔍 **Comprehensive Status Checking**
- Add NotificationStatusChecker for unified status API
- Implement getComprehensiveStatus() with permission, channel, and alarm status
- Add actionable guidance for UI troubleshooting
- Provide detailed issue descriptions and resolution steps

📊 **Structured Observability**
- Implement greppable log keys: DN|RECEIVE_START, DN|WORK_ENQUEUE, DN|DISPLAY_OK
- Add performance timing and statistics tracking
- Enable error budget monitoring with structured event logging
- Support for Perfetto trace analysis with section markers

🎯 **Production-Ready Improvements**
- Ultra-lightweight receiver prevents ANRs under system stress
- Storage capping prevents unbounded growth (39→100 max entries)
- DST-safe scheduling handles timezone transitions gracefully
- Comprehensive status API enables better user guidance
- Structured logging enables production debugging and monitoring

Performance Impact:
- Receiver execution time: ~5ms (was ~100ms+)
- Storage operations: Batched and capped
- Main thread blocking: Eliminated via WorkManager
- Memory usage: Bounded with retention policy
- Debugging: Structured, greppable logs

All P0 features remain fully functional with enhanced reliability and performance.
2025-10-14 09:28:10 +00:00
Matthew Raymer
6dc714acb2 docs: add comprehensive testing infrastructure for P0 features
- Add comprehensive-testing-guide-v2.md with detailed test procedures
- Add testing-quick-reference-v2.md for quick access to test commands
- Add reboot-test-v2.sh for automated reboot testing
- Covers all P0 production-grade features:
  * Channel management (P0 Priority 1)
  * PendingIntent flags & exact alarms (P0 Priority 2)
  * JIT freshness re-check (P0 Priority 3)
  * Recovery coexistence (P0 Priority 4)
- Includes manual and automated testing procedures
- Ready for comprehensive test run after P0 completion
2025-10-14 08:02:16 +00:00
Matthew Raymer
dc4d342bef feat(scripts): add automated testing scripts for notification system
- Add daily-notification-test.sh for basic notification testing
- Add daily-notification-test.py for Python-based testing
- Add reboot-test.sh for automated reboot recovery testing
- Include comprehensive error handling and logging
- Add colored output for better user experience
- Support for different testing scenarios and edge cases
- Include ADB command validation and device connectivity checks

Scripts provide:
- Automated notification scheduling and verification
- Reboot recovery testing with proper timing
- Permission management testing
- Comprehensive logging and error reporting
- Cross-platform compatibility (bash and Python)

These scripts enable automated testing of the complete notification
system including boot receiver and app startup recovery mechanisms.
2025-10-14 06:17:09 +00:00
Matthew Raymer
fc031bf341 docs: add comprehensive documentation for automatic capacitor.build.gradle fix
- Add detailed inline documentation in build-native.sh explaining the problem, why it happens, and the solution
- Update fix-capacitor-build.sh with comprehensive header documentation
- Include clear explanations of when the fix gets overwritten and how to restore it
- Add user-friendly output with emojis and clear messaging
- Document the automatic fix process with step-by-step explanations

This provides complete transparency about what the scripts do and why,
making it easy for developers to understand and maintain the fix.
2025-10-12 06:17:42 +00:00
Matthew Raymer
a6d7d39c34 feat: add protection against capacitor.build.gradle overwrites
- Create fix-capacitor-build.sh script to restore fixes after Capacitor operations
- Update build-native.sh to automatically apply fix when needed
- Add warnings to BUILDING.md about auto-generated file risks
- Document which Capacitor commands will overwrite manual fixes

This protects against losing the capacitor.build.gradle fix when running
npx cap sync, npx cap update, or other Capacitor CLI commands.
2025-10-12 06:15:52 +00:00
Matthew Raymer
2712c8bf9b fix: update build script to handle plugin development projects
- Detect when this is a plugin development project vs full Capacitor app
- Skip Android test app build when Capacitor integration files are missing
- Provide helpful warnings about plugin development workflow
- Allow successful build completion for plugin source code only

This fixes the Gradle build failure when trying to build a plugin
development project that doesn't have a properly initialized test app.
2025-10-11 02:39:34 +00:00
Matthew Raymer
8dfd3c26f5 chore: update package configuration and dependencies
- Update package.json with native-first architecture description
- Add new build scripts for platform-specific builds
- Update dependencies to align with TimeSafari PWA requirements
- Add development scripts for environment checking and setup
- Update package keywords to reflect native-first focus
- Add bundle size checking and API change detection
- Update version to 2.2.0 with comprehensive feature set

Dependencies: Capacitor 6.2.1, TypeScript 5.2.2, Jest 29.7.0
2025-10-08 06:19:57 +00:00
Matthew Raymer
79dd1d82a7 feat: add platform-specific configuration and build system
- Add Android configuration with notification channels and WorkManager
- Add iOS configuration with BGTaskScheduler and notification categories
- Add platform-specific build scripts and bundle size checking
- Add API change detection and type checksum validation
- Add release notes generation and chaos testing scripts
- Add Vite configuration for TimeSafari-specific builds
- Add Android notification channels XML configuration
- Update package.json with new build scripts and dependencies

Platforms: Android (WorkManager + SQLite), iOS (BGTaskScheduler + Core Data), Electron (Desktop notifications)
2025-10-08 06:18:32 +00:00
Matthew Raymer
34ab8b7b46 fix(build): correct AAR file path in Android build script
- Update AAR file verification path from 'build/outputs/aar/daily-notification-release.aar'
  to 'capacitor-cordova-android-plugins/build/outputs/aar/capacitor-cordova-android-plugins-release.aar'
- Fixes build script error where it couldn't find the generated AAR file
- Android builds now complete successfully without false error messages

The build script was looking for a non-existent file path, causing the build to fail
even though the Android compilation was successful. This aligns the verification
path with the actual Gradle output structure.
2025-10-07 11:56:20 +00:00
Matthew Raymer
71e0f297ff refactor: improve build configuration and code organization
- Add build scripts for Android and iOS platforms
- Remove duplicate web implementation (src/web.ts)
- Add proper TypeScript configuration
- Add module documentation to index.ts
- Clean up package.json scripts

This commit improves the project structure and build process by:
1. Adding dedicated build scripts for native platforms
2. Removing redundant web implementation
3. Adding proper TypeScript configuration with strict mode
4. Improving code documentation
5. Organizing package.json scripts

The changes maintain backward compatibility while improving
the development experience and code quality.
2025-03-25 13:13:55 +00:00